Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp92651pxb; Mon, 13 Sep 2021 13:52:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7Oft+FSIKYS/F7l9qfD5+4155cRT18NC5F3FmMm9AeoVg/yZKIWJLJKlm0DViwvJNKmRz X-Received: by 2002:a17:906:1b08:: with SMTP id o8mr15026649ejg.21.1631566364665; Mon, 13 Sep 2021 13:52:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631566364; cv=none; d=google.com; s=arc-20160816; b=c18p1dZXuU7d+m+MLzY0dpMqEjU0NJBS/tqbG4mN9uitfdr3uhPehZQWz4VSY+nhF+ 8TNry2mOUboDEnR3j1pcysvf9d1xlLajiN4Gnpjld2hrjUhaWWgFTqFsOcTLX/7n9OtT b/4y6HSWYefWDiO13CJLRNDlvxdm+w29/WcSDKqnSGgN8HBATe5/kULGrsnLIu4ypx3+ vCFigpQybkUkWYaX92wKb+Mj9JdVaRIbwajJwWWXroqi9DA2oo4RfPbkR9tqErrYq9Ks u1UVRns57pLoi2DahLfMYiQpSiNabi/a1jikfWezjHJ5lGUqwO9t7iHcleXSVXyOSKGt vL4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uaK4/1xUWtxn7n8EfSio0bsJ2qxINkaIdpEjLx0dTtE=; b=IVOis7RqsAw4tgdCOfUZZP6SvzhMiPsIC5gMVZSaqXiOi7RJbUdAsYsm3TAEOOypme IBo+WG3d3etEOBsqxeei4rDpdFJWPaVBDSzAXrEzbDCAd/bnZQpFW6sQKNPfq+pW/yBe Bv6v2M0TL+OPiI2HjMjF8syseYlJG+qeqFPC23oJq89SabfQo8/YLc5UP2liXqyOqetF fTKKcjp1aSYDoj+DZsswrn+6ket7lZRmPBZw846EU5Gt/RKhfMBQuzNNtN544yluMJl1 soHYlttyjpMAGjI0eUPLDUfMlvNjaXNc/xIZI9+0mpS6SNA4tmBNe68H0p567/S+HiKU Of6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=f4APdFhF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g8si770362edq.535.2021.09.13.13.52.21; Mon, 13 Sep 2021 13:52:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=f4APdFhF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243664AbhIMNv3 (ORCPT + 99 others); Mon, 13 Sep 2021 09:51:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:53604 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243516AbhIMNsB (ORCPT ); Mon, 13 Sep 2021 09:48:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9CB4D61155; Mon, 13 Sep 2021 13:32:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631539963; bh=oSuHavw6d5Ppp9inLTtcKCfRsLgY9+3wel+3yvojdhs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f4APdFhFdoq0ufIZSRrY79uW0Pa5iG+bXeslxkmSBt32cL4DgPssNWX279PTplIuj w5a9d8JhYp7L64EQJ7OEMaXuTDcrvhCipvBfYf67k9XDLzuTME0mdCXehxFYPXfYdR ukHZZvmJjfPkoAvDWg15HgnuvVUacopHgBtZiGVk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miklos Szeredi Subject: [PATCH 5.10 231/236] fuse: flush extending writes Date: Mon, 13 Sep 2021 15:15:36 +0200 Message-Id: <20210913131108.205855591@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131100.316353015@linuxfoundation.org> References: <20210913131100.316353015@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miklos Szeredi commit 59bda8ecee2ffc6a602b7bf2b9e43ca669cdbdcd upstream. Callers of fuse_writeback_range() assume that the file is ready for modification by the server in the supplied byte range after the call returns. If there's a write that extends the file beyond the end of the supplied range, then the file needs to be extended to at least the end of the range, but currently that's not done. There are at least two cases where this can cause problems: - copy_file_range() will return short count if the file is not extended up to end of the source range. - FALLOC_FL_ZERO_RANGE | FALLOC_FL_KEEP_SIZE will not extend the file, hence the region may not be fully allocated. Fix by flushing writes from the start of the range up to the end of the file. This could be optimized if the writes are non-extending, etc, but it's probably not worth the trouble. Fixes: a2bc92362941 ("fuse: fix copy_file_range() in the writeback case") Fixes: 6b1bdb56b17c ("fuse: allow fallocate(FALLOC_FL_ZERO_RANGE)") Cc: # v5.2 Signed-off-by: Miklos Szeredi Signed-off-by: Greg Kroah-Hartman --- fs/fuse/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -3240,7 +3240,7 @@ fuse_direct_IO(struct kiocb *iocb, struc static int fuse_writeback_range(struct inode *inode, loff_t start, loff_t end) { - int err = filemap_write_and_wait_range(inode->i_mapping, start, end); + int err = filemap_write_and_wait_range(inode->i_mapping, start, -1); if (!err) fuse_sync_writes(inode);