Skip to content

Commit 7c48e7d

Browse files
Kemeng Shitytso
authored andcommitted
jbd2: remove unneeded done_copy_out variable in jbd2_journal_write_metadata_buffer
It's more intuitive to use jh_in->b_frozen_data directly instead of done_copy_out variable. Simply remove unneeded done_copy_out variable and use b_frozen_data instead. Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com> Reviewed-by: Zhang Yi <yi.zhang@huawei.com> Reviewed-by: Jan Kara <jack@suse.cz> Link: https://patch.msgid.link/20240801013815.2393869-6-shikemeng@huaweicloud.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent debbfd9 commit 7c48e7d

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

fs/jbd2/journal.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,6 @@ int jbd2_journal_write_metadata_buffer(transaction_t *transaction,
318318
struct buffer_head **bh_out,
319319
sector_t blocknr)
320320
{
321-
int done_copy_out = 0;
322321
int do_escape = 0;
323322
char *mapped_data;
324323
struct buffer_head *new_bh;
@@ -349,25 +348,22 @@ int jbd2_journal_write_metadata_buffer(transaction_t *transaction,
349348
* we use that version of the data for the commit.
350349
*/
351350
if (jh_in->b_frozen_data) {
352-
done_copy_out = 1;
353351
new_folio = virt_to_folio(jh_in->b_frozen_data);
354352
new_offset = offset_in_folio(new_folio, jh_in->b_frozen_data);
355353
mapped_data = jh_in->b_frozen_data;
356354
} else {
357355
new_folio = bh_in->b_folio;
358356
new_offset = offset_in_folio(new_folio, bh_in->b_data);
359357
mapped_data = kmap_local_folio(new_folio, new_offset);
360-
}
361-
362-
/*
363-
* Fire data frozen trigger if data already wasn't frozen. Do this
364-
* before checking for escaping, as the trigger may modify the magic
365-
* offset. If a copy-out happens afterwards, it will have the correct
366-
* data in the buffer.
367-
*/
368-
if (!done_copy_out)
358+
/*
359+
* Fire data frozen trigger if data already wasn't frozen. Do
360+
* this before checking for escaping, as the trigger may modify
361+
* the magic offset. If a copy-out happens afterwards, it will
362+
* have the correct data in the buffer.
363+
*/
369364
jbd2_buffer_frozen_trigger(jh_in, mapped_data,
370365
jh_in->b_triggers);
366+
}
371367

372368
/*
373369
* Check for escaping
@@ -380,7 +376,7 @@ int jbd2_journal_write_metadata_buffer(transaction_t *transaction,
380376
/*
381377
* Do we need to do a data copy?
382378
*/
383-
if (do_escape && !done_copy_out) {
379+
if (do_escape && !jh_in->b_frozen_data) {
384380
char *tmp;
385381

386382
spin_unlock(&jh_in->b_state_lock);
@@ -408,7 +404,6 @@ int jbd2_journal_write_metadata_buffer(transaction_t *transaction,
408404
copy_done:
409405
new_folio = virt_to_folio(jh_in->b_frozen_data);
410406
new_offset = offset_in_folio(new_folio, jh_in->b_frozen_data);
411-
done_copy_out = 1;
412407
}
413408

414409
/*

0 commit comments

Comments
 (0)