dm: move DMF_SUSPENDED flag set before postsuspend
PATCH 1/4 dm: move DMF_SUSPENDED flag set before postsuspend
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 <[email protected]>
Signed-off-by Jun'ichi Nomura <[email protected]>
Cc Mike Anderson <[email protected]>
Cc Alasdair G Kergon <[email protected]>
--- drivers/md/dm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/dm.c +2 -2
@@ -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);
PATCH 2/4 dm: rename dm_suspended() to dm_suspended_md()
This patch renames dm_suspended() to dm_suspended_md(). No functional change.
Signed-off-by Kiyoshi Ueda <[email protected]>
Signed-off-by Jun'ichi Nomura <[email protected]>
Cc Mike Anderson <[email protected]>
Cc Alasdair G Kergon <[email protected]>
--- 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(-)
drivers/md/dm-ioctl.c +4 -4
@@ -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 *pif (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 *paset_disk_ro (dm_disk (md),1 ); } -if (dm_suspended (md)) +if (dm_suspended_md (md)) r =dm_resume (md);
drivers/md/dm-sysfs.c +1 -1
@@ -59,7 +59,7 @@ static ssize_t dm_attr_uuid_show(structstatic 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); }
drivers/md/dm.c +6 -6
@@ -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_kobjecreturn md; } -int dm_suspended (struct mapped_device *md) +int dm_suspended_md (struct mapped_device *md) {return test_bit (DMF_SUSPENDED , &md->flags); }
drivers/md/dm.h +5 -0
@@ -94,6 +94,11 @@ int dm_split_args(int *argc, char ***argint 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. */
include/linux/device-mapper.h +0 -1
@@ -235,7 +235,6 @@ void dm_uevent_add(struct mapped_deviceconst 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);
PATCH 3/4 dm: export suspended state
In reply to Kiyoshi UedaThis patch adds the exported dm_suspended() function so that targets can check whether themselves are suspended or not.
Signed-off-by Kiyoshi Ueda <[email protected]>
Signed-off-by Jun'ichi Nomura <[email protected]>
Cc Mike Anderson <[email protected]>
Cc Alasdair G Kergon <[email protected]>
--- drivers/md/dm.c | 11 +++++++++++ include/linux/device-mapper.h | 1 + 2 files changed, 12 insertions(+)
drivers/md/dm.c +11 -0
@@ -2676,6 +2676,17 @@ int dm_suspended_md(struct mapped_devicereturn 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);
include/linux/device-mapper.h +1 -0
@@ -235,6 +235,7 @@ void dm_uevent_add(struct mapped_deviceconst 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);
PATCH 4/4 dm-mpath: reject message when the device is suspended
In reply to Kiyoshi UedaThis patch rejects messages that can generate I/O while the device itself is suspended.
Signed-off-by Kiyoshi Ueda <[email protected]>
Signed-off-by Jun'ichi Nomura <[email protected]>
Cc Mike Anderson <[email protected]>
Cc Alasdair G Kergon <[email protected]>
--- drivers/md/dm-mpath.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/md/dm-mpath.c +5 -0
@@ -1421,6 +1421,11 @@ static int multipath_message(struct dm_tmutex_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 );