Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3011801imm; Sun, 1 Jul 2018 10:16:00 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLTzRAezmrXR/RvqTN3lsuC7L2v06s6aVygBY81EeH/kivJYC4ilsWJCXg+H5BLDmmaa0ci X-Received: by 2002:a17:902:b60b:: with SMTP id b11-v6mr23181933pls.330.1530465360319; Sun, 01 Jul 2018 10:16:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530465360; cv=none; d=google.com; s=arc-20160816; b=Jr5NowBVe8SCzuAMwhxdCgqTzGPygmszi6Fo+UEzTwbbbrGF3IX/VgjcdzPkMlIqp8 IXCuTiDeJgbcrEWQAQkjHj/Q3Gx3H9+7FAGJXDBG2jxy/A6XrBoXpTbrPkSNJpav8Too k4BKvXO6Du689mbI27AoXOedAYx6Z9taOws8jUMzOUNd7HMFdR84JouuDrVpEXuFEXhK y76qgnW/yocfw9C5kT9kQ2HSzzbCGaEyHM/LV7GP5BLIceSgNEP5MLj0LUyHTxM97P8E 8qeXBGXc+Bm88z3F0LOBukCy70dJanrYvQh35hLTAtx+IHVORnZfgVUHuKEOK6n0i6WL nQsw== 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=mpuC3Cp0egDXiWu7Iq8epia+5fuUd9JOVNaGG3/YCXs=; b=pR4LmAQYHt9953OD7zlSDb8o7EGvX1bEFFiHXOZDFU1lm+ySsJoeIkjTbIXg1PkY4s 2IvR1r+GHYR3WJguS6YmmJ4T4lkQ7tNx0Jedw0YELuNvFWzYHIbb2OkVeloiXqPwkw4o 6ZkgafPRwvY9jYFQ893u+Srxu6Y1Nz8fYZEqU31ZpfbUKrpAkGONJRafhgkRl14bZ4PN plgjK3g8TMiVRURBksE0Cv3Nb3jcppdz8iSTqhMqwp2SSRXmkDUGSop/QFYucuhPn2gq MNHH6nIPsGT2ZqIgnIvplWIXTGX+/j0FMvXtqBJl6btjdSFBZU+LA/CKpvTTXMBls6Mx qeaQ== 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 n187-v6si13002483pgn.368.2018.07.01.10.15.45; Sun, 01 Jul 2018 10:16:00 -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 S965927AbeGARPI (ORCPT + 99 others); Sun, 1 Jul 2018 13:15:08 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37072 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031835AbeGAQkB (ORCPT ); Sun, 1 Jul 2018 12:40:01 -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 1A42CACD; Sun, 1 Jul 2018 16:40:00 +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 4.17 041/220] fuse: atomic_o_trunc should truncate pagecache Date: Sun, 1 Jul 2018 18:21:05 +0200 Message-Id: <20180701160910.043200363@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160908.272447118@linuxfoundation.org> References: <20180701160908.272447118@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 4.17-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 @@ -1629,8 +1629,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; }