From e0d0e6ffdbb11d5445b129ef0bd5030aec59d333 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. Change-Id: Ia7f3f0b1bdbb922dca06be9de02a9c2b33f9ffee Reviewed-on: http://gerrit.openafs.org/11316 Reviewed-by: Marc Dionne Reviewed-by: D Brashear Reviewed-by: Chas Williams - CONTRACTOR Tested-by: BuildBot --- 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 18d013a9c..e03187f9d 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -627,16 +627,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