aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorAnna Schumaker <Anna.Schumaker@netapp.com>2015-03-16 14:06:24 -0400
committerTrond Myklebust <trond.myklebust@primarydata.com>2015-04-23 14:36:28 -0400
commitf830f7ddd9165c8bd69127458627f03df4b1a406 (patch)
treefb92b7097ce59629094ea59e0cc3a1cf0acf14be /fs/nfs
parent9a51940bf65bf9fdc93027d70bdecdfc403c5b24 (diff)
NFS: Reduce time spent holding the i_mutex during fallocate()
At the very least, we should not be taking the i_mutex until after checking if the server even supports ALLOCATE or DEALLOCATE, allowing v4.0 or v4.1 to exit without potentially waiting on a lock. Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/nfs42proc.c8
-rw-r--r--fs/nfs/nfs4file.c9
2 files changed, 10 insertions, 7 deletions
diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c
index b9aa6bbcc8ed..3a9e75235f30 100644
--- a/fs/nfs/nfs42proc.c
+++ b/fs/nfs/nfs42proc.c
@@ -96,9 +96,13 @@ int nfs42_proc_allocate(struct file *filep, loff_t offset, loff_t len)
96 if (!nfs_server_capable(inode, NFS_CAP_ALLOCATE)) 96 if (!nfs_server_capable(inode, NFS_CAP_ALLOCATE))
97 return -EOPNOTSUPP; 97 return -EOPNOTSUPP;
98 98
99 mutex_lock(&inode->i_mutex);
100
99 err = nfs42_proc_fallocate(&msg, filep, offset, len); 101 err = nfs42_proc_fallocate(&msg, filep, offset, len);
100 if (err == -EOPNOTSUPP) 102 if (err == -EOPNOTSUPP)
101 NFS_SERVER(inode)->caps &= ~NFS_CAP_ALLOCATE; 103 NFS_SERVER(inode)->caps &= ~NFS_CAP_ALLOCATE;
104
105 mutex_unlock(&inode->i_mutex);
102 return err; 106 return err;
103} 107}
104 108
@@ -114,11 +118,15 @@ int nfs42_proc_deallocate(struct file *filep, loff_t offset, loff_t len)
114 return -EOPNOTSUPP; 118 return -EOPNOTSUPP;
115 119
116 nfs_wb_all(inode); 120 nfs_wb_all(inode);
121 mutex_lock(&inode->i_mutex);
122
117 err = nfs42_proc_fallocate(&msg, filep, offset, len); 123 err = nfs42_proc_fallocate(&msg, filep, offset, len);
118 if (err == 0) 124 if (err == 0)
119 truncate_pagecache_range(inode, offset, (offset + len) -1); 125 truncate_pagecache_range(inode, offset, (offset + len) -1);
120 if (err == -EOPNOTSUPP) 126 if (err == -EOPNOTSUPP)
121 NFS_SERVER(inode)->caps &= ~NFS_CAP_DEALLOCATE; 127 NFS_SERVER(inode)->caps &= ~NFS_CAP_DEALLOCATE;
128
129 mutex_unlock(&inode->i_mutex);
122 return err; 130 return err;
123} 131}
124 132
diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c
index 151ddff624d4..cb3c7879e59f 100644
--- a/fs/nfs/nfs4file.c
+++ b/fs/nfs/nfs4file.c
@@ -158,14 +158,9 @@ static long nfs42_fallocate(struct file *filep, int mode, loff_t offset, loff_t
158 if (ret < 0) 158 if (ret < 0)
159 return ret; 159 return ret;
160 160
161 mutex_lock(&inode->i_mutex);
162 if (mode & FALLOC_FL_PUNCH_HOLE) 161 if (mode & FALLOC_FL_PUNCH_HOLE)
163 ret = nfs42_proc_deallocate(filep, offset, len); 162 return nfs42_proc_deallocate(filep, offset, len);
164 else 163 return nfs42_proc_allocate(filep, offset, len);
165 ret = nfs42_proc_allocate(filep, offset, len);
166 mutex_unlock(&inode->i_mutex);
167
168 return ret;
169} 164}
170#endif /* CONFIG_NFS_V4_2 */ 165#endif /* CONFIG_NFS_V4_2 */
171 166