From: wangdi Date: Sun, 1 Dec 2013 02:03:19 +0000 (-0800) Subject: LU-2739 mdt: Deny non-DNE client to access remote directory X-Git-Tag: 2.3.62~33 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=6125dec0a2b07822ef8149ff49c02d95df997668;hp=8421d161cc0f76ca4d635b8f9e6ebb1b5e7b9b47 LU-2739 mdt: Deny non-DNE client to access remote directory Return EIO to old clients, if they try to access the remote directory. Signed-off-by: wang di Change-Id: I1cc4e8fa6e0f3a4b31b5610642e204bd100c1743 Reviewed-on: http://review.whamcloud.com/5425 Reviewed-by: Andreas Dilger Reviewed-by: Fan Yong Tested-by: Hudson Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index a88a872..e11d46b 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -686,6 +686,10 @@ static int mdt_getattr_internal(struct mdt_thread_info *info, if (mdt_object_remote(o)) { /* This object is located on remote node.*/ + /* Return -EIO for old client */ + if (!mdt_is_dne_client(req->rq_export)) + GOTO(out, rc = -EIO); + repbody->fid1 = *mdt_object_fid(o); repbody->valid = OBD_MD_FLID | OBD_MD_MDS; GOTO(out, rc = 0); @@ -5518,12 +5522,12 @@ static int mdt_fid2path(const struct lu_env *env, struct mdt_device *mdt, RETURN(-EINVAL); } - rc = lu_object_exists(&obj->mot_obj.mo_lu); - if (rc <= 0) { - if (rc == -1) - rc = -EREMOTE; - else - rc = -ENOENT; + if (mdt_object_remote(obj)) + rc = -EREMOTE; + else if (!mdt_object_exists(obj)) + rc = -ENOENT; + + if (rc < 0) { mdt_object_put(env, obj); CDEBUG(D_IOCTL, "nonlocal object "DFID": %d\n", PFID(&fp->gf_fid), rc); diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index 2b65a37..664940c 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -620,6 +620,13 @@ static inline void mdt_export_evict(struct obd_export *exp) class_export_put(exp); } +/* Here we use LVB_TYPE to check dne client, because it is + * also landed on 2.4. */ +static inline int mdt_is_dne_client(struct obd_export *exp) +{ + return !!(exp_connect_flags(exp) & OBD_CONNECT_LVB_TYPE); +} + int mdt_get_disposition(struct ldlm_reply *rep, int flag); void mdt_set_disposition(struct mdt_thread_info *info, struct ldlm_reply *rep, int flag); diff --git a/lustre/mdt/mdt_open.c b/lustre/mdt/mdt_open.c index 0e95251..6c2483f 100644 --- a/lustre/mdt/mdt_open.c +++ b/lustre/mdt/mdt_open.c @@ -1051,6 +1051,12 @@ void mdt_reconstruct_open(struct mdt_thread_info *info, if (unlikely(mdt_object_remote(child))) { /* the child object was created on remote server */ + if (!mdt_is_dne_client(exp)) { + /* Return -EIO for old client */ + mdt_object_put(env, parent); + mdt_object_put(env, child); + GOTO(out, rc = -EIO); + } repbody->fid1 = *rr->rr_fid2; repbody->valid |= (OBD_MD_FLID | OBD_MD_MDS); rc = 0; diff --git a/lustre/mdt/mdt_recovery.c b/lustre/mdt/mdt_recovery.c index a936f97..9102eaa 100644 --- a/lustre/mdt/mdt_recovery.c +++ b/lustre/mdt/mdt_recovery.c @@ -739,14 +739,18 @@ static void mdt_reconstruct_create(struct mdt_thread_info *mti, mti->mti_attr.ma_need = MA_INODE; mti->mti_attr.ma_valid = 0; rc = mdt_attr_get_complex(mti, child, &mti->mti_attr); - if (rc == -EREMOTE) { - /* object was created on remote server */ - req->rq_status = rc; - body->valid |= OBD_MD_MDS; - } - mdt_pack_attr2body(mti, body, &mti->mti_attr.ma_attr, - mdt_object_fid(child)); - mdt_object_put(mti->mti_env, child); + if (rc == -EREMOTE) { + /* object was created on remote server */ + if (!mdt_is_dne_client(exp)) + /* Return -EIO for old client */ + rc = -EIO; + + req->rq_status = rc; + body->valid |= OBD_MD_MDS; + } + mdt_pack_attr2body(mti, body, &mti->mti_attr.ma_attr, + mdt_object_fid(child)); + mdt_object_put(mti->mti_env, child); } static void mdt_reconstruct_setattr(struct mdt_thread_info *mti, diff --git a/lustre/mdt/mdt_reint.c b/lustre/mdt/mdt_reint.c index b5c5cb9..f16da5d 100644 --- a/lustre/mdt/mdt_reint.c +++ b/lustre/mdt/mdt_reint.c @@ -326,6 +326,11 @@ static int mdt_md_create(struct mdt_thread_info *info) mdt2obd_dev(mdt)->obd_name); GOTO(out_put_child, rc = -EPERM); } + if (!mdt_is_dne_client(mdt_info_req(info)->rq_export)) { + /* Return -EIO for old client */ + GOTO(out_put_child, rc = -EIO); + } + } ma->ma_need = MA_INODE; ma->ma_valid = 0; @@ -746,6 +751,10 @@ static int mdt_reint_unlink(struct mdt_thread_info *info, mdt2obd_dev(info->mti_mdt)->obd_name, (char *)rr->rr_name, PFID(mdt_object_fid(mc))); + if (!mdt_is_dne_client(req->rq_export)) + /* Return -EIO for old client */ + GOTO(unlock_parent, rc = -EIO); + if (info->mti_spec.sp_rm_entry) { struct lu_ucred *uc = mdt_ucred(info);