From: John Groves <j...@groves.net> This is clearly not the right way to set the holder_ops; where & how should this be done? --- drivers/dax/super.c | 16 ++++++++++++++++ include/linux/dax.h | 5 +++++ 2 files changed, 21 insertions(+)
diff --git a/drivers/dax/super.c b/drivers/dax/super.c index 0da9232ea175..3d4e205c1854 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -467,6 +467,22 @@ struct dax_device *alloc_dax(void *private, const struct dax_operations *ops) } EXPORT_SYMBOL_GPL(alloc_dax); +#if IS_ENABLED(CONFIG_DEV_DAX_IOMAP) +/* famfs calls this to add the holder_ops. There is probably a more elegant approach */ +int add_dax_ops( + struct dax_device *dax_dev, + const struct dax_holder_operations *hops) +{ + /* dax_dev->ops should have been populated by devm_create_dev_dax() */ + WARN_ON(!dax_dev->ops); + + /* Use cmpxchg? */ + dax_dev->holder_ops = hops; + return 0; +} +EXPORT_SYMBOL_GPL(add_dax_ops); +#endif /* DEV_DAX_IOMAP */ + void put_dax(struct dax_device *dax_dev) { if (!dax_dev) diff --git a/include/linux/dax.h b/include/linux/dax.h index b463502b16e1..31b68667b3cb 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -57,6 +57,11 @@ struct dax_holder_operations { #if IS_ENABLED(CONFIG_DAX) struct dax_device *alloc_dax(void *private, const struct dax_operations *ops); + +#if IS_ENABLED(CONFIG_DEV_DAX_IOMAP) +int add_dax_ops(struct dax_device *dax_dev, + const struct dax_holder_operations *hops); +#endif void *dax_holder(struct dax_device *dax_dev); void put_dax(struct dax_device *dax_dev); void kill_dax(struct dax_device *dax_dev); -- 2.40.1