Message ID | 171029430586.2061422.6975814186247298641.stgit@frogsfrogsfrogs (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [01/13] libxfs: fix incorrect porting to 6.7 | expand |
On Tue, Mar 12, 2024 at 06:50:10PM -0700, Darrick J. Wong wrote: > From: Darrick J. Wong <djwong@kernel.org> > > Due to my heinous nature, I set up an external log device with 4k LBAs > using this command: > > # losetup -b 4096 -o 4096 --sizelimit $(( (128 * 1048576) - 4096 )) -f /dev/sdb > # blockdev --getsize64 /dev/loop0 > 134213632 > > This creates a log device that is slightly smaller than 128MB in size. > Next I ran generic/054, which sets the log sunit to 256k and fails: Can we wire this exact mkfs command line up as an xfstests instead of requiring a very unused setup to trigger it with the existing test? The xfstests patch itself looks good: Reviewed-by: Christoph Hellwig <hch@lst.de>
On Wed, Mar 13, 2024 at 02:59:39PM -0700, Christoph Hellwig wrote: > On Tue, Mar 12, 2024 at 06:50:10PM -0700, Darrick J. Wong wrote: > > From: Darrick J. Wong <djwong@kernel.org> > > > > Due to my heinous nature, I set up an external log device with 4k LBAs > > using this command: > > > > # losetup -b 4096 -o 4096 --sizelimit $(( (128 * 1048576) - 4096 )) -f /dev/sdb > > # blockdev --getsize64 /dev/loop0 > > 134213632 > > > > This creates a log device that is slightly smaller than 128MB in size. > > Next I ran generic/054, which sets the log sunit to 256k and fails: > > Can we wire this exact mkfs command line up as an xfstests instead of > requiring a very unused setup to trigger it with the existing test? I'll have a look at creating an fstests for this sort of thing, unless the LBS folks already have one handy? --D > The xfstests patch itself looks good: > > Reviewed-by: Christoph Hellwig <hch@lst.de> >
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index fcbf5413269a..b8e2c0da60c4 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -3338,13 +3338,13 @@ _("log size %lld is not a multiple of the log stripe unit %d\n"), usage(); } - tmp_logblocks = ((cfg->logblocks + (sunit - 1)) / sunit) * sunit; + tmp_logblocks = roundup_64(cfg->logblocks, sunit); /* If the log is too large, round down instead of round up */ if ((tmp_logblocks > XFS_MAX_LOG_BLOCKS) || ((tmp_logblocks << cfg->blocklog) > XFS_MAX_LOG_BYTES) || tmp_logblocks > max_logblocks) { - tmp_logblocks = (cfg->logblocks / sunit) * sunit; + tmp_logblocks = rounddown_64(cfg->logblocks, sunit); } cfg->logblocks = tmp_logblocks; } @@ -3465,6 +3465,7 @@ static void calculate_log_size( struct mkfs_params *cfg, struct cli_params *cli, + struct libxfs_init *xi, struct xfs_mount *mp) { struct xfs_sb *sbp = &mp->m_sb; @@ -3503,8 +3504,13 @@ _("external log device size %lld blocks too small, must be at least %lld blocks\ } cfg->logstart = 0; cfg->logagno = 0; - if (cfg->lsunit) - align_log_size(cfg, cfg->lsunit, XFS_MAX_LOG_BLOCKS); + if (cfg->lsunit) { + uint64_t max_logblocks; + + max_logblocks = min(DTOBT(xi->log.size, cfg->blocklog), + XFS_MAX_LOG_BLOCKS); + align_log_size(cfg, cfg->lsunit, max_logblocks); + } validate_log_size(cfg->logblocks, cfg->blocklog, min_logblocks); return; @@ -4257,7 +4263,7 @@ main( * With the mount set up, we can finally calculate the log size * constraints and do default size calculations and final validation */ - calculate_log_size(&cfg, &cli, mp); + calculate_log_size(&cfg, &cli, &xi, mp); finish_superblock_setup(&cfg, mp, sbp);