[Devel] [PATCH RHEL7 COMMIT] fs/fuse: add assert on i_mutex in fuse_send_unmap()

Konstantin Khorenko khorenko at virtuozzo.com
Thu Nov 8 17:33:09 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 8fe86c5f5406b9a22e3d72f39ef5758e1e8b53c8
Author: Pavel Butsykin <pbutsykin at virtuozzo.com>
Date:   Thu Nov 8 17:28:06 2018 +0300

    fs/fuse: add assert on i_mutex in fuse_send_unmap()
    
    This is not obvious, but fuse_send_unmap() is always executed under i_mutex,
    which is taken at vfs layer in generic_file_write_iter(). This is correct
    behavior but isn't very obvious. Let's add assert to simplify understanding
    the call context of fuse_send_unmap() and to avoid possible mistakes in the
    future.
    
    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 59927669b2a4..d362eb3a7076 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1336,10 +1336,13 @@ static size_t fuse_send_unmap(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_fallocate_in *inarg = &req->misc.fallocate.in;
 
+	WARN_ON_ONCE(!mutex_is_locked(&inode->i_mutex));
+
 	inarg->fh = ff->fh;
 	inarg->offset = pos;
 	inarg->length = count;
@@ -1349,7 +1352,7 @@ static size_t fuse_send_unmap(struct fuse_req *req, struct fuse_io_priv *io,
 	req->in.numargs = 1;
 	req->in.args[0].size = sizeof(struct fuse_fallocate_in);
 	req->in.args[0].value = inarg;
-	req->io_inode = file_inode(file);
+	req->io_inode = inode;
 
 	fuse_account_request(fc, count);
 



More information about the Devel mailing list