Whamcloud - gitweb
using big endian format for fid in (name->fid) index.
authorhuanghua <huanghua>
Mon, 23 Oct 2006 07:49:04 +0000 (07:49 +0000)
committerhuanghua <huanghua>
Mon, 23 Oct 2006 07:49:04 +0000 (07:49 +0000)
lustre/fid/fid_lib.c
lustre/mdd/mdd_dir.c
lustre/mdd/mdd_internal.h
lustre/mdd/mdd_trans.c
lustre/osd/osd_handler.c
lustre/utils/loadmod_all.sh
lustre/utils/mkfs_lustre.c

index ac2d921..b66a04b 100644 (file)
@@ -73,7 +73,7 @@ void fid_cpu_to_le(struct lu_fid *dst, const struct lu_fid *src)
         CLASSERT(sizeof *src ==
                  sizeof fid_seq(src) +
                  sizeof fid_oid(src) + sizeof fid_ver(src));
-        LASSERT(fid_is_igif(src) || fid_ver(src) == 0);
+        LASSERTF(fid_is_igif(src) || fid_ver(src) == 0, DFID"\n", PFID(src));
         dst->f_seq = cpu_to_le64(fid_seq(src));
         dst->f_oid = cpu_to_le32(fid_oid(src));
         dst->f_ver = cpu_to_le32(fid_ver(src));
@@ -89,7 +89,7 @@ void fid_le_to_cpu(struct lu_fid *dst, const struct lu_fid *src)
         dst->f_seq = le64_to_cpu(fid_seq(src));
         dst->f_oid = le32_to_cpu(fid_oid(src));
         dst->f_ver = le32_to_cpu(fid_ver(src));
-        LASSERT(fid_is_igif(dst) || fid_ver(dst) == 0);
+        LASSERTF(fid_is_igif(dst) || fid_ver(dst) == 0, DFID"\n", PFID(dst));
 }
 EXPORT_SYMBOL(fid_le_to_cpu);
 
@@ -100,7 +100,7 @@ void fid_cpu_to_be(struct lu_fid *dst, const struct lu_fid *src)
         CLASSERT(sizeof *src ==
                  sizeof fid_seq(src) +
                  sizeof fid_oid(src) + sizeof fid_ver(src));
-        LASSERT(fid_is_igif(src) || fid_ver(src) == 0);
+        LASSERTF(fid_is_igif(src) || fid_ver(src) == 0, DFID"\n", PFID(src));
         dst->f_seq = cpu_to_be64(fid_seq(src));
         dst->f_oid = cpu_to_be32(fid_oid(src));
         dst->f_ver = cpu_to_be32(fid_ver(src));
@@ -116,7 +116,7 @@ void fid_be_to_cpu(struct lu_fid *dst, const struct lu_fid *src)
         dst->f_seq = be64_to_cpu(fid_seq(src));
         dst->f_oid = be32_to_cpu(fid_oid(src));
         dst->f_ver = be32_to_cpu(fid_ver(src));
-        LASSERT(fid_is_igif(dst) || fid_ver(dst) == 0);
+        LASSERTF(fid_is_igif(dst) || fid_ver(dst) == 0i, DFID"\n", PFID(dst));
 }
 EXPORT_SYMBOL(fid_be_to_cpu);
 #endif
index 221e49e..7c67f16 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/ldiskfs_fs.h>
 #include <lustre_mds.h>
 #include <lustre/lustre_idl.h>
+#include <lustre_fid.h>
 
 #include "mdd_internal.h"
 
