Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1830882pxb; Mon, 13 Sep 2021 06:31:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7Ivz8TUykcWV/RLYuqfu+G/O9N+J2PVfLSEy5Y+X1ItTN+j3Z2+FQuX5lGyzGRyKmQdS/ X-Received: by 2002:a05:6638:372a:: with SMTP id k42mr6347070jav.71.1631539868263; Mon, 13 Sep 2021 06:31:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631539868; cv=none; d=google.com; s=arc-20160816; b=m0bSpiRQkWANUctcTUXMCooE0KJc3nVM/M445FaY1H4tsEh6b0+/iNTJ/JacQSjgzC EfaL+hxHs6fYCla23w3G1Za8Gfmh99USSA773JWDBK+hIpNOTWssZRJkadP7foWYuFNt zU4uqlQ/tyn9qGqTiyg62f37wmgliAePLwwlr3+QAiyxE/DyzxCrUfdMcKMnxYuLmZQy PsIakBVImKHec2Av5ZRqkalK/3oN8DVk2q4v8lzOqu5om7ZrOrAY8LH44RtVqqLyIKaT ime65U+wmZV4tsFXwywjzllUknXCJqZ3ZFIoBwt66naeB6gLxvV00tr9Sg5gTHCG/oo9 qtLg== 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=pEF70K9gEITCus7j9MnPyhgQ2iWYpVQLwSTkw0mvecs=; b=IBGTA8+eXDD91WhTFTHymZWLQq+DrId6/BkUrGkSkvKSj5IoyydQuJyo24jWab7RVY m0WthjtOIP64qDiFbXTyXNdSWFyDbdnnROsXWX7IPYKoEp4EaVPLmFvz6u0oWrQswI1K AWVvaGWo2EHlP+RGZb82niOLM/5QUrJ8obdm7xqlLtsSbL3vgPh/L3mMjEkfHyLOzxzS 6ch/V8LByh/x02IkUoToIrJglsYFNEykFGIS6pc9dm6RbE6yUy8TJ7VnYKTnFs1jmsOC j6uaO/1tTx6pk6BeWscN3v5tTb/FG8LIkQGQw7aqWAYCl/EHGbL7VK9zlPnBgBBKeKoJ qHSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TvLW0uMF; 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 g2si7338632jat.51.2021.09.13.06.30.47; Mon, 13 Sep 2021 06:31:08 -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=TvLW0uMF; 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 S241006AbhIMN3E (ORCPT + 99 others); Mon, 13 Sep 2021 09:29:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:47048 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241830AbhIMNZz (ORCPT ); Mon, 13 Sep 2021 09:25:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5B67261159; Mon, 13 Sep 2021 13:22:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631539355; bh=131mZfcIsJTCokU51joaa8DlCPCSoScx44gNBz7jgVU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TvLW0uMFDKIdR957TiJpO4csS9c6jz1KMBd71NcyaRl/ntjwts0wHyCA5AtjE81Uu FuG6oQhO60k5Pz8zPDM1FUMbMvOty8Igk6QrZA/AGNqw+TLRYhdE9rPKhjNscf3wuX MHtqwvAczCTV+Ra41Psa0ACAjffercYYc+H8SIqU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miklos Szeredi Subject: [PATCH 5.4 139/144] fuse: flush extending writes Date: Mon, 13 Sep 2021 15:15:20 +0200 Message-Id: <20210913131052.577991332@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131047.974309396@linuxfoundation.org> References: <20210913131047.974309396@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 @@ -3188,7 +3188,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);