Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3063212imm; Sun, 1 Jul 2018 11:22:45 -0700 (PDT) X-Google-Smtp-Source: AAOMgpegDZHy6rNxH5duwnmmqOWJaoKG3/IdiLGELUXmaWo6QUWJ2+B8Dx29L+eI485eKYqleRy9 X-Received: by 2002:aa7:854e:: with SMTP id y14-v6mr22074147pfn.165.1530469365742; Sun, 01 Jul 2018 11:22:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530469365; cv=none; d=google.com; s=arc-20160816; b=Nyzm7nUgUdI42/ip3u+P622Nn4xPQ/o7Qv6goHlDTIcXrwK0EWpX3b54c7uMaDdij4 0s5v3K5vwcMeS1SfZ2ZM2wFOMLdNG/zbOvhU7AtJhThB/r2CT0uxx/jpJ6wAPT5Fh7b5 Ta8HopDq0Sg4n9aPlQtGQLJlcBWpVfyE6C7TIajEqSGZPePDI01349rDfF1QVMWWUJ+n rkBPi8SwsxfYYkfW969yUUQL7f8hBMXhMTe2YquptLIn3t/lT4TgRdQSS1l8086URB6Z QVXw7p/JVHXYrW3xhwNhWciDw+hVCvplMKHN/uyc4ztgp+vuEAO27Ohlx0lRwZDPUix4 alwg== 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=79KXBan9g84CAwJhTicMlhPuX4NS6BTX9tC+GY/byvM=; b=cXg6L+p3GOBQlBiQeT4Y9IBeAQ+kqVutlLHCsTPQ0PbxX7h9r8NhwOuro/q3vR0KK1 u7pkKqLgKuBLKFFgG1i1kTq/bGSFfLSMqqm5okS1sDT935CIg53C1S9F8MNSEaJ2u+Zt ZndibmTHjKp5KiMmIthJ3bFPioFH6zprS3yuyCFitmHcD8Ubq3QSUK5EeSamAE1zCfNW 9oEBEYT7/fHB2EfxwfcfBJX502eNC4M/L3TJP+lIbVgExSiviEqNXoamojMWqys4Y8fF dAZG4hW0t9DQP0rD4XnM/flatbmwi58I+1dxbvZd/xmLUea197EjM35hv1dp1n+FQ2IZ Mv1Q== 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 s184-v6si12618544pgb.161.2018.07.01.11.22.30; Sun, 01 Jul 2018 11:22:45 -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 S965266AbeGASVQ (ORCPT + 99 others); Sun, 1 Jul 2018 14:21:16 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33586 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933801AbeGAQYy (ORCPT ); Sun, 1 Jul 2018 12:24:54 -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 1E008AD8; Sun, 1 Jul 2018 16:24:53 +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.9 021/101] fuse: atomic_o_trunc should truncate pagecache Date: Sun, 1 Jul 2018 18:21:07 +0200 Message-Id: <20180701160757.989301182@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160757.138608453@linuxfoundation.org> References: <20180701160757.138608453@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.9-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 @@ -1633,8 +1633,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; }