• Home
  • Raw
  • Download

Lines Matching refs:journal

97 static void __journal_abort_soft (journal_t *journal, int errno);
129 journal_t *journal = arg; in kjournald2() local
136 setup_timer(&journal->j_commit_timer, commit_timeout, in kjournald2()
142 journal->j_task = current; in kjournald2()
143 wake_up(&journal->j_wait_done_commit); in kjournald2()
148 write_lock(&journal->j_state_lock); in kjournald2()
151 if (journal->j_flags & JBD2_UNMOUNT) in kjournald2()
155 journal->j_commit_sequence, journal->j_commit_request); in kjournald2()
157 if (journal->j_commit_sequence != journal->j_commit_request) { in kjournald2()
159 write_unlock(&journal->j_state_lock); in kjournald2()
160 del_timer_sync(&journal->j_commit_timer); in kjournald2()
161 jbd2_journal_commit_transaction(journal); in kjournald2()
162 write_lock(&journal->j_state_lock); in kjournald2()
166 wake_up(&journal->j_wait_done_commit); in kjournald2()
174 write_unlock(&journal->j_state_lock); in kjournald2()
176 write_lock(&journal->j_state_lock); in kjournald2()
185 prepare_to_wait(&journal->j_wait_commit, &wait, in kjournald2()
187 if (journal->j_commit_sequence != journal->j_commit_request) in kjournald2()
189 transaction = journal->j_running_transaction; in kjournald2()
193 if (journal->j_flags & JBD2_UNMOUNT) in kjournald2()
196 write_unlock(&journal->j_state_lock); in kjournald2()
198 write_lock(&journal->j_state_lock); in kjournald2()
200 finish_wait(&journal->j_wait_commit, &wait); in kjournald2()
208 transaction = journal->j_running_transaction; in kjournald2()
210 journal->j_commit_request = transaction->t_tid; in kjournald2()
216 write_unlock(&journal->j_state_lock); in kjournald2()
217 del_timer_sync(&journal->j_commit_timer); in kjournald2()
218 journal->j_task = NULL; in kjournald2()
219 wake_up(&journal->j_wait_done_commit); in kjournald2()
224 static int jbd2_journal_start_thread(journal_t *journal) in jbd2_journal_start_thread() argument
228 t = kthread_run(kjournald2, journal, "jbd2/%s", in jbd2_journal_start_thread()
229 journal->j_devname); in jbd2_journal_start_thread()
233 wait_event(journal->j_wait_done_commit, journal->j_task != NULL); in jbd2_journal_start_thread()
237 static void journal_kill_thread(journal_t *journal) in journal_kill_thread() argument
239 write_lock(&journal->j_state_lock); in journal_kill_thread()
240 journal->j_flags |= JBD2_UNMOUNT; in journal_kill_thread()
242 while (journal->j_task) { in journal_kill_thread()
243 wake_up(&journal->j_wait_commit); in journal_kill_thread()
244 write_unlock(&journal->j_state_lock); in journal_kill_thread()
245 wait_event(journal->j_wait_done_commit, journal->j_task == NULL); in journal_kill_thread()
246 write_lock(&journal->j_state_lock); in journal_kill_thread()
248 write_unlock(&journal->j_state_lock); in journal_kill_thread()
302 journal_t *journal = transaction->t_journal; in jbd2_journal_write_metadata_buffer() local
429 spin_lock(&journal->j_list_lock); in jbd2_journal_write_metadata_buffer()
431 spin_unlock(&journal->j_list_lock); in jbd2_journal_write_metadata_buffer()
453 int __jbd2_log_space_left(journal_t *journal) in __jbd2_log_space_left() argument
455 int left = journal->j_free; in __jbd2_log_space_left()
478 int __jbd2_log_start_commit(journal_t *journal, tid_t target) in __jbd2_log_start_commit() argument
485 if (journal->j_running_transaction && in __jbd2_log_start_commit()
486 journal->j_running_transaction->t_tid == target) { in __jbd2_log_start_commit()
492 journal->j_commit_request = target; in __jbd2_log_start_commit()
494 journal->j_commit_request, in __jbd2_log_start_commit()
495 journal->j_commit_sequence); in __jbd2_log_start_commit()
496 wake_up(&journal->j_wait_commit); in __jbd2_log_start_commit()
498 } else if (!tid_geq(journal->j_commit_request, target)) in __jbd2_log_start_commit()
503 journal->j_commit_request, in __jbd2_log_start_commit()
504 journal->j_commit_sequence, in __jbd2_log_start_commit()
505 target, journal->j_running_transaction ? in __jbd2_log_start_commit()
506 journal->j_running_transaction->t_tid : 0); in __jbd2_log_start_commit()
510 int jbd2_log_start_commit(journal_t *journal, tid_t tid) in jbd2_log_start_commit() argument
514 write_lock(&journal->j_state_lock); in jbd2_log_start_commit()
515 ret = __jbd2_log_start_commit(journal, tid); in jbd2_log_start_commit()
516 write_unlock(&journal->j_state_lock); in jbd2_log_start_commit()
530 int jbd2_journal_force_commit_nested(journal_t *journal) in jbd2_journal_force_commit_nested() argument
536 read_lock(&journal->j_state_lock); in jbd2_journal_force_commit_nested()
537 if (journal->j_running_transaction && !current->journal_info) { in jbd2_journal_force_commit_nested()
538 transaction = journal->j_running_transaction; in jbd2_journal_force_commit_nested()
539 if (!tid_geq(journal->j_commit_request, transaction->t_tid)) in jbd2_journal_force_commit_nested()
541 } else if (journal->j_committing_transaction) in jbd2_journal_force_commit_nested()
542 transaction = journal->j_committing_transaction; in jbd2_journal_force_commit_nested()
545 read_unlock(&journal->j_state_lock); in jbd2_journal_force_commit_nested()
550 read_unlock(&journal->j_state_lock); in jbd2_journal_force_commit_nested()
552 jbd2_log_start_commit(journal, tid); in jbd2_journal_force_commit_nested()
553 jbd2_log_wait_commit(journal, tid); in jbd2_journal_force_commit_nested()
562 int jbd2_journal_start_commit(journal_t *journal, tid_t *ptid) in jbd2_journal_start_commit() argument
566 write_lock(&journal->j_state_lock); in jbd2_journal_start_commit()
567 if (journal->j_running_transaction) { in jbd2_journal_start_commit()
568 tid_t tid = journal->j_running_transaction->t_tid; in jbd2_journal_start_commit()
570 __jbd2_log_start_commit(journal, tid); in jbd2_journal_start_commit()
576 } else if (journal->j_committing_transaction) { in jbd2_journal_start_commit()
582 *ptid = journal->j_committing_transaction->t_tid; in jbd2_journal_start_commit()
585 write_unlock(&journal->j_state_lock); in jbd2_journal_start_commit()
595 int jbd2_trans_will_send_data_barrier(journal_t *journal, tid_t tid) in jbd2_trans_will_send_data_barrier() argument
600 if (!(journal->j_flags & JBD2_BARRIER)) in jbd2_trans_will_send_data_barrier()
602 read_lock(&journal->j_state_lock); in jbd2_trans_will_send_data_barrier()
604 if (tid_geq(journal->j_commit_sequence, tid)) in jbd2_trans_will_send_data_barrier()
606 commit_trans = journal->j_committing_transaction; in jbd2_trans_will_send_data_barrier()
615 if (journal->j_fs_dev != journal->j_dev) { in jbd2_trans_will_send_data_barrier()
625 read_unlock(&journal->j_state_lock); in jbd2_trans_will_send_data_barrier()
634 int jbd2_log_wait_commit(journal_t *journal, tid_t tid) in jbd2_log_wait_commit() argument
638 read_lock(&journal->j_state_lock); in jbd2_log_wait_commit()
640 if (!tid_geq(journal->j_commit_request, tid)) { in jbd2_log_wait_commit()
643 __func__, journal->j_commit_request, tid); in jbd2_log_wait_commit()
646 while (tid_gt(tid, journal->j_commit_sequence)) { in jbd2_log_wait_commit()
648 tid, journal->j_commit_sequence); in jbd2_log_wait_commit()
649 wake_up(&journal->j_wait_commit); in jbd2_log_wait_commit()
650 read_unlock(&journal->j_state_lock); in jbd2_log_wait_commit()
651 wait_event(journal->j_wait_done_commit, in jbd2_log_wait_commit()
652 !tid_gt(tid, journal->j_commit_sequence)); in jbd2_log_wait_commit()
653 read_lock(&journal->j_state_lock); in jbd2_log_wait_commit()
655 read_unlock(&journal->j_state_lock); in jbd2_log_wait_commit()
657 if (unlikely(is_journal_aborted(journal))) { in jbd2_log_wait_commit()
668 int jbd2_journal_next_log_block(journal_t *journal, unsigned long long *retp) in jbd2_journal_next_log_block() argument
672 write_lock(&journal->j_state_lock); in jbd2_journal_next_log_block()
673 J_ASSERT(journal->j_free > 1); in jbd2_journal_next_log_block()
675 blocknr = journal->j_head; in jbd2_journal_next_log_block()
676 journal->j_head++; in jbd2_journal_next_log_block()
677 journal->j_free--; in jbd2_journal_next_log_block()
678 if (journal->j_head == journal->j_last) in jbd2_journal_next_log_block()
679 journal->j_head = journal->j_first; in jbd2_journal_next_log_block()
680 write_unlock(&journal->j_state_lock); in jbd2_journal_next_log_block()
681 return jbd2_journal_bmap(journal, blocknr, retp); in jbd2_journal_next_log_block()
691 int jbd2_journal_bmap(journal_t *journal, unsigned long blocknr, in jbd2_journal_bmap() argument
697 if (journal->j_inode) { in jbd2_journal_bmap()
698 ret = bmap(journal->j_inode, blocknr); in jbd2_journal_bmap()
704 __func__, blocknr, journal->j_devname); in jbd2_journal_bmap()
706 __journal_abort_soft(journal, err); in jbd2_journal_bmap()
724 struct journal_head *jbd2_journal_get_descriptor_buffer(journal_t *journal) in jbd2_journal_get_descriptor_buffer() argument
730 err = jbd2_journal_next_log_block(journal, &blocknr); in jbd2_journal_get_descriptor_buffer()
735 bh = __getblk(journal->j_dev, blocknr, journal->j_blocksize); in jbd2_journal_get_descriptor_buffer()
739 memset(bh->b_data, 0, journal->j_blocksize); in jbd2_journal_get_descriptor_buffer()
756 int jbd2_journal_get_log_tail(journal_t *journal, tid_t *tid, in jbd2_journal_get_log_tail() argument
762 read_lock(&journal->j_state_lock); in jbd2_journal_get_log_tail()
763 spin_lock(&journal->j_list_lock); in jbd2_journal_get_log_tail()
764 transaction = journal->j_checkpoint_transactions; in jbd2_journal_get_log_tail()
768 } else if ((transaction = journal->j_committing_transaction) != NULL) { in jbd2_journal_get_log_tail()
771 } else if ((transaction = journal->j_running_transaction) != NULL) { in jbd2_journal_get_log_tail()
773 *block = journal->j_head; in jbd2_journal_get_log_tail()
775 *tid = journal->j_transaction_sequence; in jbd2_journal_get_log_tail()
776 *block = journal->j_head; in jbd2_journal_get_log_tail()
778 ret = tid_gt(*tid, journal->j_tail_sequence); in jbd2_journal_get_log_tail()
779 spin_unlock(&journal->j_list_lock); in jbd2_journal_get_log_tail()
780 read_unlock(&journal->j_state_lock); in jbd2_journal_get_log_tail()
795 void __jbd2_update_log_tail(journal_t *journal, tid_t tid, unsigned long block) in __jbd2_update_log_tail() argument
799 BUG_ON(!mutex_is_locked(&journal->j_checkpoint_mutex)); in __jbd2_update_log_tail()
807 jbd2_journal_update_sb_log_tail(journal, tid, block, WRITE_FUA); in __jbd2_update_log_tail()
808 write_lock(&journal->j_state_lock); in __jbd2_update_log_tail()
809 freed = block - journal->j_tail; in __jbd2_update_log_tail()
810 if (block < journal->j_tail) in __jbd2_update_log_tail()
811 freed += journal->j_last - journal->j_first; in __jbd2_update_log_tail()
813 trace_jbd2_update_log_tail(journal, tid, block, freed); in __jbd2_update_log_tail()
817 journal->j_tail_sequence, tid, block, freed); in __jbd2_update_log_tail()
819 journal->j_free += freed; in __jbd2_update_log_tail()
820 journal->j_tail_sequence = tid; in __jbd2_update_log_tail()
821 journal->j_tail = block; in __jbd2_update_log_tail()
822 write_unlock(&journal->j_state_lock); in __jbd2_update_log_tail()
830 void jbd2_update_log_tail(journal_t *journal, tid_t tid, unsigned long block) in jbd2_update_log_tail() argument
832 mutex_lock(&journal->j_checkpoint_mutex); in jbd2_update_log_tail()
833 if (tid_gt(tid, journal->j_tail_sequence)) in jbd2_update_log_tail()
834 __jbd2_update_log_tail(journal, tid, block); in jbd2_update_log_tail()
835 mutex_unlock(&journal->j_checkpoint_mutex); in jbd2_update_log_tail()
839 journal_t *journal; member
863 s->journal->j_max_transaction_buffers); in jbd2_seq_info_show()
877 div_u64(s->journal->j_average_commit_time, 1000)); in jbd2_seq_info_show()
900 journal_t *journal = PDE(inode)->data; in jbd2_seq_info_open() local
913 spin_lock(&journal->j_history_lock); in jbd2_seq_info_open()
914 memcpy(s->stats, &journal->j_stats, size); in jbd2_seq_info_open()
915 s->journal = journal; in jbd2_seq_info_open()
916 spin_unlock(&journal->j_history_lock); in jbd2_seq_info_open()
949 static void jbd2_stats_proc_init(journal_t *journal) in jbd2_stats_proc_init() argument
951 journal->j_proc_entry = proc_mkdir(journal->j_devname, proc_jbd2_stats); in jbd2_stats_proc_init()
952 if (journal->j_proc_entry) { in jbd2_stats_proc_init()
953 proc_create_data("info", S_IRUGO, journal->j_proc_entry, in jbd2_stats_proc_init()
954 &jbd2_seq_info_fops, journal); in jbd2_stats_proc_init()
958 static void jbd2_stats_proc_exit(journal_t *journal) in jbd2_stats_proc_exit() argument
960 remove_proc_entry("info", journal->j_proc_entry); in jbd2_stats_proc_exit()
961 remove_proc_entry(journal->j_devname, proc_jbd2_stats); in jbd2_stats_proc_exit()
975 journal_t *journal; in journal_init_common() local
978 journal = kzalloc(sizeof(*journal), GFP_KERNEL); in journal_init_common()
979 if (!journal) in journal_init_common()
982 init_waitqueue_head(&journal->j_wait_transaction_locked); in journal_init_common()
983 init_waitqueue_head(&journal->j_wait_logspace); in journal_init_common()
984 init_waitqueue_head(&journal->j_wait_done_commit); in journal_init_common()
985 init_waitqueue_head(&journal->j_wait_checkpoint); in journal_init_common()
986 init_waitqueue_head(&journal->j_wait_commit); in journal_init_common()
987 init_waitqueue_head(&journal->j_wait_updates); in journal_init_common()
988 mutex_init(&journal->j_barrier); in journal_init_common()
989 mutex_init(&journal->j_checkpoint_mutex); in journal_init_common()
990 spin_lock_init(&journal->j_revoke_lock); in journal_init_common()
991 spin_lock_init(&journal->j_list_lock); in journal_init_common()
992 rwlock_init(&journal->j_state_lock); in journal_init_common()
994 journal->j_commit_interval = (HZ * JBD2_DEFAULT_MAX_COMMIT_AGE); in journal_init_common()
995 journal->j_min_batch_time = 0; in journal_init_common()
996 journal->j_max_batch_time = 15000; /* 15ms */ in journal_init_common()
999 journal->j_flags = JBD2_ABORT; in journal_init_common()
1002 err = jbd2_journal_init_revoke(journal, JOURNAL_REVOKE_DEFAULT_HASH); in journal_init_common()
1004 kfree(journal); in journal_init_common()
1008 spin_lock_init(&journal->j_history_lock); in journal_init_common()
1010 return journal; in journal_init_common()
1040 journal_t *journal = journal_init_common(); in jbd2_journal_init_dev() local
1045 if (!journal) in jbd2_journal_init_dev()
1049 journal->j_blocksize = blocksize; in jbd2_journal_init_dev()
1050 journal->j_dev = bdev; in jbd2_journal_init_dev()
1051 journal->j_fs_dev = fs_dev; in jbd2_journal_init_dev()
1052 journal->j_blk_offset = start; in jbd2_journal_init_dev()
1053 journal->j_maxlen = len; in jbd2_journal_init_dev()
1054 bdevname(journal->j_dev, journal->j_devname); in jbd2_journal_init_dev()
1055 p = journal->j_devname; in jbd2_journal_init_dev()
1058 jbd2_stats_proc_init(journal); in jbd2_journal_init_dev()
1059 n = journal->j_blocksize / sizeof(journal_block_tag_t); in jbd2_journal_init_dev()
1060 journal->j_wbufsize = n; in jbd2_journal_init_dev()
1061 journal->j_wbuf = kmalloc(n * sizeof(struct buffer_head*), GFP_KERNEL); in jbd2_journal_init_dev()
1062 if (!journal->j_wbuf) { in jbd2_journal_init_dev()
1068 bh = __getblk(journal->j_dev, start, journal->j_blocksize); in jbd2_journal_init_dev()
1075 journal->j_sb_buffer = bh; in jbd2_journal_init_dev()
1076 journal->j_superblock = (journal_superblock_t *)bh->b_data; in jbd2_journal_init_dev()
1078 return journal; in jbd2_journal_init_dev()
1080 kfree(journal->j_wbuf); in jbd2_journal_init_dev()
1081 jbd2_stats_proc_exit(journal); in jbd2_journal_init_dev()
1082 kfree(journal); in jbd2_journal_init_dev()
1097 journal_t *journal = journal_init_common(); in jbd2_journal_init_inode() local
1103 if (!journal) in jbd2_journal_init_inode()
1106 journal->j_dev = journal->j_fs_dev = inode->i_sb->s_bdev; in jbd2_journal_init_inode()
1107 journal->j_inode = inode; in jbd2_journal_init_inode()
1108 bdevname(journal->j_dev, journal->j_devname); in jbd2_journal_init_inode()
1109 p = journal->j_devname; in jbd2_journal_init_inode()
1112 p = journal->j_devname + strlen(journal->j_devname); in jbd2_journal_init_inode()
1113 sprintf(p, "-%lu", journal->j_inode->i_ino); in jbd2_journal_init_inode()
1116 journal, inode->i_sb->s_id, inode->i_ino, in jbd2_journal_init_inode()
1120 journal->j_maxlen = inode->i_size >> inode->i_sb->s_blocksize_bits; in jbd2_journal_init_inode()
1121 journal->j_blocksize = inode->i_sb->s_blocksize; in jbd2_journal_init_inode()
1122 jbd2_stats_proc_init(journal); in jbd2_journal_init_inode()
1125 n = journal->j_blocksize / sizeof(journal_block_tag_t); in jbd2_journal_init_inode()
1126 journal->j_wbufsize = n; in jbd2_journal_init_inode()
1127 journal->j_wbuf = kmalloc(n * sizeof(struct buffer_head*), GFP_KERNEL); in jbd2_journal_init_inode()
1128 if (!journal->j_wbuf) { in jbd2_journal_init_inode()
1134 err = jbd2_journal_bmap(journal, 0, &blocknr); in jbd2_journal_init_inode()
1142 bh = __getblk(journal->j_dev, blocknr, journal->j_blocksize); in jbd2_journal_init_inode()
1149 journal->j_sb_buffer = bh; in jbd2_journal_init_inode()
1150 journal->j_superblock = (journal_superblock_t *)bh->b_data; in jbd2_journal_init_inode()
1152 return journal; in jbd2_journal_init_inode()
1154 kfree(journal->j_wbuf); in jbd2_journal_init_inode()
1155 jbd2_stats_proc_exit(journal); in jbd2_journal_init_inode()
1156 kfree(journal); in jbd2_journal_init_inode()
1165 static void journal_fail_superblock (journal_t *journal) in journal_fail_superblock() argument
1167 struct buffer_head *bh = journal->j_sb_buffer; in journal_fail_superblock()
1169 journal->j_sb_buffer = NULL; in journal_fail_superblock()
1179 static int journal_reset(journal_t *journal) in journal_reset() argument
1181 journal_superblock_t *sb = journal->j_superblock; in journal_reset()
1189 journal_fail_superblock(journal); in journal_reset()
1193 journal->j_first = first; in journal_reset()
1194 journal->j_last = last; in journal_reset()
1196 journal->j_head = first; in journal_reset()
1197 journal->j_tail = first; in journal_reset()
1198 journal->j_free = last - first; in journal_reset()
1200 journal->j_tail_sequence = journal->j_transaction_sequence; in journal_reset()
1201 journal->j_commit_sequence = journal->j_transaction_sequence - 1; in journal_reset()
1202 journal->j_commit_request = journal->j_commit_sequence; in journal_reset()
1204 journal->j_max_transaction_buffers = journal->j_maxlen / 4; in journal_reset()
1215 journal->j_tail, journal->j_tail_sequence, in journal_reset()
1216 journal->j_errno); in journal_reset()
1217 journal->j_flags |= JBD2_FLUSHED; in journal_reset()
1220 mutex_lock(&journal->j_checkpoint_mutex); in journal_reset()
1227 jbd2_journal_update_sb_log_tail(journal, in journal_reset()
1228 journal->j_tail_sequence, in journal_reset()
1229 journal->j_tail, in journal_reset()
1231 mutex_unlock(&journal->j_checkpoint_mutex); in journal_reset()
1233 return jbd2_journal_start_thread(journal); in journal_reset()
1236 static void jbd2_write_superblock(journal_t *journal, int write_op) in jbd2_write_superblock() argument
1238 struct buffer_head *bh = journal->j_sb_buffer; in jbd2_write_superblock()
1241 trace_jbd2_write_superblock(journal, write_op); in jbd2_write_superblock()
1242 if (!(journal->j_flags & JBD2_BARRIER)) in jbd2_write_superblock()
1256 journal->j_devname); in jbd2_write_superblock()
1272 journal->j_devname); in jbd2_write_superblock()
1286 void jbd2_journal_update_sb_log_tail(journal_t *journal, tid_t tail_tid, in jbd2_journal_update_sb_log_tail() argument
1289 journal_superblock_t *sb = journal->j_superblock; in jbd2_journal_update_sb_log_tail()
1291 BUG_ON(!mutex_is_locked(&journal->j_checkpoint_mutex)); in jbd2_journal_update_sb_log_tail()
1298 jbd2_write_superblock(journal, write_op); in jbd2_journal_update_sb_log_tail()
1301 write_lock(&journal->j_state_lock); in jbd2_journal_update_sb_log_tail()
1303 journal->j_flags &= ~JBD2_FLUSHED; in jbd2_journal_update_sb_log_tail()
1304 write_unlock(&journal->j_state_lock); in jbd2_journal_update_sb_log_tail()
1314 static void jbd2_mark_journal_empty(journal_t *journal) in jbd2_mark_journal_empty() argument
1316 journal_superblock_t *sb = journal->j_superblock; in jbd2_mark_journal_empty()
1318 BUG_ON(!mutex_is_locked(&journal->j_checkpoint_mutex)); in jbd2_mark_journal_empty()
1319 read_lock(&journal->j_state_lock); in jbd2_mark_journal_empty()
1322 read_unlock(&journal->j_state_lock); in jbd2_mark_journal_empty()
1326 journal->j_tail_sequence); in jbd2_mark_journal_empty()
1328 sb->s_sequence = cpu_to_be32(journal->j_tail_sequence); in jbd2_mark_journal_empty()
1330 read_unlock(&journal->j_state_lock); in jbd2_mark_journal_empty()
1332 jbd2_write_superblock(journal, WRITE_FUA); in jbd2_mark_journal_empty()
1335 write_lock(&journal->j_state_lock); in jbd2_mark_journal_empty()
1336 journal->j_flags |= JBD2_FLUSHED; in jbd2_mark_journal_empty()
1337 write_unlock(&journal->j_state_lock); in jbd2_mark_journal_empty()
1348 void jbd2_journal_update_sb_errno(journal_t *journal) in jbd2_journal_update_sb_errno() argument
1350 journal_superblock_t *sb = journal->j_superblock; in jbd2_journal_update_sb_errno()
1352 read_lock(&journal->j_state_lock); in jbd2_journal_update_sb_errno()
1354 journal->j_errno); in jbd2_journal_update_sb_errno()
1355 sb->s_errno = cpu_to_be32(journal->j_errno); in jbd2_journal_update_sb_errno()
1356 read_unlock(&journal->j_state_lock); in jbd2_journal_update_sb_errno()
1358 jbd2_write_superblock(journal, WRITE_SYNC); in jbd2_journal_update_sb_errno()
1366 static int journal_get_superblock(journal_t *journal) in journal_get_superblock() argument
1372 bh = journal->j_sb_buffer; in journal_get_superblock()
1385 sb = journal->j_superblock; in journal_get_superblock()
1390 sb->s_blocksize != cpu_to_be32(journal->j_blocksize)) { in journal_get_superblock()
1397 journal->j_format_version = 1; in journal_get_superblock()
1400 journal->j_format_version = 2; in journal_get_superblock()
1407 if (be32_to_cpu(sb->s_maxlen) < journal->j_maxlen) in journal_get_superblock()
1408 journal->j_maxlen = be32_to_cpu(sb->s_maxlen); in journal_get_superblock()
1409 else if (be32_to_cpu(sb->s_maxlen) > journal->j_maxlen) { in journal_get_superblock()
1415 be32_to_cpu(sb->s_first) >= journal->j_maxlen) { in journal_get_superblock()
1425 journal_fail_superblock(journal); in journal_get_superblock()
1434 static int load_superblock(journal_t *journal) in load_superblock() argument
1439 err = journal_get_superblock(journal); in load_superblock()
1443 sb = journal->j_superblock; in load_superblock()
1445 journal->j_tail_sequence = be32_to_cpu(sb->s_sequence); in load_superblock()
1446 journal->j_tail = be32_to_cpu(sb->s_start); in load_superblock()
1447 journal->j_first = be32_to_cpu(sb->s_first); in load_superblock()
1448 journal->j_last = be32_to_cpu(sb->s_maxlen); in load_superblock()
1449 journal->j_errno = be32_to_cpu(sb->s_errno); in load_superblock()
1463 int jbd2_journal_load(journal_t *journal) in jbd2_journal_load() argument
1468 err = load_superblock(journal); in jbd2_journal_load()
1472 sb = journal->j_superblock; in jbd2_journal_load()
1476 if (journal->j_format_version >= 2) { in jbd2_journal_load()
1496 if (jbd2_journal_recover(journal)) in jbd2_journal_load()
1499 if (journal->j_failed_commit) { in jbd2_journal_load()
1501 "is corrupt.\n", journal->j_failed_commit, in jbd2_journal_load()
1502 journal->j_devname); in jbd2_journal_load()
1509 if (journal_reset(journal)) in jbd2_journal_load()
1512 journal->j_flags &= ~JBD2_ABORT; in jbd2_journal_load()
1513 journal->j_flags |= JBD2_LOADED; in jbd2_journal_load()
1529 int jbd2_journal_destroy(journal_t *journal) in jbd2_journal_destroy() argument
1534 journal_kill_thread(journal); in jbd2_journal_destroy()
1537 if (journal->j_running_transaction) in jbd2_journal_destroy()
1538 jbd2_journal_commit_transaction(journal); in jbd2_journal_destroy()
1543 spin_lock(&journal->j_list_lock); in jbd2_journal_destroy()
1544 while (journal->j_checkpoint_transactions != NULL) { in jbd2_journal_destroy()
1545 spin_unlock(&journal->j_list_lock); in jbd2_journal_destroy()
1546 mutex_lock(&journal->j_checkpoint_mutex); in jbd2_journal_destroy()
1547 jbd2_log_do_checkpoint(journal); in jbd2_journal_destroy()
1548 mutex_unlock(&journal->j_checkpoint_mutex); in jbd2_journal_destroy()
1549 spin_lock(&journal->j_list_lock); in jbd2_journal_destroy()
1552 J_ASSERT(journal->j_running_transaction == NULL); in jbd2_journal_destroy()
1553 J_ASSERT(journal->j_committing_transaction == NULL); in jbd2_journal_destroy()
1554 J_ASSERT(journal->j_checkpoint_transactions == NULL); in jbd2_journal_destroy()
1555 spin_unlock(&journal->j_list_lock); in jbd2_journal_destroy()
1557 if (journal->j_sb_buffer) { in jbd2_journal_destroy()
1558 if (!is_journal_aborted(journal)) { in jbd2_journal_destroy()
1559 mutex_lock(&journal->j_checkpoint_mutex); in jbd2_journal_destroy()
1560 jbd2_mark_journal_empty(journal); in jbd2_journal_destroy()
1561 mutex_unlock(&journal->j_checkpoint_mutex); in jbd2_journal_destroy()
1564 brelse(journal->j_sb_buffer); in jbd2_journal_destroy()
1567 if (journal->j_proc_entry) in jbd2_journal_destroy()
1568 jbd2_stats_proc_exit(journal); in jbd2_journal_destroy()
1569 if (journal->j_inode) in jbd2_journal_destroy()
1570 iput(journal->j_inode); in jbd2_journal_destroy()
1571 if (journal->j_revoke) in jbd2_journal_destroy()
1572 jbd2_journal_destroy_revoke(journal); in jbd2_journal_destroy()
1573 kfree(journal->j_wbuf); in jbd2_journal_destroy()
1574 kfree(journal); in jbd2_journal_destroy()
1591 int jbd2_journal_check_used_features (journal_t *journal, unsigned long compat, in jbd2_journal_check_used_features() argument
1599 if (journal->j_format_version == 0 && in jbd2_journal_check_used_features()
1600 journal_get_superblock(journal) != 0) in jbd2_journal_check_used_features()
1602 if (journal->j_format_version == 1) in jbd2_journal_check_used_features()
1605 sb = journal->j_superblock; in jbd2_journal_check_used_features()
1626 int jbd2_journal_check_available_features (journal_t *journal, unsigned long compat, in jbd2_journal_check_available_features() argument
1636 if (journal->j_format_version != 2) in jbd2_journal_check_available_features()
1659 int jbd2_journal_set_features (journal_t *journal, unsigned long compat, in jbd2_journal_set_features() argument
1664 if (jbd2_journal_check_used_features(journal, compat, ro, incompat)) in jbd2_journal_set_features()
1667 if (!jbd2_journal_check_available_features(journal, compat, ro, incompat)) in jbd2_journal_set_features()
1673 sb = journal->j_superblock; in jbd2_journal_set_features()
1693 void jbd2_journal_clear_features(journal_t *journal, unsigned long compat, in jbd2_journal_clear_features() argument
1701 sb = journal->j_superblock; in jbd2_journal_clear_features()
1718 int jbd2_journal_flush(journal_t *journal) in jbd2_journal_flush() argument
1723 write_lock(&journal->j_state_lock); in jbd2_journal_flush()
1726 if (journal->j_running_transaction) { in jbd2_journal_flush()
1727 transaction = journal->j_running_transaction; in jbd2_journal_flush()
1728 __jbd2_log_start_commit(journal, transaction->t_tid); in jbd2_journal_flush()
1729 } else if (journal->j_committing_transaction) in jbd2_journal_flush()
1730 transaction = journal->j_committing_transaction; in jbd2_journal_flush()
1736 write_unlock(&journal->j_state_lock); in jbd2_journal_flush()
1737 jbd2_log_wait_commit(journal, tid); in jbd2_journal_flush()
1739 write_unlock(&journal->j_state_lock); in jbd2_journal_flush()
1743 spin_lock(&journal->j_list_lock); in jbd2_journal_flush()
1744 while (!err && journal->j_checkpoint_transactions != NULL) { in jbd2_journal_flush()
1745 spin_unlock(&journal->j_list_lock); in jbd2_journal_flush()
1746 mutex_lock(&journal->j_checkpoint_mutex); in jbd2_journal_flush()
1747 err = jbd2_log_do_checkpoint(journal); in jbd2_journal_flush()
1748 mutex_unlock(&journal->j_checkpoint_mutex); in jbd2_journal_flush()
1749 spin_lock(&journal->j_list_lock); in jbd2_journal_flush()
1751 spin_unlock(&journal->j_list_lock); in jbd2_journal_flush()
1753 if (is_journal_aborted(journal)) in jbd2_journal_flush()
1756 mutex_lock(&journal->j_checkpoint_mutex); in jbd2_journal_flush()
1757 jbd2_cleanup_journal_tail(journal); in jbd2_journal_flush()
1764 jbd2_mark_journal_empty(journal); in jbd2_journal_flush()
1765 mutex_unlock(&journal->j_checkpoint_mutex); in jbd2_journal_flush()
1766 write_lock(&journal->j_state_lock); in jbd2_journal_flush()
1767 J_ASSERT(!journal->j_running_transaction); in jbd2_journal_flush()
1768 J_ASSERT(!journal->j_committing_transaction); in jbd2_journal_flush()
1769 J_ASSERT(!journal->j_checkpoint_transactions); in jbd2_journal_flush()
1770 J_ASSERT(journal->j_head == journal->j_tail); in jbd2_journal_flush()
1771 J_ASSERT(journal->j_tail_sequence == journal->j_transaction_sequence); in jbd2_journal_flush()
1772 write_unlock(&journal->j_state_lock); in jbd2_journal_flush()
1789 int jbd2_journal_wipe(journal_t *journal, int write) in jbd2_journal_wipe() argument
1793 J_ASSERT (!(journal->j_flags & JBD2_LOADED)); in jbd2_journal_wipe()
1795 err = load_superblock(journal); in jbd2_journal_wipe()
1799 if (!journal->j_tail) in jbd2_journal_wipe()
1805 err = jbd2_journal_skip_recovery(journal); in jbd2_journal_wipe()
1808 mutex_lock(&journal->j_checkpoint_mutex); in jbd2_journal_wipe()
1809 jbd2_mark_journal_empty(journal); in jbd2_journal_wipe()
1810 mutex_unlock(&journal->j_checkpoint_mutex); in jbd2_journal_wipe()
1830 void __jbd2_journal_abort_hard(journal_t *journal) in __jbd2_journal_abort_hard() argument
1834 if (journal->j_flags & JBD2_ABORT) in __jbd2_journal_abort_hard()
1838 journal->j_devname); in __jbd2_journal_abort_hard()
1840 write_lock(&journal->j_state_lock); in __jbd2_journal_abort_hard()
1841 journal->j_flags |= JBD2_ABORT; in __jbd2_journal_abort_hard()
1842 transaction = journal->j_running_transaction; in __jbd2_journal_abort_hard()
1844 __jbd2_log_start_commit(journal, transaction->t_tid); in __jbd2_journal_abort_hard()
1845 write_unlock(&journal->j_state_lock); in __jbd2_journal_abort_hard()
1850 static void __journal_abort_soft (journal_t *journal, int errno) in __journal_abort_soft() argument
1852 if (journal->j_flags & JBD2_ABORT) in __journal_abort_soft()
1855 if (!journal->j_errno) in __journal_abort_soft()
1856 journal->j_errno = errno; in __journal_abort_soft()
1858 __jbd2_journal_abort_hard(journal); in __journal_abort_soft()
1861 jbd2_journal_update_sb_errno(journal); in __journal_abort_soft()
1910 void jbd2_journal_abort(journal_t *journal, int errno) in jbd2_journal_abort() argument
1912 __journal_abort_soft(journal, errno); in jbd2_journal_abort()
1926 int jbd2_journal_errno(journal_t *journal) in jbd2_journal_errno() argument
1930 read_lock(&journal->j_state_lock); in jbd2_journal_errno()
1931 if (journal->j_flags & JBD2_ABORT) in jbd2_journal_errno()
1934 err = journal->j_errno; in jbd2_journal_errno()
1935 read_unlock(&journal->j_state_lock); in jbd2_journal_errno()
1946 int jbd2_journal_clear_err(journal_t *journal) in jbd2_journal_clear_err() argument
1950 write_lock(&journal->j_state_lock); in jbd2_journal_clear_err()
1951 if (journal->j_flags & JBD2_ABORT) in jbd2_journal_clear_err()
1954 journal->j_errno = 0; in jbd2_journal_clear_err()
1955 write_unlock(&journal->j_state_lock); in jbd2_journal_clear_err()
1966 void jbd2_journal_ack_err(journal_t *journal) in jbd2_journal_ack_err() argument
1968 write_lock(&journal->j_state_lock); in jbd2_journal_ack_err()
1969 if (journal->j_errno) in jbd2_journal_ack_err()
1970 journal->j_flags |= JBD2_ACK_ERR; in jbd2_journal_ack_err()
1971 write_unlock(&journal->j_state_lock); in jbd2_journal_ack_err()
1982 size_t journal_tag_bytes(journal_t *journal) in journal_tag_bytes() argument
1984 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_64BIT)) in journal_tag_bytes()
2335 void jbd2_journal_release_jbd_inode(journal_t *journal, in jbd2_journal_release_jbd_inode() argument
2338 if (!journal) in jbd2_journal_release_jbd_inode()
2341 spin_lock(&journal->j_list_lock); in jbd2_journal_release_jbd_inode()
2348 spin_unlock(&journal->j_list_lock); in jbd2_journal_release_jbd_inode()
2358 spin_unlock(&journal->j_list_lock); in jbd2_journal_release_jbd_inode()