Re: [PATCH 23/51] e2fsck: Verify htree root/node checksums

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Dec 19, 2011 at 07:57:21AM +0100, Andreas Dilger wrote:
> On 2011-12-14, at 2:15, "Darrick J. Wong" <djwong@xxxxxxxxxx> wrote:
> 
> > Check htree internal node checksums.  If broken, ask user to clear the htree
> > index and recreate it later.
> > 
> > @@ -560,8 +572,12 @@ static void parse_int_node(ext2_filsys fs,
> > #endif
> > 
> >    count = ext2fs_le16_to_cpu(limit->count);
> > -    expect_limit = (fs->blocksize - ((char *) ent - block_buf)) /
> > -        sizeof(struct ext2_dx_entry);
> > +    if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
> > +                       EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
> > +        csum_size = sizeof(struct ext2_dx_tail);
> > +    expect_limit = (fs->blocksize -
> > +            (csum_size + ((char *) ent - block_buf))) /
> > +               sizeof(struct ext2_dx_entry);
> 
> How does this handle the case where the METADATA_CSUM feature is newly
> enabled but there is a dirent usinf the end of the leaf block?  It definitely
> shouldn't cause the last entry to be considered invalid. 

For htree nodes, tune2fs decrements limit if count < limit.  If count == limit,
then fsck is run to rebuild the htree index.  For its part, e2fsck will notice
that count == limit, zero the htree node, and add the directory inode to the
pass3 rebuild list.

> > @@ -829,7 +850,7 @@ static int check_dir_block(ext2_filsys fs,
> >               (rec_len == fs->blocksize) &&
> >               (dirent->name_len == 0) &&
> >               (ext2fs_le16_to_cpu(limit->limit) ==
> > -                ((fs->blocksize-8) /
> > +                ((fs->blocksize - (8 + csum_size)) /
> >                 sizeof(struct ext2_dx_entry))))
> >            dx_db->type = DX_DIRBLOCK_NODE;
> 
> Same here.  
> 
> > diff --git a/e2fsck/problem.c b/e2fsck/problem.c
> > index 96b0de5..2e9ab7f 100644
> > --- a/e2fsck/problem.c
> > +++ b/e2fsck/problem.c
> > @@ -1374,6 +1374,16 @@ static struct e2fsck_problem problem_table[] = {
> >      N_("i_file_acl_hi @F %N, @s zero.\n"),
> >      PROMPT_CLEAR, PR_PREEN_OK },
> > 
> > +    /* htree root node fails checksum */
> > +    { PR_2_HTREE_ROOT_CSUM_INVALID,
> > +      N_("@p @h %d: root node fails checksum\n"),
> > +      PROMPT_CLEAR_HTREE, PR_PREEN_OK },
> > +
> > +    /* htree internal node fails checksum */
> > +    { PR_2_HTREE_NODE_CSUM_INVALID,
> > +      N_("@p @h %d: node fails checksum\n"),
> 
> This error message should include "internal" in the printed message. 

How about "htree node"?  I wondered why the other PR_*_HTREE messages don't say
"htree" -- is there a particular reason for this?

--D

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux