From 3448cdc16e361d2504f2f5b0982c92d7a0de933d Mon Sep 17 00:00:00 2001 From: Mikhail Pershin Date: Fri, 26 Jun 2020 20:19:05 +0300 Subject: [PATCH] LU-13599 mdt: add test for rs_lock limit exceeding The check conditions in mdt_link_parents_lock() considers there can be total 6 local locks but in fact when object has hard links then it is regular file and it may have maximum 5 local locks. Patch updates that check conditions for rs_locks as small improvement and ports test for rs_locks limit from 2.12. Signed-off-by: Mikhail Pershin Change-Id: I98cca84825ce5789094fbceb5d1f7975410d134b Reviewed-on: https://review.whamcloud.com/39194 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Lai Siyao Reviewed-by: Stephane Thiell Reviewed-by: Andreas Dilger --- lustre/mdt/mdt_reint.c | 13 +++++++++---- lustre/tests/sanity.sh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/lustre/mdt/mdt_reint.c b/lustre/mdt/mdt_reint.c index ad225ae..35eac50 100644 --- a/lustre/mdt/mdt_reint.c +++ b/lustre/mdt/mdt_reint.c @@ -1801,15 +1801,20 @@ static int mdt_link_parents_lock(struct mdt_thread_info *info, EXIT; out: - if (rc) + if (rc) { mdt_unlock_list(info, link_locks, rc); - else if (local_lnkp_cnt > RS_MAX_LOCKS - 6) + } else if (local_lnkp_cnt > RS_MAX_LOCKS - 5) { + CDEBUG(D_INFO, "Too many links (%d), sync operations\n", + local_lnkp_cnt); /* * parent may have 3 local objects: master object and 2 stripes - * (if it's being migrated too); source may have 2 local - * objects: master and 1 stripe; target has 1 local object. + * (if it's being migrated too); source may have 1 local objects + * as regular file; target has 1 local object. + * Note, source may have 2 local locks if it is directory but it + * can't have hardlinks, so it is not considered here. */ rc = 1; + } return rc; } diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index d69da54..f509d96 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -18309,6 +18309,41 @@ test_230q() { } run_test 230q "dir auto split" +test_230r() { + [[ $PARALLEL != "yes" ]] || skip "skip parallel run" + [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs" + [[ $MDS1_VERSION -ge $(version_code 2.13.54) ]] || + skip "Need MDS version at least 2.13.54" + + # maximum amount of local locks: + # parent striped dir - 2 locks + # new stripe in parent to migrate to - 1 lock + # source and target - 2 locks + # Total 5 locks for regular file + mkdir -p $DIR/$tdir + $LFS mkdir -i1 -c2 $DIR/$tdir/dir1 + touch $DIR/$tdir/dir1/eee + + # create 4 hardlink for 4 more locks + # Total: 9 locks > RS_MAX_LOCKS (8) + $LFS mkdir -i1 -c1 $DIR/$tdir/dir2 + $LFS mkdir -i1 -c1 $DIR/$tdir/dir3 + $LFS mkdir -i1 -c1 $DIR/$tdir/dir4 + $LFS mkdir -i1 -c1 $DIR/$tdir/dir5 + ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir2/eee + ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir3/eee + ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir4/eee + ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir5/eee + + cancel_lru_locks mdc + + $LFS migrate -m1 -c1 $DIR/$tdir/dir1 || + error "migrate dir fails" + + rm -rf $DIR/$tdir || error "rm dir failed after migration" +} +run_test 230r "migrate with too many local locks" + test_231a() { # For simplicity this test assumes that max_pages_per_rpc -- 1.8.3.1