From: Zorro Lang <zlang@kernel.org>
To: linux-xfs@vger.kernel.org
Cc: Eric Sandeen <sandeen@redhat.com>
Subject: [PATCH 1/2] mkfs: fix assertion failure on empty data file
Date: Sun, 5 Apr 2026 00:36:39 +0800 [thread overview]
Message-ID: <20260404163640.1013997-2-zlang@kernel.org> (raw)
In-Reply-To: <20260404163640.1013997-1-zlang@kernel.org>
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"));
+ 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-04 16:36 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 ` Zorro Lang [this message]
2026-04-06 15:26 ` [PATCH 1/2] mkfs: fix assertion failure on empty data file Darrick J. Wong
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=20260404163640.1013997-2-zlang@kernel.org \
--to=zlang@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