From: "Darrick J. Wong" <djwong@kernel.org>
To: cem@kernel.org
Cc: aalbersh@redhat.com, linux-xfs@vger.kernel.org
Subject: Re: [PATCH v2 1/2] fsr: package function should check for negative errors
Date: Tue, 17 Mar 2026 15:12:15 -0700 [thread overview]
Message-ID: <20260317221215.GL1770774@frogsfrogsfrogs> (raw)
In-Reply-To: <20260317160750.186873-2-cem@kernel.org>
On Tue, Mar 17, 2026 at 05:07:39PM +0100, cem@kernel.org wrote:
> From: Carlos Maiolino <cem@kernel.org>
>
> xfrog_defragrange as most other functions from libfrog return
> a negative error value, while xfs_fsr's packfile(), expects
> a positive error value.
>
> Whenever xfrog_defragrange fails, the switch case always falls into the
> default clausule, making the error message pointless.
>
> Update packfile() to switch between negative errors.
>
> Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
> ---
> V2:
> Change packfile() to check for negative error values
> instead of changing the return sign from xfrog_defragrange().
>
> fsr/xfs_fsr.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
> index 8845ff172fcb..aa2a10839314 100644
> --- a/fsr/xfs_fsr.c
> +++ b/fsr/xfs_fsr.c
> @@ -1463,17 +1463,17 @@ packfile(
> switch (error) {
> case 0:
> break;
> - case ENOTSUP:
> + case -ENOTSUP:
I would have just made the call site invert the sign:
error = -xfrog_defragrange(...);
because you wouldn't have to change the case statements, and...
> if (vflag || dflag)
> fsrprintf(_("%s: file type not supported\n"), fname);
> break;
> - case EFAULT:
> + case -EFAULT:
> /* The file has changed since we started the copy */
> if (vflag || dflag)
> fsrprintf(_("%s: file modified defrag aborted\n"),
> fname);
> break;
> - case EBUSY:
> + case -EBUSY:
> /* Timestamp has changed or mmap'ed file */
> if (vflag || dflag)
> fsrprintf(_("%s: file busy\n"), fname);
...the default case below is still broken due to the strerror() call:
default:
fsrprintf(_("XFS_IOC_SWAPEXT failed: %s: %s\n"),
fname, strerror(error));
https://lore.kernel.org/linux-xfs/20260120172039.GO15551@frogsfrogsfrogs/
--D
next prev parent reply other threads:[~2026-03-17 22:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-17 16:07 [PATCH v2 0/2] Improve user experience with xfs_fsr cem
2026-03-17 16:07 ` [PATCH v2 1/2] fsr: package function should check for negative errors cem
2026-03-17 22:12 ` Darrick J. Wong [this message]
2026-03-17 16:07 ` [PATCH v2 2/2] fsr: always print error messages from xfrog_defragrange() cem
2026-03-17 22:12 ` 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=20260317221215.GL1770774@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