On 08.09.2025 10:59, vasileios.almpa...@virtuozzo.com wrote:
From: Vasileios Almpanis <vasileios.almpa...@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.

Link to the jira id, please.

"Feature:" line, please.


Signed-off-by: Vasileios Almpanis <vasileios.almpa...@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));

1. better to variable definitions before actual code in the function.
   https://docs.kernel.org/process/maintainer-tip.html

   > It’s way better to move the initialization to a separate line after the 
declarations:
   > ...

2. here we directly access md->disk, and also include "dm-core.h",
   may be to drop it here as well?

Like:

+++ b/drivers/md/dm-ploop-target.c
@@ -22,7 +22,6 @@
 #include <linux/timer.h>
 #include <linux/error-injection.h>
 #include "dm-ploop.h"
-#include "dm-core.h"

 #define DM_MSG_PREFIX "ploop"

@@ -390,7 +389,11 @@ 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;
+       int minor;
+
+       md = dm_table_get_md(ploop->ti->table);
+       minor = MINOR(disk_devt(dm_disk(md)));

        worker = kzalloc(sizeof(*worker), GFP_KERNEL_ACCOUNT);
        if (!worker)

======================

        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"

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to