From: "Darrick J. Wong" <djwong@kernel.org>
To: Zorro Lang <zlang@kernel.org>
Cc: linux-xfs@vger.kernel.org, Eric Sandeen <sandeen@redhat.com>
Subject: Re: [PATCH 1/2] mkfs: fix assertion failure on empty data file
Date: Mon, 6 Apr 2026 08:26:28 -0700 [thread overview]
Message-ID: <20260406152628.GC1048989@frogsfrogsfrogs> (raw)
In-Reply-To: <20260404163640.1013997-2-zlang@kernel.org>
On Sun, Apr 05, 2026 at 12:36:39AM +0800, Zorro Lang wrote:
> mkfs.xfs triggers an assertion failure, when it trys to make a xfs
> on an empty file:
> # echo > emptyfile
> # mkfs.xfs emptyfile
> mkfs.xfs: xfs_mkfs.c:3852: validate_datadev: Assertion `cfg->dblocks' failed.
> Aborted (core dumped) mkfs.xfs emptyfile
>
> This shouldn't be an assertion, but a warning.
>
> Signed-off-by: Zorro Lang <zlang@kernel.org>
> ---
> mkfs/xfs_mkfs.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index 527a662f..9a93330f 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -3848,8 +3848,13 @@ validate_datadev(
> if (!xi->data.isfile) {
> fprintf(stderr, _("can't get size of data subvolume\n"));
> usage();
> + } else {
> + if (!cli->dsize) {
> + fprintf(stderr,
> +_("Warning: Empty file needs a data subvolume size by -d size=<value> option\n"));
I'm not sure why "Warning" is appropriate here -- this error is fatal to
the program, and most fatal mkfs error messages don't have a prefix.
Other than that, the logic is sound that we need a softer landing for
this scenario.
--D
> + usage();
> + }
> }
> - ASSERT(cfg->dblocks);
> } else if (cfg->dblocks) {
> /* check the size fits into the underlying device */
> if (cfg->dblocks > DTOBT(xi->data.size, cfg->blocklog)) {
> --
> 2.52.0
>
>
next prev parent reply other threads:[~2026-04-06 15:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-04 16:36 [PATCH 0/2] xfsprogs/mkfs: consolidate subvolume validation logic for file images Zorro Lang
2026-04-04 16:36 ` [PATCH 1/2] mkfs: fix assertion failure on empty data file Zorro Lang
2026-04-06 15:26 ` Darrick J. Wong [this message]
2026-04-04 16:36 ` [PATCH 2/2] mkfs: unify validation behavior for data, log and rt dev Zorro Lang
2026-04-06 15:37 ` Darrick J. Wong
2026-04-07 5:38 ` Christoph Hellwig
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=20260406152628.GC1048989@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@redhat.com \
--cc=zlang@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