From: "Darrick J. Wong" <djwong@kernel.org>
To: 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, 13 Apr 2026 09:05:18 -0700 [thread overview]
Message-ID: <20260413160518.GK1048989@frogsfrogsfrogs> (raw)
In-Reply-To: <advyLsWynjlIF40m@zlang-laptop>
On Mon, Apr 13, 2026 at 03:52:59AM +0800, Zorro Lang wrote:
> On Mon, Apr 06, 2026 at 08:26:28AM -0700, Darrick J. Wong wrote:
> > 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.
>
> Oh, you're right, the mkfs.xfs command failing here is a total failure, not
> just a warning.
>
> How about:
> _(Bad empty file, needs a data subvolume size by -d size=<value> option)
>
> or any other you feel good.
"Please specify desired data subvolume file size by -d size=<value> option\n" ?
--D
> Thanks,
> Zorro
>
> >
> > 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-13 16:05 UTC|newest]
Thread overview: 9+ 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
2026-04-12 19:52 ` Zorro Lang
2026-04-13 16:05 ` 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
2026-04-12 20:04 ` Zorro Lang
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=20260413160518.GK1048989@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@redhat.com \
/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