[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210617082416.GC32587@quack2.suse.cz>
Date: Thu, 17 Jun 2021 10:24:16 +0200
From: Jan Kara <jack@...e.cz>
To: Andreas Dilger <adilger@...ger.ca>
Cc: Jan Kara <jack@...e.cz>, Ted Tso <tytso@....edu>,
linux-ext4@...r.kernel.org
Subject: Re: [PATCH 1/4] ext4: Support for checksumming from journal triggers
On Wed 16-06-21 13:56:30, Andreas Dilger wrote:
> On Jun 16, 2021, at 4:56 AM, Jan Kara <jack@...e.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@...e.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.
Good point, I'll fix that.
Honza
--
Jan Kara <jack@...e.com>
SUSE Labs, CR
Powered by blists - more mailing lists