Commit f521f074 authored by Tejun Heo's avatar Tejun Heo Committed by Alasdair G Kergon

dm stripe: switch from local workqueue to system_wq

kstriped only serves sc->kstriped_ws which runs dm_table_event().
This doesn't need to be executed from an ordered workqueue w/ rescuer.
Drop kstriped and use the system_wq instead.  While at it, rename
kstriped_ws to trigger_event so that it's consistent with other dm
modules.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
Signed-off-by: default avatarAlasdair G Kergon <agk@redhat.com>
parent d5ffa387
...@@ -39,23 +39,20 @@ struct stripe_c { ...@@ -39,23 +39,20 @@ struct stripe_c {
struct dm_target *ti; struct dm_target *ti;
/* Work struct used for triggering events*/ /* Work struct used for triggering events*/
struct work_struct kstriped_ws; struct work_struct trigger_event;
struct stripe stripe[0]; struct stripe stripe[0];
}; };
static struct workqueue_struct *kstriped;
/* /*
* An event is triggered whenever a drive * An event is triggered whenever a drive
* drops out of a stripe volume. * drops out of a stripe volume.
*/ */
static void trigger_event(struct work_struct *work) static void trigger_event(struct work_struct *work)
{ {
struct stripe_c *sc = container_of(work, struct stripe_c, kstriped_ws); struct stripe_c *sc = container_of(work, struct stripe_c,
trigger_event);
dm_table_event(sc->ti->table); dm_table_event(sc->ti->table);
} }
static inline struct stripe_c *alloc_context(unsigned int stripes) static inline struct stripe_c *alloc_context(unsigned int stripes)
...@@ -160,7 +157,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv) ...@@ -160,7 +157,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
return -ENOMEM; return -ENOMEM;
} }
INIT_WORK(&sc->kstriped_ws, trigger_event); INIT_WORK(&sc->trigger_event, trigger_event);
/* Set pointer to dm target; used in trigger_event */ /* Set pointer to dm target; used in trigger_event */
sc->ti = ti; sc->ti = ti;
...@@ -211,7 +208,7 @@ static void stripe_dtr(struct dm_target *ti) ...@@ -211,7 +208,7 @@ static void stripe_dtr(struct dm_target *ti)
for (i = 0; i < sc->stripes; i++) for (i = 0; i < sc->stripes; i++)
dm_put_device(ti, sc->stripe[i].dev); dm_put_device(ti, sc->stripe[i].dev);
flush_workqueue(kstriped); flush_work_sync(&sc->trigger_event);
kfree(sc); kfree(sc);
} }
...@@ -367,7 +364,7 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, ...@@ -367,7 +364,7 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio,
atomic_inc(&(sc->stripe[i].error_count)); atomic_inc(&(sc->stripe[i].error_count));
if (atomic_read(&(sc->stripe[i].error_count)) < if (atomic_read(&(sc->stripe[i].error_count)) <
DM_IO_ERROR_THRESHOLD) DM_IO_ERROR_THRESHOLD)
queue_work(kstriped, &sc->kstriped_ws); schedule_work(&sc->trigger_event);
} }
return error; return error;
...@@ -401,7 +398,7 @@ static void stripe_io_hints(struct dm_target *ti, ...@@ -401,7 +398,7 @@ static void stripe_io_hints(struct dm_target *ti,
static struct target_type stripe_target = { static struct target_type stripe_target = {
.name = "striped", .name = "striped",
.version = {1, 3, 0}, .version = {1, 3, 1},
.module = THIS_MODULE, .module = THIS_MODULE,
.ctr = stripe_ctr, .ctr = stripe_ctr,
.dtr = stripe_dtr, .dtr = stripe_dtr,
...@@ -422,20 +419,10 @@ int __init dm_stripe_init(void) ...@@ -422,20 +419,10 @@ int __init dm_stripe_init(void)
return r; return r;
} }
kstriped = create_singlethread_workqueue("kstriped");
if (!kstriped) {
DMERR("failed to create workqueue kstriped");
dm_unregister_target(&stripe_target);
return -ENOMEM;
}
return r; return r;
} }
void dm_stripe_exit(void) void dm_stripe_exit(void)
{ {
dm_unregister_target(&stripe_target); dm_unregister_target(&stripe_target);
destroy_workqueue(kstriped);
return;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment