public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Andreas Dilger <adilger@dilger.ca>
Cc: Jan Kara <jack@suse.cz>, Ted Tso <tytso@mit.edu>,
	linux-ext4@vger.kernel.org
Subject: Re: [PATCH] ext4: Don't report EOPNOTSUPP errors from discard
Date: Thu, 15 Feb 2024 10:46:35 +0100	[thread overview]
Message-ID: <20240215094635.p5anw5w36snmqwsh@quack3> (raw)
In-Reply-To: <4AC7AEC3-25FC-4147-9C62-2CE5A1686199@dilger.ca>

On Wed 14-02-24 16:01:57, Andreas Dilger wrote:
> On Feb 13, 2024, at 3:16 AM, Jan Kara <jack@suse.cz> wrote:
> > 
> > When ext4 is mounted without journal, with discard mount option, and on
> > a device not supporting trim, we print error for each and every freed
> > extent. This is not only useless but actively harmful. Instead ignore
> > the EOPNOTSUPP error. Trim is only advisory anyway and when the
> > filesystem has journal we silently ignore trim error as well.
> > 
> 
> > Signed-off-by: Jan Kara <jack@suse.cz>
> > ---
> > fs/ext4/mballoc.c | 8 +++++++-
> > 1 file changed, 7 insertions(+), 1 deletion(-)
> > 
> > diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> > index e4f7cf9d89c4..aed620cf4d40 100644
> > --- a/fs/ext4/mballoc.c
> > +++ b/fs/ext4/mballoc.c
> > @@ -6488,7 +6488,13 @@ static void ext4_mb_clear_bb(handle_t *handle, struct inode *inode,
> > 		if (test_opt(sb, DISCARD)) {
> > 			err = ext4_issue_discard(sb, block_group, bit,
> > 						 count_clusters, NULL);
> > -			if (err && err != -EOPNOTSUPP)
> > +			/*
> > +			 * Ignore EOPNOTSUPP error. This is consistent with
> > +			 * what happens when using journal.
> > +			 */
> > +			if (err == -EOPNOTSUPP)
> > +				err = 0;
> > +			if (err)
> 
> I don't see how this patch is actually changing whether the error message
> is printed?  Previously, if "err" was set and err was -EOPNOTSUPP the
> message was skipped.  Now it is doing the same thing in a different way?
> 
> The "err" value is overwritten 50 lines later on without being used:
> 
>         err = ext4_handle_dirty_metadata(handle, NULL, bitmap_bh);
> 
> so the setting "err = 0" doesn't really affect the later code either.
> What am I missing?

Yeah, the code flow is a bit contrived. The error message gets printed by
ext4_std_error() at the end of ext4_mb_clear_bb(). I don't think there's
any ext4_handle_dirty_metadata() call in the current version of
ext4_mb_clear_bb()...

								Honza

> 
> Cheers, Andreas
> 
> 


-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  reply	other threads:[~2024-02-15  9:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-13 10:16 [PATCH] ext4: Don't report EOPNOTSUPP errors from discard Jan Kara
2024-02-14 23:01 ` Andreas Dilger
2024-02-15  9:46   ` Jan Kara [this message]
2024-02-22 21:23     ` Andreas Dilger
2024-02-23 13:07       ` Jan Kara
2024-02-17 11:53 ` Zhang Yi
2024-02-22 15:54 ` Theodore Ts'o

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=20240215094635.p5anw5w36snmqwsh@quack3 \
    --to=jack@suse.cz \
    --cc=adilger@dilger.ca \
    --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