From patchwork Fri Sep 16 03:35:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 12978056 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4251FC32771 for ; Fri, 16 Sep 2022 03:35:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DA7608D0001; Thu, 15 Sep 2022 23:35:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D2FEA80008; Thu, 15 Sep 2022 23:35:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BAA5A8D0006; Thu, 15 Sep 2022 23:35:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id AABA48D0001 for ; Thu, 15 Sep 2022 23:35:35 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 8011E1A06A4 for ; Fri, 16 Sep 2022 03:35:35 +0000 (UTC) X-FDA: 79916533830.18.94B1980 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by imf08.hostedemail.com (Postfix) with ESMTP id E39F41600AA for ; Fri, 16 Sep 2022 03:35:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663299335; x=1694835335; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JMW9u8fUfl6xVouZZpm8FHKzsQjwv8MqqGLA900GgrQ=; b=JCNfjSAGP5zZLy+N/qJaLoTWDZfm1n5Fx/GZiYqeiJtwXGc2oVAXIipf GUj+EWzIpAqAGLHE6vB9G8gXVyE+3b1KP54X1hhIDexQ9/YwXZZUIEFn+ BcCs7pLTFWWhMzkU7Y27Vy2+wKz3xjOwp6zyLjD6j5AWXekgU288aG+LV eSaJouDUlQKVTvcuWSgJ93VN1YXiHA5ansFBYhGZv8iw5T3KVdFuIFQNZ K3DZnxKv/iFa2jYl7Cwv4rvaLU/e2S+C+mmQnkGTCxZ1ROZVigDvSv7vV idcw4Ws4YajsCHESbUm69BdA2r6Wxal/kjeYiVwKiRDZJCb79pTauY3Cj w==; X-IronPort-AV: E=McAfee;i="6500,9779,10471"; a="360643112" X-IronPort-AV: E=Sophos;i="5.93,319,1654585200"; d="scan'208";a="360643112" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2022 20:35:33 -0700 X-IronPort-AV: E=Sophos;i="5.93,319,1654585200"; d="scan'208";a="792961823" Received: from colinlix-mobl.amr.corp.intel.com (HELO dwillia2-xfh.jf.intel.com) ([10.209.29.52]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2022 20:35:33 -0700 Subject: [PATCH v2 04/18] ext4: Add ext4_break_layouts() to the inode eviction path From: Dan Williams To: akpm@linux-foundation.org Cc: Matthew Wilcox , Jan Kara , "Darrick J. Wong" , Jason Gunthorpe , Christoph Hellwig , John Hubbard , linux-fsdevel@vger.kernel.org, nvdimm@lists.linux.dev, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-ext4@vger.kernel.org Date: Thu, 15 Sep 2022 20:35:33 -0700 Message-ID: <166329933305.2786261.13953404062673878108.stgit@dwillia2-xfh.jf.intel.com> In-Reply-To: <166329930818.2786261.6086109734008025807.stgit@dwillia2-xfh.jf.intel.com> References: <166329930818.2786261.6086109734008025807.stgit@dwillia2-xfh.jf.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663299335; a=rsa-sha256; cv=none; b=xopSIGl1TPA2hioKhCy6VMi8HPmfS8ZBve57OvMaCX6ue87f30Gq2j3J07yc5OeQDOZyfB RTVnK9rTCbn5encSCDsO0BJVJxj0kVr0oTpQKHDVAqJqXqG/R4Diae7o09Svr56Q6BDc2u 9MP5IOr2RhbbhvZzD1k6tBCFFCdMWcY= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=JCNfjSAG; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf08.hostedemail.com: domain of dan.j.williams@intel.com designates 134.134.136.31 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663299335; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=yDhWgkGnFcULcWPVdwPBarlx337nQjWxNrIx6swgbO4=; b=riEremv5yNFZNIAJhVLJivlTpVKklhGwMlgGZM7FkwIn+cnbCCsx1IOdJISsfJwzYfwC+y 7/E9uT58OsKdwe3TNHweZRYcpdzEiHPxTDgiiF2r7iaAXR9oU6fmYqpLgMOwHpMlYt6SCv jmPW3VD4gf9ssVRYYNOZkOQaKGzdItU= X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: E39F41600AA Authentication-Results: imf08.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=JCNfjSAG; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf08.hostedemail.com: domain of dan.j.williams@intel.com designates 134.134.136.31 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com X-Stat-Signature: bp15tbn4ydq5jpsxqh76rmyxpggjgqgk X-HE-Tag: 1663299334-98886 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: In preparation for moving DAX pages to be 0-based rather than 1-based for the idle refcount, the fsdax core wants to have all mappings in a "zapped" state before truncate. For typical pages this happens naturally via unmap_mapping_range(), for DAX pages some help is needed to record this state in the 'struct address_space' of the inode(s) where the page is mapped. That "zapped" state is recorded in DAX entries as a side effect of ext4_break_layouts(). Arrange for it to be called before all truncation events which already happens for truncate() and PUNCH_HOLE, but not truncate_inode_pages_final(). Arrange for ext4_break_layouts() before truncate_inode_pages_final(). Cc: Matthew Wilcox Cc: Jan Kara Cc: "Darrick J. Wong" Cc: Jason Gunthorpe Cc: Christoph Hellwig Cc: John Hubbard Signed-off-by: Dan Williams --- fs/ext4/inode.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 478ec6bc0935..326269ad3961 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -207,7 +207,11 @@ void ext4_evict_inode(struct inode *inode) jbd2_complete_transaction(journal, commit_tid); filemap_write_and_wait(&inode->i_data); } + + filemap_invalidate_lock(inode->i_mapping); + ext4_break_layouts(inode); truncate_inode_pages_final(&inode->i_data); + filemap_invalidate_unlock(inode->i_mapping); goto no_delete; } @@ -218,7 +222,11 @@ void ext4_evict_inode(struct inode *inode) if (ext4_should_order_data(inode)) ext4_begin_ordered_truncate(inode, 0); + + filemap_invalidate_lock(inode->i_mapping); + ext4_break_layouts(inode); truncate_inode_pages_final(&inode->i_data); + filemap_invalidate_unlock(inode->i_mapping); /* * For inodes with journalled data, transaction commit could have