Skip to contentSkip to conversation

file-posix: check the use_lock before setting the file lock

PATCH Applied Li Feng 2 participants 2 messages Dec 7, 2020 Block layer

lore
Share & tools
lore

Li Feng

author
#0 lore raw

PATCH v2 1/1 file-posix: check the use_lock before setting the file lock

The scenario is that when accessing a volume on an NFS filesystem without supporting the file lock, Qemu will complain "Failed to lock byte 100", even when setting the file.locking = off.

We should do file lock related operations only when the file.locking is enabled, otherwise, the syscall of 'fcnctl' will return non-zero.

---
 block/file-posix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/file-posix.c +1 -1
index d5fd1dbcd2..806764f7e3 100644
@@ -3104,7 +3104,7 @@ static int raw_check_perm(BlockDriverState *bs, uint64_t perm, uint64_t shared,
     }
 
     /* Copy locks to the new fd */
-    if (s->perm_change_fd) {
+    if (s->perm_change_fd && s->use_lock) {
         ret = raw_apply_lock_bytes(NULL, s->perm_change_fd, perm, ~shared,
                                    false, errp);
         if (ret < 0) {
Signature · 1 line
2.24.3
Applied
#1 lore raw

Am 07.12.2020 um 12:44 hat Li Feng geschrieben:

Quoted 8 lines

The scenario is that when accessing a volume on an NFS filesystem without supporting the file lock, Qemu will complain "Failed to lock byte 100", even when setting the file.locking = off.

We should do file lock related operations only when the file.locking is enabled, otherwise, the syscall of 'fcnctl' will return non-zero.

Thanks, applied to the block branch.

Kevin