Whamcloud - gitweb
directory maybe have been deleted, and need to check this.
authorhuanghua <huanghua>
Tue, 10 Oct 2006 06:44:17 +0000 (06:44 +0000)
committerhuanghua <huanghua>
Tue, 10 Oct 2006 06:44:17 +0000 (06:44 +0000)
That is: check the existance of parent directory.

lustre/mdd/mdd_handler.c
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_internal.h
lustre/mdt/mdt_lib.c
lustre/mdt/mdt_open.c
lustre/mdt/mdt_reint.c
lustre/tests/sanity.sh

index 5c2fdb9..5ebcadf 100644 (file)
@@ -1646,6 +1646,7 @@ static int mdd_dir_is_empty(const struct lu_env *env,
         struct dt_object *obj;
         struct dt_it_ops *iops;
         int result;
+        ENTRY;
 
         obj = mdd_object_child(dir);
         iops = &obj->do_index_ops->dio_it;
@@ -1670,7 +1671,7 @@ static int mdd_dir_is_empty(const struct lu_env *env,
                 iops->fini(env, it);
         } else
                 result = -ENOMEM;
-        return result;
+        RETURN(result);
 }
 
 /* return md_attr back,
@@ -2097,6 +2098,15 @@ __mdd_lookup(const struct lu_env *env, struct md_object *pobj,
         if (mdd_is_dead_obj(mdd_obj))
                 RETURN(-ESTALE);
 
+        rc = lu_object_exists(mdd2lu_obj(mdd_obj));
+        if (rc == 0)
+                RETURN(-ESTALE);
+        else if (rc < 0) {
+                CERROR("Object "DFID" locates on remote server\n",
+                        PFID(mdo2fid(mdd_obj)));
+                LBUG();
+        }
+
         if (mask == MAY_EXEC)
                 rc = mdd_exec_permission_lite(env, mdd_obj);
         else
index efd5394..8fff090 100644 (file)
@@ -608,6 +608,15 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info,
                 GOTO(out, rc);
         }
 
+        rc = mdt_object_exists(parent);
+        if (rc == 0)
+                RETURN(-ESTALE);
+        else if (rc < 0) {
+                CERROR("Object "DFID" locates on remote server\n",
+                        PFID(mdt_object_fid(parent)));
+                LBUG();
+        }
+
         /*step 1: lock parent */
         lhp = &info->mti_lh[MDT_LH_PARENT];
         lhp->mlh_mode = LCK_CR;
