summaryrefslogtreecommitdiffstats
path: root/fs/jbd2
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2015-06-08 12:39:07 -0400
committerTheodore Ts'o <tytso@mit.edu>2015-06-08 12:39:07 -0400
commitee57aba159a5c329dc78c181a3ae0549e59f0925 (patch)
tree68c77867c84de451aefcc518463649b924055380 /fs/jbd2
parentb4ab9e29820bf2e8842281a6b5e645e59c9992a5 (diff)
jbd2: simplify code flow in do_get_write_access()
needs_copy is set only in one place in do_get_write_access(), just move the frozen buffer copying into that place and factor it out to a separate function to make do_get_write_access() slightly more readable. Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/jbd2')
-rw-r--r--fs/jbd2/transaction.c49
1 files changed, 25 insertions, 24 deletions
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index 799242cecffb..2bcb43d770a0 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -755,6 +755,30 @@ static void warn_dirty_buffer(struct buffer_head *bh)
755 bdevname(bh->b_bdev, b), (unsigned long long)bh->b_blocknr); 755 bdevname(bh->b_bdev, b), (unsigned long long)bh->b_blocknr);
756} 756}
757 757
758/* Call t_frozen trigger and copy buffer data into jh->b_frozen_data. */
759static void jbd2_freeze_jh_data(struct journal_head *jh)
760{
761 struct page *page;
762 int offset;
763 char *source;
764 struct buffer_head *bh = jh2bh(jh);
765
766 J_EXPECT_JH(jh, buffer_uptodate(bh), "Possible IO failure.\n");
767 page = bh->b_page;
768 offset = offset_in_page(bh->b_data);
769 source = kmap_atomic(page);
770 /* Fire data frozen trigger just before we copy the data */
771 jbd2_buffer_frozen_trigger(jh, source + offset, jh->b_triggers);
772 memcpy(jh->b_frozen_data, source + offset, bh->b_size);
773 kunmap_atomic(source);
774
775 /*
776 * Now that the frozen data is saved off, we need to store any matching
777 * triggers.
778 */
779 jh->b_frozen_triggers = jh->b_triggers;
780}
781
758/* 782/*
759 * If the buffer is already part of the current transaction, then there 783 * If the buffer is already part of the current transaction, then there
760 * is nothing we need to do. If it is already part of a prior 784 * is nothing we need to do. If it is already part of a prior
@@ -774,7 +798,6 @@ do_get_write_access(handle_t *handle, struct journal_head *jh,
774 journal_t *journal; 798 journal_t *journal;
775 int error; 799 int error;
776 char *frozen_buffer = NULL; 800 char *frozen_buffer = NULL;
777 int need_copy = 0;
778 unsigned long start_lock, time_lock; 801 unsigned long start_lock, time_lock;
779 802
780 if (is_handle_aborted(handle)) 803 if (is_handle_aborted(handle))
@@ -931,7 +954,7 @@ repeat:
931 } 954 }
932 jh->b_frozen_data = frozen_buffer; 955 jh->b_frozen_data = frozen_buffer;
933 frozen_buffer = NULL; 956 frozen_buffer = NULL;
934 need_copy = 1; 957 jbd2_freeze_jh_data(jh);
935 } 958 }
936 jh->b_next_transaction = transaction; 959 jh->b_next_transaction = transaction;
937 } 960 }
@@ -952,28 +975,6 @@ repeat:
952 } 975 }
953 976
954done: 977done:
955 if (need_copy) {
956 struct page *page;
957 int offset;
958 char *source;
959
960 J_EXPECT_JH(jh, buffer_uptodate(jh2bh(jh)),
961 "Possible IO failure.\n");
962 page = jh2bh(jh)->b_page;
963 offset = offset_in_page(jh2bh(jh)->b_data);
964 source = kmap_atomic(page);
965 /* Fire data frozen trigger just before we copy the data */
966 jbd2_buffer_frozen_trigger(jh, source + offset,
967 jh->b_triggers);
968 memcpy(jh->b_frozen_data, source+offset, jh2bh(jh)->b_size);
969 kunmap_atomic(source);
970
971 /*
972 * Now that the frozen data is saved off, we need to store
973 * any matching triggers.
974 */
975 jh->b_frozen_triggers = jh->b_triggers;
976 }
977 jbd_unlock_bh_state(bh); 978 jbd_unlock_bh_state(bh);
978 979
979 /* 980 /*