All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] dm: move DMF_SUSPENDED flag set before postsuspend
@ 2009-11-20  7:08 Kiyoshi Ueda
  2009-11-20  7:12 ` [PATCH 2/4] dm: rename dm_suspended() to dm_suspended_md() Kiyoshi Ueda
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Kiyoshi Ueda @ 2009-11-20  7:08 UTC (permalink / raw)
  To: Alasdair Kergon, Mike Anderson; +Cc: device-mapper development

This patch moves DMF_SUSPENDED flag set before postsuspend.
No one should care about the ordering, because the flag set and
the postsuspend are protected by a single lock, md->suspend_lock,
and all strict flag-checkers take the lock.

Signed-off-by: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>
Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Cc: Mike Anderson <andmike@linux.vnet.ibm.com>
Cc: Alasdair G Kergon <agk@redhat.com>
---
 drivers/md/dm.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: 2.6.32-rc7/drivers/md/dm.c
===================================================================
--- 2.6.32-rc7.orig/drivers/md/dm.c
+++ 2.6.32-rc7/drivers/md/dm.c
@@ -2542,10 +2542,10 @@ int dm_suspend(struct mapped_device *md,
 	 * requests are being added to md->deferred list.
 	 */
 
-	dm_table_postsuspend_targets(map);
-
 	set_bit(DMF_SUSPENDED, &md->flags);
 
+	dm_table_postsuspend_targets(map);
+
 out:
 	dm_table_put(map);
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/4] dm: rename dm_suspended() to dm_suspended_md()
  2009-11-20  7:08 [PATCH 1/4] dm: move DMF_SUSPENDED flag set before postsuspend Kiyoshi Ueda
@ 2009-11-20  7:12 ` Kiyoshi Ueda
  2009-11-20  7:14 ` [PATCH 3/4] dm: export suspended state Kiyoshi Ueda
  2009-11-20  7:15 ` [PATCH 4/4] dm-mpath: reject message when the device is suspended Kiyoshi Ueda
  2 siblings, 0 replies; 4+ messages in thread
From: Kiyoshi Ueda @ 2009-11-20  7:12 UTC (permalink / raw)
  To: Alasdair Kergon, Mike Anderson; +Cc: device-mapper development

This patch renames dm_suspended() to dm_suspended_md().
No functional change.

Signed-off-by: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>
Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Cc: Mike Anderson <andmike@linux.vnet.ibm.com>
Cc: Alasdair G Kergon <agk@redhat.com>
---
 drivers/md/dm-ioctl.c         |    8 ++++----
 drivers/md/dm-sysfs.c         |    2 +-
 drivers/md/dm.c               |   12 ++++++------
 drivers/md/dm.h               |    5 +++++
 include/linux/device-mapper.h |    1 -
 5 files changed, 16 insertions(+), 12 deletions(-)

