commit.c (79feb521a44705262d15cc819a4117a447b11ea7) commit.c (3339578f05787259917788f461f4196b7349c2a4)
1/*
2 * linux/fs/jbd2/commit.c
3 *
4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1998
5 *
6 * Copyright 1998 Red Hat corp --- All Rights Reserved
7 *
8 * This file is part of the Linux kernel and is made available under

--- 317 unchanged lines hidden (view full) ---

326 int space_left = 0;
327 int first_tag = 0;
328 int tag_flag;
329 int i, to_free = 0;
330 int tag_bytes = journal_tag_bytes(journal);
331 struct buffer_head *cbh = NULL; /* For transactional checksums */
332 __u32 crc32_sum = ~0;
333 struct blk_plug plug;
1/*
2 * linux/fs/jbd2/commit.c
3 *
4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1998
5 *
6 * Copyright 1998 Red Hat corp --- All Rights Reserved
7 *
8 * This file is part of the Linux kernel and is made available under

--- 317 unchanged lines hidden (view full) ---

326 int space_left = 0;
327 int first_tag = 0;
328 int tag_flag;
329 int i, to_free = 0;
330 int tag_bytes = journal_tag_bytes(journal);
331 struct buffer_head *cbh = NULL; /* For transactional checksums */
332 __u32 crc32_sum = ~0;
333 struct blk_plug plug;
334 /* Tail of the journal */
335 unsigned long first_block;
336 tid_t first_tid;
337 int update_tail;
334
335 /*
336 * First job: lock down the current transaction and wait for
337 * all outstanding updates to complete.
338 */
339
340 /* Do we need to erase the effects of a prior jbd2_journal_flush? */
341 if (journal->j_flags & JBD2_FLUSHED) {

--- 341 unchanged lines hidden (view full) ---

683 printk(KERN_WARNING
684 "JBD2: Detected IO errors while flushing file data "
685 "on %s\n", journal->j_devname);
686 if (journal->j_flags & JBD2_ABORT_ON_SYNCDATA_ERR)
687 jbd2_journal_abort(journal, err);
688 err = 0;
689 }
690
338
339 /*
340 * First job: lock down the current transaction and wait for
341 * all outstanding updates to complete.
342 */
343
344 /* Do we need to erase the effects of a prior jbd2_journal_flush? */
345 if (journal->j_flags & JBD2_FLUSHED) {

--- 341 unchanged lines hidden (view full) ---

687 printk(KERN_WARNING
688 "JBD2: Detected IO errors while flushing file data "
689 "on %s\n", journal->j_devname);
690 if (journal->j_flags & JBD2_ABORT_ON_SYNCDATA_ERR)
691 jbd2_journal_abort(journal, err);
692 err = 0;
693 }
694
695 /*
696 * Get current oldest transaction in the log before we issue flush
697 * to the filesystem device. After the flush we can be sure that
698 * blocks of all older transactions are checkpointed to persistent
699 * storage and we will be safe to update journal start in the
700 * superblock with the numbers we get here.
701 */
702 update_tail =
703 jbd2_journal_get_log_tail(journal, &first_tid, &first_block);
704
691 write_lock(&journal->j_state_lock);
705 write_lock(&journal->j_state_lock);
706 if (update_tail) {
707 long freed = first_block - journal->j_tail;
708
709 if (first_block < journal->j_tail)
710 freed += journal->j_last - journal->j_first;
711 /* Update tail only if we free significant amount of space */
712 if (freed < journal->j_maxlen / 4)
713 update_tail = 0;
714 }
692 J_ASSERT(commit_transaction->t_state == T_COMMIT);
693 commit_transaction->t_state = T_COMMIT_DFLUSH;
694 write_unlock(&journal->j_state_lock);
715 J_ASSERT(commit_transaction->t_state == T_COMMIT);
716 commit_transaction->t_state = T_COMMIT_DFLUSH;
717 write_unlock(&journal->j_state_lock);
718
695 /*
696 * If the journal is not located on the file system device,
697 * then we must flush the file system device before we issue
698 * the commit record
699 */
700 if (commit_transaction->t_need_data_flush &&
701 (journal->j_fs_dev != journal->j_dev) &&
702 (journal->j_flags & JBD2_BARRIER))

--- 134 unchanged lines hidden (view full) ---

837 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT) &&
838 journal->j_flags & JBD2_BARRIER) {
839 blkdev_issue_flush(journal->j_dev, GFP_KERNEL, NULL);
840 }
841
842 if (err)
843 jbd2_journal_abort(journal, err);
844
719 /*
720 * If the journal is not located on the file system device,
721 * then we must flush the file system device before we issue
722 * the commit record
723 */
724 if (commit_transaction->t_need_data_flush &&
725 (journal->j_fs_dev != journal->j_dev) &&
726 (journal->j_flags & JBD2_BARRIER))

--- 134 unchanged lines hidden (view full) ---

861 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT) &&
862 journal->j_flags & JBD2_BARRIER) {
863 blkdev_issue_flush(journal->j_dev, GFP_KERNEL, NULL);
864 }
865
866 if (err)
867 jbd2_journal_abort(journal, err);
868
869 /*
870 * Now disk caches for filesystem device are flushed so we are safe to
871 * erase checkpointed transactions from the log by updating journal
872 * superblock.
873 */
874 if (update_tail)
875 jbd2_update_log_tail(journal, first_tid, first_block);
876
845 /* End of a transaction! Finally, we can do checkpoint
846 processing: any buffers committed as a result of this
847 transaction can be removed from any checkpoint list it was on
848 before. */
849
850 jbd_debug(3, "JBD2: commit phase 6\n");
851
852 J_ASSERT(list_empty(&commit_transaction->t_inode_list));

--- 213 unchanged lines hidden ---
877 /* End of a transaction! Finally, we can do checkpoint
878 processing: any buffers committed as a result of this
879 transaction can be removed from any checkpoint list it was on
880 before. */
881
882 jbd_debug(3, "JBD2: commit phase 6\n");
883
884 J_ASSERT(list_empty(&commit_transaction->t_inode_list));

--- 213 unchanged lines hidden ---