From 54c61781e2a1e59e9bfbd5cc065d9fef0c6f83a0 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Thu, 17 Jul 2014 10:33:23 -0500 Subject: [PATCH] LINUX: Avoid premature RO volume lock error Commit 0fc27471e7da0c5de4addcdec1bfbca5208072cc avoids processing lock requests for RO volumes, but it did this both in afs_lockctl() and in the Linux-specific afs_linux_lock(). The changes in afs_linux_lock() are incorrect, since they also avoid F_GETLK requests (whereas afs_lockctl() just avoids F_SETLK* requests). Additionally, the section in afs_linux_lock() incorrectly reports an error, since it returns a positive EBADF error code, when we are supposed to return -EBADF. The result of all of this is that an F_GETLK F_WRLCK request for an RO volume always fails with fcntl() returning 9 (EBADF), which is an invalid return code for fcntl() F_GETLK (instead we should return -1 with an errno of 9). But if there are no locks, we should return success anyway. Just remove this section, since afs_lockctl() handles this case itself anyway. Thanks to Todd Lewis for reporting this issue. Reviewed-on: http://gerrit.openafs.org/11316 Reviewed-by: Marc Dionne Reviewed-by: D Brashear Reviewed-by: Chas Williams - CONTRACTOR Tested-by: BuildBot (cherry picked from commit e0d0e6ffdbb11d5445b129ef0bd5030aec59d333) Change-Id: Ia5d03e55f7bad9f5678cdb82808b56d975865438 Reviewed-on: http://gerrit.openafs.org/11361 Reviewed-by: Chas Williams - CONTRACTOR Tested-by: BuildBot Reviewed-by: Andrew Deason Reviewed-by: Michael Meffie Reviewed-by: Stephan Wiesand --- src/afs/LINUX/osi_vnodeops.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index 2a8253e6e..7e5cdd1e7 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -616,16 +616,6 @@ afs_linux_lock(struct file *fp, int cmd, struct file_lock *flp) #endif /* F_GETLK64 && F_GETLK != F_GETLK64 */ AFS_GLOCK(); - if ((vcp->f.states & CRO)) { - if (flp->fl_type == F_WRLCK) { - code = EBADF; - } else { - code = 0; - } - AFS_GUNLOCK(); - crfree(credp); - return code; - } code = afs_convert_code(afs_lockctl(vcp, &flock, cmd, credp)); AFS_GUNLOCK(); -- 2.39.5