afs: Avoid tracking file locks for RO volumes
authorAndrew Deason <adeason@sinenomine.net>
Tue, 2 Oct 2012 19:38:20 +0000 (14:38 -0500)
committerDerrick Brashear <shadow@your-file-system.com>
Wed, 3 Oct 2012 17:26:53 +0000 (10:26 -0700)
Advisory file locks for RO volumes don't make a lot of sense, since
there are no possible writes to worry about. The fileserver already
does not track these, so don't even bother processing them in the
client.

Change-Id: Ie2a20d2f7af67799cfb8d30e72aa3e52a1ecc2d5
Reviewed-on: http://gerrit.openafs.org/8197
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

src/afs/LINUX/osi_vnodeops.c
src/afs/VNOPS/afs_vnop_flock.c

index 5814386..4a4c96a 100644 (file)
@@ -571,6 +571,16 @@ 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();
 
index 37e58ed..b6325e1 100644 (file)
@@ -588,6 +588,18 @@ int afs_lockctl(struct vcache * avc, struct AFS_FLOCK * af, int acmd,
 #else
        ) {
 #endif
+
+    if ((avc->f.states & CRO)) {
+       /* for RO volumes, don't do anything for locks; the fileserver doesn't
+        * even track them. A write lock should not be possible, though. */
+       if (af->l_type == F_WRLCK) {
+           code = EBADF;
+       } else {
+           code = 0;
+       }
+       goto done;
+    }
+
     /* Java VMs ask for l_len=(long)-1 regardless of OS/CPU */
     if ((sizeof(af->l_len) == 8) && (af->l_len == 0x7fffffffffffffffLL))
        af->l_len = 0;