Whamcloud - gitweb
(1) mdd_name_insert(), the return value is lost;
authorhuanghua <huanghua>
Wed, 15 Nov 2006 10:28:34 +0000 (10:28 +0000)
committerhuanghua <huanghua>
Wed, 15 Nov 2006 10:28:34 +0000 (10:28 +0000)
(2) The cmr_create() should check the child existence at very first.

lustre/cmm/cmm_object.c
lustre/mdd/mdd_dir.c
lustre/mdd/mdd_lock.c
lustre/mdd/mdd_object.c
lustre/tests/sanity.sh

index 8c00059..0aff9a2 100644 (file)
@@ -842,9 +842,14 @@ static int cmr_create(const struct lu_env *env, struct md_object *mo_p,
         struct cmm_thread_info *cmi;
         struct md_attr *tmp_ma;
         int rc;
-
         ENTRY;
 
+        /* Make sure that name isn't exist before doing remote call. */
+        rc = mdo_lookup(env, md_object_next(mo_p), child_name,
+                        &cmm_env_info(env)->cmi_fid, NULL);
+        if (rc == 0)
+                RETURN(-EEXIST);
+
         /* check the SGID attr */
         cmi = cmm_env_info(env);
         LASSERT(cmi);
index 64050e2..7b6562b 100644 (file)
@@ -664,10 +664,11 @@ static int mdd_name_insert(const struct lu_env *env, struct md_object *pobj,
 
         rc = __mdd_index_insert(env, mdd_obj, fid, name, is_dir,
                                 handle, BYPASS_CAPA);
-
-        la->la_ctime = la->la_atime = CURRENT_SECONDS;
-        la->la_valid = LA_ATIME | LA_CTIME;
-        rc = mdd_attr_set_internal_locked(env, mdd_obj, la, handle, 0);
+        if (rc == 0) {
+                la->la_ctime = la->la_atime = CURRENT_SECONDS;
+                la->la_valid = LA_ATIME | LA_CTIME;
+                rc = mdd_attr_set_internal_locked(env, mdd_obj, la, handle, 0);
+        }
         EXIT;
 out_unlock:
         mdd_pdo_write_unlock(env, mdd_obj, dlh);
index 5a5199c..2bbbbda 100644 (file)
@@ -44,7 +44,6 @@ void mdd_write_lock(const struct lu_env *env, struct mdd_object *obj)
 void mdd_read_lock(const struct lu_env *env, struct mdd_object *obj)
 {
         struct dt_object  *next = mdd_object_child(obj);
-
         next->do_ops->do_read_lock(env, next);
 }
 
index a88d29f..e1f9195 100644 (file)
@@ -468,10 +468,10 @@ int mdd_object_create_internal(const struct lu_env *env,
         if (!lu_object_exists(mdd2lu_obj(obj))) {
                 next = mdd_object_child(obj);
                 rc = next->do_ops->do_create(env, next, attr, handle);
+                LASSERT(ergo(rc == 0, lu_object_exists(mdd2lu_obj(obj))));
         } else
                 rc = -EEXIST;
 
-        LASSERT(ergo(rc == 0, lu_object_exists(mdd2lu_obj(obj))));
         mdd_lprocfs_time_end(mdd, &start, LPROC_MDD_CREATE_OBJ);
         RETURN(rc);
 }
@@ -485,6 +485,7 @@ int mdd_attr_set_internal(const struct lu_env *env, struct mdd_object *o,
         struct dt_object *next;
         struct timeval  start;
         int rc;
+        ENTRY;
 
         mdd_lprocfs_time_start(mdd, &start, LPROC_MDD_ATTR_SET);
         LASSERT(lu_object_exists(mdd2lu_obj(o)));
@@ -496,7 +497,7 @@ int mdd_attr_set_internal(const struct lu_env *env, struct mdd_object *o,
                 rc = mdd_acl_chmod(env, o, attr->la_mode, handle);
 #endif
         mdd_lprocfs_time_end(mdd, &start, LPROC_MDD_ATTR_SET);        
-        return rc;
+        RETURN(rc);
 }
 
 int mdd_attr_set_internal_locked(const struct lu_env *env,
@@ -505,6 +506,7 @@ int mdd_attr_set_internal_locked(const struct lu_env *env,
                                  struct thandle *handle, int needacl)
 {
         int rc;
+        ENTRY;
 
         needacl = needacl && (attr->la_valid & LA_MODE);
 
@@ -515,7 +517,7 @@ int mdd_attr_set_internal_locked(const struct lu_env *env,
 
         if (needacl)
                 mdd_write_unlock(env, o);
-        return rc;
+        RETURN(rc);
 }
 
 static int __mdd_xattr_set(const struct lu_env *env, struct mdd_object *o,
index ae4ae4a..f1edf2d 100644 (file)
@@ -279,6 +279,7 @@ run_test 0b "chmod 0755 $DIR ============================="
 test_1a() {
        mkdir $DIR/d1
        mkdir $DIR/d1/d2
+       mkdir $DIR/d1/d2 && error "we expect EEXIST, but not returned"
        $CHECKSTAT -t dir $DIR/d1/d2 || error
 }
 run_test 1a "mkdir .../d1; mkdir .../d1/d2 ====================="