[Ocfs2-tools-devel] [PATCH 3/6] Fix index of directories

Goldwyn Rodrigues rgoldwyn at gmail.com
Tue Nov 8 20:01:14 PST 2011


On Wed, Oct 26, 2011 at 2:15 AM, Sunil Mushran <sunil.mushran at oracle.com> wrote:
> Question for Mark inlined.
>
> On 08/22/2011 03:36 PM, Goldwyn Rodrigues wrote:
>>
>> In case the i_size of the directory changes, reset the dx_root of the
>> inode, so it may be later detected for index directory rebuilds. In
>> pass2, if the filesystem supports directory indexing, rebuild directory
>> indexes.
>>
>> I used this method because otherwise we will have to bounce
>> dirblock_data struct between passes. The dirblock_data is used only in
>> pass1.
>>
>> This also helps the patchset - avoiding EROFS on index dir corruptions.
>> http://oss.oracle.com/pipermail/ocfs2-devel/2011-August/008312.html
>>
>> Signed-off-by: Goldwyn Rodrigues<rgoldwyn at suse.de>
>> ---
>>  fsck.ocfs2/extent.c |    5 +++++
>>  fsck.ocfs2/pass2.c  |   13 ++++++++++---
>>  2 files changed, 15 insertions(+), 3 deletions(-)
>>
>> diff --git a/fsck.ocfs2/extent.c b/fsck.ocfs2/extent.c
>> index 2bd9738..8c765ab 100644
>> --- a/fsck.ocfs2/extent.c
>> +++ b/fsck.ocfs2/extent.c
>> @@ -459,6 +459,11 @@ errcode_t o2fsck_check_extents(o2fsck_state *ost,
>>                                (uint64_t)di->i_blkno,
>>                                (uint64_t)di->i_size, expected)) {
>>                        di->i_size = expected;
>> +                       /* Reset i_dx_root for later re-build */
>> +                       if (di->i_dyn_features&  OCFS2_INDEXED_DIR_FL) {
>> +                               di->i_dx_root = 0ULL;
>> +                               di->i_dyn_features&=
>> ~OCFS2_INDEXED_DIR_FL;
>> +                       }
>
> Shouldn't we be calling ocfs2_dx_dir_truncate()?
>
> Mark?


My thoughts: yes that would be better. However, we might have to
ignore the return status of ocfs2_dx_dir_truncate() for incorporating
fixing corrupt indexed directories.


>
>>                        changed = 1;
>>                }
>>        }
>> diff --git a/fsck.ocfs2/pass2.c b/fsck.ocfs2/pass2.c
>> index 4b43a22..d1133b2 100644
>> --- a/fsck.ocfs2/pass2.c
>> +++ b/fsck.ocfs2/pass2.c
>> @@ -732,6 +732,13 @@ static unsigned
>> pass2_dir_block_iterate(o2fsck_dirblock_entry *dbe,
>>                verbosef("dir inode %"PRIu64" i_size %"PRIu64"\n",
>>                         dbe->e_ino, (uint64_t)di->i_size);
>>
>> +               /* Set the flag for index rebuilding */
>> +               if
>> (ocfs2_supports_indexed_dirs(OCFS2_RAW_SB(dd->fs->fs_super))
>> +                       &&  !(di->i_dyn_features&  OCFS2_INLINE_DATA_FL)
>> +                       &&  !(di->i_dyn_features&  OCFS2_INDEXED_DIR_FL))
>> {
>> +                       ret_flags |= OCFS2_DIRENT_CHANGED;
>> +               }
>> +
>>        }
>>
>>        verbosef("dir block %"PRIu64" block offs %"PRIu64" in ino\n",
>> @@ -896,9 +903,9 @@ next:
>>                        goto out;
>>                }
>>
>> -               if
>> (ocfs2_supports_indexed_dirs(OCFS2_RAW_SB(dd->fs->fs_super))&&
>> -                   !(di->i_dyn_features&  OCFS2_INLINE_DATA_FL)&&
>> -                   (di->i_dyn_features&  OCFS2_INDEXED_DIR_FL)) {
>> +               if
>> (ocfs2_supports_indexed_dirs(OCFS2_RAW_SB(dd->fs->fs_super))
>> +                       &&  !(di->i_dyn_features&  OCFS2_INLINE_DATA_FL))
>> {
>> +                       di->i_dyn_features |= OCFS2_INDEXED_DIR_FL;
>>                        ret = o2fsck_try_add_reidx_dir(&dd->re_idx_dirs,
>> dbe->e_ino);
>>                        if (ret) {
>>                                com_err(whoami, ret, "while adding block
>> for "
>
>



-- 
Goldwyn



More information about the Ocfs2-tools-devel mailing list