@@ -1337,7 +1346,7 @@ int mdt_object_lock(struct mdt_thread_info *info, struct mdt_object *o,
 
         LASSERT(!lustre_handle_is_used(&lh->mlh_lh));
         LASSERT(lh->mlh_mode != LCK_MINMODE);
-        if (lu_object_exists(&o->mot_obj.mo_lu) < 0) {
+        if (mdt_object_exists(o) < 0) {
                 LASSERT(!(ibits & MDS_INODELOCK_UPDATE));
                 LASSERT(ibits & MDS_INODELOCK_LOOKUP);
         }
@@ -1352,7 +1361,7 @@ int mdt_object_lock(struct mdt_thread_info *info, struct mdt_object *o,
 int mdt_object_cr_lock(struct mdt_thread_info *info, struct mdt_object *o,
                        struct mdt_lock_handle *lh, __u64 ibits)
 {
-        if (lu_object_exists(&o->mot_obj.mo_lu) < 0) {
+        if (mdt_object_exists(o) < 0) {
                 /* cross-ref object fix */
                 ibits &= ~MDS_INODELOCK_UPDATE;
                 ibits |= MDS_INODELOCK_LOOKUP;
@@ -1500,7 +1509,7 @@ static int mdt_body_unpack(struct mdt_thread_info *info, __u32 flags)
         obj = mdt_object_find(env, info->mti_mdt, &body->fid1);
         if (!IS_ERR(obj)) {
                 if ((flags & HABEO_CORPUS) &&
-                    !lu_object_exists(&obj->mot_obj.mo_lu)) {
+                    !mdt_object_exists(obj)) {
                         mdt_object_put(env, obj);
                         rc = -ENOENT;
                 } else {
index 7d4516d..d0420b8 100644 (file)
@@ -367,6 +367,11 @@ static inline void mdt_object_put(const struct lu_env *env,
         EXIT;
 }
 
+static inline int mdt_object_exists(const struct mdt_object *o)
+{
+        return lu_object_exists(&o->mot_obj.mo_lu);
+}
+
 static inline const struct lu_fid *mdt_object_fid(struct mdt_object *o)
 {
         return lu_object_fid(&o->mot_obj.mo_lu);
index b4495e4..14956d1 100644 (file)
@@ -531,7 +531,7 @@ int mdt_handle_last_unlink(struct mdt_thread_info *info, struct mdt_object *mo,
         if (ma->ma_valid & MA_LOV) {
                 __u32 mode;
 
-                if (lu_object_exists(&mo->mot_obj.mo_lu) < 0)
+                if (mdt_object_exists(mo) < 0)
                         /* If it is a remote object, and we do not retrieve
                          * EA back unlink reg file*/
                         mode = S_IFREG;
index 35237e3..e289fb7 100644 (file)
@@ -541,7 +541,7 @@ void mdt_reconstruct_open(struct mdt_thread_info *info,
                 child = mdt_object_find(env, mdt, rr->rr_fid2);
                 LASSERT(!IS_ERR(child));
 
-                rc = lu_object_exists(&child->mot_obj.mo_lu);
+                rc = mdt_object_exists(child);
                 if (rc > 0) {
                         struct md_object *next;
                         next = mdt_object_child(child);
@@ -590,7 +590,7 @@ static int mdt_open_by_fid(struct mdt_thread_info* info,
         if (IS_ERR(o))
                 RETURN(rc = PTR_ERR(o));
 
-        rc = lu_object_exists(&o->mot_obj.mo_lu);
+        rc = mdt_object_exists(o);
         if (rc > 0) {
                 const struct lu_env *env = info->mti_env;
 
@@ -635,7 +635,7 @@ static int mdt_cross_open(struct mdt_thread_info* info,
         if (IS_ERR(o))
                 RETURN(rc = PTR_ERR(o));
 
-        rc = lu_object_exists(&o->mot_obj.mo_lu);
+        rc = mdt_object_exists(o);
         if (rc > 0) {
                 mdt_set_capainfo(info, 0, fid, BYPASS_CAPA);
                 rc = mo_attr_get(info->mti_env, mdt_object_child(o), ma);
@@ -746,6 +746,15 @@ int mdt_reint_open(struct mdt_thread_info *info, struct mdt_lock_handle *lhc)
         if (IS_ERR(parent))
                 GOTO(out, result = PTR_ERR(parent));
 
+        result = mdt_object_exists(parent);
+        if (result == 0)
+                GOTO(out_parent, result = -ESTALE);
+        else if (result < 0) {
+                CERROR("Object "DFID" locates on remote server\n",
+                        PFID(mdt_object_fid(parent)));
+                LBUG();
+        }
+
         result = mdo_lookup(info->mti_env, mdt_object_child(parent),
                             rr->rr_name, child_fid);
         if (result != 0 && result != -ENOENT && result != -ESTALE)
index 1e45ca7..6fcee2d 100644 (file)
@@ -58,6 +58,15 @@ static int mdt_md_create(struct mdt_thread_info *info)
         if (IS_ERR(parent))
                 RETURN(PTR_ERR(parent));
 
+        rc = mdt_object_exists(parent);
+        if (rc == 0)
+                GOTO(out, rc = -ESTALE);
+        else if (rc < 0) {
+                CERROR("Object "DFID" locates on remote server\n",
+                        PFID(mdt_object_fid(parent)));
+                LBUG();
+        }
+
         child = mdt_object_find(info->mti_env, mdt, rr->rr_fid2);
         if (!IS_ERR(child)) {
                 struct md_object *next = mdt_object_child(parent);
@@ -79,6 +88,7 @@ static int mdt_md_create(struct mdt_thread_info *info)
                 mdt_object_put(info->mti_env, child);
         } else
                 rc = PTR_ERR(child);
+out:
         mdt_object_unlock_put(info, parent, lh, rc);
         RETURN(rc);
 }
@@ -102,7 +112,7 @@ static int mdt_md_mkobj(struct mdt_thread_info *info)
                 ma->ma_need = MA_INODE;
                 /* Cross-ref create can encounter already created obj in case
                  * of recovery, just get attr in that case */
-                if (lu_object_exists(&o->mot_obj.mo_lu) == 1) {
+                if (mdt_object_exists(o) == 1) {
                         rc = mo_attr_get(info->mti_env, next, ma);
                 } else {
                         rc = mo_object_create(info->mti_env, next, 
@@ -354,6 +364,15 @@ static int mdt_reint_unlink(struct mdt_thread_info *info,
         if (IS_ERR(mp))
                 GOTO(out, rc = PTR_ERR(mp));
 
+        rc = mdt_object_exists(mp);
+        if (rc == 0)
+                GOTO(out_unlock_parent, rc = -ESTALE);
+        else if (rc < 0) {
+                CERROR("Object "DFID" locates on remote server\n",
+                        PFID(mdt_object_fid(mp)));
+                LBUG();
+        }
+
         ma->ma_lmm = req_capsule_server_get(&info->mti_pill, &RMF_MDT_MD);
         ma->ma_lmm_size = req_capsule_get_size(&info->mti_pill,
                                                &RMF_MDT_MD, RCL_SERVER);
@@ -375,7 +394,7 @@ static int mdt_reint_unlink(struct mdt_thread_info *info,
                  * Therefore the object absense is allowed case
                  * and nothing should be done
                  */
-                if (lu_object_exists(&mp->mot_obj.mo_lu) > 0) {
+                if (mdt_object_exists(mp) > 0) {
                         rc = mo_ref_del(info->mti_env,
                                         mdt_object_child(mp), ma);
                         mdt_handle_last_unlink(info, mp, ma);
index cae91f9..631be2a 100644 (file)
@@ -994,6 +994,7 @@ test_27m() {
        [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
                error "OST0 was full but new created file still use it"
        rm -r $DIR/d27
+       sleep 15
 }
 run_test 27m "create file while OST0 was full =================="