Whamcloud - gitweb
lmv: 0. more fid correctness checks, 1. fix wrong mea_hash_segment calculation.
authornikita <nikita>
Fri, 24 Nov 2006 17:27:15 +0000 (17:27 +0000)
committernikita <nikita>
Fri, 24 Nov 2006 17:27:15 +0000 (17:27 +0000)
lustre/include/lustre/lustre_idl.h
lustre/kernel_patches/patches/ext3-iam-separate.patch
lustre/llite/llite_internal.h
lustre/llite/namei.c
lustre/lmv/lmv_intent.c
lustre/lmv/lmv_object.c
lustre/obdclass/mea.c

index 9ee7f14..fa04da2 100644 (file)
@@ -269,8 +269,8 @@ static inline int lu_fid_eq(const struct lu_fid *f0,
        /* Check that there is no alignment padding. */
        CLASSERT(sizeof *f0 ==
                  sizeof f0->f_seq + sizeof f0->f_oid + sizeof f0->f_ver);
-        LASSERT(fid_is_igif(f0) || fid_ver(f0) == 0);
-        LASSERT(fid_is_igif(f1) || fid_ver(f1) == 0);
+        LASSERTF(fid_is_igif(f0) || fid_ver(f0) == 0, DFID, PFID(f0));
+        LASSERTF(fid_is_igif(f1) || fid_ver(f1) == 0, DFID, PFID(f1));
        return memcmp(f0, f1, sizeof *f0) == 0;
 }
 
@@ -313,7 +313,7 @@ static inline struct lu_dirent *lu_dirent_next(struct lu_dirent *ent)
                 next = ((void *)ent) + le16_to_cpu(ent->lde_reclen);
         else
                 next = NULL;
-        
+
         return next;
 }
 
index 965c641..1772c5a 100644 (file)
@@ -3103,7 +3103,7 @@ Index: iam/fs/ext3/iam_lvar.c
 +
 +        hash = (hash_build0(name, namelen) << 1) & MAX_HASH_SIZE;
 +        if (hash > MAX_HASH_SIZE - HASH_GRAY_AREA)
-+                hash += HASH_GRAY_AREA;
++                hash &= HASH_GRAY_AREA - 1;
 +        return hash;
 +}
 +
index e16839a..27e4abb 100644 (file)
@@ -498,7 +498,7 @@ int ll_file_open(struct inode *inode, struct file *file);
 int ll_file_release(struct inode *inode, struct file *file);
 int ll_lsm_getattr(struct obd_export *, struct lov_stripe_md *, struct obdo *);
 int ll_local_size(struct inode *inode);
