Lines Matching refs:journal

137 	journal_t *journal = from_timer(journal, t, j_commit_timer);  in commit_timeout()  local
139 wake_up_process(journal->j_task); in commit_timeout()
162 journal_t *journal = arg; in kjournald2() local
169 timer_setup(&journal->j_commit_timer, commit_timeout, 0); in kjournald2()
174 journal->j_task = current; in kjournald2()
175 wake_up(&journal->j_wait_done_commit); in kjournald2()
188 write_lock(&journal->j_state_lock); in kjournald2()
191 if (journal->j_flags & JBD2_UNMOUNT) in kjournald2()
195 journal->j_commit_sequence, journal->j_commit_request); in kjournald2()
197 if (journal->j_commit_sequence != journal->j_commit_request) { in kjournald2()
199 write_unlock(&journal->j_state_lock); in kjournald2()
200 del_timer_sync(&journal->j_commit_timer); in kjournald2()
201 jbd2_journal_commit_transaction(journal); in kjournald2()
202 write_lock(&journal->j_state_lock); in kjournald2()
206 wake_up(&journal->j_wait_done_commit); in kjournald2()
214 write_unlock(&journal->j_state_lock); in kjournald2()
216 write_lock(&journal->j_state_lock); in kjournald2()
224 prepare_to_wait(&journal->j_wait_commit, &wait, in kjournald2()
226 transaction = journal->j_running_transaction; in kjournald2()
229 write_unlock(&journal->j_state_lock); in kjournald2()
231 write_lock(&journal->j_state_lock); in kjournald2()
233 finish_wait(&journal->j_wait_commit, &wait); in kjournald2()
241 transaction = journal->j_running_transaction; in kjournald2()
243 journal->j_commit_request = transaction->t_tid; in kjournald2()
249 del_timer_sync(&journal->j_commit_timer); in kjournald2()
250 journal->j_task = NULL; in kjournald2()
251 wake_up(&journal->j_wait_done_commit); in kjournald2()
253 write_unlock(&journal->j_state_lock); in kjournald2()
257 static int jbd2_journal_start_thread(journal_t *journal) in jbd2_journal_start_thread() argument
261 t = kthread_run(kjournald2, journal, "jbd2/%s", in jbd2_journal_start_thread()
262 journal->j_devname); in jbd2_journal_start_thread()
266 wait_event(journal->j_wait_done_commit, journal->j_task != NULL); in jbd2_journal_start_thread()
270 static void journal_kill_thread(journal_t *journal) in journal_kill_thread() argument
272 write_lock(&journal->j_state_lock); in journal_kill_thread()
273 journal->j_flags |= JBD2_UNMOUNT; in journal_kill_thread()
275 while (journal->j_task) { in journal_kill_thread()
276 write_unlock(&journal->j_state_lock); in journal_kill_thread()
277 wake_up(&journal->j_wait_commit); in journal_kill_thread()
278 wait_event(journal->j_wait_done_commit, journal->j_task == NULL); in journal_kill_thread()
279 write_lock(&journal->j_state_lock); in journal_kill_thread()
281 write_unlock(&journal->j_state_lock); in journal_kill_thread()
336 journal_t *journal = transaction->t_journal; in jbd2_journal_write_metadata_buffer() local
419 new_bh->b_bdev = journal->j_dev; in jbd2_journal_write_metadata_buffer()
433 spin_lock(&journal->j_list_lock); in jbd2_journal_write_metadata_buffer()
435 spin_unlock(&journal->j_list_lock); in jbd2_journal_write_metadata_buffer()
451 static int __jbd2_log_start_commit(journal_t *journal, tid_t target) in __jbd2_log_start_commit() argument
454 if (journal->j_commit_request == target) in __jbd2_log_start_commit()
462 if (journal->j_running_transaction && in __jbd2_log_start_commit()
463 journal->j_running_transaction->t_tid == target) { in __jbd2_log_start_commit()
469 journal->j_commit_request = target; in __jbd2_log_start_commit()
471 journal->j_commit_request, in __jbd2_log_start_commit()
472 journal->j_commit_sequence); in __jbd2_log_start_commit()
473 journal->j_running_transaction->t_requested = jiffies; in __jbd2_log_start_commit()
474 wake_up(&journal->j_wait_commit); in __jbd2_log_start_commit()
476 } else if (!tid_geq(journal->j_commit_request, target)) in __jbd2_log_start_commit()
481 journal->j_commit_request, in __jbd2_log_start_commit()
482 journal->j_commit_sequence, in __jbd2_log_start_commit()
483 target, journal->j_running_transaction ? in __jbd2_log_start_commit()
484 journal->j_running_transaction->t_tid : 0); in __jbd2_log_start_commit()
488 int jbd2_log_start_commit(journal_t *journal, tid_t tid) in jbd2_log_start_commit() argument
492 write_lock(&journal->j_state_lock); in jbd2_log_start_commit()
493 ret = __jbd2_log_start_commit(journal, tid); in jbd2_log_start_commit()
494 write_unlock(&journal->j_state_lock); in jbd2_log_start_commit()
505 static int __jbd2_journal_force_commit(journal_t *journal) in __jbd2_journal_force_commit() argument
511 read_lock(&journal->j_state_lock); in __jbd2_journal_force_commit()
512 if (journal->j_running_transaction && !current->journal_info) { in __jbd2_journal_force_commit()
513 transaction = journal->j_running_transaction; in __jbd2_journal_force_commit()
514 if (!tid_geq(journal->j_commit_request, transaction->t_tid)) in __jbd2_journal_force_commit()
516 } else if (journal->j_committing_transaction) in __jbd2_journal_force_commit()
517 transaction = journal->j_committing_transaction; in __jbd2_journal_force_commit()
521 read_unlock(&journal->j_state_lock); in __jbd2_journal_force_commit()
525 read_unlock(&journal->j_state_lock); in __jbd2_journal_force_commit()
527 jbd2_log_start_commit(journal, tid); in __jbd2_journal_force_commit()
528 ret = jbd2_log_wait_commit(journal, tid); in __jbd2_journal_force_commit()
545 int jbd2_journal_force_commit_nested(journal_t *journal) in jbd2_journal_force_commit_nested() argument
549 ret = __jbd2_journal_force_commit(journal); in jbd2_journal_force_commit_nested()
560 int jbd2_journal_force_commit(journal_t *journal) in jbd2_journal_force_commit() argument
565 ret = __jbd2_journal_force_commit(journal); in jbd2_journal_force_commit()
576 int jbd2_journal_start_commit(journal_t *journal, tid_t *ptid) in jbd2_journal_start_commit() argument
580 write_lock(&journal->j_state_lock); in jbd2_journal_start_commit()
581 if (journal->j_running_transaction) { in jbd2_journal_start_commit()
582 tid_t tid = journal->j_running_transaction->t_tid; in jbd2_journal_start_commit()
584 __jbd2_log_start_commit(journal, tid); in jbd2_journal_start_commit()
590 } else if (journal->j_committing_transaction) { in jbd2_journal_start_commit()
596 *ptid = journal->j_committing_transaction->t_tid; in jbd2_journal_start_commit()
599 write_unlock(&journal->j_state_lock); in jbd2_journal_start_commit()
609 int jbd2_trans_will_send_data_barrier(journal_t *journal, tid_t tid) in jbd2_trans_will_send_data_barrier() argument
614 if (!(journal->j_flags & JBD2_BARRIER)) in jbd2_trans_will_send_data_barrier()
616 read_lock(&journal->j_state_lock); in jbd2_trans_will_send_data_barrier()
618 if (tid_geq(journal->j_commit_sequence, tid)) in jbd2_trans_will_send_data_barrier()
620 commit_trans = journal->j_committing_transaction; in jbd2_trans_will_send_data_barrier()
629 if (journal->j_fs_dev != journal->j_dev) { in jbd2_trans_will_send_data_barrier()
639 read_unlock(&journal->j_state_lock); in jbd2_trans_will_send_data_barrier()
648 int jbd2_log_wait_commit(journal_t *journal, tid_t tid) in jbd2_log_wait_commit() argument
652 read_lock(&journal->j_state_lock); in jbd2_log_wait_commit()
659 if (tid_gt(tid, journal->j_commit_sequence) && in jbd2_log_wait_commit()
660 (!journal->j_committing_transaction || in jbd2_log_wait_commit()
661 journal->j_committing_transaction->t_tid != tid)) { in jbd2_log_wait_commit()
662 read_unlock(&journal->j_state_lock); in jbd2_log_wait_commit()
663 jbd2_might_wait_for_commit(journal); in jbd2_log_wait_commit()
664 read_lock(&journal->j_state_lock); in jbd2_log_wait_commit()
668 if (!tid_geq(journal->j_commit_request, tid)) { in jbd2_log_wait_commit()
671 __func__, journal->j_commit_request, tid); in jbd2_log_wait_commit()
674 while (tid_gt(tid, journal->j_commit_sequence)) { in jbd2_log_wait_commit()
676 tid, journal->j_commit_sequence); in jbd2_log_wait_commit()
677 read_unlock(&journal->j_state_lock); in jbd2_log_wait_commit()
678 wake_up(&journal->j_wait_commit); in jbd2_log_wait_commit()
679 wait_event(journal->j_wait_done_commit, in jbd2_log_wait_commit()
680 !tid_gt(tid, journal->j_commit_sequence)); in jbd2_log_wait_commit()
681 read_lock(&journal->j_state_lock); in jbd2_log_wait_commit()
683 read_unlock(&journal->j_state_lock); in jbd2_log_wait_commit()
685 if (unlikely(is_journal_aborted(journal))) in jbd2_log_wait_commit()
697 int jbd2_fc_begin_commit(journal_t *journal, tid_t tid) in jbd2_fc_begin_commit() argument
699 if (unlikely(is_journal_aborted(journal))) in jbd2_fc_begin_commit()
705 if (!journal->j_stats.ts_tid) in jbd2_fc_begin_commit()
708 write_lock(&journal->j_state_lock); in jbd2_fc_begin_commit()
709 if (tid_geq(journal->j_commit_sequence, tid)) { in jbd2_fc_begin_commit()
710 write_unlock(&journal->j_state_lock); in jbd2_fc_begin_commit()
714 if (journal->j_flags & JBD2_FULL_COMMIT_ONGOING || in jbd2_fc_begin_commit()
715 (journal->j_flags & JBD2_FAST_COMMIT_ONGOING)) { in jbd2_fc_begin_commit()
718 prepare_to_wait(&journal->j_fc_wait, &wait, in jbd2_fc_begin_commit()
720 write_unlock(&journal->j_state_lock); in jbd2_fc_begin_commit()
722 finish_wait(&journal->j_fc_wait, &wait); in jbd2_fc_begin_commit()
725 journal->j_flags |= JBD2_FAST_COMMIT_ONGOING; in jbd2_fc_begin_commit()
726 write_unlock(&journal->j_state_lock); in jbd2_fc_begin_commit()
727 jbd2_journal_lock_updates(journal); in jbd2_fc_begin_commit()
737 static int __jbd2_fc_end_commit(journal_t *journal, tid_t tid, bool fallback) in __jbd2_fc_end_commit() argument
739 if (journal->j_fc_cleanup_callback) in __jbd2_fc_end_commit()
740 journal->j_fc_cleanup_callback(journal, 0, tid); in __jbd2_fc_end_commit()
741 jbd2_journal_unlock_updates(journal); in __jbd2_fc_end_commit()
742 write_lock(&journal->j_state_lock); in __jbd2_fc_end_commit()
743 journal->j_flags &= ~JBD2_FAST_COMMIT_ONGOING; in __jbd2_fc_end_commit()
745 journal->j_flags |= JBD2_FULL_COMMIT_ONGOING; in __jbd2_fc_end_commit()
746 write_unlock(&journal->j_state_lock); in __jbd2_fc_end_commit()
747 wake_up(&journal->j_fc_wait); in __jbd2_fc_end_commit()
749 return jbd2_complete_transaction(journal, tid); in __jbd2_fc_end_commit()
753 int jbd2_fc_end_commit(journal_t *journal) in jbd2_fc_end_commit() argument
755 return __jbd2_fc_end_commit(journal, 0, false); in jbd2_fc_end_commit()
759 int jbd2_fc_end_commit_fallback(journal_t *journal) in jbd2_fc_end_commit_fallback() argument
763 read_lock(&journal->j_state_lock); in jbd2_fc_end_commit_fallback()
764 tid = journal->j_running_transaction ? in jbd2_fc_end_commit_fallback()
765 journal->j_running_transaction->t_tid : 0; in jbd2_fc_end_commit_fallback()
766 read_unlock(&journal->j_state_lock); in jbd2_fc_end_commit_fallback()
767 return __jbd2_fc_end_commit(journal, tid, true); in jbd2_fc_end_commit_fallback()
772 int jbd2_transaction_committed(journal_t *journal, tid_t tid) in jbd2_transaction_committed() argument
774 return tid_geq(READ_ONCE(journal->j_commit_sequence), tid); in jbd2_transaction_committed()
785 int jbd2_complete_transaction(journal_t *journal, tid_t tid) in jbd2_complete_transaction() argument
789 read_lock(&journal->j_state_lock); in jbd2_complete_transaction()
790 if (journal->j_running_transaction && in jbd2_complete_transaction()
791 journal->j_running_transaction->t_tid == tid) { in jbd2_complete_transaction()
792 if (journal->j_commit_request != tid) { in jbd2_complete_transaction()
794 read_unlock(&journal->j_state_lock); in jbd2_complete_transaction()
795 jbd2_log_start_commit(journal, tid); in jbd2_complete_transaction()
798 } else if (!(journal->j_committing_transaction && in jbd2_complete_transaction()
799 journal->j_committing_transaction->t_tid == tid)) in jbd2_complete_transaction()
801 read_unlock(&journal->j_state_lock); in jbd2_complete_transaction()
805 return jbd2_log_wait_commit(journal, tid); in jbd2_complete_transaction()
813 int jbd2_journal_next_log_block(journal_t *journal, unsigned long long *retp) in jbd2_journal_next_log_block() argument
817 write_lock(&journal->j_state_lock); in jbd2_journal_next_log_block()
818 J_ASSERT(journal->j_free > 1); in jbd2_journal_next_log_block()
820 blocknr = journal->j_head; in jbd2_journal_next_log_block()
821 journal->j_head++; in jbd2_journal_next_log_block()
822 journal->j_free--; in jbd2_journal_next_log_block()
823 if (journal->j_head == journal->j_last) in jbd2_journal_next_log_block()
824 journal->j_head = journal->j_first; in jbd2_journal_next_log_block()
825 write_unlock(&journal->j_state_lock); in jbd2_journal_next_log_block()
826 return jbd2_journal_bmap(journal, blocknr, retp); in jbd2_journal_next_log_block()
830 int jbd2_fc_get_buf(journal_t *journal, struct buffer_head **bh_out) in jbd2_fc_get_buf() argument
840 if (journal->j_fc_off + journal->j_fc_first >= journal->j_fc_last) in jbd2_fc_get_buf()
843 fc_off = journal->j_fc_off; in jbd2_fc_get_buf()
844 blocknr = journal->j_fc_first + fc_off; in jbd2_fc_get_buf()
845 journal->j_fc_off++; in jbd2_fc_get_buf()
846 ret = jbd2_journal_bmap(journal, blocknr, &pblock); in jbd2_fc_get_buf()
850 bh = __getblk(journal->j_dev, pblock, journal->j_blocksize); in jbd2_fc_get_buf()
854 journal->j_fc_wbuf[fc_off] = bh; in jbd2_fc_get_buf()
866 int jbd2_fc_wait_bufs(journal_t *journal, int num_blks) in jbd2_fc_wait_bufs() argument
871 j_fc_off = journal->j_fc_off; in jbd2_fc_wait_bufs()
878 bh = journal->j_fc_wbuf[i]; in jbd2_fc_wait_bufs()
885 journal->j_fc_off = i + 1; in jbd2_fc_wait_bufs()
889 journal->j_fc_wbuf[i] = NULL; in jbd2_fc_wait_bufs()
896 void jbd2_fc_release_bufs(journal_t *journal) in jbd2_fc_release_bufs() argument
901 j_fc_off = journal->j_fc_off; in jbd2_fc_release_bufs()
904 bh = journal->j_fc_wbuf[i]; in jbd2_fc_release_bufs()
908 journal->j_fc_wbuf[i] = NULL; in jbd2_fc_release_bufs()
920 int jbd2_journal_bmap(journal_t *journal, unsigned long blocknr, in jbd2_journal_bmap() argument
927 if (journal->j_bmap) { in jbd2_journal_bmap()
928 err = journal->j_bmap(journal, &block); in jbd2_journal_bmap()
931 } else if (journal->j_inode) { in jbd2_journal_bmap()
932 ret = bmap(journal->j_inode, &block); in jbd2_journal_bmap()
937 __func__, blocknr, journal->j_devname); in jbd2_journal_bmap()
939 jbd2_journal_abort(journal, err); in jbd2_journal_bmap()
963 journal_t *journal = transaction->t_journal; in jbd2_journal_get_descriptor_buffer() local
969 err = jbd2_journal_next_log_block(journal, &blocknr); in jbd2_journal_get_descriptor_buffer()
974 bh = __getblk(journal->j_dev, blocknr, journal->j_blocksize); in jbd2_journal_get_descriptor_buffer()
979 memset(bh->b_data, 0, journal->j_blocksize); in jbd2_journal_get_descriptor_buffer()
1015 int jbd2_journal_get_log_tail(journal_t *journal, tid_t *tid, in jbd2_journal_get_log_tail() argument
1021 read_lock(&journal->j_state_lock); in jbd2_journal_get_log_tail()
1022 spin_lock(&journal->j_list_lock); in jbd2_journal_get_log_tail()
1023 transaction = journal->j_checkpoint_transactions; in jbd2_journal_get_log_tail()
1027 } else if ((transaction = journal->j_committing_transaction) != NULL) { in jbd2_journal_get_log_tail()
1030 } else if ((transaction = journal->j_running_transaction) != NULL) { in jbd2_journal_get_log_tail()
1032 *block = journal->j_head; in jbd2_journal_get_log_tail()
1034 *tid = journal->j_transaction_sequence; in jbd2_journal_get_log_tail()
1035 *block = journal->j_head; in jbd2_journal_get_log_tail()
1037 ret = tid_gt(*tid, journal->j_tail_sequence); in jbd2_journal_get_log_tail()
1038 spin_unlock(&journal->j_list_lock); in jbd2_journal_get_log_tail()
1039 read_unlock(&journal->j_state_lock); in jbd2_journal_get_log_tail()
1054 int __jbd2_update_log_tail(journal_t *journal, tid_t tid, unsigned long block) in __jbd2_update_log_tail() argument
1059 BUG_ON(!mutex_is_locked(&journal->j_checkpoint_mutex)); in __jbd2_update_log_tail()
1067 ret = jbd2_journal_update_sb_log_tail(journal, tid, block, REQ_FUA); in __jbd2_update_log_tail()
1071 write_lock(&journal->j_state_lock); in __jbd2_update_log_tail()
1072 freed = block - journal->j_tail; in __jbd2_update_log_tail()
1073 if (block < journal->j_tail) in __jbd2_update_log_tail()
1074 freed += journal->j_last - journal->j_first; in __jbd2_update_log_tail()
1076 trace_jbd2_update_log_tail(journal, tid, block, freed); in __jbd2_update_log_tail()
1080 journal->j_tail_sequence, tid, block, freed); in __jbd2_update_log_tail()
1082 journal->j_free += freed; in __jbd2_update_log_tail()
1083 journal->j_tail_sequence = tid; in __jbd2_update_log_tail()
1084 journal->j_tail = block; in __jbd2_update_log_tail()
1085 write_unlock(&journal->j_state_lock); in __jbd2_update_log_tail()
1096 void jbd2_update_log_tail(journal_t *journal, tid_t tid, unsigned long block) in jbd2_update_log_tail() argument
1098 mutex_lock_io(&journal->j_checkpoint_mutex); in jbd2_update_log_tail()
1099 if (tid_gt(tid, journal->j_tail_sequence)) in jbd2_update_log_tail()
1100 __jbd2_update_log_tail(journal, tid, block); in jbd2_update_log_tail()
1101 mutex_unlock(&journal->j_checkpoint_mutex); in jbd2_update_log_tail()
1105 journal_t *journal; member
1131 s->journal->j_max_transaction_buffers); in jbd2_seq_info_show()
1149 div_u64(s->journal->j_average_commit_time, 1000)); in jbd2_seq_info_show()
1172 journal_t *journal = pde_data(inode); in jbd2_seq_info_open() local
1185 spin_lock(&journal->j_history_lock); in jbd2_seq_info_open()
1186 memcpy(s->stats, &journal->j_stats, size); in jbd2_seq_info_open()
1187 s->journal = journal; in jbd2_seq_info_open()
1188 spin_unlock(&journal->j_history_lock); in jbd2_seq_info_open()
1220 static void jbd2_stats_proc_init(journal_t *journal) in jbd2_stats_proc_init() argument
1222 journal->j_proc_entry = proc_mkdir(journal->j_devname, proc_jbd2_stats); in jbd2_stats_proc_init()
1223 if (journal->j_proc_entry) { in jbd2_stats_proc_init()
1224 proc_create_data("info", S_IRUGO, journal->j_proc_entry, in jbd2_stats_proc_init()
1225 &jbd2_info_proc_ops, journal); in jbd2_stats_proc_init()
1229 static void jbd2_stats_proc_exit(journal_t *journal) in jbd2_stats_proc_exit() argument
1231 remove_proc_entry("info", journal->j_proc_entry); in jbd2_stats_proc_exit()
1232 remove_proc_entry(journal->j_devname, proc_jbd2_stats); in jbd2_stats_proc_exit()
1256 journal_t *journal = shrink->private_data; in jbd2_journal_shrink_scan() local
1261 count = percpu_counter_read_positive(&journal->j_checkpoint_jh_count); in jbd2_journal_shrink_scan()
1262 trace_jbd2_shrink_scan_enter(journal, sc->nr_to_scan, count); in jbd2_journal_shrink_scan()
1264 nr_shrunk = jbd2_journal_shrink_checkpoint_list(journal, &nr_to_scan); in jbd2_journal_shrink_scan()
1266 count = percpu_counter_read_positive(&journal->j_checkpoint_jh_count); in jbd2_journal_shrink_scan()
1267 trace_jbd2_shrink_scan_exit(journal, nr_to_scan, nr_shrunk, count); in jbd2_journal_shrink_scan()
1282 journal_t *journal = shrink->private_data; in jbd2_journal_shrink_count() local
1285 count = percpu_counter_read_positive(&journal->j_checkpoint_jh_count); in jbd2_journal_shrink_count()
1286 trace_jbd2_shrink_count(journal, sc->nr_to_scan, count); in jbd2_journal_shrink_count()
1296 static void journal_fail_superblock(journal_t *journal) in journal_fail_superblock() argument
1298 struct buffer_head *bh = journal->j_sb_buffer; in journal_fail_superblock()
1300 journal->j_sb_buffer = NULL; in journal_fail_superblock()
1307 static int journal_check_superblock(journal_t *journal) in journal_check_superblock() argument
1309 journal_superblock_t *sb = journal->j_superblock; in journal_check_superblock()
1314 sb->s_blocksize != cpu_to_be32(journal->j_blocksize)) { in journal_check_superblock()
1325 if (be32_to_cpu(sb->s_maxlen) > journal->j_total_len) { in journal_check_superblock()
1331 be32_to_cpu(sb->s_first) >= journal->j_total_len) { in journal_check_superblock()
1342 if (!jbd2_format_support_feature(journal)) in journal_check_superblock()
1353 num_fc_blks = jbd2_has_feature_fast_commit(journal) ? in journal_check_superblock()
1362 if (jbd2_has_feature_csum2(journal) && in journal_check_superblock()
1363 jbd2_has_feature_csum3(journal)) { in journal_check_superblock()
1370 if (jbd2_journal_has_csum_v2or3_feature(journal) && in journal_check_superblock()
1371 jbd2_has_feature_checksum(journal)) { in journal_check_superblock()
1379 if (jbd2_journal_has_csum_v2or3_feature(journal)) { in journal_check_superblock()
1385 journal->j_chksum_driver = crypto_alloc_shash("crc32c", 0, 0); in journal_check_superblock()
1386 if (IS_ERR(journal->j_chksum_driver)) { in journal_check_superblock()
1388 err = PTR_ERR(journal->j_chksum_driver); in journal_check_superblock()
1389 journal->j_chksum_driver = NULL; in journal_check_superblock()
1393 if (sb->s_checksum != jbd2_superblock_csum(journal, sb)) { in journal_check_superblock()
1403 static int journal_revoke_records_per_block(journal_t *journal) in journal_revoke_records_per_block() argument
1406 int space = journal->j_blocksize - sizeof(jbd2_journal_revoke_header_t); in journal_revoke_records_per_block()
1408 if (jbd2_has_feature_64bit(journal)) in journal_revoke_records_per_block()
1413 if (jbd2_journal_has_csum_v2or3(journal)) in journal_revoke_records_per_block()
1418 static int jbd2_journal_get_max_txn_bufs(journal_t *journal) in jbd2_journal_get_max_txn_bufs() argument
1420 return (journal->j_total_len - journal->j_fc_wbufsize) / 3; in jbd2_journal_get_max_txn_bufs()
1426 static int jbd2_descriptor_blocks_per_trans(journal_t *journal) in jbd2_descriptor_blocks_per_trans() argument
1428 int tag_space = journal->j_blocksize - sizeof(journal_header_t); in jbd2_descriptor_blocks_per_trans()
1433 if (jbd2_journal_has_csum_v2or3(journal)) in jbd2_descriptor_blocks_per_trans()
1436 tags_per_block = (tag_space - 16) / journal_tag_bytes(journal); in jbd2_descriptor_blocks_per_trans()
1441 return 1 + DIV_ROUND_UP(jbd2_journal_get_max_txn_bufs(journal), in jbd2_descriptor_blocks_per_trans()
1450 static void jbd2_journal_init_transaction_limits(journal_t *journal) in jbd2_journal_init_transaction_limits() argument
1452 journal->j_revoke_records_per_block = in jbd2_journal_init_transaction_limits()
1453 journal_revoke_records_per_block(journal); in jbd2_journal_init_transaction_limits()
1454 journal->j_transaction_overhead_buffers = in jbd2_journal_init_transaction_limits()
1455 jbd2_descriptor_blocks_per_trans(journal); in jbd2_journal_init_transaction_limits()
1456 journal->j_max_transaction_buffers = in jbd2_journal_init_transaction_limits()
1457 jbd2_journal_get_max_txn_bufs(journal); in jbd2_journal_init_transaction_limits()
1464 static int journal_load_superblock(journal_t *journal) in journal_load_superblock() argument
1470 bh = getblk_unmovable(journal->j_dev, journal->j_blk_offset, in journal_load_superblock()
1471 journal->j_blocksize); in journal_load_superblock()
1480 journal->j_sb_buffer = bh; in journal_load_superblock()
1482 journal->j_superblock = sb; in journal_load_superblock()
1483 err = journal_check_superblock(journal); in journal_load_superblock()
1485 journal_fail_superblock(journal); in journal_load_superblock()
1489 journal->j_tail_sequence = be32_to_cpu(sb->s_sequence); in journal_load_superblock()
1490 journal->j_tail = be32_to_cpu(sb->s_start); in journal_load_superblock()
1491 journal->j_first = be32_to_cpu(sb->s_first); in journal_load_superblock()
1492 journal->j_errno = be32_to_cpu(sb->s_errno); in journal_load_superblock()
1493 journal->j_last = be32_to_cpu(sb->s_maxlen); in journal_load_superblock()
1495 if (be32_to_cpu(sb->s_maxlen) < journal->j_total_len) in journal_load_superblock()
1496 journal->j_total_len = be32_to_cpu(sb->s_maxlen); in journal_load_superblock()
1498 if (jbd2_journal_has_csum_v2or3(journal)) in journal_load_superblock()
1499 journal->j_csum_seed = jbd2_chksum(journal, ~0, sb->s_uuid, in journal_load_superblock()
1502 jbd2_journal_init_transaction_limits(journal); in journal_load_superblock()
1504 if (jbd2_has_feature_fast_commit(journal)) { in journal_load_superblock()
1505 journal->j_fc_last = be32_to_cpu(sb->s_maxlen); in journal_load_superblock()
1506 journal->j_last = journal->j_fc_last - in journal_load_superblock()
1508 journal->j_fc_first = journal->j_last + 1; in journal_load_superblock()
1509 journal->j_fc_off = 0; in journal_load_superblock()
1530 journal_t *journal; in journal_init_common() local
1534 journal = kzalloc(sizeof(*journal), GFP_KERNEL); in journal_init_common()
1535 if (!journal) in journal_init_common()
1538 journal->j_blocksize = blocksize; in journal_init_common()
1539 journal->j_dev = bdev; in journal_init_common()
1540 journal->j_fs_dev = fs_dev; in journal_init_common()
1541 journal->j_blk_offset = start; in journal_init_common()
1542 journal->j_total_len = len; in journal_init_common()
1543 jbd2_init_fs_dev_write_error(journal); in journal_init_common()
1545 err = journal_load_superblock(journal); in journal_init_common()
1549 init_waitqueue_head(&journal->j_wait_transaction_locked); in journal_init_common()
1550 init_waitqueue_head(&journal->j_wait_done_commit); in journal_init_common()
1551 init_waitqueue_head(&journal->j_wait_commit); in journal_init_common()
1552 init_waitqueue_head(&journal->j_wait_updates); in journal_init_common()
1553 init_waitqueue_head(&journal->j_wait_reserved); in journal_init_common()
1554 init_waitqueue_head(&journal->j_fc_wait); in journal_init_common()
1555 mutex_init(&journal->j_abort_mutex); in journal_init_common()
1556 mutex_init(&journal->j_barrier); in journal_init_common()
1557 mutex_init(&journal->j_checkpoint_mutex); in journal_init_common()
1558 spin_lock_init(&journal->j_revoke_lock); in journal_init_common()
1559 spin_lock_init(&journal->j_list_lock); in journal_init_common()
1560 spin_lock_init(&journal->j_history_lock); in journal_init_common()
1561 rwlock_init(&journal->j_state_lock); in journal_init_common()
1563 journal->j_commit_interval = (HZ * JBD2_DEFAULT_MAX_COMMIT_AGE); in journal_init_common()
1564 journal->j_min_batch_time = 0; in journal_init_common()
1565 journal->j_max_batch_time = 15000; /* 15ms */ in journal_init_common()
1566 atomic_set(&journal->j_reserved_credits, 0); in journal_init_common()
1567 lockdep_init_map(&journal->j_trans_commit_map, "jbd2_handle", in journal_init_common()
1571 journal->j_flags = JBD2_ABORT; in journal_init_common()
1574 err = jbd2_journal_init_revoke(journal, JOURNAL_REVOKE_DEFAULT_HASH); in journal_init_common()
1583 n = journal->j_blocksize / jbd2_min_tag_size(); in journal_init_common()
1584 journal->j_wbufsize = n; in journal_init_common()
1585 journal->j_fc_wbuf = NULL; in journal_init_common()
1586 journal->j_wbuf = kmalloc_array(n, sizeof(struct buffer_head *), in journal_init_common()
1588 if (!journal->j_wbuf) in journal_init_common()
1591 err = percpu_counter_init(&journal->j_checkpoint_jh_count, 0, in journal_init_common()
1596 journal->j_shrink_transaction = NULL; in journal_init_common()
1598 journal->j_shrinker = shrinker_alloc(0, "jbd2-journal:(%u:%u)", in journal_init_common()
1601 if (!journal->j_shrinker) { in journal_init_common()
1606 journal->j_shrinker->scan_objects = jbd2_journal_shrink_scan; in journal_init_common()
1607 journal->j_shrinker->count_objects = jbd2_journal_shrink_count; in journal_init_common()
1608 journal->j_shrinker->private_data = journal; in journal_init_common()
1610 shrinker_register(journal->j_shrinker); in journal_init_common()
1612 return journal; in journal_init_common()
1615 percpu_counter_destroy(&journal->j_checkpoint_jh_count); in journal_init_common()
1616 if (journal->j_chksum_driver) in journal_init_common()
1617 crypto_free_shash(journal->j_chksum_driver); in journal_init_common()
1618 kfree(journal->j_wbuf); in journal_init_common()
1619 jbd2_journal_destroy_revoke(journal); in journal_init_common()
1620 journal_fail_superblock(journal); in journal_init_common()
1621 kfree(journal); in journal_init_common()
1652 journal_t *journal; in jbd2_journal_init_dev() local
1654 journal = journal_init_common(bdev, fs_dev, start, len, blocksize); in jbd2_journal_init_dev()
1655 if (IS_ERR(journal)) in jbd2_journal_init_dev()
1656 return ERR_CAST(journal); in jbd2_journal_init_dev()
1658 snprintf(journal->j_devname, sizeof(journal->j_devname), in jbd2_journal_init_dev()
1659 "%pg", journal->j_dev); in jbd2_journal_init_dev()
1660 strreplace(journal->j_devname, '/', '!'); in jbd2_journal_init_dev()
1661 jbd2_stats_proc_init(journal); in jbd2_journal_init_dev()
1663 return journal; in jbd2_journal_init_dev()
1676 journal_t *journal; in jbd2_journal_init_inode() local
1691 journal = journal_init_common(inode->i_sb->s_bdev, inode->i_sb->s_bdev, in jbd2_journal_init_inode()
1694 if (IS_ERR(journal)) in jbd2_journal_init_inode()
1695 return ERR_CAST(journal); in jbd2_journal_init_inode()
1697 journal->j_inode = inode; in jbd2_journal_init_inode()
1698 snprintf(journal->j_devname, sizeof(journal->j_devname), in jbd2_journal_init_inode()
1699 "%pg-%lu", journal->j_dev, journal->j_inode->i_ino); in jbd2_journal_init_inode()
1700 strreplace(journal->j_devname, '/', '!'); in jbd2_journal_init_inode()
1701 jbd2_stats_proc_init(journal); in jbd2_journal_init_inode()
1703 return journal; in jbd2_journal_init_inode()
1713 static int journal_reset(journal_t *journal) in journal_reset() argument
1715 journal_superblock_t *sb = journal->j_superblock; in journal_reset()
1723 journal_fail_superblock(journal); in journal_reset()
1727 journal->j_first = first; in journal_reset()
1728 journal->j_last = last; in journal_reset()
1730 if (journal->j_head != 0 && journal->j_flags & JBD2_CYCLE_RECORD) { in journal_reset()
1735 if (journal->j_head < first || journal->j_head >= last) { in journal_reset()
1738 journal->j_head); in journal_reset()
1739 journal->j_head = journal->j_first; in journal_reset()
1742 journal->j_head = journal->j_first; in journal_reset()
1744 journal->j_tail = journal->j_head; in journal_reset()
1745 journal->j_free = journal->j_last - journal->j_first; in journal_reset()
1747 journal->j_tail_sequence = journal->j_transaction_sequence; in journal_reset()
1748 journal->j_commit_sequence = journal->j_transaction_sequence - 1; in journal_reset()
1749 journal->j_commit_request = journal->j_commit_sequence; in journal_reset()
1756 jbd2_clear_feature_fast_commit(journal); in journal_reset()
1767 journal->j_tail, journal->j_tail_sequence, in journal_reset()
1768 journal->j_errno); in journal_reset()
1769 journal->j_flags |= JBD2_FLUSHED; in journal_reset()
1772 mutex_lock_io(&journal->j_checkpoint_mutex); in journal_reset()
1779 jbd2_journal_update_sb_log_tail(journal, in journal_reset()
1780 journal->j_tail_sequence, in journal_reset()
1781 journal->j_tail, REQ_FUA); in journal_reset()
1782 mutex_unlock(&journal->j_checkpoint_mutex); in journal_reset()
1784 return jbd2_journal_start_thread(journal); in journal_reset()
1791 static int jbd2_write_superblock(journal_t *journal, blk_opf_t write_flags) in jbd2_write_superblock() argument
1793 struct buffer_head *bh = journal->j_sb_buffer; in jbd2_write_superblock()
1794 journal_superblock_t *sb = journal->j_superblock; in jbd2_write_superblock()
1808 if (!(journal->j_flags & JBD2_BARRIER)) in jbd2_write_superblock()
1811 trace_jbd2_write_superblock(journal, write_flags); in jbd2_write_superblock()
1824 journal->j_devname); in jbd2_write_superblock()
1828 if (jbd2_journal_has_csum_v2or3(journal)) in jbd2_write_superblock()
1829 sb->s_checksum = jbd2_superblock_csum(journal, sb); in jbd2_write_superblock()
1841 journal->j_devname); in jbd2_write_superblock()
1842 if (!is_journal_aborted(journal)) in jbd2_write_superblock()
1843 jbd2_journal_abort(journal, ret); in jbd2_write_superblock()
1859 int jbd2_journal_update_sb_log_tail(journal_t *journal, tid_t tail_tid, in jbd2_journal_update_sb_log_tail() argument
1863 journal_superblock_t *sb = journal->j_superblock; in jbd2_journal_update_sb_log_tail()
1866 if (is_journal_aborted(journal)) in jbd2_journal_update_sb_log_tail()
1868 if (jbd2_check_fs_dev_write_error(journal)) { in jbd2_journal_update_sb_log_tail()
1869 jbd2_journal_abort(journal, -EIO); in jbd2_journal_update_sb_log_tail()
1873 BUG_ON(!mutex_is_locked(&journal->j_checkpoint_mutex)); in jbd2_journal_update_sb_log_tail()
1877 lock_buffer(journal->j_sb_buffer); in jbd2_journal_update_sb_log_tail()
1881 ret = jbd2_write_superblock(journal, write_flags); in jbd2_journal_update_sb_log_tail()
1886 write_lock(&journal->j_state_lock); in jbd2_journal_update_sb_log_tail()
1888 journal->j_flags &= ~JBD2_FLUSHED; in jbd2_journal_update_sb_log_tail()
1889 write_unlock(&journal->j_state_lock); in jbd2_journal_update_sb_log_tail()
1903 static void jbd2_mark_journal_empty(journal_t *journal, blk_opf_t write_flags) in jbd2_mark_journal_empty() argument
1905 journal_superblock_t *sb = journal->j_superblock; in jbd2_mark_journal_empty()
1908 BUG_ON(!mutex_is_locked(&journal->j_checkpoint_mutex)); in jbd2_mark_journal_empty()
1909 lock_buffer(journal->j_sb_buffer); in jbd2_mark_journal_empty()
1911 unlock_buffer(journal->j_sb_buffer); in jbd2_mark_journal_empty()
1916 journal->j_tail_sequence); in jbd2_mark_journal_empty()
1918 sb->s_sequence = cpu_to_be32(journal->j_tail_sequence); in jbd2_mark_journal_empty()
1920 sb->s_head = cpu_to_be32(journal->j_head); in jbd2_mark_journal_empty()
1921 if (jbd2_has_feature_fast_commit(journal)) { in jbd2_mark_journal_empty()
1926 jbd2_clear_feature_fast_commit(journal); in jbd2_mark_journal_empty()
1930 jbd2_write_superblock(journal, write_flags); in jbd2_mark_journal_empty()
1933 jbd2_set_feature_fast_commit(journal); in jbd2_mark_journal_empty()
1936 write_lock(&journal->j_state_lock); in jbd2_mark_journal_empty()
1937 journal->j_flags |= JBD2_FLUSHED; in jbd2_mark_journal_empty()
1938 write_unlock(&journal->j_state_lock); in jbd2_mark_journal_empty()
1953 static int __jbd2_journal_erase(journal_t *journal, unsigned int flags) in __jbd2_journal_erase() argument
1967 !bdev_max_discard_sectors(journal->j_dev)) in __jbd2_journal_erase()
1974 log_offset = be32_to_cpu(journal->j_superblock->s_first); in __jbd2_journal_erase()
1976 for (block = log_offset; block < journal->j_total_len; block++) { in __jbd2_journal_erase()
1977 err = jbd2_journal_bmap(journal, block, &phys_block); in __jbd2_journal_erase()
2002 if (block != journal->j_total_len - 1) in __jbd2_journal_erase()
2010 byte_start = block_start * journal->j_blocksize; in __jbd2_journal_erase()
2011 byte_stop = block_stop * journal->j_blocksize; in __jbd2_journal_erase()
2013 journal->j_blocksize; in __jbd2_journal_erase()
2015 truncate_inode_pages_range(journal->j_dev->bd_mapping, in __jbd2_journal_erase()
2019 err = blkdev_issue_discard(journal->j_dev, in __jbd2_journal_erase()
2024 err = blkdev_issue_zeroout(journal->j_dev, in __jbd2_journal_erase()
2040 return blkdev_issue_flush(journal->j_dev); in __jbd2_journal_erase()
2050 void jbd2_journal_update_sb_errno(journal_t *journal) in jbd2_journal_update_sb_errno() argument
2052 journal_superblock_t *sb = journal->j_superblock; in jbd2_journal_update_sb_errno()
2055 lock_buffer(journal->j_sb_buffer); in jbd2_journal_update_sb_errno()
2056 errcode = journal->j_errno; in jbd2_journal_update_sb_errno()
2062 jbd2_write_superblock(journal, REQ_FUA); in jbd2_journal_update_sb_errno()
2074 int jbd2_journal_load(journal_t *journal) in jbd2_journal_load() argument
2077 journal_superblock_t *sb = journal->j_superblock; in jbd2_journal_load()
2088 err = jbd2_journal_recover(journal); in jbd2_journal_load()
2094 if (journal->j_failed_commit) { in jbd2_journal_load()
2096 "is corrupt.\n", journal->j_failed_commit, in jbd2_journal_load()
2097 journal->j_devname); in jbd2_journal_load()
2104 journal->j_flags &= ~JBD2_ABORT; in jbd2_journal_load()
2109 err = journal_reset(journal); in jbd2_journal_load()
2115 journal->j_flags |= JBD2_LOADED; in jbd2_journal_load()
2127 int jbd2_journal_destroy(journal_t *journal) in jbd2_journal_destroy() argument
2132 journal_kill_thread(journal); in jbd2_journal_destroy()
2135 if (journal->j_running_transaction) in jbd2_journal_destroy()
2136 jbd2_journal_commit_transaction(journal); in jbd2_journal_destroy()
2141 spin_lock(&journal->j_list_lock); in jbd2_journal_destroy()
2142 while (journal->j_checkpoint_transactions != NULL) { in jbd2_journal_destroy()
2143 spin_unlock(&journal->j_list_lock); in jbd2_journal_destroy()
2144 mutex_lock_io(&journal->j_checkpoint_mutex); in jbd2_journal_destroy()
2145 err = jbd2_log_do_checkpoint(journal); in jbd2_journal_destroy()
2146 mutex_unlock(&journal->j_checkpoint_mutex); in jbd2_journal_destroy()
2152 jbd2_journal_destroy_checkpoint(journal); in jbd2_journal_destroy()
2153 spin_lock(&journal->j_list_lock); in jbd2_journal_destroy()
2156 spin_lock(&journal->j_list_lock); in jbd2_journal_destroy()
2159 J_ASSERT(journal->j_running_transaction == NULL); in jbd2_journal_destroy()
2160 J_ASSERT(journal->j_committing_transaction == NULL); in jbd2_journal_destroy()
2161 J_ASSERT(journal->j_checkpoint_transactions == NULL); in jbd2_journal_destroy()
2162 spin_unlock(&journal->j_list_lock); in jbd2_journal_destroy()
2170 if (!is_journal_aborted(journal) && in jbd2_journal_destroy()
2171 jbd2_check_fs_dev_write_error(journal)) in jbd2_journal_destroy()
2172 jbd2_journal_abort(journal, -EIO); in jbd2_journal_destroy()
2174 if (journal->j_sb_buffer) { in jbd2_journal_destroy()
2175 if (!is_journal_aborted(journal)) { in jbd2_journal_destroy()
2176 mutex_lock_io(&journal->j_checkpoint_mutex); in jbd2_journal_destroy()
2178 write_lock(&journal->j_state_lock); in jbd2_journal_destroy()
2179 journal->j_tail_sequence = in jbd2_journal_destroy()
2180 ++journal->j_transaction_sequence; in jbd2_journal_destroy()
2181 write_unlock(&journal->j_state_lock); in jbd2_journal_destroy()
2183 jbd2_mark_journal_empty(journal, REQ_PREFLUSH | REQ_FUA); in jbd2_journal_destroy()
2184 mutex_unlock(&journal->j_checkpoint_mutex); in jbd2_journal_destroy()
2187 brelse(journal->j_sb_buffer); in jbd2_journal_destroy()
2190 if (journal->j_shrinker) { in jbd2_journal_destroy()
2191 percpu_counter_destroy(&journal->j_checkpoint_jh_count); in jbd2_journal_destroy()
2192 shrinker_free(journal->j_shrinker); in jbd2_journal_destroy()
2194 if (journal->j_proc_entry) in jbd2_journal_destroy()
2195 jbd2_stats_proc_exit(journal); in jbd2_journal_destroy()
2196 iput(journal->j_inode); in jbd2_journal_destroy()
2197 if (journal->j_revoke) in jbd2_journal_destroy()
2198 jbd2_journal_destroy_revoke(journal); in jbd2_journal_destroy()
2199 if (journal->j_chksum_driver) in jbd2_journal_destroy()
2200 crypto_free_shash(journal->j_chksum_driver); in jbd2_journal_destroy()
2201 kfree(journal->j_fc_wbuf); in jbd2_journal_destroy()
2202 kfree(journal->j_wbuf); in jbd2_journal_destroy()
2203 kfree(journal); in jbd2_journal_destroy()
2220 int jbd2_journal_check_used_features(journal_t *journal, unsigned long compat, in jbd2_journal_check_used_features() argument
2227 if (!jbd2_format_support_feature(journal)) in jbd2_journal_check_used_features()
2230 sb = journal->j_superblock; in jbd2_journal_check_used_features()
2251 int jbd2_journal_check_available_features(journal_t *journal, unsigned long compat, in jbd2_journal_check_available_features() argument
2257 if (!jbd2_format_support_feature(journal)) in jbd2_journal_check_available_features()
2269 jbd2_journal_initialize_fast_commit(journal_t *journal) in jbd2_journal_initialize_fast_commit() argument
2271 journal_superblock_t *sb = journal->j_superblock; in jbd2_journal_initialize_fast_commit()
2275 if (journal->j_last - num_fc_blks < JBD2_MIN_JOURNAL_BLOCKS) in jbd2_journal_initialize_fast_commit()
2279 WARN_ON(journal->j_fc_wbuf != NULL); in jbd2_journal_initialize_fast_commit()
2280 journal->j_fc_wbuf = kmalloc_array(num_fc_blks, in jbd2_journal_initialize_fast_commit()
2282 if (!journal->j_fc_wbuf) in jbd2_journal_initialize_fast_commit()
2285 journal->j_fc_wbufsize = num_fc_blks; in jbd2_journal_initialize_fast_commit()
2286 journal->j_fc_last = journal->j_last; in jbd2_journal_initialize_fast_commit()
2287 journal->j_last = journal->j_fc_last - num_fc_blks; in jbd2_journal_initialize_fast_commit()
2288 journal->j_fc_first = journal->j_last + 1; in jbd2_journal_initialize_fast_commit()
2289 journal->j_fc_off = 0; in jbd2_journal_initialize_fast_commit()
2290 journal->j_free = journal->j_last - journal->j_first; in jbd2_journal_initialize_fast_commit()
2307 int jbd2_journal_set_features(journal_t *journal, unsigned long compat, in jbd2_journal_set_features() argument
2316 if (jbd2_journal_check_used_features(journal, compat, ro, incompat)) in jbd2_journal_set_features()
2319 if (!jbd2_journal_check_available_features(journal, compat, ro, incompat)) in jbd2_journal_set_features()
2336 sb = journal->j_superblock; in jbd2_journal_set_features()
2339 if (jbd2_journal_initialize_fast_commit(journal)) { in jbd2_journal_set_features()
2346 if ((journal->j_chksum_driver == NULL) && in jbd2_journal_set_features()
2348 journal->j_chksum_driver = crypto_alloc_shash("crc32c", 0, 0); in jbd2_journal_set_features()
2349 if (IS_ERR(journal->j_chksum_driver)) { in jbd2_journal_set_features()
2351 journal->j_chksum_driver = NULL; in jbd2_journal_set_features()
2355 journal->j_csum_seed = jbd2_chksum(journal, ~0, sb->s_uuid, in jbd2_journal_set_features()
2359 lock_buffer(journal->j_sb_buffer); in jbd2_journal_set_features()
2377 unlock_buffer(journal->j_sb_buffer); in jbd2_journal_set_features()
2378 jbd2_journal_init_transaction_limits(journal); in jbd2_journal_set_features()
2396 void jbd2_journal_clear_features(journal_t *journal, unsigned long compat, in jbd2_journal_clear_features() argument
2404 sb = journal->j_superblock; in jbd2_journal_clear_features()
2409 jbd2_journal_init_transaction_limits(journal); in jbd2_journal_clear_features()
2427 int jbd2_journal_flush(journal_t *journal, unsigned int flags) in jbd2_journal_flush() argument
2432 write_lock(&journal->j_state_lock); in jbd2_journal_flush()
2435 if (journal->j_running_transaction) { in jbd2_journal_flush()
2436 transaction = journal->j_running_transaction; in jbd2_journal_flush()
2437 __jbd2_log_start_commit(journal, transaction->t_tid); in jbd2_journal_flush()
2438 } else if (journal->j_committing_transaction) in jbd2_journal_flush()
2439 transaction = journal->j_committing_transaction; in jbd2_journal_flush()
2445 write_unlock(&journal->j_state_lock); in jbd2_journal_flush()
2446 jbd2_log_wait_commit(journal, tid); in jbd2_journal_flush()
2448 write_unlock(&journal->j_state_lock); in jbd2_journal_flush()
2452 spin_lock(&journal->j_list_lock); in jbd2_journal_flush()
2453 while (!err && journal->j_checkpoint_transactions != NULL) { in jbd2_journal_flush()
2454 spin_unlock(&journal->j_list_lock); in jbd2_journal_flush()
2455 mutex_lock_io(&journal->j_checkpoint_mutex); in jbd2_journal_flush()
2456 err = jbd2_log_do_checkpoint(journal); in jbd2_journal_flush()
2457 mutex_unlock(&journal->j_checkpoint_mutex); in jbd2_journal_flush()
2458 spin_lock(&journal->j_list_lock); in jbd2_journal_flush()
2460 spin_unlock(&journal->j_list_lock); in jbd2_journal_flush()
2462 if (is_journal_aborted(journal)) in jbd2_journal_flush()
2465 mutex_lock_io(&journal->j_checkpoint_mutex); in jbd2_journal_flush()
2467 err = jbd2_cleanup_journal_tail(journal); in jbd2_journal_flush()
2469 mutex_unlock(&journal->j_checkpoint_mutex); in jbd2_journal_flush()
2480 jbd2_mark_journal_empty(journal, REQ_FUA); in jbd2_journal_flush()
2483 err = __jbd2_journal_erase(journal, flags); in jbd2_journal_flush()
2485 mutex_unlock(&journal->j_checkpoint_mutex); in jbd2_journal_flush()
2486 write_lock(&journal->j_state_lock); in jbd2_journal_flush()
2487 J_ASSERT(!journal->j_running_transaction); in jbd2_journal_flush()
2488 J_ASSERT(!journal->j_committing_transaction); in jbd2_journal_flush()
2489 J_ASSERT(!journal->j_checkpoint_transactions); in jbd2_journal_flush()
2490 J_ASSERT(journal->j_head == journal->j_tail); in jbd2_journal_flush()
2491 J_ASSERT(journal->j_tail_sequence == journal->j_transaction_sequence); in jbd2_journal_flush()
2492 write_unlock(&journal->j_state_lock); in jbd2_journal_flush()
2510 int jbd2_journal_wipe(journal_t *journal, int write) in jbd2_journal_wipe() argument
2514 J_ASSERT (!(journal->j_flags & JBD2_LOADED)); in jbd2_journal_wipe()
2516 if (!journal->j_tail) in jbd2_journal_wipe()
2522 err = jbd2_journal_skip_recovery(journal); in jbd2_journal_wipe()
2525 mutex_lock_io(&journal->j_checkpoint_mutex); in jbd2_journal_wipe()
2526 jbd2_mark_journal_empty(journal, REQ_FUA); in jbd2_journal_wipe()
2527 mutex_unlock(&journal->j_checkpoint_mutex); in jbd2_journal_wipe()
2574 void jbd2_journal_abort(journal_t *journal, int errno) in jbd2_journal_abort() argument
2584 mutex_lock(&journal->j_abort_mutex); in jbd2_journal_abort()
2590 write_lock(&journal->j_state_lock); in jbd2_journal_abort()
2591 if (journal->j_flags & JBD2_ABORT) { in jbd2_journal_abort()
2592 int old_errno = journal->j_errno; in jbd2_journal_abort()
2594 write_unlock(&journal->j_state_lock); in jbd2_journal_abort()
2596 journal->j_errno = errno; in jbd2_journal_abort()
2597 jbd2_journal_update_sb_errno(journal); in jbd2_journal_abort()
2599 mutex_unlock(&journal->j_abort_mutex); in jbd2_journal_abort()
2607 pr_err("Aborting journal on device %s.\n", journal->j_devname); in jbd2_journal_abort()
2609 journal->j_flags |= JBD2_ABORT; in jbd2_journal_abort()
2610 journal->j_errno = errno; in jbd2_journal_abort()
2611 transaction = journal->j_running_transaction; in jbd2_journal_abort()
2613 __jbd2_log_start_commit(journal, transaction->t_tid); in jbd2_journal_abort()
2614 write_unlock(&journal->j_state_lock); in jbd2_journal_abort()
2620 jbd2_journal_update_sb_errno(journal); in jbd2_journal_abort()
2621 mutex_unlock(&journal->j_abort_mutex); in jbd2_journal_abort()
2635 int jbd2_journal_errno(journal_t *journal) in jbd2_journal_errno() argument
2639 read_lock(&journal->j_state_lock); in jbd2_journal_errno()
2640 if (journal->j_flags & JBD2_ABORT) in jbd2_journal_errno()
2643 err = journal->j_errno; in jbd2_journal_errno()
2644 read_unlock(&journal->j_state_lock); in jbd2_journal_errno()
2655 int jbd2_journal_clear_err(journal_t *journal) in jbd2_journal_clear_err() argument
2659 write_lock(&journal->j_state_lock); in jbd2_journal_clear_err()
2660 if (journal->j_flags & JBD2_ABORT) in jbd2_journal_clear_err()
2663 journal->j_errno = 0; in jbd2_journal_clear_err()
2664 write_unlock(&journal->j_state_lock); in jbd2_journal_clear_err()
2675 void jbd2_journal_ack_err(journal_t *journal) in jbd2_journal_ack_err() argument
2677 write_lock(&journal->j_state_lock); in jbd2_journal_ack_err()
2678 if (journal->j_errno) in jbd2_journal_ack_err()
2679 journal->j_flags |= JBD2_ACK_ERR; in jbd2_journal_ack_err()
2680 write_unlock(&journal->j_state_lock); in jbd2_journal_ack_err()
2691 size_t journal_tag_bytes(journal_t *journal) in journal_tag_bytes() argument
2695 if (jbd2_has_feature_csum3(journal)) in journal_tag_bytes()
2700 if (jbd2_has_feature_csum2(journal)) in journal_tag_bytes()
2703 if (jbd2_has_feature_64bit(journal)) in journal_tag_bytes()
3038 void jbd2_journal_release_jbd_inode(journal_t *journal, in jbd2_journal_release_jbd_inode() argument
3041 if (!journal) in jbd2_journal_release_jbd_inode()
3044 spin_lock(&journal->j_list_lock); in jbd2_journal_release_jbd_inode()
3051 spin_unlock(&journal->j_list_lock); in jbd2_journal_release_jbd_inode()
3061 spin_unlock(&journal->j_list_lock); in jbd2_journal_release_jbd_inode()