Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp110586lqg; Wed, 10 Apr 2024 17:58:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWXuiL/Pl4VtF4GO8YndDYhdlwuZmohNx6FDPNfyPOj7sx/3Ez4blrb782Osj1r6l85AKRzuBzYBzxdJ5uP1XeVqXeDIKD32T2gWzIJhg== X-Google-Smtp-Source: AGHT+IFLHLB+tdHi4wF0HhXzgUxml5b13f6qSJOhTkJjWQra31LSHBfeVwPu3HUAzu8Hqv4GwetC X-Received: by 2002:a05:6214:2464:b0:699:1763:16bf with SMTP id im4-20020a056214246400b00699176316bfmr4269194qvb.43.1712797126596; Wed, 10 Apr 2024 17:58:46 -0700 (PDT) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id z14-20020a0cda8e000000b0069b29ce9e35si433236qvj.286.2024.04.10.17.58.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 17:58:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-2014-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b="szgG42R/"; arc=fail (signature failed); spf=pass (google.com: domain of linux-ext4+bounces-2014-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2014-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 447E41C20E7F for ; Thu, 11 Apr 2024 00:58:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 52720DDA6; Thu, 11 Apr 2024 00:58:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="szgG42R/" X-Original-To: linux-ext4@vger.kernel.org Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2124.outbound.protection.outlook.com [40.107.223.124]) (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 4CED6D518; Thu, 11 Apr 2024 00:58:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.124 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712797093; cv=fail; b=kmhe6de5wWcmG1x4DMxthzqaGlzPFBdlhtfe+2tCN5dwElEHoci3mDoCEpr3T9LGMmvVnvKF+ZEE6xPFfjIlAmSBSgzj1jSk/AD9N4qd6IvpdXPU80VDOExTlQtrnumZLeX/ifSl228bBPSqQgh192pGKh+vGZioo2qhPCoJess= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712797093; c=relaxed/simple; bh=iDC+XE27WGdKGNBTcifQ/8l3wBTYxkmPBaUhftnB5/I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=sSKW2ankAeexCnGQSTVCSVsHBLWe+GwB5wneXfaJSs63eecH6l572ui1854+c6LCMnJNIvnL6EG/gChGpfAHD5e8n3rdkKvLywsDjlXC8foHlTLXpHEnTRC5yjAtCP+8e4vHY8xr1wQMBaSV4xtt1pKr7tIS6d4fqMPLm95Hphc= 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=szgG42R/; arc=fail smtp.client-ip=40.107.223.124 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 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R5DYjnX0apxHf35/VxJoFF7rkXAeqre03t7VuUoTi3NtzYO2owJqwnUuuYORDzr8Qv86TyJbnrqharMZwLqmK+kiGaKAJHh1bLKQbF4Fn5YSO2mCTeTkd345r44QLhO5JwzVxuBVHRKR0Yjz7WDQprLVcELbM0FnQl/yhg0nGvOuXcbm2DFbGXUErKRKR2NX+u+tK1IiyRZHzDo44ZL6MizyHh9oFN04hDyBmLF2y0z/T47Rd+CtUYGBTn1Op9SZfLQIgSrJaX5Wr7MGxrkryHUElfwNW12dviF+OUiY3xEVLFjmKveb8h9HiNm//l4vLa9fTmz4sKhgS7uggwoHJQ== 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=jWq7sIsAjoy6Q8qfUd969PXNtY0sRneqqLCOZHWtLns=; b=RLdtwsXyOFCH5T0yyXzuLDU0l+H/jt5pSrLvV+0+i5GLqq21YT0B5ZyYM6HgSZWBH/jsq0sf4dX8C20xMBFMwoUZX45Fu4yIgOzFF4QjqxkotnopibtkaVHQeQ+7YTCpG1Qr0+5pTvcAOGjykaDs7F5/Y/4wvMgSkDgSVmYv0WI2QC1pF81jn2E56kZtovsDCnmtHvS4qYHzciy2RqjfV7P3iDyJn+rTHhuYMVV44xR+zZrOEVno0pEQEvy3ZMeCsoxE7bGXrR+T5B4z650L5Wyf75f6R6SruopWZcmS/ckjGzH/A98y7+2IYILh6+qshKekB/8GlNfCaHuEulQWXA== 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=jWq7sIsAjoy6Q8qfUd969PXNtY0sRneqqLCOZHWtLns=; b=szgG42R/j9M9nCh4I9XtGL2akKPtJ0cS+BgO6qry24U79FDmfd4GjY67roQB8re1riD2b4etQCLOphG0EP0bmQtF1NmYbRJ/U0rSSDQZ7culKq26w9vp7EzBE0jlhDHQOfNqnhD8pnvLXfGo8qkT3C2+nxnTAkPRoBORwlEfMFYo5fZurCyECBoa3gVC5tybdjD9P8dMRLAq5jpPZgCuOmDr24imZoBFwTQ0gA4/lwAxw3S5OoTB2YIV6Qxnno8elfkNstR7wGgMgi2eTtDgqttgwCXaI83GZ2TAjxVG7NJl+PUnTFBQBgG3ed/j13ynLD+divxUe7oeT263OW0J1g== 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:09 +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:09 +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 06/10] fs/dax: Add dax_page_free callback Date: Thu, 11 Apr 2024 10:57:27 +1000 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SYBPR01CA0120.ausprd01.prod.outlook.com (2603:10c6:10:1::36) To DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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: b5iZ/h/44MWpPBnZwfbSDpgSF88KmGFRGXL1kx6IDRAcfk7S2uR9dF6nyz7bgXS7yGFKhho1jdW6C92DmEjlsf3I5ATMxwHNZXSHwVU219G3gLw/nXNEpQqIu1e4Jr6KLH3/8Spvu5EoqSYpXbkYvLocpjRlNdmy8lQAGrwfIYLuofDZ+Z13Akzs6te+ha+hd3mFaPsEPikqQeWiMkfGRcE4ajnQQfbVCd50R/IMbuashKyECmTAbMKJCcpOxVMAxaNNlhQXLeEW3JTxzD5d309YkhFQwoo73c2y+7SwXk4ak6fgj5cVwJ3MX0bMAVGv1B24L4h2AlNG5E953B/LfFi3pJ7QL2w+mLmJDJG2vf5icI8H7FIz1ak/YiSci6hkujoCn+CkSH/LUdr9De22YnbkWxogu2wC/vlgaZxbmd7uv5HxI2Gi5cmvMI4VMqwV7unnD+EM/THjbGyLVcaBnLDpzeTzEmifkEyD4Z/n68m4UASifwc3g4bAwHIBCG4hsjdLrBRX0c5p5K6Mc+6spF+7qf8onVQIiqaqFI5TGgifvmNFmZcc7jz40RwjLcVxHDF3oI61o56oQYNy1XTD/BnmLBJ7UsNCBl9rqkmcEXxC9OlJ7oBwliqhxVGRKuq0tJsG7VLnuti1wyCDF3o8/HyTP1wDF8/ULT70ModbxAM= 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: =?us-ascii?Q?Y1djZlK3WKvLZX62X1x7MeSTDIua8cX3Gkaz4MyEAIBoQRQC5ut3+Flxi4A7?= =?us-ascii?Q?TG6cq64Tqi7GME7hQZpJZxASnGVthA1EF4H+1aC1UH1I9zjEFHFna187jmFT?= =?us-ascii?Q?/PIGdxrG4SC2u5GrsTYKxD/YN+iUQWvn946cez+/zqUaTT2Vkd1DzDBy6UmV?= =?us-ascii?Q?m5noEsx0No56g3rLQhvE5u+7VKw/ylOzeRFvOspY1QT1zYEtw9s+drBHbcXa?= =?us-ascii?Q?BY1/4jCy6ftiVFYv7HPJ4jYx7nkBiBtqCUGyBEtP/0UKRyzjWUGslehg/tz6?= =?us-ascii?Q?X4WsL4qZjs1BC7/FmYXFH2n3ZxCFl0ZNJtJx+LMLP2VfB/hvX9jBXMNDJBBe?= =?us-ascii?Q?O4ykmOuE7+7k1n6+vJ2kU7wMmKTapHA26jDd6zyoUPrkMzWpz3C9oaum2mpe?= =?us-ascii?Q?d5AKN/hch4dUxuFmnBsRCbwZV5WrCHSxyfUThCVDdwRNXnN6JEqAP/dQMK+V?= =?us-ascii?Q?56up6DoJP26+HLvyJ0MGxTTugtzE/GZ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B8C0p31zdlwat2VR/3xlv3axSzRILSxDV6ECjjK8lRz/skeUsmltc7gLwDSC?= =?us-ascii?Q?wvtW7Ch/4qzoMKGF9ENFdKopg8+pblVYINvNqlB1BFBU7JojrJcbXP52OJLy?= =?us-ascii?Q?Pi/WhQMcNOoDcHEzlNN1ADYHDcq57hAL9WShmeg30oCOayQk/p+ch21EzmZ/?= =?us-ascii?Q?U2QNv0u4HNGr7KroJZca4lAJtRozL8p8I1Lqjy5c?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: bdc425fe-c4b7-4c63-3363-08dc59c27467 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:09.2440 (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: +wgsujitMp4RQ6awuizuDAa0W13m4lfGYlIt1Ni85t043cRoI2+lAUH1v8gQezl5iK7zfyPLtZr6J3ltwJJUDw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7854 When a fs dax page is freed it has to notify filesystems that the page has been unpinned/unmapped and is free. Currently this involves special code in the page free paths to detect a transition of refcount from 2 to 1 and to call some fs dax specific code. A future change will require this to happen when the page refcount drops to zero. In this case we can use the existing pgmap->ops->page_free() callback so wire that up for all devices that support FS DAX (nvdimm and virtio). Signed-off-by: Alistair Popple --- drivers/nvdimm/pmem.c | 1 + fs/dax.c | 6 ++++++ fs/fuse/virtio_fs.c | 5 +++++ include/linux/dax.h | 1 + 4 files changed, 13 insertions(+) diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 4e8fdcb..b027e1f 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -444,6 +444,7 @@ static int pmem_pagemap_memory_failure(struct dev_pagemap *pgmap, static const struct dev_pagemap_ops fsdax_pagemap_ops = { .memory_failure = pmem_pagemap_memory_failure, + .page_free = dax_page_free, }; static int pmem_attach_disk(struct device *dev, diff --git a/fs/dax.c b/fs/dax.c index a7bd423..17b1c5f 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -1981,3 +1981,9 @@ int dax_remap_file_range_prep(struct file *file_in, loff_t pos_in, pos_out, len, remap_flags, ops); } EXPORT_SYMBOL_GPL(dax_remap_file_range_prep); + +void dax_page_free(struct page *page) +{ + wake_up_var(page); +} +EXPORT_SYMBOL_GPL(dax_page_free); diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c index 5f1be1d..11bfc28 100644 --- a/fs/fuse/virtio_fs.c +++ b/fs/fuse/virtio_fs.c @@ -795,6 +795,10 @@ static void virtio_fs_cleanup_dax(void *data) put_dax(dax_dev); } +static const struct dev_pagemap_ops fsdax_pagemap_ops = { + .page_free = dax_page_free, +}; + static int virtio_fs_setup_dax(struct virtio_device *vdev, struct virtio_fs *fs) { struct virtio_shm_region cache_reg; @@ -827,6 +831,7 @@ static int virtio_fs_setup_dax(struct virtio_device *vdev, struct virtio_fs *fs) return -ENOMEM; pgmap->type = MEMORY_DEVICE_FS_DAX; + pgmap->ops = &fsdax_pagemap_ops; /* Ideally we would directly use the PCI BAR resource but * devm_memremap_pages() wants its own copy in pgmap. So diff --git a/include/linux/dax.h b/include/linux/dax.h index bced4d4..c0c3206 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -212,6 +212,7 @@ 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); +void dax_page_free(struct page *page); static inline int dax_wait_page_idle(struct page *page, void (cb)(struct inode *), struct inode *inode) -- git-series 0.9.1