On 5/18/20 11:39 PM, xiakaixu1987@xxxxxxxxx wrote: > From: Kaixu Xia <kaixuxia@xxxxxxxxxxx> > > There are two places that set the configured sector sizes in validate_sectorsize, > actually we can simplify them and combine into one if statement. >Is it me or patch description seems to be longer than what is in the tree ? > Signed-off-by: Kaixu Xia <kaixuxia@xxxxxxxxxxx> > --- > mkfs/xfs_mkfs.c | 14 ++++---------- > 1 file changed, 4 insertions(+), 10 deletions(-) > > diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c > index 039b1dcc..e1904d57 100644 > --- a/mkfs/xfs_mkfs.c > +++ b/mkfs/xfs_mkfs.c > @@ -1696,14 +1696,6 @@ validate_sectorsize( > int dry_run, > int force_overwrite) > { > - /* set configured sector sizes in preparation for checks */ > - if (!cli->sectorsize) { > - cfg->sectorsize = dft->sectorsize; > - } else { > - cfg->sectorsize = cli->sectorsize; > - } > - cfg->sectorlog = libxfs_highbit32(cfg->sectorsize); > - If above logic is correct which I've not looked into it, then dft is not used in validate_sectorsize(), how about something like this on the top of this this patch (totally untested):- diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 3ed7d844..6cbd5d9d 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -1690,7 +1690,6 @@ static void validate_sectorsize( struct mkfs_params *cfg, struct cli_params *cli, - struct mkfs_default_params *dft, struct fs_topology *ft, char *dfile, int dry_run, @@ -3696,8 +3695,7 @@ main( * before opening the libxfs devices. */ validate_blocksize(&cfg, &cli, &dft); - validate_sectorsize(&cfg, &cli, &dft, &ft, dfile, dry_run, - force_overwrite); + validate_sectorsize(&cfg, &cli, &ft, dfile, dry_run, force_overwrite); /* * XXX: we still need to set block size and sector size global variables > /* > * Before anything else, verify that we are correctly operating on > * files or block devices and set the control parameters correctly. > @@ -1730,6 +1722,7 @@ validate_sectorsize( > memset(ft, 0, sizeof(*ft)); > get_topology(cli->xi, ft, force_overwrite); > > + /* set configured sector sizes in preparation for checks */ > if (!cli->sectorsize) { > /* > * Unless specified manually on the command line use the > @@ -1759,9 +1752,10 @@ _("specified blocksize %d is less than device physical sector size %d\n" > ft->lsectorsize); > cfg->sectorsize = ft->lsectorsize; > } > + } else > + cfg->sectorsize = cli->sectorsize; > > - cfg->sectorlog = libxfs_highbit32(cfg->sectorsize); > - } > + cfg->sectorlog = libxfs_highbit32(cfg->sectorsize); > > /* validate specified/probed sector size */ > if (cfg->sectorsize < XFS_MIN_SECTORSIZE || >