From c5e6de3fc15ed0790f36c841b4154d4ec5acc825 Mon Sep 17 00:00:00 2001 From: huanghua Date: Tue, 10 Oct 2006 06:44:17 +0000 Subject: [PATCH] directory maybe have been deleted, and need to check this. That is: check the existance of parent directory. --- lustre/mdd/mdd_handler.c | 12 +++++++++++- lustre/mdt/mdt_handler.c | 15 ++++++++++++--- lustre/mdt/mdt_internal.h | 5 +++++ lustre/mdt/mdt_lib.c | 2 +- lustre/mdt/mdt_open.c | 15 ++++++++++++--- lustre/mdt/mdt_reint.c | 23 +++++++++++++++++++++-- lustre/tests/sanity.sh | 1 + 7 files changed, 63 insertions(+), 10 deletions(-) diff --git a/lustre/mdd/mdd_handler.c b/lustre/mdd/mdd_handler.c index 5c2fdb9..5ebcadf 100644 --- a/lustre/mdd/mdd_handler.c +++ b/lustre/mdd/mdd_handler.c @@ -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 diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index efd5394..8fff0903 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -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 { diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index 7d4516d..d0420b8 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -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); diff --git a/lustre/mdt/mdt_lib.c b/lustre/mdt/mdt_lib.c index b4495e4..14956d1 100644 --- a/lustre/mdt/mdt_lib.c +++ b/lustre/mdt/mdt_lib.c @@ -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; diff --git a/lustre/mdt/mdt_open.c b/lustre/mdt/mdt_open.c index 35237e3..e289fb7 100644 --- a/lustre/mdt/mdt_open.c +++ b/lustre/mdt/mdt_open.c @@ -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) diff --git a/lustre/mdt/mdt_reint.c b/lustre/mdt/mdt_reint.c index 1e45ca7..6fcee2d 100644 --- a/lustre/mdt/mdt_reint.c +++ b/lustre/mdt/mdt_reint.c @@ -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); diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index cae91f9..631be2a 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -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 ==================" -- 1.8.3.1