Whamcloud - gitweb
LU-15670 clio: Disable lockless for DIO with O_APPEND
authorShaun Tancheff <shaun.tancheff@hpe.com>
Tue, 22 Mar 2022 13:08:35 +0000 (08:08 -0500)
committerAndreas Dilger <adilger@whamcloud.com>
Fri, 26 May 2023 10:22:10 +0000 (10:22 +0000)
Lockless O_DIRECT with O_APPEND can allow interleaved / racy
appends from concurrent I/O.

Disable lockless I/O when O_APPEND is set

Lustre-change: https://review.whamcloud.com/46890
Lustre-commit: 649d638467c0375797cd59ab7c9ac4113e6c682e

HPE-bug-id: LUS-9776
Signed-off-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Change-Id: I5c56f92c90e631c295f56e5958985f516e1990f8
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/49666
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/llite/file.c
lustre/tests/sanity.sh

index 2e57eea..ab61444 100644 (file)
@@ -1707,6 +1707,8 @@ ll_file_io_generic(const struct lu_env *env, struct vvp_io_args *args,
 
        io = vvp_env_thread_io(env);
        if (file->f_flags & O_DIRECT) {
+               if (file->f_flags & O_APPEND)
+                       dio_lock = 1;
                if (!is_sync_kiocb(args->u.normal.via_iocb))
                        is_aio = true;
 
index 5bb3691..d70d0a3 100755 (executable)
@@ -24546,11 +24546,20 @@ test_398a() { # LU-4198
 
        $LCTL set_param ldlm.namespaces.*-OST0000-osc-ffff*.lru_size=clear
 
-       # no lock cached, should use lockless IO and not enqueue new lock
+       # no lock cached, should use lockless DIO and not enqueue new lock
        dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct conv=notrunc
        lock_count=$($LCTL get_param -n \
                     ldlm.namespaces.$imp_name.lru_size)
        [[ $lock_count -eq 0 ]] || error "no lock should be held by direct IO"
+
+       $LCTL set_param ldlm.namespaces.*-OST0000-osc-ffff*.lru_size=clear
+
+       # no lock cached, should use locked DIO append
+       dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct oflag=append \
+               conv=notrunc || error "DIO append failed"
+       lock_count=$($LCTL get_param -n \
+                    ldlm.namespaces.*-OST0000-osc-ffff*.lru_size)
+       [[ $lock_count -ne 0 ]] || error "lock still must be held by DIO append"
 }
 run_test 398a "direct IO should cancel lock otherwise lockless"