Whamcloud - gitweb
LU-4543 osd: return actual hash value for a record
[fs/lustre-release.git] / lustre / osd-zfs / osd_index.c
index 29b0d68..1e7c441 100644 (file)
@@ -472,8 +472,8 @@ static inline void osd_object_put(const struct lu_env *env,
        lu_object_put(env, &obj->oo_dt.do_lu);
 }
 
-static int osd_mdt_seq_exists(const struct lu_env *env, struct osd_device *osd,
-                             obd_seq seq)
+static int osd_seq_exists(const struct lu_env *env, struct osd_device *osd,
+                         obd_seq seq)
 {
        struct lu_seq_range     *range = &osd_oti_get(env)->oti_seq_range;
        struct seq_server_site  *ss = osd_seq_site(osd);
@@ -483,10 +483,6 @@ static int osd_mdt_seq_exists(const struct lu_env *env, struct osd_device *osd,
        if (ss == NULL)
                RETURN(1);
 
-       /* XXX: currently, each MDT only store avaible sequence on disk,
-        * and no allocated sequences information on disk, so it has to
-        * lookup FLDB. It probably makes more sense also store allocated
-        * sequence locally, so we do not need do remote FLDB lookup in OSD */
        rc = osd_fld_lookup(env, osd, seq, range);
        if (rc != 0) {
                CERROR("%s: Can not lookup fld for "LPX64"\n",
@@ -505,8 +501,7 @@ static int osd_remote_fid(const struct lu_env *env, struct osd_device *osd,
        if (!fid_is_norm(fid) && !fid_is_root(fid))
                RETURN(0);
 
-       /* Currently, it only used to check FID on MDT */
-       if (osd_mdt_seq_exists(env, osd, fid_seq(fid)))
+       if (osd_seq_exists(env, osd, fid_seq(fid)))
                RETURN(0);
 
        RETURN(1);
@@ -937,11 +932,11 @@ static int osd_dir_it_rec(const struct lu_env *env, const struct dt_it *di,
 
        LASSERT(lde);
 
-       lde->lde_hash = cpu_to_le64(udmu_zap_cursor_serialize(it->ozi_zc));
-
-       if ((rc = -zap_cursor_retrieve(it->ozi_zc, za)))
+       rc = -zap_cursor_retrieve(it->ozi_zc, za);
+       if (unlikely(rc != 0))
                GOTO(out, rc);
 
+       lde->lde_hash = cpu_to_le64(udmu_zap_cursor_serialize(it->ozi_zc));
        namelen = strlen(za->za_name);
        if (namelen > NAME_MAX)
                GOTO(out, rc = -EOVERFLOW);
@@ -1048,8 +1043,9 @@ static struct dt_index_operations osd_dir_ops = {
  * Primitives for index files using binary keys.
  */
 
-static int osd_prepare_key(struct osd_object *o, __u64 *dst,
-                          const struct dt_key *src)
+/* key integer_size is 8 */
+static int osd_prepare_key_uint64(struct osd_object *o, __u64 *dst,
+                                 const struct dt_key *src)
 {
        int size;
 
@@ -1066,7 +1062,7 @@ static int osd_prepare_key(struct osd_object *o, __u64 *dst,
                memset(dst + o->oo_keysize, 0, size - o->oo_keysize);
        memcpy(dst, (const char *)src, o->oo_keysize);
 
-       return size;
+       return (size/sizeof(__u64));
 }
 
 static int osd_index_lookup(const struct lu_env *env, struct dt_object *dt,
@@ -1079,7 +1075,7 @@ static int osd_index_lookup(const struct lu_env *env, struct dt_object *dt,
        int                rc;
        ENTRY;
 
-       rc = osd_prepare_key(obj, k, key);
+       rc = osd_prepare_key_uint64(obj, k, key);
 
        rc = -zap_lookup_uint64(osd->od_objset.os, obj->oo_db->db_object,
                                k, rc, obj->oo_recusize, obj->oo_recsize,
@@ -1131,7 +1127,7 @@ static int osd_index_insert(const struct lu_env *env, struct dt_object *dt,
 
        oh = container_of0(th, struct osd_thandle, ot_super);
 
-       rc = osd_prepare_key(obj, k, key);
+       rc = osd_prepare_key_uint64(obj, k, key);
 
        /* Insert (key,oid) into ZAP */
        rc = -zap_add_uint64(osd->od_objset.os, obj->oo_db->db_object,
@@ -1175,7 +1171,7 @@ static int osd_index_delete(const struct lu_env *env, struct dt_object *dt,
        LASSERT(th != NULL);
        oh = container_of0(th, struct osd_thandle, ot_super);
 
-       rc = osd_prepare_key(obj, k, key);
+       rc = osd_prepare_key_uint64(obj, k, key);
 
        /* Remove binary key from the ZAP */
        rc = -zap_remove_uint64(osd->od_objset.os, obj->oo_db->db_object,
@@ -1276,7 +1272,7 @@ static int osd_index_it_rec(const struct lu_env *env, const struct dt_it *di,
        if (rc)
                RETURN(rc);
 
-       rc = osd_prepare_key(obj, k, (const struct dt_key *)za->za_name);
+       rc = osd_prepare_key_uint64(obj, k, (const struct dt_key *)za->za_name);
 
        rc = -zap_lookup_uint64(osd->od_objset.os, obj->oo_db->db_object,
                                k, rc, obj->oo_recusize, obj->oo_recsize,