[RHEL7,COMMIT] fs/fuse kio_pcs: add assert on i_mutex for PUNCH_HOLE and ZERO_RANGE

Submitted by Konstantin Khorenko on Nov. 8, 2018, 2:28 p.m.

Details

Message ID 201811081428.wA8ES70H003758@finist-ce7.sw.ru
State New
Series "fs/fuse kio_pcs: add assert on i_mutex for PUNCH_HOLE and ZERO_RANGE"
Headers show

Commit Message

Konstantin Khorenko Nov. 8, 2018, 2:28 p.m.
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 85e7860fc38b2c8db1220f676860545e7ee60361
Author: Pavel Butsykin <pbutsykin@virtuozzo.com>
Date:   Thu Nov 8 17:28:07 2018 +0300

    fs/fuse kio_pcs: add assert on i_mutex for PUNCH_HOLE and ZERO_RANGE
    
    PUNCH_HOLE and ZERO_RANGE operations must be performed only under i_mutex.
    
    https://pmc.acronis.com/browse/VSTOR-16876
    
    Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
    Reviewed-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 fs/fuse/kio/pcs/pcs_fuse_kdirect.c | 2 ++
 1 file changed, 2 insertions(+)

Patch hide | download patch | download mbox

diff --git a/fs/fuse/kio/pcs/pcs_fuse_kdirect.c b/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
index 3940d6c255ba..a0225de80c0e 100644
--- a/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
+++ b/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
@@ -944,6 +944,8 @@  static void pcs_fuse_submit(struct pcs_fuse_cluster *pfc, struct fuse_req *req,
 			inarg->mode &= ~FALLOC_FL_ZERO_RANGE;
 
 		if (inarg->mode & (FALLOC_FL_ZERO_RANGE|FALLOC_FL_PUNCH_HOLE)) {
+			WARN_ON_ONCE(!mutex_is_locked(&fi->inode.i_mutex));
+
 			if ((inarg->offset & (PAGE_SIZE - 1)) || (inarg->length & (PAGE_SIZE - 1))) {
 				r->req.out.h.error = -EINVAL;
 				goto error;