Whamcloud - gitweb
LU-3573 osd-zfs: Only advance zap cursor as needed 04/12904/2
authorNathaniel Clark <nathaniel.l.clark@intel.com>
Wed, 5 Nov 2014 18:05:22 +0000 (13:05 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 10 Dec 2014 23:31:20 +0000 (23:31 +0000)
Only advance the zap cursor when ozi_pos is not advanced, otherwise
occasionally the a file could get "lost" because the zap_cursor would
advance over it before the retrieve happened.  Handle '..' like '.'
when retrieving ZAP values.

Test-Parameters: mdtfilesystemtype=zfs mdsfilesystemtype=zfs ostfilesystemtype=zfs testlist=conf-sanity,conf-sanity,conf-sanity,conf-sanity
Signed-off-by: Nathaniel Clark <nathaniel.l.clark@intel.com>
Reviewed-by: Isaac Huang <he.huang@intel.com>
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Change-Id: I916573c70c8828bed6905b5eda9344b4a49b7f11
Reviewed-on: http://review.whamcloud.com/12904
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/osd-zfs/osd_index.c

index dbc8f30..d14efbb 100644 (file)
@@ -865,6 +865,8 @@ static int osd_dir_it_next(const struct lu_env *env, struct dt_it *di)
        zap_attribute_t   *za = &osd_oti_get(env)->oti_za;
        int                rc;
 
+       ENTRY;
+
        /* temp. storage should be enough for any key supported by ZFS */
        CLASSERT(sizeof(za->za_name) <= sizeof(it->ozi_name));
 
@@ -877,9 +879,10 @@ static int osd_dir_it_next(const struct lu_env *env, struct dt_it *di)
                it->ozi_pos++;
                if (it->ozi_pos <=2)
                        RETURN(0);
-       }
 
-       zap_cursor_advance(it->ozi_zc);
+       } else {
+               zap_cursor_advance(it->ozi_zc);
+       }
 
        /*
         * According to current API we need to return error if its last entry.
@@ -969,14 +972,11 @@ static int osd_dir_it_rec(const struct lu_env *env, const struct dt_it *di,
                osd_it_append_attrs(lde, attr, 2, IFTODT(S_IFDIR));
                lde->lde_reclen = cpu_to_le16(lu_dirent_calc_size(2, attr));
                rc = osd_find_parent_fid(env, &it->ozi_obj->oo_dt, &lde->lde_fid);
-               /*
-                * early Orion code was not setting LinkEA, so it's possible
-                * some setups still have objects with no LinkEA set.
-                * but at that time .. was a real record in the directory
-                * so we should try to lookup .. in ZAP
-                */
-               if (rc != -ENOENT)
-                       GOTO(out, rc);
+
+               /* ENOENT happens at the root of filesystem so ignore it */
+               if (rc == -ENOENT)
+                       rc = 0;
+               GOTO(out, rc);
        }
 
        LASSERT(lde);