From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.6 required=3.0 tests=DATE_IN_PAST_06_12, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B83F7C7618B for ; Thu, 25 Jul 2019 05:48:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 86EF520657 for ; Thu, 25 Jul 2019 05:48:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564033739; bh=LjIDZqtXK5w0WHul7K81AazFzJyfDclnAICa0fHRd5Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Xy/rd9fooaAhDn4s2+8LPaTA8t4RVc0qlmC1WZWzdujXtDH6LaO5LRLqs0MaIdHY3 jYhTli/NQcsxWo4tmWQMf+XxngmmVqIOb6SLTjv1IdpMWKyfBDWzPGZ3VWo+SHWZ8W Hx/vix1t7awQTULe/p7ydGDlQpOQMkM7qr2ZBqFE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388535AbfGYFpO (ORCPT ); Thu, 25 Jul 2019 01:45:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:60664 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405133AbfGYFpN (ORCPT ); Thu, 25 Jul 2019 01:45:13 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 55B1922C7C; Thu, 25 Jul 2019 05:45:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564033512; bh=LjIDZqtXK5w0WHul7K81AazFzJyfDclnAICa0fHRd5Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JvkmS4lMWN6xmtm7ckcqBFJX3+VlOzg5WGrsH83iXy2qGxZAo8zhbPm9v0ZSzeF+y qqD9dIy7IPaXYvgjwINEsdFxwxg6eXfmkT0si1/wa1tuqRDmim8XDYUQbNnPEDFnRs 0LUxcc9xhH7y5fhIDAtrwWurd5iP0gT6ByDXYzFs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Filipe Manana , David Sterba Subject: [PATCH 4.19 234/271] Btrfs: add missing inode version, ctime and mtime updates when punching hole Date: Wed, 24 Jul 2019 21:21:43 +0200 Message-Id: <20190724191715.211811475@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191655.268628197@linuxfoundation.org> References: <20190724191655.268628197@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Filipe Manana commit 179006688a7e888cbff39577189f2e034786d06a upstream. If the range for which we are punching a hole covers only part of a page, we end up updating the inode item but we skip the update of the inode's iversion, mtime and ctime. Fix that by ensuring we update those properties of the inode. A patch for fstests test case generic/059 that tests this as been sent along with this fix. Fixes: 2aaa66558172b0 ("Btrfs: add hole punching") Fixes: e8c1c76e804b18 ("Btrfs: add missing inode update when punching hole") CC: stable@vger.kernel.org # 4.4+ Signed-off-by: Filipe Manana Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/file.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -2732,6 +2732,11 @@ out_only_mutex: * for detecting, at fsync time, if the inode isn't yet in the * log tree or it's there but not up to date. */ + struct timespec64 now = current_time(inode); + + inode_inc_iversion(inode); + inode->i_mtime = now; + inode->i_ctime = now; trans = btrfs_start_transaction(root, 1); if (IS_ERR(trans)) { err = PTR_ERR(trans);