Skip to content

Commit d6a7766

Browse files
dhowellsbrauner
authored andcommitted
netfs: Downgrade i_rwsem for a buffered write
In the I/O locking code borrowed from NFS into netfslib, i_rwsem is held locked across a buffered write - but this causes a performance regression in cifs as it excludes buffered reads for the duration (cifs didn't use any locking for buffered reads). Mitigate this somewhat by downgrading the i_rwsem to a read lock across the buffered write. This at least allows parallel reads to occur whilst excluding other writes, DIO, truncate and setattr. Note that this shouldn't be a problem for a buffered write as a read through an mmap can circumvent i_rwsem anyway. Also note that we might want to make this change in NFS also. Signed-off-by: David Howells <dhowells@redhat.com> Link: https://lore.kernel.org/r/1317958.1729096113@warthog.procyon.org.uk cc: Steve French <sfrench@samba.org> cc: Paulo Alcantara <pc@manguebit.com> cc: Trond Myklebust <trondmy@kernel.org> cc: Jeff Layton <jlayton@kernel.org> cc: netfs@lists.linux.dev cc: linux-cifs@vger.kernel.org cc: linux-nfs@vger.kernel.org cc: linux-fsdevel@vger.kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 6ed469d commit d6a7766

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

fs/netfs/locking.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ int netfs_start_io_write(struct inode *inode)
109109
up_write(&inode->i_rwsem);
110110
return -ERESTARTSYS;
111111
}
112+
downgrade_write(&inode->i_rwsem);
112113
return 0;
113114
}
114115
EXPORT_SYMBOL(netfs_start_io_write);
@@ -123,7 +124,7 @@ EXPORT_SYMBOL(netfs_start_io_write);
123124
void netfs_end_io_write(struct inode *inode)
124125
__releases(inode->i_rwsem)
125126
{
126-
up_write(&inode->i_rwsem);
127+
up_read(&inode->i_rwsem);
127128
}
128129
EXPORT_SYMBOL(netfs_end_io_write);
129130

0 commit comments

Comments
 (0)