From: Andreas Dilger <adilger@dilger.ca>
To: Jan Kara <jack@suse.cz>
Cc: Ted Tso <tytso@mit.edu>, linux-ext4@vger.kernel.org
Subject: Re: [PATCH 1/4] ext4: Support for checksumming from journal triggers
Date: Wed, 16 Jun 2021 13:56:30 -0600 [thread overview]
Message-ID: <0DB920A0-26A5-4B76-B2E6-78B1B678072C@dilger.ca> (raw)
In-Reply-To: <20210616105655.5129-2-jack@suse.cz>
[-- Attachment #1: Type: text/plain, Size: 3266 bytes --]
On Jun 16, 2021, at 4:56 AM, Jan Kara <jack@suse.cz> wrote:
>
> JBD2 layer support triggers which are called when journaling layer moves
> buffer to a certain state. We can use the frozen trigger, which gets
> called when buffer data is frozen and about to be written out to the
> journal, to compute block checksums for some buffer types (similarly as
> does ocfs2). This avoids unnecessary repeated recomputation of the
> checksum (at the cost of larger window where memory corruption won't be
> caught by checksumming) and is even necessary when there are
> unsynchronized updaters of the checksummed data.
>
> So add argument to ext4_journal_get_write_access() and
> ext4_journal_get_create_access() which describes buffer type so that
> triggers can be set accordingly. This patch is mostly only a change of
> prototype of the above mentioned functions and a few small helpers. Real
> checksumming will come later.
>
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
Comment inline.
>
> diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c
> index be799040a415..f601e24b6015 100644
> --- a/fs/ext4/ext4_jbd2.c
> +++ b/fs/ext4/ext4_jbd2.c
> @@ -229,11 +231,18 @@ int __ext4_journal_get_write_access(const char *where, unsigned int line,
>
> if (ext4_handle_valid(handle)) {
> err = jbd2_journal_get_write_access(handle, bh);
> - if (err)
> + if (err) {
> ext4_journal_abort_handle(where, line, __func__, bh,
> handle, err);
> + return err;
> + }
> }
> - return err;
> + if (trigger_type == EXT4_JTR_NONE || !ext4_has_metadata_csum(sb))
> + return 0;
> + WARN_ON_ONCE(trigger_type >= EXT4_JOURNAL_TRIGGER_COUNT);
I'm not sure WARN_ON_ONCE() is enough here. This would essentially result
in executing a random (or maybe NULL) function pointer later on. Either
trigger_type should be checked early and return an error, or this should
be a BUG_ON() so that the crash happens here instead of in jbd context.
> + jbd2_journal_set_triggers(bh,
> + &EXT4_SB(sb)->s_journal_triggers[trigger_type].tr_triggers);
> + return 0;
> }
>
> /*
> @@ -304,17 +313,27 @@ int __ext4_forget(const char *where, unsigned int line,
> int __ext4_journal_get_create_access(const char *where, unsigned int line,
> - handle_t *handle, struct buffer_head *bh)
> + handle_t *handle, struct super_block *sb,
> + struct buffer_head *bh,
> + enum ext4_journal_trigger_type trigger_type)
> {
> - int err = 0;
> + int err;
>
> - if (ext4_handle_valid(handle)) {
> - err = jbd2_journal_get_create_access(handle, bh);
> - if (err)
> - ext4_journal_abort_handle(where, line, __func__,
> - bh, handle, err);
> + if (!ext4_handle_valid(handle))
> + return 0;
> +
> + err = jbd2_journal_get_create_access(handle, bh);
> + if (err) {
> + ext4_journal_abort_handle(where, line, __func__, bh, handle,
> + err);
> + return err;
> }
> - return err;
> + if (trigger_type == EXT4_JTR_NONE || !ext4_has_metadata_csum(sb))
> + return 0;
> + WARN_ON_ONCE(trigger_type >= EXT4_JOURNAL_TRIGGER_COUNT);
Same.
> + jbd2_journal_set_triggers(bh,
> + &EXT4_SB(sb)->s_journal_triggers[trigger_type].tr_triggers);
> + return 0;
> }
Cheers, Andreas
[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 873 bytes --]
next prev parent reply other threads:[~2021-06-16 19:56 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-16 10:56 [PATCH 0/4 v3] ext4: Speedup orphan file handling Jan Kara
2021-06-16 10:56 ` [PATCH 1/4] ext4: Support for checksumming from journal triggers Jan Kara
2021-06-16 19:56 ` Andreas Dilger [this message]
2021-06-17 8:24 ` Jan Kara
2021-06-16 10:56 ` [PATCH 2/4] ext4: Move orphan inode handling into a separate file Jan Kara
2021-06-17 3:24 ` Andreas Dilger
2021-06-17 6:56 ` kernel test robot
2021-06-17 12:40 ` kernel test robot
2021-06-16 10:56 ` [PATCH 3/4] ext4: Speedup ext4 orphan inode handling Jan Kara
2021-06-17 7:44 ` Andreas Dilger
2021-06-17 8:22 ` Jan Kara
2021-06-30 13:25 ` Lukas Czerner
2021-06-30 15:54 ` Darrick J. Wong
2021-06-16 10:56 ` [PATCH 4/4] ext4: Improve scalability of ext4 orphan file handling Jan Kara
2021-06-30 13:46 ` Lukas Czerner
2021-07-08 18:30 ` Jan Kara
-- strict thread matches above, loose matches on Subject: below --
2015-05-22 11:21 [PATCH 0/3 v2] ext4: Speedup " Jan Kara
2015-05-22 11:21 ` [PATCH 1/4] ext4: Support for checksumming from journal triggers Jan Kara
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=0DB920A0-26A5-4B76-B2E6-78B1B678072C@dilger.ca \
--to=adilger@dilger.ca \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).