Index: 2.6.32-rc7/drivers/md/dm-ioctl.c
===================================================================
--- 2.6.32-rc7.orig/drivers/md/dm-ioctl.c
+++ 2.6.32-rc7/drivers/md/dm-ioctl.c
@@ -547,7 +547,7 @@ static int __dev_status(struct mapped_de
 	param->flags &= ~(DM_SUSPEND_FLAG | DM_READONLY_FLAG |
 			  DM_ACTIVE_PRESENT_FLAG);
 
-	if (dm_suspended(md))
+	if (dm_suspended_md(md))
 		param->flags |= DM_SUSPEND_FLAG;
 
 	param->dev = huge_encode_dev(disk_devt(disk));
@@ -795,7 +795,7 @@ static int do_suspend(struct dm_ioctl *p
 	if (param->flags & DM_NOFLUSH_FLAG)
 		suspend_flags |= DM_SUSPEND_NOFLUSH_FLAG;
 
-	if (!dm_suspended(md))
+	if (!dm_suspended_md(md))
 		r = dm_suspend(md, suspend_flags);
 
 	if (!r)
@@ -837,7 +837,7 @@ static int do_resume(struct dm_ioctl *pa
 			suspend_flags &= ~DM_SUSPEND_LOCKFS_FLAG;
 		if (param->flags & DM_NOFLUSH_FLAG)
 			suspend_flags |= DM_SUSPEND_NOFLUSH_FLAG;
-		if (!dm_suspended(md))
+		if (!dm_suspended_md(md))
 			dm_suspend(md, suspend_flags);
 
 		r = dm_swap_table(md, new_map);
@@ -853,7 +853,7 @@ static int do_resume(struct dm_ioctl *pa
 			set_disk_ro(dm_disk(md), 1);
 	}
 
-	if (dm_suspended(md))
+	if (dm_suspended_md(md))
 		r = dm_resume(md);
 
 
Index: 2.6.32-rc7/drivers/md/dm-sysfs.c
===================================================================
--- 2.6.32-rc7.orig/drivers/md/dm-sysfs.c
+++ 2.6.32-rc7/drivers/md/dm-sysfs.c
@@ -59,7 +59,7 @@ static ssize_t dm_attr_uuid_show(struct 
 
 static ssize_t dm_attr_suspended_show(struct mapped_device *md, char *buf)
 {
-	sprintf(buf, "%d\n", dm_suspended(md));
+	sprintf(buf, "%d\n", dm_suspended_md(md));
 
 	return strlen(buf);
 }
Index: 2.6.32-rc7/drivers/md/dm.c
===================================================================
--- 2.6.32-rc7.orig/drivers/md/dm.c
+++ 2.6.32-rc7/drivers/md/dm.c
@@ -415,7 +415,7 @@ static int dm_blk_ioctl(struct block_dev
 
 	tgt = dm_table_get_target(map, 0);
 
-	if (dm_suspended(md)) {
+	if (dm_suspended_md(md)) {
 		r = -EAGAIN;
 		goto out;
 	}
@@ -2176,7 +2176,7 @@ void dm_put(struct mapped_device *md)
 			    MINOR(disk_devt(dm_disk(md))));
 		set_bit(DMF_FREEING, &md->flags);
 		spin_unlock(&_minor_lock);
-		if (!dm_suspended(md)) {
+		if (!dm_suspended_md(md)) {
 			dm_table_presuspend_targets(map);
 			dm_table_postsuspend_targets(map);
 		}
@@ -2374,7 +2374,7 @@ int dm_swap_table(struct mapped_device *
 	mutex_lock(&md->suspend_lock);
 
 	/* device must be suspended */
-	if (!dm_suspended(md))
+	if (!dm_suspended_md(md))
 		goto out;
 
 	r = dm_calculate_queue_limits(table, &limits);
@@ -2453,7 +2453,7 @@ int dm_suspend(struct mapped_device *md,
 
 	mutex_lock(&md->suspend_lock);
 
-	if (dm_suspended(md)) {
+	if (dm_suspended_md(md)) {
 		r = -EINVAL;
 		goto out_unlock;
 	}
@@ -2560,7 +2560,7 @@ int dm_resume(struct mapped_device *md)
 	struct dm_table *map = NULL;
 
 	mutex_lock(&md->suspend_lock);
-	if (!dm_suspended(md))
+	if (!dm_suspended_md(md))
 		goto out;
 
 	map = dm_get_live_table(md);
@@ -2671,7 +2671,7 @@ struct mapped_device *dm_get_from_kobjec
 	return md;
 }
 
-int dm_suspended(struct mapped_device *md)
+int dm_suspended_md(struct mapped_device *md)
 {
 	return test_bit(DMF_SUSPENDED, &md->flags);
 }
Index: 2.6.32-rc7/drivers/md/dm.h
===================================================================
--- 2.6.32-rc7.orig/drivers/md/dm.h
+++ 2.6.32-rc7/drivers/md/dm.h
@@ -94,6 +94,11 @@ int dm_split_args(int *argc, char ***arg
 int dm_deleting_md(struct mapped_device *md);
 
 /*
+ * Is this mapped_device suspended?
+ */
+int dm_suspended_md(struct mapped_device *md);
+
+/*
  * The device-mapper can be driven through one of two interfaces;
  * ioctl or filesystem, depending which patch you have applied.
  */
Index: 2.6.32-rc7/include/linux/device-mapper.h
===================================================================
--- 2.6.32-rc7.orig/include/linux/device-mapper.h
+++ 2.6.32-rc7/include/linux/device-mapper.h
@@ -235,7 +235,6 @@ void dm_uevent_add(struct mapped_device 
 const char *dm_device_name(struct mapped_device *md);
 int dm_copy_name_and_uuid(struct mapped_device *md, char *name, char *uuid);
 struct gendisk *dm_disk(struct mapped_device *md);
-int dm_suspended(struct mapped_device *md);
 int dm_noflush_suspending(struct dm_target *ti);
 union map_info *dm_get_mapinfo(struct bio *bio);
 union map_info *dm_get_rq_mapinfo(struct request *rq);

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3/4] dm: export suspended state
  2009-11-20  7:08 [PATCH 1/4] dm: move DMF_SUSPENDED flag set before postsuspend Kiyoshi Ueda
  2009-11-20  7:12 ` [PATCH 2/4] dm: rename dm_suspended() to dm_suspended_md() Kiyoshi Ueda
@ 2009-11-20  7:14 ` Kiyoshi Ueda
  2009-11-20  7:15 ` [PATCH 4/4] dm-mpath: reject message when the device is suspended Kiyoshi Ueda
  2 siblings, 0 replies; 4+ messages in thread
From: Kiyoshi Ueda @ 2009-11-20  7:14 UTC (permalink / raw)
  To: Alasdair Kergon, Mike Anderson; +Cc: device-mapper development

This patch adds the exported dm_suspended() function so that targets
can check whether themselves are suspended or not.

Signed-off-by: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>
Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Cc: Mike Anderson <andmike@linux.vnet.ibm.com>
Cc: Alasdair G Kergon <agk@redhat.com>
---
 drivers/md/dm.c               |   11 +++++++++++
 include/linux/device-mapper.h |    1 +
 2 files changed, 12 insertions(+)

Index: 2.6.32-rc7/drivers/md/dm.c
===================================================================
--- 2.6.32-rc7.orig/drivers/md/dm.c
+++ 2.6.32-rc7/drivers/md/dm.c
@@ -2676,6 +2676,17 @@ int dm_suspended_md(struct mapped_device
 	return test_bit(DMF_SUSPENDED, &md->flags);
 }
 
+int dm_suspended(struct dm_target *ti)
+{
+	struct mapped_device *md = dm_table_get_md(ti->table);
+	int r = dm_suspended_md(md);
+
+	dm_put(md);
+
+	return r;
+}
+EXPORT_SYMBOL_GPL(dm_suspended);
+
 int dm_noflush_suspending(struct dm_target *ti)
 {
 	struct mapped_device *md = dm_table_get_md(ti->table);
Index: 2.6.32-rc7/include/linux/device-mapper.h
===================================================================
--- 2.6.32-rc7.orig/include/linux/device-mapper.h
+++ 2.6.32-rc7/include/linux/device-mapper.h
@@ -235,6 +235,7 @@ void dm_uevent_add(struct mapped_device 
 const char *dm_device_name(struct mapped_device *md);
 int dm_copy_name_and_uuid(struct mapped_device *md, char *name, char *uuid);
 struct gendisk *dm_disk(struct mapped_device *md);
+int dm_suspended(struct dm_target *ti);
 int dm_noflush_suspending(struct dm_target *ti);
 union map_info *dm_get_mapinfo(struct bio *bio);
 union map_info *dm_get_rq_mapinfo(struct request *rq);

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 4/4] dm-mpath: reject message when the device is suspended
  2009-11-20  7:08 [PATCH 1/4] dm: move DMF_SUSPENDED flag set before postsuspend Kiyoshi Ueda
  2009-11-20  7:12 ` [PATCH 2/4] dm: rename dm_suspended() to dm_suspended_md() Kiyoshi Ueda
  2009-11-20  7:14 ` [PATCH 3/4] dm: export suspended state Kiyoshi Ueda
@ 2009-11-20  7:15 ` Kiyoshi Ueda
  2 siblings, 0 replies; 4+ messages in thread
From: Kiyoshi Ueda @ 2009-11-20  7:15 UTC (permalink / raw)
  To: Alasdair Kergon, Mike Anderson; +Cc: device-mapper development

This patch rejects messages that can generate I/O while the device itself
is suspended.

Signed-off-by: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>
Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Cc: Mike Anderson <andmike@linux.vnet.ibm.com>
Cc: Alasdair G Kergon <agk@redhat.com>
---
 drivers/md/dm-mpath.c |    5 +++++
 1 file changed, 5 insertions(+)

Index: 2.6.32-rc7/drivers/md/dm-mpath.c
===================================================================
--- 2.6.32-rc7.orig/drivers/md/dm-mpath.c
+++ 2.6.32-rc7/drivers/md/dm-mpath.c
@@ -1421,6 +1421,11 @@ static int multipath_message(struct dm_t
 
 	mutex_lock(&m->work_mutex);
 
+	if (dm_suspended(ti)) {
+		r = -EBUSY;
+		goto out;
+	}
+
 	if (argc == 1) {
 		if (!strnicmp(argv[0], MESG_STR("queue_if_no_path"))) {
 			r = queue_if_no_path(m, 1, 0);

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-11-20  7:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-20  7:08 [PATCH 1/4] dm: move DMF_SUSPENDED flag set before postsuspend Kiyoshi Ueda
2009-11-20  7:12 ` [PATCH 2/4] dm: rename dm_suspended() to dm_suspended_md() Kiyoshi Ueda
2009-11-20  7:14 ` [PATCH 3/4] dm: export suspended state Kiyoshi Ueda
2009-11-20  7:15 ` [PATCH 4/4] dm-mpath: reject message when the device is suspended Kiyoshi Ueda

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.