1 jbd2: simplify code flow in do_get_write_access()
3 From: Jan Kara <jack@suse.cz>
5 needs_copy is set only in one place in do_get_write_access(), just move
6 the frozen buffer copying into that place and factor it out to a
7 separate function to make do_get_write_access() slightly more readable.
9 Signed-off-by: Jan Kara <jack@suse.cz>
10 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 fs/jbd2/transaction.c | 49 +++++++++++++++++++++++++------------------------
13 1 file changed, 25 insertions(+), 24 deletions(-)
15 diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
16 index 5f09370c90a8..2b75f0f109be 100644
17 --- a/fs/jbd2/transaction.c
18 +++ b/fs/jbd2/transaction.c
19 @@ -763,6 +763,30 @@ static void warn_dirty_buffer(struct buffer_head *bh)
20 bdevname(bh->b_bdev, b), (unsigned long long)bh->b_blocknr);
23 +/* Call t_frozen trigger and copy buffer data into jh->b_frozen_data. */
24 +static void jbd2_freeze_jh_data(struct journal_head *jh)
29 + struct buffer_head *bh = jh2bh(jh);
31 + J_EXPECT_JH(jh, buffer_uptodate(bh), "Possible IO failure.\n");
33 + offset = offset_in_page(bh->b_data);
34 + source = kmap_atomic(page);
35 + /* Fire data frozen trigger just before we copy the data */
36 + jbd2_buffer_frozen_trigger(jh, source + offset, jh->b_triggers);
37 + memcpy(jh->b_frozen_data, source + offset, bh->b_size);
38 + kunmap_atomic(source);
41 + * Now that the frozen data is saved off, we need to store any matching
44 + jh->b_frozen_triggers = jh->b_triggers;
48 * If the buffer is already part of the current transaction, then there
49 * is nothing we need to do. If it is already part of a prior
50 @@ -782,7 +806,6 @@ do_get_write_access(handle_t *handle, struct journal_head *jh,
53 char *frozen_buffer = NULL;
55 unsigned long start_lock, time_lock;
57 WARN_ON(!transaction);
58 @@ -940,7 +963,7 @@ repeat:
60 jh->b_frozen_data = frozen_buffer;
63 + jbd2_freeze_jh_data(jh);
65 jh->b_next_transaction = transaction;
67 @@ -961,28 +984,6 @@ repeat:
76 - J_EXPECT_JH(jh, buffer_uptodate(jh2bh(jh)),
77 - "Possible IO failure.\n");
78 - page = jh2bh(jh)->b_page;
79 - offset = offset_in_page(jh2bh(jh)->b_data);
80 - source = kmap_atomic(page);
81 - /* Fire data frozen trigger just before we copy the data */
82 - jbd2_buffer_frozen_trigger(jh, source + offset,
84 - memcpy(jh->b_frozen_data, source+offset, jh2bh(jh)->b_size);
85 - kunmap_atomic(source);
88 - * Now that the frozen data is saved off, we need to store
89 - * any matching triggers.
91 - jh->b_frozen_triggers = jh->b_triggers;
93 jbd_unlock_bh_state(bh);