Lines Matching refs:lc
85 static int userspace_do_request(struct log_c *lc, const char *uuid, in userspace_do_request() argument
97 r = dm_consult_userspace(uuid, lc->luid, request_type, data, in userspace_do_request()
108 r = dm_consult_userspace(uuid, lc->luid, DM_ULOG_CTR, in userspace_do_request()
109 lc->usr_argv_str, in userspace_do_request()
110 strlen(lc->usr_argv_str) + 1, in userspace_do_request()
116 r = dm_consult_userspace(uuid, lc->luid, DM_ULOG_RESUME, NULL, in userspace_do_request()
160 struct log_c *lc = container_of(work, struct log_c, flush_log_work.work); in do_flush() local
162 atomic_set(&lc->sched_flush, 0); in do_flush()
164 r = userspace_do_request(lc, lc->uuid, DM_ULOG_FLUSH, NULL, 0, NULL, NULL); in do_flush()
167 dm_table_event(lc->ti->table); in do_flush()
197 struct log_c *lc = NULL; in userspace_ctr() local
208 lc = kzalloc(sizeof(*lc), GFP_KERNEL); in userspace_ctr()
209 if (!lc) { in userspace_ctr()
215 lc->luid = (unsigned long)lc; in userspace_ctr()
217 lc->ti = ti; in userspace_ctr()
221 kfree(lc); in userspace_ctr()
225 lc->usr_argc = argc; in userspace_ctr()
227 strncpy(lc->uuid, argv[0], DM_UUID_LEN); in userspace_ctr()
230 spin_lock_init(&lc->flush_lock); in userspace_ctr()
231 INIT_LIST_HEAD(&lc->mark_list); in userspace_ctr()
232 INIT_LIST_HEAD(&lc->clear_list); in userspace_ctr()
235 lc->integrated_flush = 1; in userspace_ctr()
242 kfree(lc); in userspace_ctr()
253 r = mempool_init_slab_pool(&lc->flush_entry_pool, FLUSH_ENTRY_POOL_SIZE, in userspace_ctr()
263 r = dm_consult_userspace(lc->uuid, lc->luid, DM_ULOG_CTR, in userspace_ctr()
277 r = dm_consult_userspace(lc->uuid, lc->luid, DM_ULOG_GET_REGION_SIZE, in userspace_ctr()
285 lc->region_size = (uint32_t)rdata; in userspace_ctr()
286 lc->region_count = dm_sector_div_up(ti->len, lc->region_size); in userspace_ctr()
295 dm_table_get_mode(ti->table), &lc->log_dev); in userspace_ctr()
301 if (lc->integrated_flush) { in userspace_ctr()
302 lc->dmlog_wq = alloc_workqueue("dmlogd", WQ_MEM_RECLAIM, 0); in userspace_ctr()
303 if (!lc->dmlog_wq) { in userspace_ctr()
309 INIT_DELAYED_WORK(&lc->flush_log_work, do_flush); in userspace_ctr()
310 atomic_set(&lc->sched_flush, 0); in userspace_ctr()
316 mempool_exit(&lc->flush_entry_pool); in userspace_ctr()
317 kfree(lc); in userspace_ctr()
320 lc->usr_argv_str = ctr_str; in userspace_ctr()
321 log->context = lc; in userspace_ctr()
329 struct log_c *lc = log->context; in userspace_dtr() local
331 if (lc->integrated_flush) { in userspace_dtr()
333 if (atomic_read(&lc->sched_flush)) in userspace_dtr()
334 flush_delayed_work(&lc->flush_log_work); in userspace_dtr()
336 destroy_workqueue(lc->dmlog_wq); in userspace_dtr()
339 (void) dm_consult_userspace(lc->uuid, lc->luid, DM_ULOG_DTR, in userspace_dtr()
342 if (lc->log_dev) in userspace_dtr()
343 dm_put_device(lc->ti, lc->log_dev); in userspace_dtr()
345 mempool_exit(&lc->flush_entry_pool); in userspace_dtr()
347 kfree(lc->usr_argv_str); in userspace_dtr()
348 kfree(lc); in userspace_dtr()
354 struct log_c *lc = log->context; in userspace_presuspend() local
356 r = dm_consult_userspace(lc->uuid, lc->luid, DM_ULOG_PRESUSPEND, in userspace_presuspend()
365 struct log_c *lc = log->context; in userspace_postsuspend() local
370 if (lc->integrated_flush && atomic_read(&lc->sched_flush)) in userspace_postsuspend()
371 flush_delayed_work(&lc->flush_log_work); in userspace_postsuspend()
373 r = dm_consult_userspace(lc->uuid, lc->luid, DM_ULOG_POSTSUSPEND, in userspace_postsuspend()
382 struct log_c *lc = log->context; in userspace_resume() local
384 lc->in_sync_hint = 0; in userspace_resume()
385 r = dm_consult_userspace(lc->uuid, lc->luid, DM_ULOG_RESUME, in userspace_resume()
393 struct log_c *lc = log->context; in userspace_get_region_size() local
395 return lc->region_size; in userspace_get_region_size()
412 struct log_c *lc = log->context; in userspace_is_clean() local
415 r = userspace_do_request(lc, lc->uuid, DM_ULOG_IS_CLEAN, in userspace_is_clean()
440 struct log_c *lc = log->context; in userspace_in_sync() local
459 r = userspace_do_request(lc, lc->uuid, DM_ULOG_IN_SYNC, in userspace_in_sync()
465 static int flush_one_by_one(struct log_c *lc, struct list_head *flush_list) in flush_one_by_one() argument
471 r = userspace_do_request(lc, lc->uuid, fe->type, in flush_one_by_one()
482 static int flush_by_group(struct log_c *lc, struct list_head *flush_list, in flush_by_group() argument
510 r = userspace_do_request(lc, lc->uuid, DM_ULOG_FLUSH, in flush_by_group()
520 r = userspace_do_request(lc, lc->uuid, type, in flush_by_group()
529 r = flush_one_by_one(lc, flush_list); in flush_by_group()
565 struct log_c *lc = log->context; in userspace_flush() local
571 mempool_t *flush_entry_pool = &lc->flush_entry_pool; in userspace_flush()
573 spin_lock_irqsave(&lc->flush_lock, flags); in userspace_flush()
574 list_splice_init(&lc->mark_list, &mark_list); in userspace_flush()
575 list_splice_init(&lc->clear_list, &clear_list); in userspace_flush()
576 spin_unlock_irqrestore(&lc->flush_lock, flags); in userspace_flush()
584 r = flush_by_group(lc, &clear_list, 0); in userspace_flush()
588 if (!lc->integrated_flush) { in userspace_flush()
589 r = flush_by_group(lc, &mark_list, 0); in userspace_flush()
592 r = userspace_do_request(lc, lc->uuid, DM_ULOG_FLUSH, in userspace_flush()
600 r = flush_by_group(lc, &mark_list, 1); in userspace_flush()
604 if (mark_list_is_empty && !atomic_read(&lc->sched_flush)) { in userspace_flush()
609 queue_delayed_work(lc->dmlog_wq, &lc->flush_log_work, 3 * HZ); in userspace_flush()
610 atomic_set(&lc->sched_flush, 1); in userspace_flush()
616 cancel_delayed_work(&lc->flush_log_work); in userspace_flush()
617 atomic_set(&lc->sched_flush, 0); in userspace_flush()
636 dm_table_event(lc->ti->table); in userspace_flush()
650 struct log_c *lc = log->context; in userspace_mark_region() local
654 fe = mempool_alloc(&lc->flush_entry_pool, GFP_NOIO); in userspace_mark_region()
657 spin_lock_irqsave(&lc->flush_lock, flags); in userspace_mark_region()
660 list_add(&fe->list, &lc->mark_list); in userspace_mark_region()
661 spin_unlock_irqrestore(&lc->flush_lock, flags); in userspace_mark_region()
677 struct log_c *lc = log->context; in userspace_clear_region() local
686 fe = mempool_alloc(&lc->flush_entry_pool, GFP_ATOMIC); in userspace_clear_region()
692 spin_lock_irqsave(&lc->flush_lock, flags); in userspace_clear_region()
695 list_add(&fe->list, &lc->clear_list); in userspace_clear_region()
696 spin_unlock_irqrestore(&lc->flush_lock, flags); in userspace_clear_region()
711 struct log_c *lc = log->context; in userspace_get_resync_work() local
717 if (lc->in_sync_hint >= lc->region_count) in userspace_get_resync_work()
721 r = userspace_do_request(lc, lc->uuid, DM_ULOG_GET_RESYNC_WORK, in userspace_get_resync_work()
737 struct log_c *lc = log->context; in userspace_set_region_sync() local
746 (void) userspace_do_request(lc, lc->uuid, DM_ULOG_SET_REGION_SYNC, in userspace_set_region_sync()
768 struct log_c *lc = log->context; in userspace_get_sync_count() local
771 r = userspace_do_request(lc, lc->uuid, DM_ULOG_GET_SYNC_COUNT, in userspace_get_sync_count()
777 if (sync_count >= lc->region_count) in userspace_get_sync_count()
778 lc->in_sync_hint = lc->region_count; in userspace_get_sync_count()
794 struct log_c *lc = log->context; in userspace_status() local
798 r = userspace_do_request(lc, lc->uuid, DM_ULOG_STATUS_INFO, in userspace_status()
808 table_args = strchr(lc->usr_argv_str, ' '); in userspace_status()
812 DMEMIT("%s %u %s ", log->type->name, lc->usr_argc, lc->uuid); in userspace_status()
813 if (lc->integrated_flush) in userspace_status()
834 struct log_c *lc = log->context; in userspace_is_remote_recovering() local
849 if (region < lc->in_sync_hint) in userspace_is_remote_recovering()
855 r = userspace_do_request(lc, lc->uuid, DM_ULOG_IS_REMOTE_RECOVERING, in userspace_is_remote_recovering()
861 lc->in_sync_hint = pkg.in_sync_hint; in userspace_is_remote_recovering()