public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Carlos Maiolino <cem@kernel.org>
Cc: aalbersh@redhat.com, linux-xfs@vger.kernel.org
Subject: Re: [RFC PATCH 1/2] libfrog: make xfrog_defragrange return a positive valued
Date: Wed, 21 Jan 2026 09:42:36 -0800	[thread overview]
Message-ID: <20260121174236.GD5945@frogsfrogsfrogs> (raw)
In-Reply-To: <s3welc2n2qbdqdr4nuwgef4uwckjkq4lzzsnzp3vzxozpkoy6w@hym4evwdf63k>

On Wed, Jan 21, 2026 at 09:57:51AM +0100, Carlos Maiolino wrote:
> On Tue, Jan 20, 2026 at 09:20:39AM -0800, Darrick J. Wong wrote:
> > On Mon, Jan 19, 2026 at 03:26:50PM +0100, cem@kernel.org wrote:
> > > From: Carlos Maiolino <cem@kernel.org>
> > >
> > > Currently, the only user for xfrog_defragrange is xfs_fsr's packfile(),
> > > which expects error to be a positive value.
> > >
> > > Whenever xfrog_defragrange fails, the switch case always falls into the
> > > default clausule, making the error message pointless.
> > >
> > > Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
> > > ---
> > >  libfrog/file_exchange.c | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/libfrog/file_exchange.c b/libfrog/file_exchange.c
> > > index e6c3f486b0ff..31bbc6da60c3 100644
> > > --- a/libfrog/file_exchange.c
> > > +++ b/libfrog/file_exchange.c
> > > @@ -232,7 +232,7 @@ xfrog_defragrange(
> > >  	if (ret) {
> > >  		if (errno == EOPNOTSUPP || errno != ENOTTY)
> > >  			goto legacy_fallback;
> > > -		return -errno;
> > > +		return errno;
> > 
> > Hrmm.  If you're going to change the polarity of the error numbers (e.g.
> > negative to positive) then please update the comments.
> 
> Sorry, I did it quickly and didn't even pay attention there were
> comments :)
> 
> > 
> > That said, I'd prefer to keep the errno polarity the same at least
> > within a .c file ... even though libfrog is a mess of different error
> > number return strategies.  What if the callsite changed to:
> > 
> > 	/* Swap the extents */
> > 	error = -xfrog_defragrange(...);
> 
> This looks to just add more confusion to it IMHO, it's not 'easy' for me
> at least to notice the minus sign in front of it.
> 
> What about just changing the switch case to catch for -ERROR instead of
> their positive counterparts? At least we stop playing the error sign
> change and just catch what we already have.

Sure, do whatever you think is best.  This whole part of C is an
unfixable mess as far as I'm concerned.

--D

> 
> > 
> > and
> > 
> > 	/* Snapshot file_fd before we start copying data... */
> > 	error = -xfrog_defragrange_prep(...);
> > 
> > (and I guess io/exchrange.c also needs a fix)
> > 
> > 	/* Snapshot the original file metadata in anticipation... */
> > 	ret = -xfrog_commitrange_prep(...);
> > 
> > Hrm?
> > 
> > --D
> > 
> > >  	}
> > >
> > >  	return 0;
> > > @@ -240,7 +240,7 @@ xfrog_defragrange(
> > >  legacy_fallback:
> > >  	ret = xfrog_ioc_swapext(file2_fd, xdf);
> > >  	if (ret)
> > > -		return -errno;
> > > +		return errno;
> > >
> > >  	return 0;
> > >  }
> > > --
> > > 2.52.0
> > >
> > >
> > 
> 

  reply	other threads:[~2026-01-21 17:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-19 14:26 [RFC PATCH 0/2] Improve user experience with xfs_fsr cem
2026-01-19 14:26 ` [RFC PATCH 1/2] libfrog: make xfrog_defragrange return a positive valued cem
2026-01-20 17:20   ` Darrick J. Wong
2026-01-21  8:57     ` Carlos Maiolino
2026-01-21 17:42       ` Darrick J. Wong [this message]
2026-01-19 14:26 ` [RFC PATCH 2/2] fsr: Always print error messages from xfrog_defragrange() cem
2026-01-20 17:23   ` Darrick J. Wong

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=20260121174236.GD5945@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=aalbersh@redhat.com \
    --cc=cem@kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /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