Lines Matching refs:lc
84 static int userspace_do_request(struct log_c *lc, const char *uuid, in userspace_do_request() argument
96 r = dm_consult_userspace(uuid, lc->luid, request_type, data, in userspace_do_request()
107 r = dm_consult_userspace(uuid, lc->luid, DM_ULOG_CTR, in userspace_do_request()
108 lc->usr_argv_str, in userspace_do_request()
109 strlen(lc->usr_argv_str) + 1, in userspace_do_request()
115 r = dm_consult_userspace(uuid, lc->luid, DM_ULOG_RESUME, NULL, in userspace_do_request()
159 struct log_c *lc = container_of(work, struct log_c, flush_log_work.work); in do_flush() local
161 atomic_set(&lc->sched_flush, 0); in do_flush()
163 r = userspace_do_request(lc, lc->uuid, DM_ULOG_FLUSH, NULL, 0, NULL, NULL); in do_flush()
166 dm_table_event(lc->ti->table); in do_flush()
196 struct log_c *lc = NULL; in userspace_ctr() local
207 lc = kzalloc(sizeof(*lc), GFP_KERNEL); in userspace_ctr()
208 if (!lc) { in userspace_ctr()
214 lc->luid = (unsigned long)lc; in userspace_ctr()
216 lc->ti = ti; in userspace_ctr()
220 kfree(lc); in userspace_ctr()
224 lc->usr_argc = argc; in userspace_ctr()
226 strncpy(lc->uuid, argv[0], DM_UUID_LEN); in userspace_ctr()
229 spin_lock_init(&lc->flush_lock); in userspace_ctr()
230 INIT_LIST_HEAD(&lc->mark_list); in userspace_ctr()
231 INIT_LIST_HEAD(&lc->clear_list); in userspace_ctr()
234 lc->integrated_flush = 1; in userspace_ctr()
241 kfree(lc); in userspace_ctr()
252 r = mempool_init_slab_pool(&lc->flush_entry_pool, FLUSH_ENTRY_POOL_SIZE, in userspace_ctr()
262 r = dm_consult_userspace(lc->uuid, lc->luid, DM_ULOG_CTR, in userspace_ctr()
276 r = dm_consult_userspace(lc->uuid, lc->luid, DM_ULOG_GET_REGION_SIZE, in userspace_ctr()
284 lc->region_size = (uint32_t)rdata; in userspace_ctr()
285 lc->region_count = dm_sector_div_up(ti->len, lc->region_size); in userspace_ctr()
294 dm_table_get_mode(ti->table), &lc->log_dev); in userspace_ctr()
300 if (lc->integrated_flush) { in userspace_ctr()
301 lc->dmlog_wq = alloc_workqueue("dmlogd", WQ_MEM_RECLAIM, 0); in userspace_ctr()
302 if (!lc->dmlog_wq) { in userspace_ctr()
308 INIT_DELAYED_WORK(&lc->flush_log_work, do_flush); in userspace_ctr()
309 atomic_set(&lc->sched_flush, 0); in userspace_ctr()
315 mempool_exit(&lc->flush_entry_pool); in userspace_ctr()
316 kfree(lc); in userspace_ctr()
319 lc->usr_argv_str = ctr_str; in userspace_ctr()
320 log->context = lc; in userspace_ctr()
328 struct log_c *lc = log->context; in userspace_dtr() local
330 if (lc->integrated_flush) { in userspace_dtr()
332 if (atomic_read(&lc->sched_flush)) in userspace_dtr()
333 flush_delayed_work(&lc->flush_log_work); in userspace_dtr()
335 destroy_workqueue(lc->dmlog_wq); in userspace_dtr()
338 (void) dm_consult_userspace(lc->uuid, lc->luid, DM_ULOG_DTR, in userspace_dtr()
341 if (lc->log_dev) in userspace_dtr()
342 dm_put_device(lc->ti, lc->log_dev); in userspace_dtr()
344 mempool_exit(&lc->flush_entry_pool); in userspace_dtr()
346 kfree(lc->usr_argv_str); in userspace_dtr()
347 kfree(lc); in userspace_dtr()
355 struct log_c *lc = log->context; in userspace_presuspend() local
357 r = dm_consult_userspace(lc->uuid, lc->luid, DM_ULOG_PRESUSPEND, in userspace_presuspend()
366 struct log_c *lc = log->context; in userspace_postsuspend() local
371 if (lc->integrated_flush && atomic_read(&lc->sched_flush)) in userspace_postsuspend()
372 flush_delayed_work(&lc->flush_log_work); in userspace_postsuspend()
374 r = dm_consult_userspace(lc->uuid, lc->luid, DM_ULOG_POSTSUSPEND, in userspace_postsuspend()
383 struct log_c *lc = log->context; in userspace_resume() local
385 lc->in_sync_hint = 0; in userspace_resume()
386 r = dm_consult_userspace(lc->uuid, lc->luid, DM_ULOG_RESUME, in userspace_resume()
394 struct log_c *lc = log->context; in userspace_get_region_size() local
396 return lc->region_size; in userspace_get_region_size()
413 struct log_c *lc = log->context; in userspace_is_clean() local
416 r = userspace_do_request(lc, lc->uuid, DM_ULOG_IS_CLEAN, in userspace_is_clean()
441 struct log_c *lc = log->context; in userspace_in_sync() local
460 r = userspace_do_request(lc, lc->uuid, DM_ULOG_IN_SYNC, in userspace_in_sync()
466 static int flush_one_by_one(struct log_c *lc, struct list_head *flush_list) in flush_one_by_one() argument
472 r = userspace_do_request(lc, lc->uuid, fe->type, in flush_one_by_one()
483 static int flush_by_group(struct log_c *lc, struct list_head *flush_list, in flush_by_group() argument
511 r = userspace_do_request(lc, lc->uuid, DM_ULOG_FLUSH, in flush_by_group()
521 r = userspace_do_request(lc, lc->uuid, type, in flush_by_group()
530 r = flush_one_by_one(lc, flush_list); in flush_by_group()
566 struct log_c *lc = log->context; in userspace_flush() local
572 mempool_t *flush_entry_pool = &lc->flush_entry_pool; in userspace_flush()
574 spin_lock_irqsave(&lc->flush_lock, flags); in userspace_flush()
575 list_splice_init(&lc->mark_list, &mark_list); in userspace_flush()
576 list_splice_init(&lc->clear_list, &clear_list); in userspace_flush()
577 spin_unlock_irqrestore(&lc->flush_lock, flags); in userspace_flush()
585 r = flush_by_group(lc, &clear_list, 0); in userspace_flush()
589 if (!lc->integrated_flush) { in userspace_flush()
590 r = flush_by_group(lc, &mark_list, 0); in userspace_flush()
593 r = userspace_do_request(lc, lc->uuid, DM_ULOG_FLUSH, in userspace_flush()
601 r = flush_by_group(lc, &mark_list, 1); in userspace_flush()
605 if (mark_list_is_empty && !atomic_read(&lc->sched_flush)) { in userspace_flush()
610 queue_delayed_work(lc->dmlog_wq, &lc->flush_log_work, 3 * HZ); in userspace_flush()
611 atomic_set(&lc->sched_flush, 1); in userspace_flush()
617 cancel_delayed_work(&lc->flush_log_work); in userspace_flush()
618 atomic_set(&lc->sched_flush, 0); in userspace_flush()
637 dm_table_event(lc->ti->table); in userspace_flush()
651 struct log_c *lc = log->context; in userspace_mark_region() local
655 fe = mempool_alloc(&lc->flush_entry_pool, GFP_NOIO); in userspace_mark_region()
658 spin_lock_irqsave(&lc->flush_lock, flags); in userspace_mark_region()
661 list_add(&fe->list, &lc->mark_list); in userspace_mark_region()
662 spin_unlock_irqrestore(&lc->flush_lock, flags); in userspace_mark_region()
680 struct log_c *lc = log->context; in userspace_clear_region() local
689 fe = mempool_alloc(&lc->flush_entry_pool, GFP_ATOMIC); in userspace_clear_region()
695 spin_lock_irqsave(&lc->flush_lock, flags); in userspace_clear_region()
698 list_add(&fe->list, &lc->clear_list); in userspace_clear_region()
699 spin_unlock_irqrestore(&lc->flush_lock, flags); in userspace_clear_region()
716 struct log_c *lc = log->context; in userspace_get_resync_work() local
722 if (lc->in_sync_hint >= lc->region_count) in userspace_get_resync_work()
726 r = userspace_do_request(lc, lc->uuid, DM_ULOG_GET_RESYNC_WORK, in userspace_get_resync_work()
742 struct log_c *lc = log->context; in userspace_set_region_sync() local
751 (void) userspace_do_request(lc, lc->uuid, DM_ULOG_SET_REGION_SYNC, in userspace_set_region_sync()
774 struct log_c *lc = log->context; in userspace_get_sync_count() local
777 r = userspace_do_request(lc, lc->uuid, DM_ULOG_GET_SYNC_COUNT, in userspace_get_sync_count()
783 if (sync_count >= lc->region_count) in userspace_get_sync_count()
784 lc->in_sync_hint = lc->region_count; in userspace_get_sync_count()
800 struct log_c *lc = log->context; in userspace_status() local
804 r = userspace_do_request(lc, lc->uuid, DM_ULOG_STATUS_INFO, in userspace_status()
814 table_args = strchr(lc->usr_argv_str, ' '); in userspace_status()
818 DMEMIT("%s %u %s ", log->type->name, lc->usr_argc, lc->uuid); in userspace_status()
819 if (lc->integrated_flush) in userspace_status()
840 struct log_c *lc = log->context; in userspace_is_remote_recovering() local
855 if (region < lc->in_sync_hint) in userspace_is_remote_recovering()
861 r = userspace_do_request(lc, lc->uuid, DM_ULOG_IS_REMOTE_RECOVERING, in userspace_is_remote_recovering()
867 lc->in_sync_hint = pkg.in_sync_hint; in userspace_is_remote_recovering()