Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Anna Schumaker and committed by
Trond Myklebust
f830f7dd 9a51940b

+10 -7
+8
fs/nfs/nfs42proc.c
··· 96 96 if (!nfs_server_capable(inode, NFS_CAP_ALLOCATE)) 97 97 return -EOPNOTSUPP; 98 98 99 + mutex_lock(&inode->i_mutex); 100 + 99 101 err = nfs42_proc_fallocate(&msg, filep, offset, len); 100 102 if (err == -EOPNOTSUPP) 101 103 NFS_SERVER(inode)->caps &= ~NFS_CAP_ALLOCATE; 104 + 105 + mutex_unlock(&inode->i_mutex); 102 106 return err; 103 107 } 104 108 ··· 118 114 return -EOPNOTSUPP; 119 115 120 116 nfs_wb_all(inode); 117 + mutex_lock(&inode->i_mutex); 118 + 121 119 err = nfs42_proc_fallocate(&msg, filep, offset, len); 122 120 if (err == 0) 123 121 truncate_pagecache_range(inode, offset, (offset + len) -1); 124 122 if (err == -EOPNOTSUPP) 125 123 NFS_SERVER(inode)->caps &= ~NFS_CAP_DEALLOCATE; 124 + 125 + mutex_unlock(&inode->i_mutex); 126 126 return err; 127 127 } 128 128
+2 -7
fs/nfs/nfs4file.c
··· 158 158 if (ret < 0) 159 159 return ret; 160 160 161 - mutex_lock(&inode->i_mutex); 162 161 if (mode & FALLOC_FL_PUNCH_HOLE) 163 - ret = nfs42_proc_deallocate(filep, offset, len); 164 - else 165 - ret = nfs42_proc_allocate(filep, offset, len); 166 - mutex_unlock(&inode->i_mutex); 167 - 168 - return ret; 162 + return nfs42_proc_deallocate(filep, offset, len); 163 + return nfs42_proc_allocate(filep, offset, len); 169 164 } 170 165 #endif /* CONFIG_NFS_V4_2 */ 171 166