[Devel] [PATCH RHEL7 COMMIT] fs/fuse kio: fix FALLOC_FL_ZERO_RANGE outside end of file

Konstantin Khorenko khorenko at virtuozzo.com
Thu Jun 6 15:14:13 MSK 2019


The commit is pushed to "branch-rh7-3.10.0-957.12.2.vz7.96.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.12.2.vz7.96.12
------>
commit 33c58ff3ba8da6560785833500c8d0d91a59a683
Author: Pavel Butsykin <pbutsykin at virtuozzo.com>
Date:   Thu Jun 6 15:14:11 2019 +0300

    fs/fuse kio: fix FALLOC_FL_ZERO_RANGE outside end of file
    
    Fallocate FALLOC_FL_ZERO_RANGE beyond end of file should change the file size.
    
    Fixes: a4c0a32b5b78 ("fs/fuse kio: cosmetic changes in pcs_fuse_prep_rw()")
    https://pmc.acronis.com/browse/VSTOR-23781
    
    Signed-off-by: Pavel Butsykin <pbutsykin at virtuozzo.com>
    Acked-by: Alexey Kuznetsov <kuznet at virtuozzo.com>
---
 fs/fuse/kio/pcs/pcs_fuse_kdirect.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/fs/fuse/kio/pcs/pcs_fuse_kdirect.c b/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
index 0d8cb3a751e2..60c47aaf592e 100644
--- a/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
+++ b/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
@@ -858,7 +858,7 @@ static bool kqueue_insert(struct pcs_dentry_info *di, struct fuse_file *ff,
 }
 
 static inline int req_wait_grow_queue(struct pcs_fuse_req *r,
-				      struct fuse_file *ff, u16 type,
+				      struct fuse_file *ff,
 				      off_t offset, size_t size)
 {
 	struct pcs_dentry_info *di = get_pcs_inode(r->req.io_inode);
@@ -866,7 +866,6 @@ static inline int req_wait_grow_queue(struct pcs_fuse_req *r,
 	if (!kqueue_insert(di, ff, &r->req))
 		return -EIO;
 
-	pcs_fuse_prep_io(r, type, offset, size, 0);
 	inode_dio_begin(r->req.io_inode);
 	wait_grow(r, di, offset + size);
 	return 1;
@@ -922,8 +921,9 @@ static int pcs_fuse_prep_rw(struct pcs_fuse_req *r, struct fuse_file *ff)
 		struct fuse_write_in *in = &req->misc.write.in;
 
 		if (in->offset + in->size > di->fileinfo.attr.size) {
-			ret = req_wait_grow_queue(r, ff, PCS_REQ_T_WRITE,
-						  in->offset, in->size);
+			pcs_fuse_prep_io(r, PCS_REQ_T_WRITE, in->offset,
+					 in->size, 0);
+			ret = req_wait_grow_queue(r, ff, in->offset, in->size);
 			goto pending;
 		}
 		spin_unlock(&di->lock);
@@ -957,25 +957,28 @@ static int pcs_fuse_prep_rw(struct pcs_fuse_req *r, struct fuse_file *ff)
 	}
 	case FUSE_FALLOCATE: {
 		struct fuse_fallocate_in const *in = req->in.args[0].value;
-		u16 type;
+		u16 type = PCS_REQ_T_MAX;
 
 		if (in->mode & FALLOC_FL_PUNCH_HOLE)
 			type = PCS_REQ_T_WRITE_HOLE;
 		else if (in->mode & FALLOC_FL_ZERO_RANGE)
 			type = PCS_REQ_T_WRITE_ZERO;
-		else {
-			ret = -EPERM;
-			goto fail;
-		}
 
 		if (in->offset + in->length > di->fileinfo.attr.size) {
-			ret = req_wait_grow_queue(r, ff, type, in->offset,
-						  in->length);
+			if (type < PCS_REQ_T_MAX)
+				pcs_fuse_prep_io(r, type, in->offset,
+						 in->length, 0);
+			else
+				pcs_fuse_prep_fallocate(r);
+			ret = req_wait_grow_queue(r, ff, in->offset, in->length);
 			goto pending;
 		}
 		spin_unlock(&di->lock);
 
-		pcs_fuse_prep_io(r, type, in->offset, in->length, 0);
+		if (type < PCS_REQ_T_MAX)
+			pcs_fuse_prep_io(r, type, in->offset, in->length, 0);
+		else
+			return -EPERM; /* NOPE */
 		break;
 	}
 	default:



More information about the Devel mailing list