From 4dccd8ea612f651281623d6ef97d88d3cd8f1405 Mon Sep 17 00:00:00 2001 From: huanghua Date: Wed, 15 Nov 2006 10:28:34 +0000 Subject: [PATCH] (1) mdd_name_insert(), the return value is lost; (2) The cmr_create() should check the child existence at very first. --- lustre/cmm/cmm_object.c | 7 ++++++- lustre/mdd/mdd_dir.c | 9 +++++---- lustre/mdd/mdd_lock.c | 1 - lustre/mdd/mdd_object.c | 8 +++++--- lustre/tests/sanity.sh | 1 + 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/lustre/cmm/cmm_object.c b/lustre/cmm/cmm_object.c index 8c00059..0aff9a2 100644 --- a/lustre/cmm/cmm_object.c +++ b/lustre/cmm/cmm_object.c @@ -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); diff --git a/lustre/mdd/mdd_dir.c b/lustre/mdd/mdd_dir.c index 64050e2..7b6562b 100644 --- a/lustre/mdd/mdd_dir.c +++ b/lustre/mdd/mdd_dir.c @@ -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); diff --git a/lustre/mdd/mdd_lock.c b/lustre/mdd/mdd_lock.c index 5a5199c..2bbbbda 100644 --- a/lustre/mdd/mdd_lock.c +++ b/lustre/mdd/mdd_lock.c @@ -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); } diff --git a/lustre/mdd/mdd_object.c b/lustre/mdd/mdd_object.c index a88d29f..e1f9195 100644 --- a/lustre/mdd/mdd_object.c +++ b/lustre/mdd/mdd_object.c @@ -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, diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index ae4ae4a..f1edf2d 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -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 =====================" -- 1.8.3.1