From 5e3678542301482e8e344df26d0624c014c2961a Mon Sep 17 00:00:00 2001 From: wang di Date: Fri, 6 Sep 2013 00:02:34 -0700 Subject: [PATCH] LU-3894 mdt: return EXDEV for cross-MDT rename If target does not exist, and source directory is remote directory, it should return -EXDEV. Add test in test_24x to verify it. Create local directory for test_214, since cross-MDT rename is not allowed yet. Signed-off-by: wang di Change-Id: I0d4d8d96249ec23fcea5ab6ac5fce196728e8e73 Reviewed-on: http://review.whamcloud.com/7579 Tested-by: Hudson Reviewed-by: Andreas Dilger Tested-by: Maloo --- lustre/include/lustre_fid.h | 5 +++++ lustre/mdt/mdt_reint.c | 9 ++++++++- lustre/osd-ldiskfs/osd_oi.c | 3 ++- lustre/tests/sanity.sh | 12 ++++++++---- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/lustre/include/lustre_fid.h b/lustre/include/lustre_fid.h index 8d221e8..a1caa5c 100644 --- a/lustre/include/lustre_fid.h +++ b/lustre/include/lustre_fid.h @@ -289,6 +289,11 @@ static inline int fid_is_quota(const struct lu_fid *fid) fid_seq(fid) == FID_SEQ_QUOTA_GLB; } +static inline int fid_is_name_llog(const struct lu_fid *fid) +{ + return fid_seq(fid) == FID_SEQ_LLOG_NAME; +} + static inline int fid_is_namespace_visible(const struct lu_fid *fid) { const __u64 seq = fid_seq(fid); diff --git a/lustre/mdt/mdt_reint.c b/lustre/mdt/mdt_reint.c index 2a0aa4e..a1bd60b 100644 --- a/lustre/mdt/mdt_reint.c +++ b/lustre/mdt/mdt_reint.c @@ -1295,7 +1295,14 @@ static int mdt_reint_rename(struct mdt_thread_info *info, } else if (rc != -EREMOTE && rc != -ENOENT) { GOTO(out_unlock_old, rc); } else { - mdt_enoent_version_save(info, 3); + /* If mnew does not exist and mold are remote directory, + * it only allows rename if they are under same directory */ + if (mtgtdir != msrcdir && mdt_object_remote(mold)) { + CDEBUG(D_INFO, "Src child "DFID" is on another MDT\n", + PFID(old_fid)); + GOTO(out_unlock_old, rc = -EXDEV); + } + mdt_enoent_version_save(info, 3); } /* step 5: rename it */ diff --git a/lustre/osd-ldiskfs/osd_oi.c b/lustre/osd-ldiskfs/osd_oi.c index 5fa3707..a7d8581 100644 --- a/lustre/osd-ldiskfs/osd_oi.c +++ b/lustre/osd-ldiskfs/osd_oi.c @@ -499,7 +499,8 @@ int fid_is_on_ost(struct osd_thread_info *info, struct osd_device *osd, RETURN(1); if (unlikely(fid_is_local_file(fid) || fid_is_igif(fid) || - fid_is_llog(fid))) + fid_is_llog(fid)) || fid_is_name_llog(fid) || + fid_is_quota(fid)) RETURN(0); if (fid_is_idif(fid) || fid_is_last_id(fid)) diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index b4918ed..20050c2 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -1050,6 +1050,9 @@ test_24x() { mkdir -p $remote_dir/tgt_dir touch $remote_dir/tgt_file + mrename $remote_dir $DIR/ && + error "rename dir cross MDT works!" + mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir && error "rename dir cross MDT works!" @@ -10775,14 +10778,15 @@ test_213() { run_test 213 "OSC lock completion and cancel race don't crash - bug 18829" test_214() { # for bug 20133 - test_mkdir -p $DIR/d214p/d214c + mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed" for (( i=0; i < 340; i++ )) ; do - touch $DIR/d214p/d214c/a$i + touch $DIR/$tdir/d214c/a$i done - ls -l $DIR/d214p || error "ls -l $DIR/d214p failed" - mv $DIR/d214p/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed" + ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed" + mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed" ls $DIR/d214c || error "ls $DIR/d214c failed" + rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed" rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed" } run_test 214 "hash-indexed directory test - bug 20133" -- 1.8.3.1