reiserfs: call truncate_setsize under tailpack mutex
authorJeff Mahoney <jeffm@suse.com>
Wed, 21 May 2014 17:28:07 +0000 (13:28 -0400)
committerBen Hutchings <ben@decadent.org.uk>
Fri, 11 Jul 2014 12:33:35 +0000 (13:33 +0100)
commit4e6efff9b1e11c0e825a025f308a6322ca3241e5
treeb27eb385ee5b212eeb70f50e50ec8f938f7369cd
parentf6975fe1d8ca4f40768575a8e7b8360e7fa48a45
reiserfs: call truncate_setsize under tailpack mutex

commit 22e7478ddbcb670e33fab72d0bbe7c394c3a2c84 upstream.

Prior to commit 0e4f6a791b1e (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: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
fs/reiserfs/inode.c