Lines Matching full:dc

55 	struct delay_c *dc = from_timer(dc, t, delay_timer);  in handle_delayed_timer()  local
57 queue_work(dc->kdelayd_wq, &dc->flush_expired_bios); in handle_delayed_timer()
60 static void queue_timeout(struct delay_c *dc, unsigned long expires) in queue_timeout() argument
62 timer_reduce(&dc->delay_timer, expires); in queue_timeout()
65 static inline bool delay_is_fast(struct delay_c *dc) in delay_is_fast() argument
67 return !!dc->worker; in delay_is_fast()
82 static void flush_delayed_bios(struct delay_c *dc, bool flush_all) in flush_delayed_bios() argument
91 mutex_lock(&dc->process_bios_lock); in flush_delayed_bios()
92 spin_lock(&dc->delayed_bios_lock); in flush_delayed_bios()
93 list_replace_init(&dc->delayed_bios, &local_list); in flush_delayed_bios()
94 spin_unlock(&dc->delayed_bios_lock); in flush_delayed_bios()
106 if (!delay_is_fast(dc)) { in flush_delayed_bios()
115 spin_lock(&dc->delayed_bios_lock); in flush_delayed_bios()
116 list_splice(&local_list, &dc->delayed_bios); in flush_delayed_bios()
117 spin_unlock(&dc->delayed_bios_lock); in flush_delayed_bios()
118 mutex_unlock(&dc->process_bios_lock); in flush_delayed_bios()
121 queue_timeout(dc, next_expires); in flush_delayed_bios()
128 struct delay_c *dc = data; in flush_worker_fn() local
131 flush_delayed_bios(dc, false); in flush_worker_fn()
132 spin_lock(&dc->delayed_bios_lock); in flush_worker_fn()
133 if (unlikely(list_empty(&dc->delayed_bios))) { in flush_worker_fn()
135 spin_unlock(&dc->delayed_bios_lock); in flush_worker_fn()
138 spin_unlock(&dc->delayed_bios_lock); in flush_worker_fn()
148 struct delay_c *dc; in flush_expired_bios() local
150 dc = container_of(work, struct delay_c, flush_expired_bios); in flush_expired_bios()
151 flush_delayed_bios(dc, false); in flush_expired_bios()
156 struct delay_c *dc = ti->private; in delay_dtr() local
158 if (dc->kdelayd_wq) { in delay_dtr()
159 timer_shutdown_sync(&dc->delay_timer); in delay_dtr()
160 destroy_workqueue(dc->kdelayd_wq); in delay_dtr()
163 if (dc->read.dev) in delay_dtr()
164 dm_put_device(ti, dc->read.dev); in delay_dtr()
165 if (dc->write.dev) in delay_dtr()
166 dm_put_device(ti, dc->write.dev); in delay_dtr()
167 if (dc->flush.dev) in delay_dtr()
168 dm_put_device(ti, dc->flush.dev); in delay_dtr()
169 if (dc->worker) in delay_dtr()
170 kthread_stop(dc->worker); in delay_dtr()
172 mutex_destroy(&dc->process_bios_lock); in delay_dtr()
174 kfree(dc); in delay_dtr()
213 struct delay_c *dc; in delay_ctr() local
222 dc = kzalloc(sizeof(*dc), GFP_KERNEL); in delay_ctr()
223 if (!dc) { in delay_ctr()
228 ti->private = dc; in delay_ctr()
229 INIT_LIST_HEAD(&dc->delayed_bios); in delay_ctr()
230 mutex_init(&dc->process_bios_lock); in delay_ctr()
231 spin_lock_init(&dc->delayed_bios_lock); in delay_ctr()
232 dc->may_delay = true; in delay_ctr()
233 dc->argc = argc; in delay_ctr()
235 ret = delay_class_ctr(ti, &dc->read, argv); in delay_ctr()
238 max_delay = dc->read.delay; in delay_ctr()
241 ret = delay_class_ctr(ti, &dc->write, argv); in delay_ctr()
244 ret = delay_class_ctr(ti, &dc->flush, argv); in delay_ctr()
250 ret = delay_class_ctr(ti, &dc->write, argv + 3); in delay_ctr()
253 max_delay = max(max_delay, dc->write.delay); in delay_ctr()
256 ret = delay_class_ctr(ti, &dc->flush, argv + 3); in delay_ctr()
262 ret = delay_class_ctr(ti, &dc->flush, argv + 6); in delay_ctr()
265 max_delay = max(max_delay, dc->flush.delay); in delay_ctr()
273 dc->worker = kthread_run(&flush_worker_fn, dc, "dm-delay-flush-worker"); in delay_ctr()
274 if (IS_ERR(dc->worker)) { in delay_ctr()
275 ret = PTR_ERR(dc->worker); in delay_ctr()
276 dc->worker = NULL; in delay_ctr()
280 timer_setup(&dc->delay_timer, handle_delayed_timer, 0); in delay_ctr()
281 INIT_WORK(&dc->flush_expired_bios, flush_expired_bios); in delay_ctr()
282 dc->kdelayd_wq = alloc_workqueue("kdelayd", WQ_MEM_RECLAIM, 0); in delay_ctr()
283 if (!dc->kdelayd_wq) { in delay_ctr()
301 static int delay_bio(struct delay_c *dc, struct delay_class *c, struct bio *bio) in delay_bio() argument
311 delayed->context = dc; in delay_bio()
314 spin_lock(&dc->delayed_bios_lock); in delay_bio()
315 if (unlikely(!dc->may_delay)) { in delay_bio()
316 spin_unlock(&dc->delayed_bios_lock); in delay_bio()
320 list_add_tail(&delayed->list, &dc->delayed_bios); in delay_bio()
321 spin_unlock(&dc->delayed_bios_lock); in delay_bio()
323 if (delay_is_fast(dc)) in delay_bio()
324 wake_up_process(dc->worker); in delay_bio()
326 queue_timeout(dc, expires); in delay_bio()
333 struct delay_c *dc = ti->private; in delay_presuspend() local
335 spin_lock(&dc->delayed_bios_lock); in delay_presuspend()
336 dc->may_delay = false; in delay_presuspend()
337 spin_unlock(&dc->delayed_bios_lock); in delay_presuspend()
339 if (!delay_is_fast(dc)) in delay_presuspend()
340 timer_delete(&dc->delay_timer); in delay_presuspend()
341 flush_delayed_bios(dc, true); in delay_presuspend()
346 struct delay_c *dc = ti->private; in delay_resume() local
348 dc->may_delay = true; in delay_resume()
353 struct delay_c *dc = ti->private; in delay_map() local
359 c = &dc->flush; in delay_map()
361 c = &dc->write; in delay_map()
363 c = &dc->read; in delay_map()
369 return delay_bio(dc, c, bio); in delay_map()
378 struct delay_c *dc = ti->private; in delay_status() local
383 DMEMIT("%u %u %u", dc->read.ops, dc->write.ops, dc->flush.ops); in delay_status()
387 DMEMIT_DELAY_CLASS(&dc->read); in delay_status()
388 if (dc->argc >= 6) { in delay_status()
390 DMEMIT_DELAY_CLASS(&dc->write); in delay_status()
392 if (dc->argc >= 9) { in delay_status()
394 DMEMIT_DELAY_CLASS(&dc->flush); in delay_status()
407 struct delay_c *dc = ti->private; in delay_iterate_devices() local
410 ret = fn(ti, dc->read.dev, dc->read.start, ti->len, data); in delay_iterate_devices()
413 ret = fn(ti, dc->write.dev, dc->write.start, ti->len, data); in delay_iterate_devices()
416 ret = fn(ti, dc->flush.dev, dc->flush.start, ti->len, data); in delay_iterate_devices()