* [PATCH] reiserfs: call truncate_setsize under tailpack mutex
@ 2014-05-21 17:26 Jeff Mahoney
0 siblings, 0 replies; 3+ messages in thread
From: Jeff Mahoney @ 2014-05-21 17:26 UTC (permalink / raw)
To: reiserfs-devel, Jan Kara
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>
---
fs/reiserfs/inode.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -3214,8 +3214,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);
}
}
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] reiserfs: call truncate_setsize under tailpack mutex
@ 2014-05-21 17:28 Jeff Mahoney
2014-05-21 20:37 ` Jan Kara
0 siblings, 1 reply; 3+ messages in thread
From: Jeff Mahoney @ 2014-05-21 17:28 UTC (permalink / raw)
To: reiserfs-devel, Jan Kara
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>
Cc: <stable@vger.kernel.org>
---
fs/reiserfs/inode.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -3214,8 +3214,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);
}
}
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] reiserfs: call truncate_setsize under tailpack mutex
2014-05-21 17:28 [PATCH] reiserfs: call truncate_setsize under tailpack mutex Jeff Mahoney
@ 2014-05-21 20:37 ` Jan Kara
0 siblings, 0 replies; 3+ messages in thread
From: Jan Kara @ 2014-05-21 20:37 UTC (permalink / raw)
To: Jeff Mahoney; +Cc: reiserfs-devel, Jan Kara
On Wed 21-05-14 13:28:07, Jeff Mahoney wrote:
> 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.
Thanks. I've merged the patch to my tree.
Honza
>
> Signed-off-by: Jeff Mahoney <jeffm@suse.com>
> Cc: <stable@vger.kernel.org>
> ---
> fs/reiserfs/inode.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> --- a/fs/reiserfs/inode.c
> +++ b/fs/reiserfs/inode.c
> @@ -3214,8 +3214,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);
> }
> }
>
> --
> Jeff Mahoney
> SUSE Labs
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-05-21 20:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-21 17:28 [PATCH] reiserfs: call truncate_setsize under tailpack mutex Jeff Mahoney
2014-05-21 20:37 ` Jan Kara
-- strict thread matches above, loose matches on Subject: below --
2014-05-21 17:26 Jeff Mahoney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).