[Devel] [PATCH RHEL7 COMMIT] fs/fuse: add assert on i_mutex in fuse_send_write()
Konstantin Khorenko
khorenko at virtuozzo.com
Thu Nov 8 17:28:10 MSK 2018
The commit is pushed to "branch-rh7-3.10.0-862.20.2.vz7.73.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-862.20.2.vz7.73.2
------>
commit 3c63d83b4be7684ba740d1404d233775e82e5743
Author: Pavel Butsykin <pbutsykin at virtuozzo.com>
Date: Thu Nov 8 17:28:08 2018 +0300
fs/fuse: add assert on i_mutex in fuse_send_write()
All write/falloc requests should be protected from simultaneous execution
with truncate (setattr size). Write requests are protected either by i_mutex
or by fc->lock and fuse_set_nowrite/__fuse_release_nowrite.
The way with fuse_send_write() should always be protected by i_mutex,
let's add the assert to avoid possible mistakes and misunderstandings in
the future, as it happened with fuse_direct_IO_bvec().
https://pmc.acronis.com/browse/VSTOR-16876
Signed-off-by: Pavel Butsykin <pbutsykin at virtuozzo.com>
Reviewed-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
fs/fuse/file.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index d362eb3a7076..34a39478f93c 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1367,11 +1367,14 @@ static size_t fuse_send_write(struct fuse_req *req, struct fuse_io_priv *io,
loff_t pos, size_t count, fl_owner_t owner)
{
struct file *file = io->file;
+ struct inode *inode = file_inode(file);
struct fuse_file *ff = file->private_data;
struct fuse_conn *fc = ff->fc;
struct fuse_write_in *inarg = &req->misc.write.in;
- fuse_write_fill(req, ff, file_inode(file), pos, count);
+ WARN_ON_ONCE(!mutex_is_locked(&inode->i_mutex));
+
+ fuse_write_fill(req, ff, inode, pos, count);
fuse_account_request(fc, count);
inarg->flags = file->f_flags;
if (owner != NULL) {
More information about the Devel
mailing list