Whamcloud - gitweb
LU-4925 lmv: validate lock with correct stripe FID 26/10026/20
authorwang di <di.wang@intel.com>
Fri, 18 Apr 2014 19:28:45 +0000 (12:28 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 21 May 2014 17:00:07 +0000 (17:00 +0000)
In ll_lookup_it_finish, we need use the real parent(stripe)
FID to validate the parent UPDATE lock.

Add test81 in sanityn to verify the case.

Signed-off-by: wang di <di.wang@intel.com>
Change-Id: Iba07f9e17103867ad7f3d78a5adcc3c9857999d6
Reviewed-on: http://review.whamcloud.com/10026
Tested-by: Jenkins
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/include/obd.h
lustre/include/obd_class.h
lustre/llite/namei.c
lustre/lmv/lmv_obd.c
lustre/tests/sanityn.sh

index 94f9d8c..bda6723 100644 (file)
@@ -1262,6 +1262,7 @@ struct md_ops {
 
         int (*m_revalidate_lock)(struct obd_export *, struct lookup_intent *,
                                  struct lu_fid *, __u64 *bits);
+
 #define MD_STATS_LAST_OP m_revalidate_lock
 
        int (*m_getstatus)(struct obd_export *, struct lu_fid *,
@@ -1324,6 +1325,11 @@ struct md_ops {
        int (*m_get_remote_perm)(struct obd_export *, const struct lu_fid *,
                                 struct obd_capa *, __u32,
                                 struct ptlrpc_request **);
+
+       int (*m_get_fid_from_lsm)(struct obd_export *,
+                                 const struct lmv_stripe_md *,
+                                 const char *name, int namelen,
+                                 struct lu_fid *fid);
 };
 
 struct lsm_operations {
index 2692599..741991b 100644 (file)
@@ -2026,6 +2026,18 @@ static inline int md_revalidate_lock(struct obd_export *exp,
         RETURN(rc);
 }
 
+static inline int md_get_fid_from_lsm(struct obd_export *exp,
+                                     const struct lmv_stripe_md *lsm,
+                                     const char *name, int namelen,
+                                     struct lu_fid *fid)
+{
+       int rc;
+       ENTRY;
+       EXP_CHECK_MD_OP(exp, get_fid_from_lsm);
+       EXP_MD_COUNTER_INCREMENT(exp, get_fid_from_lsm);
+       rc = MDP(exp->exp_obd, get_fid_from_lsm)(exp, lsm, name, namelen, fid);
+       RETURN(rc);
+}
 
 /* OBD Metadata Support */
 
index 69da17e..6cd0c43 100644 (file)
@@ -512,9 +512,20 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request,
                struct lookup_intent parent_it = {
                                        .it_op = IT_GETATTR,
                                        .d.lustre.it_lock_handle = 0 };
+               struct lu_fid   fid = ll_i2info(parent)->lli_fid;
+
+               /* If it is striped directory, get the real stripe parent */
+               if (unlikely(ll_i2info(parent)->lli_lsm_md != NULL)) {
+                       rc = md_get_fid_from_lsm(ll_i2mdexp(parent),
+                                                ll_i2info(parent)->lli_lsm_md,
+                                                (*de)->d_name.name,
+                                                (*de)->d_name.len, &fid);
+                       if (rc != 0)
+                               RETURN(rc);
+               }
 
-               if (md_revalidate_lock(ll_i2mdexp(parent), &parent_it,
-                                      &ll_i2info(parent)->lli_fid, NULL)) {
+               if (md_revalidate_lock(ll_i2mdexp(parent), &parent_it, &fid,
+                                      NULL)) {
                        d_lustre_revalidate(*de);
                        ll_intent_release(&parent_it);
                }
index 8a7395f..c294acd 100644 (file)
@@ -3275,6 +3275,22 @@ int lmv_revalidate_lock(struct obd_export *exp, struct lookup_intent *it,
         RETURN(rc);
 }
 
+int lmv_get_fid_from_lsm(struct obd_export *exp,
+                        const struct lmv_stripe_md *lsm,
+                        const char *name, int namelen, struct lu_fid *fid)
+{
+       const struct lmv_oinfo *oinfo;
+
+       LASSERT(lsm != NULL);
+       oinfo = lsm_name_to_stripe_info(lsm, name, namelen);
+       if (IS_ERR(oinfo))
+               return PTR_ERR(oinfo);
+
+       *fid = oinfo->lmo_fid;
+
+       RETURN(0);
+}
+
 /**
  * For lmv, only need to send request to master MDT, and the master MDT will
  * process with other slave MDTs. The only exception is Q_GETOQUOTA for which
@@ -3449,7 +3465,8 @@ struct md_ops lmv_md_ops = {
         .m_unpack_capa          = lmv_unpack_capa,
         .m_get_remote_perm      = lmv_get_remote_perm,
         .m_intent_getattr_async = lmv_intent_getattr_async,
-        .m_revalidate_lock      = lmv_revalidate_lock
+       .m_revalidate_lock      = lmv_revalidate_lock,
+       .m_get_fid_from_lsm     = lmv_get_fid_from_lsm,
 };
 
 int __init lmv_init(void)
index 2f5ab1b..a3bf7ca 100644 (file)
@@ -2811,6 +2811,34 @@ test_80() {
 }
 run_test 80 "migrate directory when some children is being opened"
 
+test_81() {
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+
+       rm -rf $DIR1/$tdir
+
+       mkdir -p $DIR1/$tdir
+
+       $LFS setdirstripe -i0 -c$MDSCOUNT  $DIR1/$tdir/d0
+       $LFS setdirstripe -i0 -c$MDSCOUNT  $DIR1/$tdir/d1
+
+       cd $DIR1/$tdir
+       touch d0/0      || error "create 0 failed"
+       mv d0/0 d1/0    || error "rename d0/0 d1/0 failed"
+       stat d0/0       && error "stat mv filed succeed"
+       mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || "rename d1/0 d0/0 failed"
+       stat d0/0       || error "stat failed"
+
+       local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
+
+       if [ $t -ne 3 ]; then
+               ls -ai $DIR1/$tdir/d0
+               error "expect 3 get $t"
+       fi
+
+       return 0
+}
+run_test 81 "rename and stat under striped directory"
+
 log "cleanup: ======================================================"
 
 [ "$(mount | grep $MOUNT2)" ] && umount $MOUNT2