This is a note to let you know that I've just added the patch titled

    reiserfs: call truncate_setsize under tailpack mutex

to the 3.15-stable tree which can be found at:
    
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     reiserfs-call-truncate_setsize-under-tailpack-mutex.patch
and it can be found in the queue-3.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


>From 22e7478ddbcb670e33fab72d0bbe7c394c3a2c84 Mon Sep 17 00:00:00 2001
From: Jeff Mahoney <je...@suse.com>
Date: Wed, 21 May 2014 13:28:07 -0400
Subject: reiserfs: call truncate_setsize under tailpack mutex

From: Jeff Mahoney <je...@suse.com>

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 <je...@suse.com>
Signed-off-by: Jan Kara <j...@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gre...@linuxfoundation.org>

---
 fs/reiserfs/inode.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -3220,8 +3220,14 @@ int reiserfs_setattr(struct dentry *dent
            attr->ia_size != i_size_read(inode)) {
                error = inode_newsize_ok(inode, attr->ia_size);
                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);
-                       reiserfs_vfs_truncate_file(inode);
+                       reiserfs_truncate_file(inode, 1);
+                       mutex_unlock(&REISERFS_I(inode)->tailpack);
                }
        }
 


Patches currently in stable-queue which might be from je...@suse.com are

queue-3.15/reiserfs-call-truncate_setsize-under-tailpack-mutex.patch
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to