]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
mkfs: fix the issue of maxpct set to 0 not taking effect
authorliuh <liuhuan01@kylinos.cn>
Fri, 11 Apr 2025 07:12:03 +0000 (15:12 +0800)
committerAndrey Albershteyn <aalbersh@kernel.org>
Mon, 28 Apr 2025 10:57:41 +0000 (12:57 +0200)
commit81f646b0d6afb797fdd14eccc9965a3212ba358e
treeb40e3450348f4cef23a7ffb600802eca0fffeec1
parent044e134fffff0706f1141a8fb1d19f95641abfdf
mkfs: fix the issue of maxpct set to 0 not taking effect

If a filesystem has the sb_imax_pct field set to zero, there is no limit to the number of inode blocks in the filesystem.

However, when using mkfs.xfs and specifying maxpct = 0, the result is not as expected.
[root@fs ~]# mkfs.xfs -f -i maxpct=0 xfs.img
data     =               bsize=4096   blocks=262144, imaxpct=25
         =               sunit=0      swidth=0 blks

The reason is that the condition will never succeed when specifying maxpct = 0. As a result, the default algorithm was applied.
cfg->imaxpct = cli->imaxpct;
if (cfg->imaxpct)
return;

The result with patch:
[root@fs ~]# mkfs.xfs -f -i maxpct=0 xfs.img
data     =               bsize=4096   blocks=262144, imaxpct=0
         =               sunit=0      swidth=0 blks

[root@fs ~]# mkfs.xfs -f xfs.img
data     =               bsize=4096   blocks=262144, imaxpct=25
         =               sunit=0      swidth=0 blks

Cc: linux-xfs@vger.kernel.org # v4.15.0
Fixes: d7240c965389e1 ("mkfs: rework imaxpct calculation")
Suggested-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: liuh <liuhuan01@kylinos.cn>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
mkfs/xfs_mkfs.c