From: "Darrick J. Wong" <djwong@kernel.org>
To: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Cc: linux-ext4@vger.kernel.org, Theodore Ts'o <tytso@mit.edu>,
Ritesh Harjani <ritesh.list@gmail.com>,
Zhang Yi <yi.zhang@huawei.com>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 2/2] ext4: Fix reserved gdt blocks handling in fsmap
Date: Thu, 7 Aug 2025 12:58:18 -0700 [thread overview]
Message-ID: <20250807195818.GT2672022@frogsfrogsfrogs> (raw)
In-Reply-To: <08781b796453a5770112aa96ad14c864fbf31935.1754377641.git.ojaswin@linux.ibm.com>
On Tue, Aug 05, 2025 at 02:00:31PM +0530, Ojaswin Mujoo wrote:
> In some cases like small FSes with no meta_bg and where the resize doesn't
> need extra gdt blocks as it can fit in the current one,
> s_reserved_gdt_blocks is set as 0, which causes fsmap to emit a 0 length
> entry, which is incorrect.
>
> $ mkfs.ext4 -b 65536 -O bigalloc /dev/sda 5G
> $ mount /dev/sda /mnt/scratch
> $ xfs_io -c "fsmap -d" /mnt/scartch
>
> 0: 253:48 [0..127]: static fs metadata 128
> 1: 253:48 [128..255]: special 102:1 128
> 2: 253:48 [256..255]: special 102:2 0 <---- 0 len entry
> 3: 253:48 [256..383]: special 102:3 128
>
> Fix this by adding a check for this case.
>
> Fixes: 0c9ec4beecac ("ext4: support GETFSMAP ioctls")
> Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
I had no idea that this could be zero, so....
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> fs/ext4/fsmap.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/fs/ext4/fsmap.c b/fs/ext4/fsmap.c
> index 9d63c39f6077..91185c40f755 100644
> --- a/fs/ext4/fsmap.c
> +++ b/fs/ext4/fsmap.c
> @@ -393,6 +393,14 @@ static unsigned int ext4_getfsmap_find_sb(struct super_block *sb,
> /* Reserved GDT blocks */
> if (!ext4_has_feature_meta_bg(sb) || metagroup < first_meta_bg) {
> len = le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks);
> +
> + /*
> + * mkfs.ext4 can set s_reserved_gdt_blocks as 0 in some cases,
> + * check for that.
> + */
> + if (!len)
> + return 0;
> +
> error = ext4_getfsmap_fill(meta_list, fsb, len,
> EXT4_FMR_OWN_RESV_GDT);
> if (error)
> --
> 2.49.0
>
>
next prev parent reply other threads:[~2025-08-07 19:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-05 8:30 [PATCH 1/2] ext4: Fix fsmap end of range reporting with bigalloc Ojaswin Mujoo
2025-08-05 8:30 ` [PATCH 2/2] ext4: Fix reserved gdt blocks handling in fsmap Ojaswin Mujoo
2025-08-07 19:58 ` Darrick J. Wong [this message]
2025-08-07 19:57 ` [PATCH 1/2] ext4: Fix fsmap end of range reporting with bigalloc Darrick J. Wong
2025-08-14 14:48 ` Theodore Ts'o
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=20250807195818.GT2672022@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ojaswin@linux.ibm.com \
--cc=ritesh.list@gmail.com \
--cc=tytso@mit.edu \
--cc=yi.zhang@huawei.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