Commit 22e7478d authored by Jeff Mahoney's avatar Jeff Mahoney Committed by Jan Kara

reiserfs: call truncate_setsize under tailpack mutex

Prior to commit 0e4f6a79 (Fix reiserfs_file_release()), reiserfs
truncates serialized on i_mutex. They mostly still do, with the exception
of reiserfs_file_release. That blocks out other writers via the tailpack
mutex and the inode openers counter adjusted in reiserfs_file_open.

However, NFS will call reiserfs_setattr without having called ->open, so
we end up with a race when nfs is calling ->setattr while another
process is releasing the file. Ultimately, it triggers the
BUG_ON(inode->i_size != new_file_size) check in maybe_indirect_to_direct.

The solution is to pull the lock into reiserfs_setattr to encompass the
truncate_setsize call as well.
Signed-off-by: default avatarJeff Mahoney <jeffm@suse.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent 770901cc
...@@ -3422,8 +3422,14 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr) ...@@ -3422,8 +3422,14 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
attr->ia_size != i_size_read(inode)) { attr->ia_size != i_size_read(inode)) {
error = inode_newsize_ok(inode, attr->ia_size); error = inode_newsize_ok(inode, attr->ia_size);
if (!error) { if (!error) {
/*
* Could race against reiserfs_file_release
* if called from NFS, so take tailpack mutex.
*/
mutex_lock(&REISERFS_I(inode)->tailpack);
truncate_setsize(inode, attr->ia_size); truncate_setsize(inode, attr->ia_size);
reiserfs_vfs_truncate_file(inode); reiserfs_truncate_file(inode, 1);
mutex_unlock(&REISERFS_I(inode)->tailpack);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment