From patchwork Thu Jun 27 00:54:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 13713607 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2062.outbound.protection.outlook.com [40.107.220.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5000C6FC6; Thu, 27 Jun 2024 00:54:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719449698; cv=fail; b=r7/SPcfYz5vq0XfN6oee2l8SDVBY+eXWmHEhdGYpG5FrkxLiU5m2pBaVrlCnbdGj92+azUF3P2iyFHAks2hIVgb1tvPwUQdLVXFDQ58QeT2KFH1IzsHN0R4NI9cwX+pJEtDXdJ3gui0W7otVkT2X8j36Zs47DOSqaamRop9bWKI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719449698; c=relaxed/simple; bh=yRxDZ6fr1cX2nMt3Ynph/cAhrXXy2Mxm2ZTUB5nLWIc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=cUsTK/NXyu4j8zMCLKL5j/4SW/4RArR6vMNkA9Acwi8MbzgLy9QvsHoQVuPVsiJXdRh4heG7iXT15RRn3OT8I5z02hrHVi29ltZt66jwLn7/HX74rHdh3shdF5M8cnoLYICmQuO1XoSZsLdaaGYoikQ3rrbXBowCBjUO23279oE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=VS8XlZaS; arc=fail smtp.client-ip=40.107.220.62 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="VS8XlZaS" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZPDfYzPAFZO4u5U0fZDyPG9SM0ws2UCCHvf5790JCbuCEBgWBvlAaVYcdXPiPxgH/fuZkUMtZLU7wIScmXIKMCgC/1H4wblnLmXMjLIzfG9cQqpVjulK91m85bFvwfsccw9iHNkxVf5vdqFkFIyPNq5Hg6ycV/42FSr30cMhQWzVkKp+x7TbDgSLJMWfZ71pok61y3w2rQJ1ek8bazZ4JuiRxrx+x9sxGpgZzPHk7O6zevkJBFV12RAUCiCeFJLL30CyCp5l/9EoDfyrI4wPW8HM8kvGy7XbpMPPRNiILlOZk8hcu/Y9/EqyU1p3eyILvEW2fsScphhWGlUyEsbnmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mkUV5xCCQA5m1br9rTXYMXBe6uTUnQXYw2g5A0ZnCWs=; b=UHZtML0E7xPH8r4oApQzPKP8F9JSWROAeCUk+Uze6UjBS510khjCgNL/+PDJdFekjFEZtWqpyj05+7NvTuEMD58FEEh4bTeNsV+OmJEKdd+kd41A4RXDT1hrC41pugEDoXEEM8CZCs4eNr2dBiOy0A+vkS5EjBWGov7UOM0WAvDLI+7aAqA6pn5/AJWMB/LdXeyi29QKIueg0jJzCu8+fh81XTJN05nKNF01oisptrJwk4Ej5Bavf27aFpGAJSZ6NfgR4lvdn94UCIEi9AkzzwpUkfcZCrZ0srao/iKf4IYL0jt7/ZR8lc7lFGW62egssA+UBsVW0uXXTv+BMlRYMA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mkUV5xCCQA5m1br9rTXYMXBe6uTUnQXYw2g5A0ZnCWs=; b=VS8XlZaSL4vliXrE93EJBTfkYq47yLhn4gs5eXtHKXZFH1jTJTKBDlkAE4sKSRP0s1UyWD60ysH9GCHx/ieA5kRuEvObXIlS+a0+cwb0KvHe+weZptUlLRReOZ2bo0gncJGecK8mbQ56hLiy5+bS/u6STrDt26Q0ovbVsR5uCMVa/8av13DMgI/oAn7ciKpgzNGGmgq202TzW1N/sKgAs3zYRS7RC8pEIHgl+WyRfbvkEBAo0LJNu4xMfELZoiUAMciuPtGDbU4fCs9B+BkXN1ndxbNvjDfGhbLSZvNE7NUNLCvErTVXt/s1Xakvw+zgYUJNvQzuhJM7V69kPXf8rQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) by MW6PR12MB7071.namprd12.prod.outlook.com (2603:10b6:303:238::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.32; Thu, 27 Jun 2024 00:54:53 +0000 Received: from DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe]) by DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe%6]) with mapi id 15.20.7698.025; Thu, 27 Jun 2024 00:54:50 +0000 From: Alistair Popple To: dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, logang@deltatee.com, bhelgaas@google.com, jack@suse.cz, jgg@ziepe.ca Cc: catalin.marinas@arm.com, will@kernel.org, mpe@ellerman.id.au, npiggin@gmail.com, dave.hansen@linux.intel.com, ira.weiny@intel.com, willy@infradead.org, djwong@kernel.org, tytso@mit.edu, linmiaohe@huawei.com, david@redhat.com, peterx@redhat.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, jhubbard@nvidia.com, hch@lst.de, david@fromorbit.com, Alistair Popple Subject: [PATCH 03/13] fs/dax: Refactor wait for dax idle page Date: Thu, 27 Jun 2024 10:54:18 +1000 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: X-ClientProxiedBy: SYBPR01CA0185.ausprd01.prod.outlook.com (2603:10c6:10:52::29) To DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR12MB7726:EE_|MW6PR12MB7071:EE_ X-MS-Office365-Filtering-Correlation-Id: e5359390-95cb-49cf-39eb-08dc9643bfa7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: 7cprG3ZHO/n8TBIFj+nmCoFPsYgpW525x6KFdp7aXP1Baxi5Pws2RO++/9nKjb2um6s3JuWGJ6yjhoUp8o3uKjXpT2XOoCMGjiacO1kJ+am7OqjNTNtZxRWcRAz4IMjQYioXDGuPIpUy7hzBUU5VJLb3FMoFWYEpbQWNtDGwLWdXel62gv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E0ZSy9LnR7/NaxVnCizswLyVMmgv9CD8DkeRx+Y5qqu0YSW7dr29187dy/LO9eq/Y1kMBQig/wfCNlN4HbuPV3ACBnFy0Tz6w6KTo3FVL/Fl07IJBsXKA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR12MB7726.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: F659aibZ3vZcoGSv009Kqz79YlJ4kJnGrHfjaZZ6IkUBtSE7tfdpEQ4FcecOBuNVY8r5OsLqlsEMqThN/gkUhqccxVwIUPuJQMIKkDdHAka99M+JmH0Q22mXykwPmXZyUWHOCZuvESAtvqTdqj6eJq5BN2PFtMRGsxlr0JblqRFgF3NaWUBFRGihKClroHNu74gL0hsg6d9s7+DgSRc9qlLZb3cJ/39gXg2rYWQ2hFryGHOwVlyXaE6z9FY1EREZOPDfTOnnFm+vGO/AZnhayUl/Teoy10yBTD3Bhwt2VGA3o4FTLCoO1JPT6uhhYejNocVoNjxWKVKeIsaVxVHwAD1gQOs1tdVcU0yiOFNio1inaLYjxeKIKn3H+wkx4TJT8yfXG2zKRNeTc3pU5pAGr7gJ7RgBDHKT5U9VHvBMIAgIFKwdK8moEw+X+CgeW47uyUjCzssrB+BH6qnHoCC5rNv8x+oqZFGjWEiG0U6vPP1laWsmQxvkKko7HX2pwZ8ZyodljTg5AL6GGN1ZYfEum6PhxP9wCd6YuhfFWRsWo19hKfTb8XLAw7+fob0W8kTeUlLQxyW3Bc+1DH+xv8YtZLsBFgHZnf+samNDEoorPUPuMVdcTOQaBlDzA0lObtpnP3gkz+3jPMmeJJYZQjwzbHByyG/h/HTPtg52OpjW2fCDxPGFs/KLjfGLPrRSW9SSLsacQOaxFAVTNvHeQMef/564GXt2FoN1MEVTSbYFeRVmmCoMqr7eiXX1atFHncCA2NEglX5cUQD1Bgg6UYsG12UGaygBy+n8LoAJ1V/gmiPuoWOy3LGK1bJP15WAIJki/uk3KyYcjbiCEkS/f/RW2sbzJOaidANR2exiyBGBT4mt1Qi/tPI9rLPdSyGzkR+9DzPeHm+Ziw2up6lILdfBo060iU9n+HGm8lezw0nlfOZf46NWgp5hhUO9k28fHD+nTk5SsYw7sahZ66BWiPEPJqH3kkIwn0J1RvoOfQF4TMnUisz6dIebngXoYEKuegQMJxGeTF8grTFAJuZeY+zg8bxqdy4/gLj+96YckT/0gSStuDwRBXCm9+iOSzxHmMWF/GcToviVD8DvgY2Y/NzoHgtzEhbe+XMg/HyXKYUj5uFde9TCy6aMzgh4RtEuY2kaXE5Jc7d7PtRNCIPCSoAzzRuqf/LqvykZbSfX3VN5WVmWSMJCIAiaY7yXtxxefRJ46FW53lsuaZmTSWt973MsT1mCTN8IMJWmhBrcwXe9ksIpEbXjRFxCltpqe1zzyMFJ/5yk3SBsDHLlFtBerSXhG/85GhbmNzhfeYJT57Co9Mks3IKtliTD31WOd+5z5GHk8yQZ03Bv8ihtmwZRrwEF2kGewZ6SeaE/xob98qKTFVuhiaDrxJWJ9e1Uk+4WvUfOMAvzSJo58B58Ao/lGc2qfB+xjvI47LncMlJfKQiLeYm4z9OZAP4/hv47uZpl6UqnN7eRCHrUJcYjFoOtbtF+V1ZRYc32eIzuIyjYiHGOw/6N/og0oK8v/TZo3DdKXeHdZAu7fg3j52Qe72NLALIAXo25U43k74dKsOmPoE12DI68bkwkoQIrBy5fnXFlH2bN X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: e5359390-95cb-49cf-39eb-08dc9643bfa7 X-MS-Exchange-CrossTenant-AuthSource: DS0PR12MB7726.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2024 00:54:50.4900 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: F52wrDVx8N1dKAJsJ1pHfPmD9Tg2c1chNjqp+yzOoQI82P4JSm5DaMh/9rVfkMe2875tmXJ1obHbVT06Og9bog== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB7071 A FS DAX page is considered idle when its refcount drops to one. This is currently open-coded in all file systems supporting FS DAX. Move the idle detection to a common function to make future changes easier. Signed-off-by: Alistair Popple Reviewed-by: Jan Kara Reviewed-by: Christoph Hellwig --- fs/ext4/inode.c | 5 +---- fs/fuse/dax.c | 4 +--- fs/xfs/xfs_inode.c | 4 +--- include/linux/dax.h | 8 ++++++++ 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 4bae9cc..4737450 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3844,10 +3844,7 @@ int ext4_break_layouts(struct inode *inode) if (!page) return 0; - error = ___wait_var_event(&page->_refcount, - atomic_read(&page->_refcount) == 1, - TASK_INTERRUPTIBLE, 0, 0, - ext4_wait_dax_page(inode)); + error = dax_wait_page_idle(page, ext4_wait_dax_page, inode); } while (error == 0); return error; diff --git a/fs/fuse/dax.c b/fs/fuse/dax.c index 12ef91d..da50595 100644 --- a/fs/fuse/dax.c +++ b/fs/fuse/dax.c @@ -676,9 +676,7 @@ static int __fuse_dax_break_layouts(struct inode *inode, bool *retry, return 0; *retry = true; - return ___wait_var_event(&page->_refcount, - atomic_read(&page->_refcount) == 1, TASK_INTERRUPTIBLE, - 0, 0, fuse_wait_dax_page(inode)); + return dax_wait_page_idle(page, fuse_wait_dax_page, inode); } /* dmap_end == 0 leads to unmapping of whole file */ diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index f36091e..b5742aa 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -4243,9 +4243,7 @@ xfs_break_dax_layouts( return 0; *retry = true; - return ___wait_var_event(&page->_refcount, - atomic_read(&page->_refcount) == 1, TASK_INTERRUPTIBLE, - 0, 0, xfs_wait_dax_page(inode)); + return dax_wait_page_idle(page, xfs_wait_dax_page, inode); } int diff --git a/include/linux/dax.h b/include/linux/dax.h index 9d3e332..773dfc4 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -213,6 +213,14 @@ int dax_zero_range(struct inode *inode, loff_t pos, loff_t len, bool *did_zero, int dax_truncate_page(struct inode *inode, loff_t pos, bool *did_zero, const struct iomap_ops *ops); +static inline int dax_wait_page_idle(struct page *page, + void (cb)(struct inode *), + struct inode *inode) +{ + return ___wait_var_event(page, page_ref_count(page) == 1, + TASK_INTERRUPTIBLE, 0, 0, cb(inode)); +} + #if IS_ENABLED(CONFIG_DAX) int dax_read_lock(void); void dax_read_unlock(int id);