From 0fc27471e7da0c5de4addcdec1bfbca5208072cc 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. Change-Id: Ie2a20d2f7af67799cfb8d30e72aa3e52a1ecc2d5 Reviewed-on: http://gerrit.openafs.org/8197 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- 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 581438688..4a4c96a26 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -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(); diff --git a/src/afs/VNOPS/afs_vnop_flock.c b/src/afs/VNOPS/afs_vnop_flock.c index 37e58edb3..b6325e129 100644 --- a/src/afs/VNOPS/afs_vnop_flock.c +++ b/src/afs/VNOPS/afs_vnop_flock.c @@ -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; -- 2.39.5