Whamcloud - gitweb
LU-18860 mdd: fix CLF_UNLINK_LAST on open file unlink 78/58578/4
authorEtienne AUJAMES <etienne.aujames@cea.fr>
Fri, 28 Mar 2025 17:57:11 +0000 (18:57 +0100)
committerOleg Drokin <green@whamcloud.com>
Wed, 16 Apr 2025 20:44:05 +0000 (20:44 +0000)
The flag CLF_UNLINK_LAST should be set for UNLINK changelog if the
last link is removed.

This flag is not set if the file is open on a client.
If the file open, Lustre will re-link the file in the PENDING
MDT directory. So, la_nlink == 1 after mdd_finish_unlink() and
CLF_UNLINK_LAST will not be set.

Check if the object is dead instead of relying on la_nlink to set the
flag.

Update the sanity 161c for that use case.

Test-Parameters: testlist=sanity env=ONLY=161c,ONLY_REPEAT=20
Test-Parameters: testlist=sanity env=ONLY=161
Signed-off-by: Etienne AUJAMES <eaujames@ddn.com>
Change-Id: I35ef530cd55cd5e07ad79a7cdae056de95735f61
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58578
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Qian Yingjin <qian@ddn.com>
Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mdd/mdd_dir.c
lustre/tests/sanity.sh

index b1c1a6d..a70086f 100644 (file)
@@ -2210,7 +2210,7 @@ cleanup:
                mdd_write_unlock(env, mdd_cobj);
 
        if (rc == 0) {
-               if (cattr->la_nlink == 0)
+               if (mdd_is_dead_obj(mdd_cobj))
                        cl_flags |= CLF_UNLINK_LAST;
                else
                        cl_flags &= ~CLF_UNLINK_HSM_EXISTS;
index d460b3c..fa71e02 100755 (executable)
@@ -20675,6 +20675,23 @@ test_161c() {
                error "flag $flags is not 0x0"
        fi
        echo "unlink a file having nlink > 1, changelog record flags '$flags'"
+
+       (( MDS1_VERSION >= $(version_code v2_16_53-39) )) ||
+               { echo "CLF_UNLINK_LAST is not set with open file (LU-18860)";
+               return 0; }
+
+       # unlink a file open having nlink = 1 (changelog flag 0x1)
+       local pid
+       touch $DIR/$tdir/open_161c
+       tail -f $DIR/$tdir/open_161c & pid=$!
+       sleep 0.2
+       unlink $DIR/$tdir/open_161c
+       kill $pid
+       changelog_dump | grep UNLNK | tail -n 5
+       flags=$(changelog_dump | awk '/UNLNK/ {f=$5} END {print f}')
+       changelog_clear 0 || error "changelog_clear failed"
+       [[ "$flags" == "0x1" ]] || error "flag $flags is not 0x1"
+       echo "unlink a open file having nlink = 1, changelog record has flags of $flags"
 }
 run_test 161c "check CL_RENME[UNLINK] changelog record flags"