Whamcloud - gitweb
LU-3838 lfsck: various defects in lfsck 63/7563/3
authorNiu Yawei <yawei.niu@intel.com>
Thu, 5 Sep 2013 13:03:50 +0000 (09:03 -0400)
committerNiu Yawei <yawei.niu@intel.com>
Tue, 8 Oct 2013 07:52:17 +0000 (03:52 -0400)
- In lfsck_get_fid(), sizeof(buf) should be passed as buffer length,
  but not sizeof(*buf);

- In lfsck_mds_dirs(), we should follow into directory if the
  directory doesn't contain self fid;

- In ext2fs_attr_ibody_get(), returns EXT2_ET_EA_TOO_BIG only when
  the buffer isn't large enough;

- In ext2fs_attr_ibody_get(), do type cast before operating on
  pointer!

Signed-off-by: Niu Yawei <yawei.niu@intel.com>
Change-Id: I8ba4139fcc51b23bfa33c82c71f9b69b2b033a37

e2fsck/lfsck_common.c
e2fsck/pass6.c
lib/ext2fs/ext_attr.c

index 9819069..4f427ae 100644 (file)
@@ -404,7 +404,7 @@ int lfsck_get_fid(ext2_filsys fs, ino_t ino, struct lu_fid *fid)
                return rc;
        }
        rc = ext2fs_attr_get(fs, inode, EXT2_ATTR_INDEX_TRUSTED,
-                            LUSTRE_XATTR_MDT_LMA, buf, sizeof(*buf), &size);
+                            LUSTRE_XATTR_MDT_LMA, buf, sizeof(buf), &size);
        if (rc) {
                if (rc != EXT2_ET_EA_NAME_NOT_FOUND &&
                    rc != EXT2_ET_EA_BAD_MAGIC) {
index 7839bdd..df5b9ba 100644 (file)
@@ -698,7 +698,7 @@ static int lfsck_mds_dirs(ext2_ino_t dir, int entry,
 
        rc = lfsck_get_fid(lctx->ctx->fs, dirent->inode, &mds_dirent.mds_fid);
        if (rc != 0)
-               return 0;
+               goto follow_on;
 
        DEBUG(lctx->ctx, "MDT: dirfid "DFID" child "DFID" file %.*s\n",
              PFID(&mds_dirent.mds_dirfid), PFID(&mds_dirent.mds_fid),
@@ -725,6 +725,7 @@ static int lfsck_mds_dirs(ext2_ino_t dir, int entry,
                        return DIRENT_ABORT;
                }
        }
+follow_on:
        if (file_type == EXT2_FT_DIR) {
                lctx2 = *lctx;
                lctx2.dot = dirent->inode;
index cedc2a2..852fe79 100644 (file)
@@ -756,12 +756,12 @@ static errcode_t ext2fs_attr_block_get(ext2_filsys fs, struct ext2_inode *inode,
        if (easize)
                *easize = entry->e_value_size;
        if (buffer) {
-               error = EXT2_ET_EA_TOO_BIG;
-               if (entry->e_value_size > buffer_size)
+               if (entry->e_value_size > buffer_size) {
+                       error = EXT2_ET_EA_TOO_BIG;
                        goto cleanup;
+               }
                memcpy(buffer, block_buf + entry->e_value_offs,
                       entry->e_value_size);
-               error = 0;
        }
 
 cleanup:
@@ -809,10 +809,11 @@ static errcode_t ext2fs_attr_ibody_get(ext2_filsys fs,
        if (easize)
                *easize = entry->e_value_size;
        if (buffer) {
-               error = EXT2_ET_EA_TOO_BIG;
-               if (entry->e_value_size > buffer_size)
+               if (entry->e_value_size > buffer_size) {
+                       error = EXT2_ET_EA_TOO_BIG;
                        goto cleanup;
-               memcpy(buffer, &IHDR(inode)->h_first_entry[0] +
+               }
+               memcpy(buffer, (void *)&IHDR(inode)->h_first_entry[0] +
                               entry->e_value_offs, entry->e_value_size);
        }