From: Jan Kara <jack@suse.cz>
To: Kemeng Shi <shikemeng@huaweicloud.com>
Cc: tytso@mit.edu, jack@suse.com, linux-ext4@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 5/7] jbd2: remove unneeded done_copy_out variable in jbd2_journal_write_metadata_buffer
Date: Tue, 30 Jul 2024 15:49:43 +0200 [thread overview]
Message-ID: <20240730134943.ircjz6l5ix6zmmwe@quack3> (raw)
In-Reply-To: <20240730113335.2365290-6-shikemeng@huaweicloud.com>
On Tue 30-07-24 19:33:33, Kemeng Shi wrote:
> 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>
> @@ -357,17 +355,15 @@ int jbd2_journal_write_metadata_buffer(transaction_t *transaction,
> new_folio = bh_in->b_folio;
> new_offset = offset_in_folio(new_folio, bh_in->b_data);
> mapped_data = kmap_local_folio(new_folio, new_offset);
> - }
> -
> - /*
> - * Fire data frozen trigger if data already wasn't frozen. Do this
> - * before checking for escaping, as the trigger may modify the magic
> - * offset. If a copy-out happens afterwards, it will have the correct
> - * data in the buffer.
> - */
> - if (!done_copy_out)
> + /*
> + * Fire data frozen trigger if data already wasn't frozen. Do
> + * this before checking for escaping, as the trigger may modify
> + * the magic offset. If a copy-out happens afterwards, it will
> + * have the correct data in the buffer.
> + */
> jbd2_buffer_frozen_trigger(jh_in, mapped_data,
> jh_in->b_triggers);
> + }
I like how you've got rid of the conditional. But I'd go further and also
move the escaping check and thus unmap & possible frozen buffer creation
into the branch. Like:
do_escape = jbd2_data_needs_escaping(mapped_data);
- create this trivial helper
kunmap_local(mapped_data);
if (do_escape) {
handle b_frozen_data creation
}
Honza
>
> /*
> * Check for escaping
> @@ -380,7 +376,7 @@ int jbd2_journal_write_metadata_buffer(transaction_t *transaction,
> /*
> * Do we need to do a data copy?
> */
> - if (do_escape && !done_copy_out) {
> + if (do_escape && !jh_in->b_frozen_data) {
> char *tmp;
>
> spin_unlock(&jh_in->b_state_lock);
> @@ -408,7 +404,6 @@ int jbd2_journal_write_metadata_buffer(transaction_t *transaction,
> copy_done:
> new_folio = virt_to_folio(jh_in->b_frozen_data);
> new_offset = offset_in_folio(new_folio, jh_in->b_frozen_data);
> - done_copy_out = 1;
> }
>
> /*
> --
> 2.30.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2024-07-30 13:49 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-30 11:33 [PATCH 0/7] Fix and cleanups to jbd2 Kemeng Shi
2024-07-30 11:33 ` [PATCH 1/7] jbd2: correctly compare tids with tid_geq function in jbd2_fc_begin_commit Kemeng Shi
2024-07-30 13:21 ` Jan Kara
2024-07-30 14:55 ` Luis Henriques
2024-07-31 3:24 ` Zhang Yi
2024-07-30 11:33 ` [PATCH 2/7] jbd2: remove dead check in journal_alloc_journal_head Kemeng Shi
2024-07-30 13:23 ` Jan Kara
2024-07-31 3:30 ` Zhang Yi
2024-07-30 11:33 ` [PATCH 3/7] jbd2: remove unused return value of jbd2_fc_release_bufs Kemeng Shi
2024-07-30 13:24 ` Jan Kara
2024-07-31 3:32 ` Zhang Yi
2024-07-30 11:33 ` [PATCH 4/7] jbd2: remove unneeded kmap for jh_in->b_frozen_data in jbd2_journal_write_metadata_buffer Kemeng Shi
2024-07-30 13:32 ` Jan Kara
2024-07-30 13:41 ` Jan Kara
2024-07-30 11:33 ` [PATCH 5/7] jbd2: remove unneeded done_copy_out variable " Kemeng Shi
2024-07-30 13:49 ` Jan Kara [this message]
2024-07-31 1:34 ` Kemeng Shi
2024-07-30 11:33 ` [PATCH 6/7] jbd2: correct comment jbd2_mark_journal_empty Kemeng Shi
2024-07-30 13:37 ` Jan Kara
2024-07-31 3:53 ` Zhang Yi
2024-07-30 11:33 ` [PATCH 7/7] jbd2: remove unneeded check of ret in jbd2_fc_get_buf Kemeng Shi
2024-07-30 13:38 ` Jan Kara
2024-07-31 6:17 ` Zhang Yi
2024-07-31 8:37 ` Kemeng Shi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240730134943.ircjz6l5ix6zmmwe@quack3 \
--to=jack@suse.cz \
--cc=jack@suse.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=shikemeng@huaweicloud.com \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox