[Devel] [PATCH 1/1] dm-ploop: drop use of dm-core.h in dm-ploop.h and dm-qcow2.h #VSTOR-111632

Andrey Zhadchenko andrey.zhadchenko at virtuozzo.com
Fri Sep 12 13:47:32 MSK 2025


LGTM

Reviewed-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>

On 9/8/25 10:59, vasileios.almpanis at virtuozzo.com wrote:
> From: Vasileios Almpanis <vasileios.almpanis at virtuozzo.com>
> 
> commit '4cc96131afce' mentions:
>    "DM targets should _never_ include dm-core.h!"
> 
> Remove the includes and use helpers like dm_table_get_md
> and dm_disk since md->queue = md->disk->queue.
> 
> Signed-off-by: Vasileios Almpanis <vasileios.almpanis at virtuozzo.com>
> ---
>   drivers/md/dm-ploop-target.c | 5 ++++-
>   drivers/md/dm-ploop.h        | 6 +++---
>   drivers/md/dm-qcow2.h        | 3 +--
>   3 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/md/dm-ploop-target.c b/drivers/md/dm-ploop-target.c
> index 8b73ec8d7b43..eba70aeb8e2f 100644
> --- a/drivers/md/dm-ploop-target.c
> +++ b/drivers/md/dm-ploop-target.c
> @@ -390,7 +390,10 @@ static struct ploop_worker *ploop_worker_create(struct ploop *ploop,
>   {
>   	struct ploop_worker *worker;
>   	struct task_struct *task;
> -	int minor = MINOR(disk_devt(ploop->ti->table->md->disk));
> +	struct mapped_device *md = NULL;
> +
> +	md = dm_table_get_md(ploop->ti->table);
> +	int minor = MINOR(disk_devt(md->disk));
>   
>   	worker = kzalloc(sizeof(*worker), GFP_KERNEL_ACCOUNT);
>   	if (!worker)
> diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
> index 5a88664feb68..54d51ab8126b 100644
> --- a/drivers/md/dm-ploop.h
> +++ b/drivers/md/dm-ploop.h
> @@ -10,7 +10,6 @@
>   
>   #include <linux/device-mapper.h>
>   #include <linux/bio.h>
> -#include "dm-core.h"
>   
>   #define PLOOP_MAP_OFFSET 16
>   typedef u32 map_index_t;
> @@ -271,7 +270,8 @@ struct ploop {
>   	atomic_t inflight_md;
>   	struct wait_queue_head inflight_md_wq;
>   };
> -#define ploop_blk_queue(p) ((p)->ti->table->md->queue)
> +
> +#define ploop_blk_queue(p) (dm_disk(dm_table_get_md((p)->ti->table))->queue)
>   
>   struct ploop_rq {
>   	struct request *rq;
> @@ -578,7 +578,7 @@ static inline void ploop_free_pio(struct ploop *ploop, struct pio *pio)
>   
>   static inline const char *ploop_device_name(struct ploop *ploop)
>   {
> -	return ploop->ti->table->md->disk->disk_name;
> +	return dm_disk(dm_table_get_md(ploop->ti->table))->disk_name;
>   }
>   
>   static inline void ploop_add_dirty_for_wb(struct ploop *ploop, struct md_page *md)
> diff --git a/drivers/md/dm-qcow2.h b/drivers/md/dm-qcow2.h
> index 5aa00c6a5ebd..bdc96f921af9 100644
> --- a/drivers/md/dm-qcow2.h
> +++ b/drivers/md/dm-qcow2.h
> @@ -6,7 +6,6 @@
>   #include <linux/device-mapper.h>
>   #include <linux/fs.h>
>   #include <linux/eventfd.h>
> -#include "dm-core.h"
>   
>   #define DM_MSG_PREFIX "qcow2"
>   
> @@ -283,7 +282,7 @@ struct qcow2 {
>   
>   static inline const char *qcow2_device_name(struct dm_target *ti)
>   {
> -	return ti ? ti->table->md->disk->disk_name : "-";
> +	return ti ? dm_disk(dm_table_get_md(ti->table))->disk_name : "-";
>   }
>   
>   #define QCOW2_FMT(fmt) "dm-qcow2: %s: " fmt "\n"



More information about the Devel mailing list