Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3337553imu; Sun, 11 Nov 2018 12:41:03 -0800 (PST) X-Google-Smtp-Source: AJdET5e0ZHi/aFLL9qoC4l14f85HWkzZwUFq8Yxc69AKJ159oO/vHLuwOs7TTTyu8ffL5wloIpX4 X-Received: by 2002:a63:f201:: with SMTP id v1mr7148353pgh.232.1541968863361; Sun, 11 Nov 2018 12:41:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541968863; cv=none; d=google.com; s=arc-20160816; b=At8+RkJ9S2dL4eKFkGfeYlKfwXB3rlcoct5uxlq7xWxc3RTbobUs3QVTPiOP4z+e7b NKxq/LINeSM30QI9P98NRenucyoq3QPfhNH9X1+lyLhFg/JuKgHUUbXwrEo36vJZSIRS GvQx0kMGfRELl3O1gi3RkMkmQ0qXJ+DyDgPsVDS3JcxaH7c5JKmVR/0d6GNWlqF8VxCq +/zs8YVwUfEzB+tErYFXXfawEX23rdzozuL4YdW21eELEBuxEGFXZmac+o+e5buBVc+w mdUzLLY1Zxlf9Egg4wLuoPDLocsWILikgrOYqeFZ4DQ2IEGaKUd0wNtnmLU6OQporj4E azEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=DINbCTbIBtBWWbD1d/GMfHd3AuFFb+uneykX2WksQUA=; b=VdslFkkSlIBSLlGkH9vvbwV/icSHH4U79pgzGC6Cx6rMATdeTrhqULP3uO/OhWHL9a ZRptfxoLSVCBMvogUjGXYY/qr/kKeJkj1rN38jw6E72PS8Ml6/u/pkYDSRWQHNejDTZ4 ZOEHbKbHYZoC0NScNltOwBc94bB24Ww5+eSbM3r+OtAuLzdvtwF8GPrtzd7WHSSvVWpc u5N1f6LEKBgLh6nlho55/vMSascWpwrHm3fpF1h0v9+49CmFhNBHuSDnzIcfDg6W5d4h Jmw5q6iqp3+vxxQ8VmUZCobOaphzbJTBBaWQc1eTX1D73ZKTorAwuEpJsLme0m1AiFo8 bCSw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z126-v6si16380687pfb.280.2018.11.11.12.40.48; Sun, 11 Nov 2018 12:41:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729942AbeKLFsF (ORCPT + 99 others); Mon, 12 Nov 2018 00:48:05 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:49372 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729830AbeKLFsD (ORCPT ); Mon, 12 Nov 2018 00:48:03 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvsN-0000lI-Ur; Sun, 11 Nov 2018 19:58:32 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsN-0001N9-PL; Sun, 11 Nov 2018 19:58:31 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Miklos Szeredi" , "Chad Austin" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 014/366] fuse: atomic_o_trunc should truncate pagecache In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Miklos Szeredi commit df0e91d488276086bc07da2e389986cae0048c37 upstream. Fuse has an "atomic_o_trunc" mode, where userspace filesystem uses the O_TRUNC flag in the OPEN request to truncate the file atomically with the open. In this mode there's no need to send a SETATTR request to userspace after the open, so fuse_do_setattr() checks this mode and returns. But this misses the important step of truncating the pagecache. Add the missing parts of truncation to the ATTR_OPEN branch. Reported-by: Chad Austin Fixes: 6ff958edbf39 ("fuse: add atomic open+truncate support") Signed-off-by: Miklos Szeredi Signed-off-by: Ben Hutchings --- fs/fuse/dir.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -1728,8 +1728,19 @@ int fuse_do_setattr(struct dentry *dentr return err; if (attr->ia_valid & ATTR_OPEN) { - if (fc->atomic_o_trunc) + /* This is coming from open(..., ... | O_TRUNC); */ + WARN_ON(!(attr->ia_valid & ATTR_SIZE)); + WARN_ON(attr->ia_size != 0); + if (fc->atomic_o_trunc) { + /* + * No need to send request to userspace, since actual + * truncation has already been done by OPEN. But still + * need to truncate page cache. + */ + i_size_write(inode, 0); + truncate_pagecache(inode, 0); return 0; + } file = NULL; }