Whamcloud - gitweb
- fixes after FIDs inspection
authoryury <yury>
Wed, 31 May 2006 13:34:02 +0000 (13:34 +0000)
committeryury <yury>
Wed, 31 May 2006 13:34:02 +0000 (13:34 +0000)
20 files changed:
lustre/fid/fid_seq.c
lustre/include/lustre/lustre_idl.h
lustre/include/obd.h
lustre/include/obd_class.h
lustre/liblustre/dir.c
lustre/liblustre/llite_lib.h
lustre/liblustre/namei.c
lustre/liblustre/super.c
lustre/llite/file.c
lustre/llite/llite_fid.c
lustre/llite/llite_internal.h
lustre/llite/llite_lib.c
lustre/llite/llite_nfs.c
lustre/llite/namei.c
lustre/lmv/lmv_intent.c
lustre/lmv/lmv_obd.c
lustre/lmv/lmv_object.c
lustre/mdc/mdc_locks.c
lustre/mdc/mdc_request.c
lustre/mdt/mdt_handler.c

index 4d310c8..1b6f5d2 100644 (file)
@@ -72,10 +72,11 @@ int seq_mgr_read(const struct lu_context *ctx, struct lu_seq_mgr *mgr)
 EXPORT_SYMBOL(seq_mgr_read);
 
 /* manager functionality stuff */
