Re: [PATCH] fix htree dir corrupt after fsck -fD

From: Theodore Ts'o (tytso@mit.edu)
Date: Sun Sep 29 2002 - 09:13:28 EST


On Sun, Sep 29, 2002 at 12:03:15AM -0700, chrisl@gnuchina.org wrote:
> When e2fsck rehash the directory index. it will left one empty
> dir entry at the end of block if next dir entry can not fit in.
> I think it is OK to do so but I also make a patch to make the empty
> space merge with previous entry to consistent with the kernel.

Nice catch! Yup, e2fsck will create an empty directory entry, instead
of letting the previous entry absorb the extra space. Both are legal
ways of doing things, but yes, the kernel does the latter in all cases
except when deleting the last directory entry in a block. (But that's
OK, because the split code would never need to be invoked on an empty
directory block.)

> dx_make_map need to skip the empty entry. So here is the patch for
> review before I push it back to htree BK repository.

That patch looks fine. Push away!

> Ted, is e2fsck endian free now? I notice some code in
> copy_dir_entries() do not have cpu_to_le32 for rec_len etc.

Yes, e2fsprogs is endian-free. The byte swapping happens in the
library routine ext2fs_read_dir_block() and ext2fs_write_dir_block().
Note that you have to tell these routines whether you're planning on
using the v2 version of dirent struct or not, because that affects
whether or not the name_len field needs to be byte-swapped or not.

                                        - Ted
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Sep 30 2002 - 22:00:40 EST