[RHEL7,COMMIT] fs/fuse kio: satisfy pure FALLOC_FL_KEEP_SIZE immediately

Submitted by Konstantin Khorenko on Jan. 10, 2019, 9:34 a.m.

Details

Message ID 201901100934.x0A9YBBV003977@finist-ce7.sw.ru
State New
Series "fs/fuse kio: satisfy pure FALLOC_FL_KEEP_SIZE immediately"
Headers show

Commit Message

Konstantin Khorenko Jan. 10, 2019, 9:34 a.m.
The commit is pushed to "branch-rh7-3.10.0-957.1.3.vz7.83.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.1.3.vz7.83.4
------>
commit 168e59188cf5743d008e8305280ef097c33b30fc
Author: Pavel Butsykin <pbutsykin@virtuozzo.com>
Date:   Thu Jan 10 12:34:11 2019 +0300

    fs/fuse kio: satisfy pure FALLOC_FL_KEEP_SIZE immediately
    
    Fallocate without mutex lock can race with setattr size request, as a result,
    may be various problems, including incorrectly changed file size. At the same
    time pure FALLOC_FL_KEEP_SIZE for vstorage is just nope, so we can immediately
    complete fallocate with mode == FALLOC_FL_KEEP_SIZE. Also move mutex_is_locked,
    since all other mode combinations either have to be under mutex or not valid.
    
    https://pmc.acronis.com/browse/VSTOR-19317
    
    Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
    Reviewed-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 fs/fuse/kio/pcs/pcs_fuse_kdirect.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

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 de54fedeb5e4..89866370a341 100644
--- a/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
+++ b/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
@@ -924,9 +924,11 @@  static void pcs_fuse_submit(struct pcs_fuse_cluster *pfc, struct fuse_req *req,
 		if (inarg->offset >= di->fileinfo.attr.size)
 			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->mode == FALLOC_FL_KEEP_SIZE)
+			break; /* NOPE */
 
+		WARN_ON_ONCE(!mutex_is_locked(&fi->inode.i_mutex));
+		if (inarg->mode & (FALLOC_FL_ZERO_RANGE|FALLOC_FL_PUNCH_HOLE)) {
 			if ((inarg->offset & (PAGE_SIZE - 1)) || (inarg->length & (PAGE_SIZE - 1))) {
 				r->req.out.h.error = -EINVAL;
 				goto error;