From patchwork Thu Apr 11 00:57:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 13625227 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 3107ACD11C2 for ; Thu, 11 Apr 2024 00:58:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B50496B0098; Wed, 10 Apr 2024 20:58:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AFE4D6B0099; Wed, 10 Apr 2024 20:58:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 92A3F6B009A; Wed, 10 Apr 2024 20:58:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 747746B0098 for ; Wed, 10 Apr 2024 20:58:10 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3EC901606EA for ; Thu, 11 Apr 2024 00:58:10 +0000 (UTC) X-FDA: 81995439540.29.7F3E5FF Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2102.outbound.protection.outlook.com [40.107.223.102]) by imf26.hostedemail.com (Postfix) with ESMTP id 85B79140011 for ; Thu, 11 Apr 2024 00:58:07 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=F08WxOof; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf26.hostedemail.com: domain of apopple@nvidia.com designates 40.107.223.102 as permitted sender) smtp.mailfrom=apopple@nvidia.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712797087; 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=2yZDNSwFmOleRmlQ9ijesy2TEv/PIC4tH282yyLCCCs=; b=3VguRsKhW3HOR8wIlLvLBRFp+vfdN86JlZ6DllB2kRgkA48y6ykAf5ii0/df5qQXwpEOp6 oPLi9daBqwZq231+68sJr9sz4rjn79rDqQd+Zqnb8A4jCz/SScHAPiKjRyFrzul/d6GetO 9fINvLmh/7mbHA/DQJtOVu2CR8htfTQ= ARC-Authentication-Results: i=2; imf26.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=F08WxOof; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf26.hostedemail.com: domain of apopple@nvidia.com designates 40.107.223.102 as permitted sender) smtp.mailfrom=apopple@nvidia.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1712797087; a=rsa-sha256; cv=pass; b=ZZoDdGU5otJD22cTVwai3I0tIHTJiCK7NLEfUC5xRK3473/WZ9oFloqs2KXbHLczrd98Pb Jbp+zVySJumlxkFd26dfIPZcMd1LGO59z8f+FXQcd4nomaW5jjiO06EDeXcloU855GGtf7 LBuH2L53qe5jnt/Cnq9aID0KydNhMoQ= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j2FaAxTUe3sHjY8WnDecl/Q8SwIfRVJO/PW1OqZ4YYuVO1KlLFzUrOnyR35kYWP8j1q37MMLydz3RUQQ+SR07SaKPbeMp7q2JVk6wFJiv2ASwxLyHwWv0gEx++nuDfdp8HOD5yhqdtLfJ+XgyWfwEQp3peShvEe4fYtEjiaeFgBJZ/elgTXpLc7gy9tahzK44X72A8/T86CYcbHa3TdWe8rqThu2ix7zsrbamB75lRdJl1crf6bCXNqSuRUXPSwc/152uC+HsGAXxzMhqqK7IV4W26Z4LlfRaY7to1KIwWk9mCmNa52llGxcOAPuG32Tp+T/kxdAJQ/ZE9lZz8P0tQ== 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=2yZDNSwFmOleRmlQ9ijesy2TEv/PIC4tH282yyLCCCs=; b=MMSDR+uOX5857gLmXHcZ+Q1BGonH8lEpfXIj/vmISygjY4kuhyntP7Ox4p2+b4O3/yX7xde2eAzEyR7A0MIFEFn2hMAe48bjRX7N7lsVbvoUHTD97wSFMk5XQu2RkNi4Iqn/W8rLhJRgxnMc5jMASqceh0VOIAtxCPQFaMMhFK/aN7MyzvaBtFFr1M8Ab8wz6rVNlDs4rZ9B1ghKoIT7plMgj/bNk2hwBJwopMlfbMVeHiNExKjkEK+YeQ2GWLrAYkzjOu1FY1EtX+8esLK6YElDgwUuD3uqr9SqPYyFVexOabyBQ5Ouh7+VDJgHYwa/vfue4i9bjB30R1nlBSyNGA== 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=2yZDNSwFmOleRmlQ9ijesy2TEv/PIC4tH282yyLCCCs=; b=F08WxOofz41eUBFVf8o8sSI6JW9BnpM2C4nn/a55KP1+0qiK3tmMbxZ/Oyl74C+PwOjFWnAyvRMMKPD0BpxL4zGMFoATQRc0IeeihnxCUagkEm8kVz1G43A9atOx9fx7aE8oFsu0P07rQYAtREDirMXV+Nhy/qsy0NG9atZ9M9PRzTtVa5BqjPIV0ON3L6GAMQq3mpyG1MWg+YRHNSJFkMebHr08vm0A12Y3JzKGnP7UW9plDYE/sikk6qyV1JR6cN5U1CW4/u1Ug2ylmSgR1yj3YiERaK66X7MEjwfgN/ys0gDNWCz07Z9pHrQ10IRXqdisrEoFnpwhNSLGZJivmg== Received: from DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) by SN7PR12MB7854.namprd12.prod.outlook.com (2603:10b6:806:32b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Thu, 11 Apr 2024 00:58:04 +0000 Received: from DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::c5de:1187:4532:de80]) by DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::c5de:1187:4532:de80%7]) with mapi id 15.20.7409.042; Thu, 11 Apr 2024 00:58:04 +0000 From: Alistair Popple To: linux-mm@kvack.org Cc: david@fromorbit.com, dan.j.williams@intel.com, jhubbard@nvidia.com, rcampbell@nvidia.com, willy@infradead.org, jgg@nvidia.com, linux-fsdevel@vger.kernel.org, jack@suse.cz, djwong@kernel.org, hch@lst.de, david@redhat.com, ruansy.fnst@fujitsu.com, nvdimm@lists.linux.dev, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, jglisse@redhat.com, Alistair Popple Subject: [RFC 05/10] fs/dax: Refactor wait for dax idle page Date: Thu, 11 Apr 2024 10:57:26 +1000 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: X-ClientProxiedBy: SY5P282CA0131.AUSP282.PROD.OUTLOOK.COM (2603:10c6:10:209::12) To DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR12MB7726:EE_|SN7PR12MB7854:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: e0ET+aGVLefGTWYo30JnMXEE3u800qBxVAayq/C7mz8dmKGyv83S0FYL97C12/LBQVbTea7kLaIO5CBGbchodsVr3czTOmJUrSZyNPIGtIULJ56iBWeCyw2H9K78oauJ17TVB8gI0DK0lMTVzZoNw7CLOr18W6GtIG7OtXqT1ITBud+ufcUilegNiItWXkO1GPJ9TEgGq8OfEvYeKXbuuPP7fWKf3WLtc9rXHmDIUruwAwQ6aXnejsBBOHO3GWtIDKgn0DgmpyqxevoNrdzZDnoutEIs0diUSN0/BZ6h6yjkBYptMt9RZFnT5N+tC7P2qXvI6ltqsd1x2FxuKJr0QXzHp1xJtuhyBjYGN/aTZ6lOIlg+jpXxhaZgZFcYEMELQV0cSMl+5SZcE9PFhpNLOjfI8vmy5WmxA8xlXCmAqiXxDoNS/vyMZtKFuC2UDdGmdD/ifhwqYwnT3WIcGZl1n9+EQQ2joGkFtPxapEAHR1iC35xxVGjcb2wrONGpfJZRQzIe01JbvL/E9FeGiwaHE4GRFVZLKPwUBKG5j4cX4KsOUoqLs2iimgwbY/F0k0vBn8baR6c8HrJfrNw6WwkCAXy+FaFltG4Ue2KLq7WoX/2KcQVSa77SN4/DpbZ0L/+5D4wynQQEIgdfKQexmzf6HPXKEucmY14TmMeOoMCR83U= 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:(13230031)(376005)(1800799015)(366007)(7416005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: o7kg0CV6A59ijmy/CoOAddz7eDQhDfTEMHPkhbdQG/BdGJOTvLJv5qAJWXxQsmoytrzn7i8hn/KiHoMs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xpPCiMHtpWvPUSm4D30YIGhUvcTd4+zO1pscBbTikafZTL2CbHLVgKDmsvUvic0YKOQulAo0Ue+Q4En5IEsNU27aNltcWChiS9Cz4rV77386NpMXSDJpuBIC/Vu7wglqDZxORQ6HBWnAB/fN9Fr+IrA7XuUHGRTbH79EcNtuts7h8X3l219us2M6jaANucS8uaaVnAg1NRCHPa742NJ0lKDdvvZiCm5SrGgBqx5Ur8VOCvxxRSZP9rfMQwo454uoJ7UIhyYVntF913dOU6HQxLUFruYO5pDOloRrwWYEIxBf7yEliN1181Kwo04keJnhuTrQNj1t0SHeanMD/4xD32HbdyUnH7vd/flDNsVkQMVLjDbxDUiOfvAUl+9teC2YNaXW9r/YiJIduJzVIU0wSfJLlGgTDohJkYgvfYlSLgjgAdpbNCWTMwXraY03OcAcC X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8845a362-aa4f-42d9-b2f1-08dc59c27159 X-MS-Exchange-CrossTenant-AuthSource: DS0PR12MB7726.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2024 00:58:04.1629 (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: ihpSG2u9CwbxReOsE/Nisc4VreTaEN7fccFZPhwjYo2DpMdmBiXDOn/nyYht2enfcHoHxToIvEwXuz8ny671tg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7854 X-Rspam-User: X-Stat-Signature: rsieixytbiwcjjbihpfuuz3nwkamphtj X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 85B79140011 X-HE-Tag: 1712797087-285309 X-HE-Meta: U2FsdGVkX18oGHG3wyBGRG2WBXVbcYoOssaiwBe3awhsqdbMbfwDNSjW/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fSA/CUfUZCvoJY62P9XWTgm82QgIXFU9Mnkg3zew4fPrJC4eeQmntCYfjzMwNIrYPcS 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: List-Subscribe: List-Unsubscribe: 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 --- fs/ext4/inode.c | 5 +---- fs/fuse/dax.c | 4 +--- fs/xfs/xfs_file.c | 4 +--- include/linux/dax.h | 11 +++++++++++ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 4ce35f1..e9cef7d 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3868,10 +3868,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 23904a6..8a62483 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_file.c b/fs/xfs/xfs_file.c index 2037002..099cd70 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -849,9 +849,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 22cd990..bced4d4 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -212,6 +212,17 @@ 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) +{ + int ret; + + ret = ___wait_var_event(page, page_ref_count(page) == 1, + TASK_INTERRUPTIBLE, 0, 0, cb(inode)); + return ret; +} + #if IS_ENABLED(CONFIG_DAX) int dax_read_lock(void); void dax_read_unlock(int id);