Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3076337imm; Sun, 1 Jul 2018 11:42:29 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJGKlyCwI2RTkFvNewTRmxpGAJ6/zL+CV5bxfi7o8PUlCTcPizdlN/AeEpv5BgeSQ6d4wvm X-Received: by 2002:a17:902:48c8:: with SMTP id u8-v6mr23065444plh.152.1530470549896; Sun, 01 Jul 2018 11:42:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530470549; cv=none; d=google.com; s=arc-20160816; b=ojRnm+xih1jWTUk6Hl6lCiw1bdlUIwiORzpFQih15sW7+jn1ZeIp9eEHqYfVSkSOSM PIx4sIg+vroHAZWGJg28QM4+wGs1uxjSueqm8+PvownvL2BywmAnjSEoGeaDIQY6+sp2 nUvwgEX47AXgx7wC304HtSbFIVWSNkNnXn7bOZdvvUTTRXV4byocKS9DS7o0NDbUOlZF cIb0wEHZM4p/4crrKmoSwQX2czlPILQ3iZLg/sSVKOiBmsWJuOGqnaIQIZoYeqR6pqq/ 09yVM+5KDT7h48J3dARP7UxGyina009zcFWcDMlqL5iqfKk53J8EFGxhX7gH39MefbmY kgrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=wCDMairdDIw+uew/VKuQCb33JCJKEJEa3yoIcTUhKYk=; b=cnE4DGFiXKNTemiLhU9o2Nvkr/gWVSwpRwYcMvN9M/Vj7BxiwSXb1wcHZZoyCm2pUe gJV32CnnTtfUW+beaU+7t0YxnC7ik+PZ0q/uU+tYt2VX283hUuU+qVLEWY/RS4TtWY6E De2UGTutMaFq0wwlIsXg4PS4Y2UvpXo/QqHn28xj8lNoRZRm0EbuFCoHO6D2JdrrpzoI 73V/s7EiUwL2h6UZdhznuT5FZVo3bLCIak5TSfUj6TeG88w3e3P321tAPZvCptXf7P8f 9VZEZvq1RAaTYiYv3yxCRrw1LI2yLlHTaAf8SThuDCgjRQ2X4uAgaTm4fsBY1F4VlS5q 3cTQ== 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 z11-v6si12720217pgz.264.2018.07.01.11.42.15; Sun, 01 Jul 2018 11:42:29 -0700 (PDT) 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 S1753114AbeGAQOP (ORCPT + 99 others); Sun, 1 Jul 2018 12:14:15 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60306 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752922AbeGAQOJ (ORCPT ); Sun, 1 Jul 2018 12:14:09 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 03B8F4A3; Sun, 1 Jul 2018 16:14:08 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chad Austin , Miklos Szeredi Subject: [PATCH 3.18 56/85] fuse: atomic_o_trunc should truncate pagecache Date: Sun, 1 Jul 2018 18:02:14 +0200 Message-Id: <20180701153124.593024681@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701153122.365061142@linuxfoundation.org> References: <20180701153122.365061142@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable 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 Cc: Signed-off-by: Greg Kroah-Hartman --- fs/fuse/dir.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -1717,8 +1717,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; }