From: John L. Hammond Date: Tue, 23 Jun 2020 18:00:55 +0000 (-0500) Subject: LU-13693 lfs: check early for MDS_OPEN_DIRECTORY X-Git-Tag: 2.13.55~43 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=3ea729fe82;p=fs%2Flustre-release.git LU-13693 lfs: check early for MDS_OPEN_DIRECTORY In mdt_reint_open() check earlier for MDS_OPEN_DIRECTORY/O_DIRECTORY to avoid breaking leases used by lfs mirror when calling lfs getstripe. Add a multi client version of sanity test_210 to sanityn. Signed-off-by: John L. Hammond Change-Id: I1860fc76c8014da3e637d83b487cb28b037ba71b Reviewed-on: https://review.whamcloud.com/39159 Tested-by: jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Alex Zhuravlev Reviewed-by: Oleg Drokin --- diff --git a/lustre/mdt/mdt_open.c b/lustre/mdt/mdt_open.c index bb46c20..5aa5314 100644 --- a/lustre/mdt/mdt_open.c +++ b/lustre/mdt/mdt_open.c @@ -1529,6 +1529,14 @@ int mdt_reint_open(struct mdt_thread_info *info, struct mdt_lock_handle *lhc) result = -MDT_EREMOTE_OPEN; GOTO(out_child, result); } else if (mdt_object_exists(child)) { + /* Check early for MDS_OPEN_DIRECTORY/O_DIRECTORY to + * avoid opening regular files from lfs getstripe + * since doing so breaks the leases used by lfs + * mirror. See LU-13693. */ + if (open_flags & MDS_OPEN_DIRECTORY && + S_ISREG(lu_object_attr(&child->mot_obj))) + GOTO(out_child, result = -ENOTDIR); + /* We have to get attr & LOV EA & HSM for this * object. */ mdt_prep_ma_buf_from_rep(info, child, ma); diff --git a/lustre/tests/sanityn.sh b/lustre/tests/sanityn.sh index 1af29dd..5dae9be 100755 --- a/lustre/tests/sanityn.sh +++ b/lustre/tests/sanityn.sh @@ -3011,6 +3011,27 @@ test_51d() { } run_test 51d "layout lock: losing layout lock should clean up memory map region" +test_51e() { + local pid + + $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc & + pid=$! + sleep 1 + + $LFS getstripe $DIR2/$tfile + kill -USR1 $pid + wait $pid || error "multiop failed" + + $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc & + pid=$! + sleep 1 + + $LFS getstripe $DIR2/$tfile + kill -USR1 $pid + wait $pid || error "multiop failed" +} +run_test 51e "lfs getstripe does not break leases, part 2" + test_54_part1() { echo "==> rename vs getattr vs setxattr should not deadlock"