From 2b8a380b5217e48826aff2b29b45dc89ac715305 Mon Sep 17 00:00:00 2001 From: huanghua Date: Mon, 9 Oct 2006 03:58:35 +0000 Subject: [PATCH] (1) correctly unlink a dir: we have to set i_nlink to zero manually. (2) some debug code; --- lustre/include/lustre_log.h | 1 + lustre/mdd/mdd_handler.c | 2 ++ lustre/mdt/mdt_internal.h | 4 ++++ lustre/mdt/mdt_reint.c | 4 ++-- lustre/osd/osd_handler.c | 13 +++++++++++-- lustre/tests/replay-single.sh | 8 ++++---- 6 files changed, 24 insertions(+), 8 deletions(-) diff --git a/lustre/include/lustre_log.h b/lustre/include/lustre_log.h index 1f60ff4..768b2ef 100644 --- a/lustre/include/lustre_log.h +++ b/lustre/include/lustre_log.h @@ -296,6 +296,7 @@ static inline int llog_write_rec(struct llog_handle *handle, rc = llog_handle2ops(handle, &lop); if (rc) RETURN(rc); + LASSERT(lop); if (lop->lop_write_rec == NULL) RETURN(-EOPNOTSUPP); diff --git a/lustre/mdd/mdd_handler.c b/lustre/mdd/mdd_handler.c index b541f3b..7ca2aff 100644 --- a/lustre/mdd/mdd_handler.c +++ b/lustre/mdd/mdd_handler.c @@ -2903,10 +2903,12 @@ __mdd_ref_del(const struct lu_env *env, struct mdd_object *obj, struct thandle *handle) { struct dt_object *next = mdd_object_child(obj); + ENTRY; LASSERT(lu_object_exists(mdd2lu_obj(obj))); next->do_ops->do_ref_del(env, next, handle); + EXIT; } /* do NOT or the MAY_*'s, you'll get the weakest */ diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index 26a0f09..7d4516d 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -354,13 +354,17 @@ static inline struct ptlrpc_request *mdt_info_req(struct mdt_thread_info *info) static inline void mdt_object_get(const struct lu_env *env, struct mdt_object *o) { + ENTRY; lu_object_get(&o->mot_obj.mo_lu); + EXIT; } static inline void mdt_object_put(const struct lu_env *env, struct mdt_object *o) { + ENTRY; lu_object_put(env, &o->mot_obj.mo_lu); + EXIT; } static inline const struct lu_fid *mdt_object_fid(struct mdt_object *o) diff --git a/lustre/mdt/mdt_reint.c b/lustre/mdt/mdt_reint.c index c1c8394..ae488e5 100644 --- a/lustre/mdt/mdt_reint.c +++ b/lustre/mdt/mdt_reint.c @@ -105,8 +105,8 @@ static int mdt_md_mkobj(struct mdt_thread_info *info) if (lu_object_exists(&o->mot_obj.mo_lu) == 1) { rc = mo_attr_get(info->mti_env, next, ma); } else { - rc = mo_object_create(info->mti_env, next, &info->mti_spec, - ma); + rc = mo_object_create(info->mti_env, next, + &info->mti_spec, ma); } if (rc == 0) { /* return fid & attr to client. */ diff --git a/lustre/osd/osd_handler.c b/lustre/osd/osd_handler.c index 55706c0..dfc9e1f 100644 --- a/lustre/osd/osd_handler.c +++ b/lustre/osd/osd_handler.c @@ -400,7 +400,12 @@ static void osd_index_fini(struct osd_object *o) static int osd_inode_unlinked(const struct inode *inode) { - return inode->i_nlink == !!S_ISDIR(inode->i_mode); + /* + * This is modified by huanghua@lusterfs.com: + * i_nlink of an unlinked object is zero even if it is a dir. + return inode->i_nlink == !!S_ISDIR(inode->i_mode); + */ + return inode->i_nlink == 0; } enum { @@ -430,8 +435,9 @@ static int osd_inode_remove(const struct lu_env *env, * The following is added by huanghua@clusterfs.com as * a temporary hack, to remove the directory entry in * "*OBJ_TEMP*". We will finally do not use this hack, - * and at that time we will remove these code. + * and at that time we will remove these code under #if. */ +#if 1 osd_fid_build_name(fid, oti->oti_name); oti->oti_str.name = oti->oti_name; oti->oti_str.len = strlen(oti->oti_name); @@ -442,8 +448,11 @@ static int osd_inode_remove(const struct lu_env *env, obj->oo_inode->i_nlink = 1; d_instantiate(dentry, obj->oo_inode); result = dir->i_op->unlink(dir, dentry); + obj->oo_inode->i_nlink = 0; + mark_inode_dirty(obj->oo_inode); dput(dentry); } else +#endif iput(obj->oo_inode); osd_trans_stop(env, th); } else diff --git a/lustre/tests/replay-single.sh b/lustre/tests/replay-single.sh index 06cc70b..3126add 100755 --- a/lustre/tests/replay-single.sh +++ b/lustre/tests/replay-single.sh @@ -911,7 +911,7 @@ test_43() { # bug 2530 run_test 43 "mds osc import failure during recovery; don't LBUG" test_44() { - mdcdev=`awk '/-mdc-/ {print $1}' $LPROC/devices` + mdcdev=`awk '/MDT0000-mdc-/ {print $1}' $LPROC/devices` [ "$mdcdev" ] || exit 2 for i in `seq 1 10`; do #define OBD_FAIL_TGT_CONN_RACE 0x701 @@ -925,7 +925,7 @@ test_44() { run_test 44 "race in target handle connect" test_44b() { - mdcdev=`awk '/-mdc-/ {print $1}' $LPROC/devices` + mdcdev=`awk '/MDT0000-mdc-/ {print $1}' $LPROC/devices` [ "$mdcdev" ] || exit 2 for i in `seq 1 10`; do #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704 @@ -940,7 +940,7 @@ run_test 44b "race in target handle connect" # Handle failed close test_45() { - mdcdev=`awk '/-mdc-/ {print $1}' $LPROC/devices` + mdcdev=`awk '/MDT0000-mdc-/ {print $1}' $LPROC/devices` [ "$mdcdev" ] || exit 2 $LCTL --device $mdcdev recover @@ -1015,7 +1015,7 @@ test_48() { run_test 48 "MDS->OSC failure during precreate cleanup (2824)" test_50() { - local oscdev=`grep ${ost1_svc}-osc-MDT $LPROC/devices | awk '{print $1}'` + local oscdev=`grep ${ost1_svc}-osc-MDT0000 $LPROC/devices | awk '{print $1}'` [ "$oscdev" ] || return 1 $LCTL --device $oscdev recover && $LCTL --device $oscdev recover # give the mds_lov_sync threads a chance to run -- 1.8.3.1