Re: [PATCH] ext4: Fix incorrect group count in ext4_fill_super error message

From: Josh Triplett
Date: Sat Mar 28 2020 - 19:56:03 EST


On Sat, Mar 28, 2020 at 05:07:55PM -0600, Andreas Dilger wrote:
> On Mar 28, 2020, at 3:54 PM, Josh Triplett <josh@xxxxxxxxxxxxxxxx> wrote:
> >
> > ext4_fill_super doublechecks the number of groups before mounting; if
> > that check fails, the resulting error message prints the group count
> > from the ext4_sb_info sbi, which hasn't been set yet. Print the freshly
> > computed group count instead (which at that point has just been computed
> > in "blocks_count").
> >
> > Signed-off-by: Josh Triplett <josh@xxxxxxxxxxxxxxxx>
> > Fixes: 4ec1102813798 ("ext4: Add sanity checks for the superblock before mounting the filesystem")
>
> Modulo the compiler warning pointed out by kbuild test robot, I think the
> patch is correct, but was definitely confusing to read within the shown
> context, since "blocks_count" definitely doesn't seem to be "groups count"
> (it *is* the "groups count", but is just used as a temporary variable).

I agree that the code and patch read confusingly due to the (lack of)
context. The commit message attempted to explain that, but clearer code
seems preferable to confusing-but-explained code.

I sent a new version of this patch, which instead just moves the
assignment to sbi's group count earlier, so that the error message can
continue referencing it that way. (That also addresses the warning.)

- Josh Triplett