From 008a0965615d0a16eb1eb402e4d240ebd70e73c2 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Tue, 2 Oct 2012 14:38:20 -0500 Subject: [PATCH] afs: Avoid tracking file locks for RO volumes 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. Reviewed-on: http://gerrit.openafs.org/8197 Tested-by: BuildBot Reviewed-by: Derrick Brashear (cherry picked from commit 0fc27471e7da0c5de4addcdec1bfbca5208072cc) Change-Id: I308d930c94708fd8d9025886c10f40cc4d10d195 Reviewed-on: http://gerrit.openafs.org/8910 Reviewed-by: Andrew Deason Reviewed-by: Derrick Brashear Reviewed-by: Stephan Wiesand Tested-by: BuildBot --- src/afs/LINUX/osi_vnodeops.c | 10 ++++++++++ src/afs/VNOPS/afs_vnop_flock.c | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index b91250ed5..2f6e5bdf6 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -588,6 +588,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(); diff --git a/src/afs/VNOPS/afs_vnop_flock.c b/src/afs/VNOPS/afs_vnop_flock.c index 33c679fef..36d42bca8 100644 --- a/src/afs/VNOPS/afs_vnop_flock.c +++ b/src/afs/VNOPS/afs_vnop_flock.c @@ -598,6 +598,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; -- 2.39.5