Skip to contentSkip to conversation

Remove path-selector's dependency to dm-mpath

PATCH New Kiyoshi Ueda 1 participant 4 messages Apr 10, 2008 Device mapper

lore
Share & tools
lore
#0 lore raw

cover Remove path-selector's dependency to dm-mpath

Hi Alasdair and List,

This patch-set removes path-selector's dependency to dm-mpath. No functional change.

So we can share the same path selector for multipath target with other targets.

It might be better to find a different word than 'path' because it's no longer about 'path'.
I left the names unchanged to avoid bloating the patches. If you have a good idea, please let me know.

Any comments are very appreciated.

If no problem, please apply.
The patch-set was created on top of 2.6.25-rc8.

Thanks,
Kiyoshi Ueda

#1 lore raw

PATCH 1/3 dm: move dm_path to include/linux/device-mapper.h

This patch moves struct dm_path to include/linux/device-mapper.h from drivers/md/dm-mpath.h.
No functional change.

Path selector is using struct dm_path as an interface structure for multipath target.
By moving the interface to dm core, other targets can use path selector.

---
 drivers/md/dm-mpath.h         |   10 +---------
 drivers/md/dm-path-selector.h |    2 --
 include/linux/device-mapper.h |    8 ++++++++
 3 files changed, 9 insertions(+), 11 deletions(-)
drivers/md/dm-mpath.h +1 -9
Index: 2.6.25-rc8/drivers/md/dm-mpath.h
===================================================================
@@ -9,15 +9,7 @@
 #ifndef	DM_MPATH_H
 #define	DM_MPATH_H
 
-struct dm_dev;
-
-struct dm_path {
-	struct dm_dev *dev;	/* Read-only */
-	unsigned is_active;	/* Read-only */
-
-	void *pscontext;	/* For path-selector use */
-	void *hwhcontext;	/* For hw-handler use */
-};
+struct dm_path;
 
 /* Callback for hwh_pg_init_fn to use when complete */
 void dm_pg_init_complete(struct dm_path *path, unsigned err_flags);
drivers/md/dm-path-selector.h +0 -2
Index: 2.6.25-rc8/drivers/md/dm-path-selector.h
===================================================================
@@ -14,8 +14,6 @@
 
 #include <linux/device-mapper.h>
 
-#include "dm-mpath.h"
-
 /*
  * We provide an abstraction for the code that chooses which path
  * to send some io down.
include/linux/device-mapper.h +8 -0
Index: 2.6.25-rc8/include/linux/device-mapper.h
===================================================================
@@ -146,6 +146,14 @@ struct dm_target {
 	char *error;
 };
 
+struct dm_path {
+	struct dm_dev *dev;	/* Read-only */
+	unsigned is_active;	/* Read-only */
+
+	void *pscontext;	/* For path-selector use */
+	void *hwhcontext;	/* For hw-handler use */
+};
+
 int dm_register_target(struct target_type *t);
 int dm_unregister_target(struct target_type *t);
 
#2 lore raw

PATCH 2/3 dm-mpath: move is_active to pgpath from dm_path

In reply to Kiyoshi Ueda

This patch moves 'is_active' in struct dm_path to struct pgpath. No functional change.

The is_active is multipath target dependent. Other dm modules don't see it.
So moving it to struct pgpath.

---
 drivers/md/dm-mpath.c         |   13 +++++++------
 include/linux/device-mapper.h |    2 --
 2 files changed, 7 insertions(+), 8 deletions(-)
drivers/md/dm-mpath.c +7 -6
Index: 2.6.25-rc8/drivers/md/dm-mpath.c
===================================================================
@@ -30,6 +30,7 @@ struct pgpath {
 	struct list_head list;
 
 	struct priority_group *pg;	/* Owning PG */
+	unsigned is_active;		/* Path status */
 	unsigned fail_count;		/* Cumulative failure count */
 
 	struct dm_path path;
@@ -120,7 +121,7 @@ static struct pgpath *alloc_pgpath(void)
 	struct pgpath *pgpath = kzalloc(sizeof(*pgpath), GFP_KERNEL);
 
 	if (pgpath)
-		pgpath->path.is_active = 1;
+		pgpath->is_active = 1;
 
 	return pgpath;
 }