@@ -48,10 +49,10 @@ static const char dot[] = ".";
 static const char dotdot[] = "..";
 
 static int __mdd_lookup(const struct lu_env *env, struct md_object *pobj,
-                        const char *name, const struct lu_fid* fid, int mask);
+                        const char *name, struct lu_fid* fid, int mask);
 static int
 __mdd_lookup_locked(const struct lu_env *env, struct md_object *pobj,
-                    const char *name, const struct lu_fid* fid, int mask)
+                    const char *name, struct lu_fid* fid, int mask)
 {
         struct mdd_object *mdd_obj = md2mdd_obj(pobj);
         struct dynlock_handle *dlh;
@@ -284,6 +285,16 @@ int mdd_link_sanity_check(const struct lu_env *env, struct mdd_object *tgt_obj,
         RETURN(rc);
 }
 
+const struct dt_rec *index_fid_key(const struct lu_env *env,
+                                   const struct lu_fid *fid)
+{
+        struct mdd_thread_info *info = mdd_env_info(env);
+
+        fid_cpu_to_be(&info->mti_fid2, fid);
+        return (const struct dt_rec *)&info->mti_fid2;
+}
+
+
 /* insert new index, add reference if isdir, update times */
 static int __mdd_index_insert(const struct lu_env *env,
                              struct mdd_object *pobj, const struct lu_fid *lf,
@@ -303,8 +314,8 @@ static int __mdd_index_insert(const struct lu_env *env,
 
         if (dt_try_as_dir(env, next))
                 rc = next->do_index_ops->dio_insert(env, next,
-                                                    (struct dt_rec *)lf,
-                                                    (struct dt_key *)name,
+                                                    index_fid_key(env, lf),
+                                                    (const struct dt_key *)name,
                                                     th, capa);
         else
                 rc = -ENOTDIR;
@@ -367,8 +378,8 @@ static int __mdd_index_insert_only(const struct lu_env *env,
 
         if (dt_try_as_dir(env, next))
                 rc = next->do_index_ops->dio_insert(env, next,
-                                         (struct dt_rec *)lf,
-                                         (struct dt_key *)name, th, capa);
+                                         index_fid_key(env, lf),
+                                         (const struct dt_key *)name, th, capa);
         else
                 rc = -ENOTDIR;
         RETURN(rc);
@@ -872,7 +883,7 @@ static int mdd_create_data(const struct lu_env *env,
 
 static int
 __mdd_lookup(const struct lu_env *env, struct md_object *pobj,
-             const char *name, const struct lu_fid* fid, int mask)
+             const char *name, struct lu_fid* fid, int mask)
 {
         struct mdd_object   *mdd_obj = md2mdd_obj(pobj);
         struct dt_object    *dir = mdd_object_child(mdd_obj);
@@ -904,10 +915,12 @@ __mdd_lookup(const struct lu_env *env, struct md_object *pobj,
         if (rc)
                 RETURN(rc);
 
-        if (S_ISDIR(mdd_object_type(mdd_obj)) && dt_try_as_dir(env, dir))
+        if (S_ISDIR(mdd_object_type(mdd_obj)) && dt_try_as_dir(env, dir)) {
                 rc = dir->do_index_ops->dio_lookup(env, dir, rec, key,
                                                    mdd_object_capa(env, mdd_obj));
-        else
+                if (rc == 0)
+                        fid_be_to_cpu(fid, fid);
+        } else
                 rc = -ENOTDIR;
 
         mdd_lproc_time_end(mdo2mdd(pobj), &start, LPROC_MDD_LOOKUP);
index 4beb446..aa54b73 100644 (file)
@@ -110,6 +110,7 @@ struct mdd_thread_info {
         struct lu_buf         mti_buf;
         struct obdo           mti_oa;
         char                  mti_xattr_buf[LUSTRE_POSIX_ACL_MAX_SIZE];
+        struct lu_fid         mti_fid2; /* used for be & cpu converting */
 };
 
 int mdd_init_obd(const struct lu_env *env, struct mdd_device *mdd,
index 470da7c..54a3065 100644 (file)
@@ -80,6 +80,7 @@ int mdd_log_txn_param_build(const struct lu_env *env, struct mdd_object *obj,
 {
         struct mdd_device *mdd = mdo2mdd(&obj->mod_obj);
         int rc, log_credits, stripe;
+        ENTRY;
         
         mdd_txn_param_build(env, mdd, op);
         
index 305cb01..8079b2b 100644 (file)
@@ -565,7 +565,7 @@ static struct thandle *osd_trans_start(const struct lu_env *env,
         hook_res = dt_txn_hook_start(env, d, p);
         if (hook_res != 0)
                 RETURN(ERR_PTR(hook_res));
-
+        
         if (osd_param_is_sane(dev, p)) {
                 OBD_ALLOC_GFP(oh, sizeof *oh, GFP_NOFS);
                 if (oh != NULL) {
@@ -1316,13 +1316,16 @@ static int osd_dir_page_build(const struct lu_env *env, int first,
                 len  = iops->key_size(env, it);
 
                 *fid  = *(struct lu_fid *)iops->rec(env, it);
-                fid_cpu_to_le(fid, fid);
+                /* convert from disk data to cpu */
+                fid_be_to_cpu(fid, fid);
 
                 recsize = (sizeof *ent + len + 3) & ~3;
                 hash = iops->store(env, it);
                 *end = hash;
                 CDEBUG(D_INFO, "%p %p %d "DFID": %#8.8x (%d) \"%*.*s\"\n",
                        name, ent, nob, PFID(fid), hash, len, len, len, name);
+                /* convert from cpu data to network */
+                fid_cpu_to_le(fid, fid);
                 if (nob >= recsize) {
                         ent->lde_fid = *fid;
                         ent->lde_hash = hash;
index 3b09ed6..9238c79 100755 (executable)
@@ -36,11 +36,12 @@ modprobe lnet
 modprobe ksocklnd
 
 
-HOST=`hostname`
-echo -1 >/proc/sys/lnet/debug
-echo "/r/tmp/$HOST.debug" >/proc/sys/lnet/daemon_file
-
 #  To generate gdb debug file:
 rm -f /r/tmp/ogdb-`hostname`
 ./lctl modules > /r/tmp/ogdb-`hostname`
 
+
+HOST=`hostname`
+echo -1 >/proc/sys/lnet/debug
+echo "/r/tmp/$HOST.debug" >/proc/sys/lnet/daemon_file
+
index 3aca10f..527947a 100644 (file)
@@ -1354,7 +1354,7 @@ static int mkfs_mdt(struct mkfs_opts *mop)
         }
 
         snprintf(recbuf, sizeof(recbuf) - 1, "0000000000000001%8.8x%8.8x",
-                 (unsigned int)generation, (unsigned int)st.st_ino);
+                 (unsigned int)st.st_ino, (unsigned int)generation);
         ret = mkfs_iam_insert(0, ".", 1, recbuf, filepnm);
         if (ret) {
                 goto out_umount;