-int seq_mgr_alloc(const struct lu_context *ctx, struct lu_seq_mgr *mgr,
+int seq_mgr_alloc(const struct lu_context *ctx,
+                  struct lu_seq_mgr *mgr,
                   __u64 *seq)
 {
-        int rc = 0;
+        int rc;
         ENTRY;
 
         LASSERT(mgr != NULL);
@@ -106,6 +107,7 @@ int seq_mgr_setup(const struct lu_context *ctx, struct lu_seq_mgr *mgr)
 
         /* set seq range */
         mgr->m_seq_last = mgr->m_seq + LUSTRE_SEQ_RANGE;
+        
         /* allocate next seq after root one */
         mgr->m_seq += LUSTRE_ROOT_FID_SEQ + 1;
 
index e1266d6..bb0f36e 100644 (file)
@@ -145,10 +145,7 @@ enum {
         LUSTRE_SEQ_RANGE = 1000,
 
         /* initial fid id value */
-        LUSTRE_FID_INIT_OID  = 1UL,
-
-        /* shift of version component */
-        LUSTRE_FID_VER_SHIFT = (sizeof(((struct lu_fid *)0)->f_ver) * 8)
+        LUSTRE_FID_INIT_OID  = 1UL
 };
 
 /* get object sequence */
@@ -169,14 +166,6 @@ static inline __u32 fid_ver(const struct lu_fid *fid)
         return fid->f_ver;
 }
 
-/* get complex object number (oid + version) */
-static inline __u64 fid_num(const struct lu_fid *fid)
-{
-        __u64 f_ver = fid_ver(fid);
-        f_ver = f_ver << LUSTRE_FID_VER_SHIFT;
-        return f_ver | fid_oid(fid);
-}
-
 static inline int fid_seq_is_sane(__u64 seq)
 {
         return seq != 0;
index 0592ab8..5d95c0d 100644 (file)
@@ -543,7 +543,7 @@ struct niobuf_local {
 #define LUSTRE_OPC_MKNODE    (1 << 2)
 #define LUSTRE_OPC_CREATE    (1 << 3)
         
-struct placement_hint {
+struct lu_placement_hint {
         struct qstr *ph_pname;
         struct qstr *ph_cname;
         int          ph_opc;
@@ -831,7 +831,7 @@ struct obd_ops {
 
         /* may be later these should be moved into separate fid_ops */
         int (*o_fid_alloc)(struct obd_export *exp, struct lu_fid *fid,
-                           struct placement_hint *hint);
+                           struct lu_placement_hint *hint);
         
         int (*o_fid_delete)(struct obd_export *exp, struct lu_fid *fid);
         
index 85ef0db..8580a10 100644 (file)
@@ -722,7 +722,7 @@ static inline int obd_disconnect(struct obd_export *exp)
 
 static inline int obd_fid_alloc(struct obd_export *exp,
                                 struct lu_fid *fid,
-                                struct placement_hint *hint)
+                                struct lu_placement_hint *hint)
 {
         int rc;
         ENTRY;
index 3ef736a..e48a29a 100644 (file)
@@ -76,7 +76,9 @@ static int llu_dir_do_readpage(struct inode *inode, struct page *page)
         struct md_op_data op_data = { { 0 } };
         struct obd_device *obddev = class_exp2obd(sbi->ll_md_exp);
         struct ldlm_res_id res_id =
-                { .name = {fid_seq(&lli->lli_fid), fid_num(&lli->lli_fid)} };
+                { .name = {fid_seq(&lli->lli_fid), 
+                           fid_oid(&lli->lli_fid), 
+                           fid_ver(&lli->lli_fid)} };
         ldlm_policy_data_t policy = { .l_inodebits = { MDS_INODELOCK_UPDATE } };
         ENTRY;
 
index f9e06b7..10376ce 100644 (file)
@@ -111,8 +111,8 @@ static inline int llu_is_root_inode(struct inode *inode)
 {
         return (fid_seq(&llu_i2info(inode)->lli_fid) ==
                 fid_seq(&llu_i2info(inode)->lli_sbi->ll_root_fid) &&
-                fid_num(&llu_i2info(inode)->lli_fid) ==
-                fid_num(&llu_i2info(inode)->lli_sbi->ll_root_fid));
+                fid_oid(&llu_i2info(inode)->lli_fid) ==
+                fid_oid(&llu_i2info(inode)->lli_sbi->ll_root_fid));
 }
 
 #define LL_SAVE_INTENT(inode, it)                                              \
index a35f4b7..9889994 100644 (file)
@@ -165,10 +165,12 @@ int llu_mdc_blocking_ast(struct ldlm_lock *lock,
                         clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &lli->lli_flags);
 
                 if (lock->l_resource->lr_name.name[0] != fid_seq(&lli->lli_fid) ||
-                    lock->l_resource->lr_name.name[1] != fid_num(&lli->lli_fid)) {
-                        LDLM_ERROR(lock, "data mismatch with ino %llu/%llu",
+                    lock->l_resource->lr_name.name[1] != fid_oid(&lli->lli_fid) ||
+                    lock->l_resource->lr_name.name[2] != fid_ver(&lli->lli_fid)) {
+                        LDLM_ERROR(lock, "data mismatch with ino %llu/%llu/%llu",
                                   (long long)fid_seq(&lli->lli_fid), 
-                                  (long long)fid_num(&lli->lli_fid));
+                                  (long long)fid_oid(&lli->lli_fid),
+                                  (long long)fid_ver(&lli->lli_fid));
                 }
                 if (S_ISDIR(st->st_mode) &&
                     (bits & MDS_INODELOCK_UPDATE)) {
index 0193ede..09d91c6 100644 (file)
@@ -392,7 +392,8 @@ static int llu_have_md_lock(struct inode *inode, __u64 lockpart)
 
         obddev = sbi->ll_md_exp->exp_obd;
         res_id.name[0] = fid_seq(&lli->lli_fid);
-        res_id.name[1] = fid_num(&lli->lli_fid);
+        res_id.name[1] = fid_oid(&lli->lli_fid);
+        res_id.name[2] = fid_ver(&lli->lli_fid);
 
         CDEBUG(D_INFO, "trying to match res "LPU64"\n", res_id.name[0]);
 
@@ -1281,7 +1282,9 @@ static int llu_file_flock(struct inode *ino,
         struct intnl_stat *st = llu_i2stat(ino);
         struct ldlm_res_id res_id =
                 { .name = {fid_seq(&lli->lli_fid),
-                           fid_num(&lli->lli_fid), LDLM_FLOCK} };
+                           fid_oid(&lli->lli_fid),
+                           fid_ver(&lli->lli_fid), 
+                           LDLM_FLOCK} };
         struct lustre_handle lockh = {0};
         ldlm_policy_data_t flock;
         ldlm_mode_t mode = 0;
@@ -1874,7 +1877,7 @@ llu_fsswop_mount(const char *source,
                 GOTO(out_request, err);
         }
 
-        LASSERT(fid_num(&sbi->ll_root_fid) != 0);
+        LASSERT(fid_is_sane(&sbi->ll_root_fid));
 
         root = llu_iget(fs, &md);
         if (!root || IS_ERR(root)) {
index 90407ad..ee9f1bf 100644 (file)
@@ -1809,7 +1809,8 @@ int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock)
         struct obd_device *obddev;
         struct ldlm_res_id res_id =
                 { .name = { fid_seq(ll_inode2fid(inode)),
-                            fid_num(ll_inode2fid(inode)),
+                            fid_oid(ll_inode2fid(inode)),
+                            fid_ver(ll_inode2fid(inode)),
                             LDLM_FLOCK} };
         struct lustre_handle lockh = {0};
         ldlm_policy_data_t flock;
index e3ffc98..ee9d8ae 100644 (file)
@@ -36,7 +36,7 @@
 #include "llite_internal.h"
 
 static int ll_fid_alloc(struct obd_export *exp, struct lu_fid *fid,
-                        struct placement_hint *hint)
+                        struct lu_placement_hint *hint)
 {
         int rc;
         ENTRY;
@@ -47,13 +47,13 @@ static int ll_fid_alloc(struct obd_export *exp, struct lu_fid *fid,
                 RETURN(rc);
         }
 
-        LASSERT(fid_seq(fid) != 0 && fid_num(fid) != 0);
+        LASSERT(fid_is_sane(fid));
         RETURN(rc);
 }
 
 /* allocates passed fid, that is assigns f_num and f_seq to the @fid */
 int ll_fid_md_alloc(struct ll_sb_info *sbi, struct lu_fid *fid,
-                    struct placement_hint *hint)
+                    struct lu_placement_hint *hint)
 {
         ENTRY;
         RETURN(ll_fid_alloc(sbi->ll_md_exp, fid, hint));
@@ -61,7 +61,7 @@ int ll_fid_md_alloc(struct ll_sb_info *sbi, struct lu_fid *fid,
 
 /* allocates passed fid, that is assigns f_num and f_seq to the @fid */
 int ll_fid_dt_alloc(struct ll_sb_info *sbi, struct lu_fid *fid,
-                    struct placement_hint *hint)
+                    struct lu_placement_hint *hint)
 {
         ENTRY;
         RETURN(ll_fid_alloc(sbi->ll_dt_exp, fid, hint));
index 3ec657a..9771b99 100644 (file)
@@ -592,10 +592,10 @@ int ll_removexattr(struct dentry *dentry, const char *name);
 
 /* llite/llite_fid.c*/
 int ll_fid_md_alloc(struct ll_sb_info *sbi, struct lu_fid *fid,
-                    struct placement_hint *hint);
+                    struct lu_placement_hint *hint);
 
 int ll_fid_dt_alloc(struct ll_sb_info *sbi, struct lu_fid *fid,
-                    struct placement_hint *hint);
+                    struct lu_placement_hint *hint);
 
 ino_t ll_fid_build_ino(struct ll_sb_info *sbi, struct lu_fid *fid);
 
index 67109d1..913a704 100644 (file)
@@ -1580,7 +1580,7 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req,
                 /* at this point server answers to client's RPC with same fid as
                  * client generated for creating some inode. So using ->fid1 is
                  * okay here. */
-                LASSERT(fid_num(&md.body->fid1) != 0);
+                LASSERT(fid_is_sane(&md.body->fid1));
                 
                 *inode = ll_iget(sb, ll_fid_build_ino(sbi, &md.body->fid1), &md);
                 if (*inode == NULL || is_bad_inode(*inode)) {
index fb05f98..f7c2e83 100644 (file)
@@ -107,7 +107,7 @@ static struct dentry *ll_iget_for_nfs(struct super_block *sb,
         struct list_head *lp;
 #endif
 
-        if (fid_num(fid) == 0)
+        if (!fid_is_sane(fid))
                 return ERR_PTR(-ESTALE);
 
         inode = search_inode_for_lustre(sb, fid, mode);
index 6953ce4..b36fde4 100644 (file)
@@ -124,10 +124,9 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
                 if (inode == NULL)
                         break;
 
-                /* DLM locks are taken using version component as well,
-                 * so we use fid_num() instead of fid_oid(). */
                 if (lock->l_resource->lr_name.name[0] != fid_seq(ll_inode2fid(inode)) ||
-                    lock->l_resource->lr_name.name[1] != fid_num(ll_inode2fid(inode))) {
+                    lock->l_resource->lr_name.name[1] != fid_oid(ll_inode2fid(inode)) ||
+                    lock->l_resource->lr_name.name[2] != fid_ver(ll_inode2fid(inode))) {
                         LDLM_ERROR(lock, "data mismatch with object "DFID3" (%p)",
                                    PFID3(ll_inode2fid(inode)), inode);
                 }
@@ -387,10 +386,11 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
         icbd.icbd_parent = parent;
 
         /* allocate new fid for child */
-        if (it->it_op & IT_CREAT) {
-                struct placement_hint hint = { .ph_pname = NULL,
-                                               .ph_cname = &dentry->d_name,
-                                               .ph_opc = LUSTRE_OPC_CREATE };
+        if (it->it_op & IT_CREAT || 
+            (it->it_op & IT_OPEN && it->it_create_mode & O_CREAT)) {
+                struct lu_placement_hint hint = { .ph_pname = NULL,
+                                                  .ph_cname = &dentry->d_name,
+                                                  .ph_opc = LUSTRE_OPC_CREATE };
                 
                 rc = ll_fid_md_alloc(ll_i2sbi(parent), &op_data.fid2, &hint);
                 if (rc) {
@@ -607,9 +607,9 @@ static int ll_create_nd(struct inode *dir, struct dentry *dentry, int mode, stru
 static int ll_symlink_generic(struct inode *dir, struct qstr *name,
                               const char *tgt)
 {
-        struct placement_hint hint = { .ph_pname = NULL,
-                                       .ph_cname = name,
-                                       .ph_opc = LUSTRE_OPC_SYMLINK };
+        struct lu_placement_hint hint = { .ph_pname = NULL,
+                                          .ph_cname = name,
+                                          .ph_opc = LUSTRE_OPC_SYMLINK };
                 
         struct ptlrpc_request *request = NULL;
         struct ll_sb_info *sbi = ll_i2sbi(dir);
@@ -671,9 +671,9 @@ static int ll_mkdir_generic(struct inode *dir, struct qstr *name, int mode,
                             struct dentry *dchild)
 
 {
-        struct placement_hint hint = { .ph_pname = NULL,
-                                       .ph_cname = name,
-                                       .ph_opc = LUSTRE_OPC_MKDIR };
+        struct lu_placement_hint hint = { .ph_pname = NULL,
+                                          .ph_cname = name,
+                                          .ph_opc = LUSTRE_OPC_MKDIR };
         struct ptlrpc_request *request = NULL;
         struct ll_sb_info *sbi = ll_i2sbi(dir);
         struct md_op_data op_data = { { 0 } };
index 255d245..bc00e51 100644 (file)
@@ -96,7 +96,7 @@ int lmv_intent_remote(struct obd_export *exp, void *lmm,
                 it->d.lustre.it_data = 0;
         }
 
-        LASSERT(fid_num(&body->fid1) != 0);
+        LASSERT(fid_is_sane(&body->fid1));
 
         nid = body->fid1;
         it->d.lustre.it_disposition &= ~DISP_ENQ_COMPLETE;
@@ -634,8 +634,8 @@ int lmv_intent_lock(struct obd_export *exp, struct md_op_data *op_data,
 
         LASSERT(it);
 
-        pid = fid_num(&op_data->fid1) != 0 ? &op_data->fid1 : NULL;
-        cid = fid_num(&op_data->fid2) != 0 ? &op_data->fid2 : NULL;
+        pid = fid_is_sane(&op_data->fid1) ? &op_data->fid1 : NULL;
+        cid = fid_is_sane(&op_data->fid2) ? &op_data->fid2 : NULL;
 
         i = lmv_fld_lookup(obd, pid);
         CDEBUG(D_OTHER, "INTENT LOCK '%s' for '%*s' on "DFID3" -> %d\n",
index 6b1f71f..33c7125 100644 (file)
@@ -649,7 +649,7 @@ static int lmv_fids_balanced(struct obd_device *obd)
 /* returns number of target where new fid should be allocated using passed @hint
  * as input data for making decision. */
 static int lmv_placment_policy(struct obd_device *obd,
-                               struct placement_hint *hint)
+                               struct lu_placement_hint *hint)
 {
         struct lmv_obd *lmv = &obd->u.lmv;
         ENTRY;
@@ -671,7 +671,7 @@ static int lmv_placment_policy(struct obd_device *obd,
 }
 
 static int lmv_fid_alloc(struct obd_export *exp, struct lu_fid *fid,
-                         struct placement_hint *hint)
+                         struct lu_placement_hint *hint)
 {
         struct obd_device *obd = class_exp2obd(exp);
         struct lmv_obd *lmv = &obd->u.lmv;
index 7740271..fd2ed2b 100644 (file)
@@ -96,7 +96,7 @@ lmv_obj_alloc(struct obd_device *obd,
                 CDEBUG(D_OTHER, "subobj "DFID3"\n",
                        PFID3(&mea->mea_ids[i]));
                 obj->lo_inodes[i].li_fid = mea->mea_ids[i];
-                LASSERT(fid_num(&obj->lo_inodes[i].li_fid));
+                LASSERT(fid_is_sane(&obj->lo_inodes[i].li_fid));
         }
 
         return obj;
index 10202b1..4f09f78 100644 (file)
@@ -147,7 +147,9 @@ int mdc_lock_match(struct obd_export *exp, int flags,
                    struct lustre_handle *lockh)
 {
         struct ldlm_res_id res_id =
-                { .name = {fid_seq(fid), fid_num(fid)} };
+                { .name = {fid_seq(fid), 
+                           fid_oid(fid),
+                           fid_ver(fid)} };
         struct obd_device *obd = class_exp2obd(exp);
         int rc;
         ENTRY;
@@ -163,7 +165,9 @@ int mdc_cancel_unused(struct obd_export *exp,
                       int flags, void *opaque)
 {
         struct ldlm_res_id res_id =
-                { .name = {fid_seq(fid), fid_num(fid)} };
+                { .name = {fid_seq(fid), 
+                           fid_oid(fid), 
+                           fid_ver(fid)} };
         struct obd_device *obd = class_exp2obd(exp);
         int rc;
         
@@ -181,7 +185,8 @@ int mdc_change_cbdata(struct obd_export *exp, struct lu_fid *fid,
         ENTRY;
 
         res_id.name[0] = fid_seq(fid);
-        res_id.name[1] = fid_num(fid);
+        res_id.name[1] = fid_oid(fid);
+        res_id.name[2] = fid_ver(fid);
 
         ldlm_change_cbdata(class_exp2obd(exp)->obd_namespace, 
                            &res_id, it, data);
@@ -276,7 +281,9 @@ int mdc_enqueue(struct obd_export *exp,
         struct ptlrpc_request *req;
         struct obd_device *obddev = class_exp2obd(exp);
         struct ldlm_res_id res_id =
-                { .name = {fid_seq(&op_data->fid1), fid_num(&op_data->fid1)} };
+                { .name = {fid_seq(&op_data->fid1), 
+                           fid_oid(&op_data->fid1),
+                           fid_ver(&op_data->fid1)} };
         ldlm_policy_data_t policy = { .l_inodebits = { MDS_INODELOCK_LOOKUP } };
         struct ldlm_request *lockreq;
         struct ldlm_intent *lit;
@@ -576,13 +583,14 @@ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data,
                op_data->namelen, op_data->name, PFID3(&op_data->fid1),
                ldlm_it2str(it->it_op), it->it_flags);
 
-        if (fid_num(&op_data->fid2) &&
+        if (fid_is_sane(&op_data->fid2) &&
             (it->it_op == IT_LOOKUP || it->it_op == IT_GETATTR)) {
                 /* We could just return 1 immediately, but since we should only
                  * be called in revalidate_it if we already have a lock, let's
                  * verify that. */
                 struct ldlm_res_id res_id = { .name = { fid_seq(&op_data->fid2),
-                                                        fid_num(&op_data->fid2) } };
+                                                        fid_oid(&op_data->fid2),
+                                                        fid_ver(&op_data->fid2) } };
                 struct lustre_handle lockh;
                 ldlm_policy_data_t policy;
                 int mode = LCK_CR;
@@ -628,7 +636,7 @@ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data,
                 if (rc < 0)
                         RETURN(rc);
                 memcpy(&it->d.lustre.it_lock_handle, &lockh, sizeof(lockh));
-        } else if (!fid_num(&op_data->fid2)) {
+        } else if (!fid_is_sane(&op_data->fid2)) {
                 /* DISP_ENQ_COMPLETE set means there is extra reference on
                  * request referenced from this intent, saved for subsequent
                  * lookup.  This path is executed when we proceed to this
@@ -667,7 +675,7 @@ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data,
 
         /* If we were revalidating a fid/name pair, mark the intent in
          * case we fail and get called again from lookup */
-        if (fid_num(&op_data->fid2)) {
+        if (fid_is_sane(&op_data->fid2)) {
                 it_set_disposition(it, DISP_ENQ_COMPLETE);
                 /* Also: did we find the same inode? */
                 if (memcmp(&op_data->fid2, &mdt_body->fid1, sizeof(op_data->fid2)))
index 4027eb2..947ec7b 100644 (file)
@@ -1087,7 +1087,7 @@ static int mdc_import_event(struct obd_device *obd, struct obd_import *imp,
 }
 
 static int mdc_fid_alloc(struct obd_export *exp, struct lu_fid *fid,
-                         struct placement_hint *hint)
+                         struct lu_placement_hint *hint)
 {
         struct client_obd *cli = &exp->exp_obd->u.cli;
         int rc = 0;
index 7ba9fbb..411a87c 100644 (file)
@@ -452,10 +452,9 @@ struct ldlm_res_id *fid_build_res_name(const struct lu_fid *f,
                                        struct ldlm_res_id *name)
 {
         memset(name, 0, sizeof *name);
-        /* we use fid_num() whoch includes also object version instread of raw
-         * fid_oid(). */
         name->name[0] = fid_seq(f);
-        name->name[1] = fid_num(f);
+        name->name[1] = fid_oid(f);
+        name->name[2] = fid_ver(f);
         return name;
 }
 
@@ -464,7 +463,9 @@ struct ldlm_res_id *fid_build_res_name(const struct lu_fid *f,
  */
 int fid_res_name_eq(const struct lu_fid *f, const struct ldlm_res_id *name)
 {
-        return name->name[0] == fid_seq(f) && name->name[1] == fid_num(f);
+        return name->name[0] == fid_seq(f) && 
+                name->name[1] == fid_oid(f) && 
+                name->name[2] == fid_ver(f);
 }
 
 /* issues dlm lock on passed @ns, @f stores it lock handle into @lh. */