From f8672e6a0ea9c4fc66a4434601a3783f731aa742 Mon Sep 17 00:00:00 2001 From: Feng Lei Date: Thu, 10 Oct 2024 09:18:59 +0800 Subject: [PATCH] LU-17660 tests: test symlink file to existing dir Create a test case to verify LU-17660. Symlink a file to an existing dir. Expect the symlink entry under dir. Error if report "cannot overwrite directory". Fixed in kernels newer than v6.9-rc4-39-gbb32cded3be2 or with a backported fix. Signed-off-by: Feng Lei Test-Parameters: trivial Test-Parameters: clientdistro=el8.10 testlist=sanity env=ONLY=17p Test-Parameters: clientdistro=el9.4 testlist=sanity env=ONLY=17p Test-Parameters: clientdistro=sles15sp5 testlist=sanity env=ONLY=17p Test-Parameters: clientdistro=sles15sp6 testlist=sanity env=ONLY=17p Test-Parameters: clientdistro=ubuntu2204 testlist=sanity env=ONLY=17p Test-Parameters: clientdistro=ubuntu2404 testlist=sanity env=ONLY=17p Change-Id: I905813c26e78ae3e6df4f88af10ab3f0c596a59b Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56639 Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin Reviewed-by: Andreas Dilger Tested-by: jenkins Tested-by: Maloo --- lustre/tests/sanity.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 0350bed..e07ea6f 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -803,6 +803,26 @@ test_17o() { } run_test 17o "stat file with incompat LMA feature" +# LU-17660: "cannot overwrite directory" when creating symlink +test_17p() { + touch $DIR/$tfile + test_mkdir $DIR/$tdir + + # there is a kernel bug in el9.x series (9.0 - 9.4 as we know till now) + # kernel, we need to stat the target dir to cache it first + if [[ "$CLIENT_OS_ID_LIKE" =~ "rhel" ]]; then + if (( $CLIENT_OS_VERSION_CODE >= $(version_code 9.0) && + $CLIENT_OS_VERSION_CODE <= $(version_code 9.4) )); then + echo "stat $DIR/$tdir to cache it in el9.0-9.4" + stat $DIR/$tdir + fi + fi + + strace ln -sf $DIR/$tfile $DIR/$tdir/ || + error "Failed to create symlink $DIR/$tfile under $DIR/$tdir/" +} +run_test 17p "symlink overwrite directory error message" + test_18() { touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?" ls $DIR || error "Failed to ls $DIR: $?" -- 1.8.3.1