[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d3b9699a56edefe16b695ac09ed659c13391a0d5.1712796818.git-series.apopple@nvidia.com>
Date: Thu, 11 Apr 2024 10:57:27 +1000
From: Alistair Popple <apopple@...dia.com>
To: linux-mm@...ck.org
Cc: david@...morbit.com,
dan.j.williams@...el.com,
jhubbard@...dia.com,
rcampbell@...dia.com,
willy@...radead.org,
jgg@...dia.com,
linux-fsdevel@...r.kernel.org,
jack@...e.cz,
djwong@...nel.org,
hch@....de,
david@...hat.com,
ruansy.fnst@...itsu.com,
nvdimm@...ts.linux.dev,
linux-xfs@...r.kernel.org,
linux-ext4@...r.kernel.org,
jglisse@...hat.com,
Alistair Popple <apopple@...dia.com>
Subject: [RFC 06/10] fs/dax: Add dax_page_free callback
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 <apopple@...dia.com>
---
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
Powered by blists - more mailing lists