@@ -844,13 +845,13 @@ static int fail_path(struct pgpath *pgpa
 
 	spin_lock_irqsave(&m->lock, flags);
 
-	if (!pgpath->path.is_active)
+	if (!pgpath->is_active)
 		goto out;
 
 	DMWARN("Failing path %s.", pgpath->path.dev->name);
 
 	pgpath->pg->ps.type->fail_path(&pgpath->pg->ps, &pgpath->path);
-	pgpath->path.is_active = 0;
+	pgpath->is_active = 0;
 	pgpath->fail_count++;
 
 	m->nr_valid_paths--;
@@ -880,7 +881,7 @@ static int reinstate_path(struct pgpath 
 
 	spin_lock_irqsave(&m->lock, flags);
 
-	if (pgpath->path.is_active)
+	if (pgpath->is_active)
 		goto out;
 
 	if (!pgpath->pg->ps.type) {
@@ -894,7 +895,7 @@ static int reinstate_path(struct pgpath 
 	if (r)
 		goto out;
 
-	pgpath->path.is_active = 1;
+	pgpath->is_active = 1;
 
 	m->current_pgpath = NULL;
 	if (!m->nr_valid_paths++ && m->queue_size)
@@ -1256,7 +1257,7 @@ static int multipath_status(struct dm_ta
 
 			list_for_each_entry(p, &pg->pgpaths, list) {
 				DMEMIT("%s %s %u ", p->path.dev->name,
-				       p->path.is_active ? "A" : "F",
+				       p->is_active ? "A" : "F",
 				       p->fail_count);
 				if (pg->ps.type->status)
 					sz += pg->ps.type->status(&pg->ps,
include/linux/device-mapper.h +0 -2
Index: 2.6.25-rc8/include/linux/device-mapper.h
===================================================================
@@ -148,8 +148,6 @@ struct dm_target {
 
 struct dm_path {
 	struct dm_dev *dev;	/* Read-only */
-	unsigned is_active;	/* Read-only */
-
 	void *pscontext;	/* For path-selector use */
 	void *hwhcontext;	/* For hw-handler use */
 };
#3 lore raw

PATCH 3/3 dm-mpath: remove hwhcontext from dm_path

In reply to Kiyoshi Ueda

This patch removes 'hwhcontext' from struct dm_path. No functional change.

The hwhcontext should be moved to struct pgpath or somewhere related to only multipath target, since hardware handler is multipath target dependent.

However, only dm-mpath-hp-sw.c is using the hwhcontext now, and using it is not necessary. So just remove it.

---
 drivers/md/dm-mpath-hp-sw.c   |    7 +++----
 include/linux/device-mapper.h |    1 -
 2 files changed, 3 insertions(+), 5 deletions(-)
drivers/md/dm-mpath-hp-sw.c +3 -4
Index: 2.6.25-rc8/drivers/md/dm-mpath-hp-sw.c
===================================================================
@@ -117,12 +117,12 @@ out:
  * 1. Make timeout configurable
  * 2. Preallocate request
  */
-static struct request *hp_sw_get_request(struct dm_path *path)
+static struct request *hp_sw_get_request(struct dm_path *path,
+					 struct hp_sw_context *h)
 {
 	struct request *req;
 	struct block_device *bdev = path->dev->bdev;
 	struct request_queue *q = bdev_get_queue(bdev);
-	struct hp_sw_context *h = path->hwhcontext;
 
 	req = blk_get_request(q, WRITE, GFP_NOIO);
 	if (!req)
@@ -170,10 +170,9 @@ static void hp_sw_pg_init(struct hw_hand
 	struct request *req;
 	struct hp_sw_context *h;
 
-	path->hwhcontext = hwh->context;
 	h = hwh->context;
 
-	req = hp_sw_get_request(path);
+	req = hp_sw_get_request(path, h);
 	if (!req) {
 		DMERR("%s path activation command - allocation fail",
 		      path->dev->name);
include/linux/device-mapper.h +0 -1
Index: 2.6.25-rc8/include/linux/device-mapper.h
===================================================================
@@ -149,7 +149,6 @@ struct dm_target {
 struct dm_path {
 	struct dm_dev *dev;	/* Read-only */
 	void *pscontext;	/* For path-selector use */
-	void *hwhcontext;	/* For hw-handler use */
 };
 
 int dm_register_target(struct target_type *t);