Re: [PATCH v8 7/9] dax: add dax holder helper for filesystems

2021-12-15 Thread Christoph Hellwig
On Wed, Dec 15, 2021 at 10:21:00AM +0800, Shiyang Ruan wrote:
> 
> 
> 在 2021/12/14 23:47, Christoph Hellwig 写道:
> > On Thu, Dec 02, 2021 at 04:48:54PM +0800, Shiyang Ruan wrote:
> > > Add these helper functions, and export them for filesystem use.
> > 
> > What is the point of adding these wrappers vs just calling the
> > underlying functions?
> 
> I added them so that they can be called in a friendly way, even if
> CONFIG_DAX is off.  Otherwise, we need #if IS_ENABLED(CONFIG_DAX) to wrap
> them where they are called.

No need for wrappers, you can stub out the underlying functions as well.



Re: [PATCH v8 7/9] dax: add dax holder helper for filesystems

2021-12-14 Thread Shiyang Ruan




在 2021/12/14 23:47, Christoph Hellwig 写道:

On Thu, Dec 02, 2021 at 04:48:54PM +0800, Shiyang Ruan wrote:

Add these helper functions, and export them for filesystem use.


What is the point of adding these wrappers vs just calling the
underlying functions?


I added them so that they can be called in a friendly way, even if 
CONFIG_DAX is off.  Otherwise, we need #if IS_ENABLED(CONFIG_DAX) to 
wrap them where they are called.



--
Thanks,
Ruan.





Re: [PATCH v8 7/9] dax: add dax holder helper for filesystems

2021-12-14 Thread Christoph Hellwig
On Thu, Dec 02, 2021 at 04:48:54PM +0800, Shiyang Ruan wrote:
> Add these helper functions, and export them for filesystem use.

What is the point of adding these wrappers vs just calling the
underlying functions?



[PATCH v8 7/9] dax: add dax holder helper for filesystems

2021-12-02 Thread Shiyang Ruan
Add these helper functions, and export them for filesystem use.

Signed-off-by: Shiyang Ruan 
---
 drivers/dax/super.c | 19 +++
 include/linux/dax.h | 15 +++
 2 files changed, 34 insertions(+)

diff --git a/drivers/dax/super.c b/drivers/dax/super.c
index a19fcc0a54f3..acbe7078ce4c 100644
--- a/drivers/dax/super.c
+++ b/drivers/dax/super.c
@@ -114,6 +114,25 @@ struct dax_device *fs_dax_get_by_bdev(struct block_device 
*bdev, u64 *start_off)
return dax_dev;
 }
 EXPORT_SYMBOL_GPL(fs_dax_get_by_bdev);
+
+void fs_dax_register_holder(struct dax_device *dax_dev, void *holder,
+   const struct dax_holder_operations *ops)
+{
+   dax_set_holder(dax_dev, holder, ops);
+}
+EXPORT_SYMBOL_GPL(fs_dax_register_holder);
+
+void fs_dax_unregister_holder(struct dax_device *dax_dev)
+{
+   dax_set_holder(dax_dev, NULL, NULL);
+}
+EXPORT_SYMBOL_GPL(fs_dax_unregister_holder);
+
+void *fs_dax_get_holder(struct dax_device *dax_dev)
+{
+   return dax_get_holder(dax_dev);
+}
+EXPORT_SYMBOL_GPL(fs_dax_get_holder);
 #endif /* CONFIG_BLOCK && CONFIG_FS_DAX */
 
 enum dax_device_flags {
diff --git a/include/linux/dax.h b/include/linux/dax.h
index 500d048d444e..15a0ad4c248d 100644
--- a/include/linux/dax.h
+++ b/include/linux/dax.h
@@ -140,6 +140,10 @@ static inline void fs_put_dax(struct dax_device *dax_dev)
 {
put_dax(dax_dev);
 }
+void fs_dax_register_holder(struct dax_device *dax_dev, void *holder,
+   const struct dax_holder_operations *ops);
+void fs_dax_unregister_holder(struct dax_device *dax_dev);
+void *fs_dax_get_holder(struct dax_device *dax_dev);
 #else
 static inline int dax_add_host(struct dax_device *dax_dev, struct gendisk 
*disk)
 {
@@ -156,6 +160,17 @@ static inline struct dax_device *fs_dax_get_by_bdev(struct 
block_device *bdev,
 static inline void fs_put_dax(struct dax_device *dax_dev)
 {
 }
+static inline void fs_dax_register_holder(struct dax_device *dax_dev,
+   void *holder, const struct dax_holder_operations *ops)
+{
+}
+static inline void fs_dax_unregister_holder(struct dax_device *dax_dev)
+{
+}
+static inline void *fs_dax_get_holder(struct dax_device *dax_dev)
+{
+   return NULL;
+}
 #endif /* CONFIG_BLOCK && CONFIG_FS_DAX */
 
 #if IS_ENABLED(CONFIG_FS_DAX)
-- 
2.34.0