-int ll_glimpse_ioctl(struct ll_sb_info *sbi, 
+int ll_glimpse_ioctl(struct ll_sb_info *sbi,
                      struct lov_stripe_md *lsm, lstat_t *st);
 int ll_glimpse_size(struct inode *inode, int ast_flags);
 int ll_local_open(struct file *file,
@@ -695,8 +695,11 @@ static inline struct obd_export *ll_i2mdexp(struct inode *inode)
 
 static inline struct lu_fid *ll_inode2fid(struct inode *inode)
 {
+        struct lu_fid *fid;
         LASSERT(inode != NULL);
-        return &ll_i2info(inode)->lli_fid;
+        fid = &ll_i2info(inode)->lli_fid;
+        LASSERT(fid_is_igif(fid) || fid_ver(fid) == 0);
+        return fid;
 }
 
 static inline int ll_mds_max_easize(struct super_block *sb)
index fa8314a..d9ab059 100644 (file)
@@ -159,18 +159,18 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
                      (bits & MDS_INODELOCK_UPDATE)) {
                         struct dentry *dentry, *tmp, *dir;
                         struct list_head *list;
-                        
+
                         CDEBUG(D_INODE, "invalidating inode %lu\n",
                                inode->i_ino);
                         truncate_inode_pages(inode->i_mapping, 0);
 
-                        
+
                         /* Drop possible cached negative dentries */
                         list = &inode->i_dentry;
                         dir = NULL;
                         spin_lock(&dcache_lock);
-                        
-                        /* It is possible to have several dentries (with 
+
+                        /* It is possible to have several dentries (with
                            racer?) */
                         while ((list = list->next) != &inode->i_dentry) {
                                 dir = list_entry(list, struct dentry, d_alias);
@@ -183,17 +183,17 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
 
                                 dir = NULL;
                         }
-                        
+
                         if (dir) {
 restart:
-                                list_for_each_entry_safe(dentry, tmp, 
-                                                         &dir->d_subdirs, 
+                                list_for_each_entry_safe(dentry, tmp,
+                                                         &dir->d_subdirs,
                                                          d_child)
                                 {
                                         /* XXX Print some debug here? */
-                                        if (!dentry->d_inode) 
-                                                /* Negative dentry. If we were 
-                                                   dropping dcache lock, go 
+                                        if (!dentry->d_inode)
+                                                /* Negative dentry. If we were
+                                                   dropping dcache lock, go
                                                    throught the list again */
                                                 if (ll_drop_dentry(dentry))
                                                         goto restart;
@@ -398,7 +398,7 @@ static int lookup_it_finish(struct ptlrpc_request *request, int offset,
                         ll_d_add(*de, inode);
                         spin_unlock(&dcache_lock);
                 } else {
-                        (*de)->d_inode = NULL; 
+                        (*de)->d_inode = NULL;
                 }
         }
 
@@ -440,9 +440,10 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
                 opc = LUSTRE_OPC_CREATE;
         else
                 opc = LUSTRE_OPC_ANY;
-        
+
         op_data = ll_prep_md_op_data(NULL, parent, NULL, dentry->d_name.name,
                                      dentry->d_name.len, lookup_flags, opc);
+
         if (op_data == NULL)
                 RETURN(ERR_PTR(-ENOMEM));
 
@@ -553,7 +554,7 @@ static struct dentry *ll_lookup_nd(struct inode *parent, struct dentry *dentry,
                 if (de)
                         dentry = de;
                 if ((nd->flags & LOOKUP_OPEN) && !IS_ERR(dentry)) { /* Open */
-                        if (dentry->d_inode && 
+                        if (dentry->d_inode &&
                             it_disposition(it, DISP_OPEN_OPEN)) { /* nocreate */
 #ifdef HAVE_FILE_IN_STRUCT_INTENT
                                 if (S_ISFIFO(dentry->d_inode->i_mode)) {
@@ -577,7 +578,7 @@ static struct dentry *ll_lookup_nd(struct inode *parent, struct dentry *dentry,
                                                 de = (struct dentry *) filp;
                                         }
 #endif
-                                                
+
                                 }
 #else /* HAVE_FILE_IN_STRUCT_INTENT */
                                 /* Release open handle as we have no way to
@@ -697,7 +698,7 @@ static void ll_update_times(struct ptlrpc_request *request, int offset,
 
         /* mtime is always updated with ctime, but can be set in past.
            As write and utime(2) may happen within 1 second, and utime's
-           mtime has a priority over write's one, so take mtime from mds 
+           mtime has a priority over write's one, so take mtime from mds
            for the same ctimes. */
         if (body->valid & OBD_MD_FLCTIME &&
             body->ctime >= LTIME_S(inode->i_ctime)) {
@@ -705,7 +706,7 @@ static void ll_update_times(struct ptlrpc_request *request, int offset,
 
                 if (body->valid & OBD_MD_FLMTIME) {
                         CDEBUG(D_INODE, "setting ino %lu mtime from %lu "
-                               "to "LPU64"\n", inode->i_ino, 
+                               "to "LPU64"\n", inode->i_ino,
                                LTIME_S(inode->i_mtime), body->mtime);
                         LTIME_S(inode->i_mtime) = body->mtime;
                 }
@@ -774,18 +775,18 @@ static int ll_create_nd(struct inode *dir, struct dentry *dentry, int mode, stru
 {
         struct lookup_intent *it = ll_d2d(dentry)->lld_it;
         int rc;
-        
+
         if (!it)
                 return ll_mknod_generic(dir, &dentry->d_name, mode, 0, dentry);
-                
+
         ll_d2d(dentry)->lld_it = NULL;
-        
+
         /* Was there an error? Propagate it! */
         if (it->d.lustre.it_status) {
                 rc = it->d.lustre.it_status;
                 goto out;
-        }       
-        
+        }
+
         rc = ll_create_it(dir, dentry, mode, it);
 #ifdef HAVE_FILE_IN_STRUCT_INTENT
         if (nd && (nd->flags & LOOKUP_OPEN) && dentry->d_inode) { /* Open */
@@ -867,7 +868,7 @@ static int ll_link_generic(struct inode *src,  struct inode *dir,
                src->i_ino, src->i_generation, src, dir->i_ino,
                dir->i_generation, dir, name->len, name->name);
 
-        op_data = ll_prep_md_op_data(NULL, src, dir, name->name, name->len, 
+        op_data = ll_prep_md_op_data(NULL, src, dir, name->name, name->len,
                                      0, LUSTRE_OPC_ANY);
         if (op_data == NULL)
                 RETURN(-ENOMEM);
@@ -890,7 +891,7 @@ static int ll_mkdir_generic(struct inode *dir, struct qstr *name,
         struct md_op_data *op_data;
         int err;
         ENTRY;
-        
+
         CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p)\n",
                name->len, name->name, dir->i_ino, dir->i_generation, dir);
 
@@ -904,7 +905,7 @@ static int ll_mkdir_generic(struct inode *dir, struct qstr *name,
         err = md_create(sbi->ll_md_exp, op_data, NULL, 0, mode,
                         current->fsuid, current->fsgid,
                         current->cap_effective, 0, &request);
-        
+
         ll_finish_md_op_data(op_data);
         if (err == 0) {
                 ll_update_times(request, REPLY_REC_OFF, dir);
@@ -1040,13 +1041,13 @@ static int ll_unlink_generic(struct inode *dir, struct qstr *name)
         CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p)\n",
                name->len, name->name, dir->i_ino, dir->i_generation, dir);
 
-        op_data = ll_prep_md_op_data(NULL, dir, NULL, name->name, 
+        op_data = ll_prep_md_op_data(NULL, dir, NULL, name->name,
                                      name->len, 0, LUSTRE_OPC_ANY);
         if (op_data == NULL)
                 RETURN(-ENOMEM);
         rc = md_unlink(ll_i2sbi(dir)->ll_md_exp, op_data, &request);
         ll_finish_md_op_data(op_data);
-        
+
         if (rc)
                 GOTO(out, rc);
 
@@ -1071,7 +1072,7 @@ static int ll_rename_generic(struct inode *src, struct qstr *src_name,
                src->i_ino, src->i_generation, src, tgt_name->len,
                tgt_name->name, tgt->i_ino, tgt->i_generation, tgt);
 
-        op_data = ll_prep_md_op_data(NULL, src, tgt, NULL, 0, 0, 
+        op_data = ll_prep_md_op_data(NULL, src, tgt, NULL, 0, 0,
                                      LUSTRE_OPC_ANY);
         if (op_data == NULL)
                 RETURN(-ENOMEM);
@@ -1205,7 +1206,7 @@ struct inode_operations ll_special_inode_operations = {
         .setattr        = ll_setattr,
 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
         .getattr        = ll_getattr,
-#else   
+#else
         .revalidate_it  = ll_inode_revalidate_it,
 #endif
         .permission     = ll_inode_permission,
index d1439a1..e2e3d22 100644 (file)
@@ -154,7 +154,7 @@ int lmv_alloc_slave_fids(struct obd_device *obd, struct lu_fid *pid,
                        PFID(pid));
                 RETURN(0);
         }
-        
+
         mea_idx = raw_name2idx(obj->lo_hashtype, obj->lo_objcount,
                                (char *)op->op_name, op->op_namelen);
         mds = obj->lo_inodes[mea_idx].li_mds;
@@ -166,10 +166,10 @@ int lmv_alloc_slave_fids(struct obd_device *obd, struct lu_fid *pid,
                        rc);
                 RETURN(rc);
         }
-        
+
         CDEBUG(D_INFO, "Allocate new fid "DFID" for split "
                "obj\n", PFID(fid));
-        
+
         RETURN(rc);
 }
 
@@ -202,11 +202,12 @@ int lmv_intent_open(struct obd_export *exp, struct md_op_data *op_data,
         *sop_data = *op_data;
 
 repeat:
+
         LASSERT(++loop <= 2);
         obj = lmv_obj_grab(obd, &rpid);
         if (obj) {
                 int mea_idx;
-                
+
                 /*
                  * Directory is already split, so we have to forward request to
                  * the right MDS.
@@ -216,6 +217,7 @@ repeat:
                                        op_data->op_namelen);
 
                 rpid = obj->lo_inodes[mea_idx].li_fid;
+
                 tgt_exp = lmv_get_export(lmv, obj->lo_inodes[mea_idx].li_mds);
                 sop_data->op_bias &= ~MDS_CHECK_SPLIT;
                 lmv_obj_put(obj);
@@ -226,11 +228,11 @@ repeat:
         }
         if (IS_ERR(tgt_exp))
                 GOTO(out_free_sop_data, rc = PTR_ERR(tgt_exp));
-        
+
         sop_data->op_fid1 = rpid;
 
         if (it->it_op & IT_CREAT) {
-                /* 
+                /*
                  * For open with IT_CREATE and for IT_CREATE cases allocate new
                  * fid and setup FLD for it.
                  */
@@ -243,18 +245,18 @@ repeat:
                 else if (rc)
                         GOTO(out_free_sop_data, rc);
         }
-        
+
         rc = md_intent_lock(tgt_exp, sop_data, lmm, lmmsize, it, flags,
                             reqp, cb_blocking, extra_lock_flags);
 
         if (rc == -ERESTART) {
                 LASSERT(*reqp != NULL);
-                DEBUG_REQ(D_WARNING|D_RPCTRACE, *reqp, 
+                DEBUG_REQ(D_WARNING|D_RPCTRACE, *reqp,
                           "Got -ERESTART during open!\n");
                 ptlrpc_req_finished(*reqp);
                 *reqp = NULL;
                 it->d.lustre.it_data = 0;
-                
+
                 /*
                  * Directory got split. Time to update local object and repeat
                  * the request with proper MDS.
@@ -269,7 +271,7 @@ repeat:
                                 goto repeat;
                 }
         }
-        
+
         if (rc != 0)
                 GOTO(out_free_sop_data, rc);
 
@@ -403,7 +405,7 @@ int lmv_intent_getattr(struct obd_export *exp, struct md_op_data *op_data,
                 obj = lmv_obj_grab(obd, &op_data->op_fid1);
                 if (obj && op_data->op_namelen) {
                         int mea_idx;
-                        
+
                         /* directory is already split. calculate mds */
                         mea_idx = raw_name2idx(obj->lo_hashtype, obj->lo_objcount,
                                                (char *)op_data->op_name,
@@ -752,7 +754,7 @@ repeat:
 
         if (rc == -ERESTART) {
                 LASSERT(*reqp != NULL);
-                DEBUG_REQ(D_WARNING|D_RPCTRACE, *reqp, 
+                DEBUG_REQ(D_WARNING|D_RPCTRACE, *reqp,
                           "Got -ERESTART during lookup!\n");
                 ptlrpc_req_finished(*reqp);
                 *reqp = NULL;
@@ -919,7 +921,7 @@ int lmv_revalidate_slaves(struct obd_export *exp, struct ptlrpc_request **reqp,
                         master = 1;
                         cb = cb_blocking;
                 }
-                
+
                 op_data->op_fid1 = fid;
                 op_data->op_fid2 = fid;
                 op_data->op_bias = MDS_CROSS_REF;
@@ -942,7 +944,7 @@ int lmv_revalidate_slaves(struct obd_export *exp, struct ptlrpc_request **reqp,
 
                 if (rc < 0)
                         GOTO(cleanup, rc);
-                
+
                 if (master) {
                         LASSERT(master_valid == 0);
                         /* save lock on master to be returned to the caller */
index 03a0f04..52a9a0b 100644 (file)
@@ -64,7 +64,7 @@ lmv_obj_alloc(struct obd_device *obd,
         struct lmv_obd *lmv = &obd->u.lmv;
 
         LASSERT(mea->mea_magic == MEA_MAGIC_LAST_CHAR
-                || mea->mea_magic == MEA_MAGIC_ALL_CHARS 
+                || mea->mea_magic == MEA_MAGIC_ALL_CHARS
                 || mea->mea_magic == MEA_MAGIC_HASH_SEGMENT);
 
         OBD_SLAB_ALLOC(obj, obj_cache, CFS_ALLOC_STD,
@@ -95,13 +95,13 @@ lmv_obj_alloc(struct obd_device *obd,
         /* put all ids in */
         for (i = 0; i < mea->mea_count; i++) {
                 int rc;
-                
+
                 CDEBUG(D_OTHER, "subobj "DFID"\n",
                        PFID(&mea->mea_ids[i]));
                 obj->lo_inodes[i].li_fid = mea->mea_ids[i];
                 LASSERT(fid_is_sane(&obj->lo_inodes[i].li_fid));
 
-                /* 
+                /*
                  * Cache slave mds number to use it in all cases it is needed
                  * instead of constant lookup.
                  */
index cc83130..59eea65 100644 (file)
@@ -108,7 +108,7 @@ static __u32 hash_build(const char *name, int namelen)
 
         hash = (hash_build0(name, namelen) << 1) & MAX_HASH_SIZE;
         if (hash > MAX_HASH_SIZE - HASH_GRAY_AREA)
-                hash += HASH_GRAY_AREA;
+                hash &= HASH_GRAY_AREA - 1;
         return hash;
 }
 
@@ -119,7 +119,7 @@ static int mea_hash_segment(int count, const char *name, int namelen)
         LASSERT(IS_PO2(MAX_HASH_SIZE + 1));
 
         hash = hash_build(name, namelen) / (MAX_HASH_SIZE / count);
-        LASSERTF(hash <= count, "hash %x count %d \n", hash, count);
+        LASSERTF(hash < count, "hash %x count %d \n", hash, count);
 
         return hash;
 }
@@ -152,6 +152,7 @@ int raw_name2idx(int hashtype, int count, const char *name, int namelen)
                         CERROR("Unknown hash type 0x%x\n", hashtype);
         }
        
+        LASSERT(c < count);
         return c;
 }