Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1878775pxb; Mon, 13 Sep 2021 07:25:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHs2Ms+HvKYnAB3vUG1mbKIsQ6OiNyjhWVI0ZFfL3UcktzY3gFjJQxkhnt589oRw75p+Lr X-Received: by 2002:a02:11c1:: with SMTP id 184mr3835372jaf.70.1631543103370; Mon, 13 Sep 2021 07:25:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631543103; cv=none; d=google.com; s=arc-20160816; b=hkOD4+v79zCYqAeYISPBveLw/qHT7CpjZfOM6eU/1yI+6Mxe9eawPEERxgzze3JEBZ 58/EgkIDBUhclID2dUKaVa0yNBePLXXn0EcmKpgPWygVjCcAGcxNLgQfjYm8qcmpBdnM VjY8ZQcIa9Zwa2NnkGBz+w+AFQtRN88z0vcjC9s5y49EEIy8pMXcbpgyMWo6FvMMqSwp xatnG8Q/tQhrBZTvTgrv+rrbjc76Dq/Y3IFPJbyUfGkAtVhI4ETk/LJniwnXevGIhfok v0Fy88tuDgEP4xnZLyCcs6qwirGxAUaKC2bPYXeRjwgONXNGYfQikfeKHw4SbhA+FXLi CF+w== 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=9x2xsn86ph848XvyVtq5SrEzhBlAy5EBlGOzBtMC3yY=; b=0roJcRagvm+4nax8BSy2AixzwNbdMNEh/bf+ZTQTzh3G71xF79DRO/ZC5Guwvz1X4e OgrSt/kIqjFGVCqOuf+Ep0Ioh9xsg49dXIL66uG9p9dRshxoOuLYHXF1OcKNUdr5U826 OBb5tyMwzzZYvIyCdKkoLdHCSk5/SpsrEucfBSaaceM5kIir2141ZE4Uz+n2ow7mua2f nnI7uRpQlxg9R9XGmywU8LMtigAlUZgFKuZ5O+nRuKf2y9tQOAo8RrVh6KAzNa2Ix8Mc Dn+o6GLF0xWahr93BWbdHK5zuCkRmsCodZrOvOSEmPrs4v0qM0YqAF668CZ9BjiU5D+D 3+MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="0Nt/38M9"; 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 a12si8094574ilt.135.2021.09.13.07.24.44; Mon, 13 Sep 2021 07:25:03 -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="0Nt/38M9"; 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 S245282AbhIMOXM (ORCPT + 99 others); Mon, 13 Sep 2021 10:23:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:37396 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344141AbhIMOQu (ORCPT ); Mon, 13 Sep 2021 10:16:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3851E61AFE; Mon, 13 Sep 2021 13:44:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631540683; bh=CL5Y3CisgtGWXW+uw3x7L2vaHHHyTBOnODkCDoZu7xI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0Nt/38M9e5mDtmXFXXVtz+R3JGD4f9wJ5IIHfkXT5rg4+og1pFxHWv9qrKYP7dRRx RrMhtgfzbg+84yZ6oSy/3rLopQma8MHVtgv/aP7MFgszkoduEtB2/B14KW8rpE5P5E c2QUGP/4/RCZoMcylHJIdHygMG83dU4fxyY3UaCI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miklos Szeredi Subject: [PATCH 5.13 293/300] fuse: flush extending writes Date: Mon, 13 Sep 2021 15:15:54 +0200 Message-Id: <20210913131119.244976614@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131109.253835823@linuxfoundation.org> References: <20210913131109.253835823@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 @@ -2886,7 +2886,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);