Lines Matching refs:lc

299 static int rw_header(struct log_c *lc, enum req_op op)  in rw_header()  argument
301 lc->io_req.bi_opf = op; in rw_header()
303 return dm_io(&lc->io_req, 1, &lc->header_location, NULL, IOPRIO_DEFAULT); in rw_header()
306 static int flush_header(struct log_c *lc) in flush_header() argument
309 .bdev = lc->header_location.bdev, in flush_header()
314 lc->io_req.bi_opf = REQ_OP_WRITE | REQ_PREFLUSH; in flush_header()
316 return dm_io(&lc->io_req, 1, &null_location, NULL, IOPRIO_DEFAULT); in flush_header()
374 struct log_c *lc; in create_log_context() local
405 lc = kmalloc(sizeof(*lc), GFP_KERNEL); in create_log_context()
406 if (!lc) { in create_log_context()
411 lc->ti = ti; in create_log_context()
412 lc->touched_dirtied = 0; in create_log_context()
413 lc->touched_cleaned = 0; in create_log_context()
414 lc->flush_failed = 0; in create_log_context()
415 lc->region_size = region_size; in create_log_context()
416 lc->region_count = region_count; in create_log_context()
417 lc->sync = sync; in create_log_context()
425 lc->bitset_uint32_count = bitset_size / sizeof(*lc->clean_bits); in create_log_context()
431 lc->clean_bits = vmalloc(bitset_size); in create_log_context()
432 if (!lc->clean_bits) { in create_log_context()
434 kfree(lc); in create_log_context()
437 lc->disk_header = NULL; in create_log_context()
439 lc->log_dev = dev; in create_log_context()
440 lc->log_dev_failed = 0; in create_log_context()
441 lc->log_dev_flush_failed = 0; in create_log_context()
442 lc->header_location.bdev = lc->log_dev->bdev; in create_log_context()
443 lc->header_location.sector = 0; in create_log_context()
450 bdev_logical_block_size(lc->header_location.bdev)); in create_log_context()
455 kfree(lc); in create_log_context()
459 lc->header_location.count = buf_size >> SECTOR_SHIFT; in create_log_context()
461 lc->io_req.mem.type = DM_IO_VMA; in create_log_context()
462 lc->io_req.notify.fn = NULL; in create_log_context()
463 lc->io_req.client = dm_io_client_create(); in create_log_context()
464 if (IS_ERR(lc->io_req.client)) { in create_log_context()
465 r = PTR_ERR(lc->io_req.client); in create_log_context()
467 kfree(lc); in create_log_context()
471 lc->disk_header = vmalloc(buf_size); in create_log_context()
472 if (!lc->disk_header) { in create_log_context()
474 dm_io_client_destroy(lc->io_req.client); in create_log_context()
475 kfree(lc); in create_log_context()
479 lc->io_req.mem.ptr.vma = lc->disk_header; in create_log_context()
480 lc->clean_bits = (void *)lc->disk_header + in create_log_context()
484 memset(lc->clean_bits, -1, bitset_size); in create_log_context()
486 lc->sync_bits = vmalloc(bitset_size); in create_log_context()
487 if (!lc->sync_bits) { in create_log_context()
490 vfree(lc->clean_bits); in create_log_context()
492 dm_io_client_destroy(lc->io_req.client); in create_log_context()
493 vfree(lc->disk_header); in create_log_context()
494 kfree(lc); in create_log_context()
497 memset(lc->sync_bits, (sync == NOSYNC) ? -1 : 0, bitset_size); in create_log_context()
498 lc->sync_count = (sync == NOSYNC) ? region_count : 0; in create_log_context()
500 lc->recovering_bits = vzalloc(bitset_size); in create_log_context()
501 if (!lc->recovering_bits) { in create_log_context()
503 vfree(lc->sync_bits); in create_log_context()
505 vfree(lc->clean_bits); in create_log_context()
507 dm_io_client_destroy(lc->io_req.client); in create_log_context()
508 vfree(lc->disk_header); in create_log_context()
509 kfree(lc); in create_log_context()
512 lc->sync_search = 0; in create_log_context()
513 log->context = lc; in create_log_context()
524 static void destroy_log_context(struct log_c *lc) in destroy_log_context() argument
526 vfree(lc->sync_bits); in destroy_log_context()
527 vfree(lc->recovering_bits); in destroy_log_context()
528 kfree(lc); in destroy_log_context()
533 struct log_c *lc = log->context; in core_dtr() local
535 vfree(lc->clean_bits); in core_dtr()
536 destroy_log_context(lc); in core_dtr()
572 struct log_c *lc = log->context; in disk_dtr() local
574 dm_put_device(lc->ti, lc->log_dev); in disk_dtr()
575 vfree(lc->disk_header); in disk_dtr()
576 dm_io_client_destroy(lc->io_req.client); in disk_dtr()
577 destroy_log_context(lc); in disk_dtr()
580 static void fail_log_device(struct log_c *lc) in fail_log_device() argument
582 if (lc->log_dev_failed) in fail_log_device()
585 lc->log_dev_failed = 1; in fail_log_device()
586 dm_table_event(lc->ti->table); in fail_log_device()
593 struct log_c *lc = log->context; in disk_resume() local
594 size_t size = lc->bitset_uint32_count * sizeof(uint32_t); in disk_resume()
597 r = read_header(lc); in disk_resume()
600 lc->log_dev->name); in disk_resume()
601 fail_log_device(lc); in disk_resume()
609 lc->header.nr_regions = 0; in disk_resume()
613 if (lc->sync == NOSYNC) in disk_resume()
614 for (i = lc->header.nr_regions; i < lc->region_count; i++) in disk_resume()
616 log_set_bit(lc, lc->clean_bits, i); in disk_resume()
618 for (i = lc->header.nr_regions; i < lc->region_count; i++) in disk_resume()
620 log_clear_bit(lc, lc->clean_bits, i); in disk_resume()
623 for (i = lc->region_count; i % BITS_PER_LONG; i++) in disk_resume()
624 log_clear_bit(lc, lc->clean_bits, i); in disk_resume()
627 memcpy(lc->sync_bits, lc->clean_bits, size); in disk_resume()
628 lc->sync_count = memweight(lc->clean_bits, in disk_resume()
629 lc->bitset_uint32_count * sizeof(uint32_t)); in disk_resume()
630 lc->sync_search = 0; in disk_resume()
633 lc->header.nr_regions = lc->region_count; in disk_resume()
635 header_to_disk(&lc->header, lc->disk_header); in disk_resume()
638 r = rw_header(lc, REQ_OP_WRITE); in disk_resume()
640 r = flush_header(lc); in disk_resume()
642 lc->log_dev_flush_failed = 1; in disk_resume()
646 lc->log_dev->name); in disk_resume()
647 fail_log_device(lc); in disk_resume()
655 struct log_c *lc = log->context; in core_get_region_size() local
657 return lc->region_size; in core_get_region_size()
662 struct log_c *lc = log->context; in core_resume() local
664 lc->sync_search = 0; in core_resume()
670 struct log_c *lc = log->context; in core_is_clean() local
672 return log_test_bit(lc->clean_bits, region); in core_is_clean()
677 struct log_c *lc = log->context; in core_in_sync() local
679 return log_test_bit(lc->sync_bits, region); in core_in_sync()
691 struct log_c *lc = log->context; in disk_flush() local
694 if (!lc->touched_cleaned && !lc->touched_dirtied) in disk_flush()
697 if (lc->touched_cleaned && log->flush_callback_fn && in disk_flush()
698 log->flush_callback_fn(lc->ti)) { in disk_flush()
705 lc->flush_failed = 1; in disk_flush()
706 for (i = 0; i < lc->region_count; i++) in disk_flush()
707 log_clear_bit(lc, lc->clean_bits, i); in disk_flush()
710 r = rw_header(lc, REQ_OP_WRITE); in disk_flush()
712 fail_log_device(lc); in disk_flush()
714 if (lc->touched_dirtied) { in disk_flush()
715 r = flush_header(lc); in disk_flush()
717 lc->log_dev_flush_failed = 1; in disk_flush()
718 fail_log_device(lc); in disk_flush()
720 lc->touched_dirtied = 0; in disk_flush()
722 lc->touched_cleaned = 0; in disk_flush()
730 struct log_c *lc = log->context; in core_mark_region() local
732 log_clear_bit(lc, lc->clean_bits, region); in core_mark_region()
737 struct log_c *lc = log->context; in core_clear_region() local
739 if (likely(!lc->flush_failed)) in core_clear_region()
740 log_set_bit(lc, lc->clean_bits, region); in core_clear_region()
745 struct log_c *lc = log->context; in core_get_resync_work() local
747 if (lc->sync_search >= lc->region_count) in core_get_resync_work()
751 *region = find_next_zero_bit_le(lc->sync_bits, in core_get_resync_work()
752 lc->region_count, in core_get_resync_work()
753 lc->sync_search); in core_get_resync_work()
754 lc->sync_search = *region + 1; in core_get_resync_work()
756 if (*region >= lc->region_count) in core_get_resync_work()
759 } while (log_test_bit(lc->recovering_bits, *region)); in core_get_resync_work()
761 log_set_bit(lc, lc->recovering_bits, *region); in core_get_resync_work()
768 struct log_c *lc = log->context; in core_set_region_sync() local
770 log_clear_bit(lc, lc->recovering_bits, region); in core_set_region_sync()
772 log_set_bit(lc, lc->sync_bits, region); in core_set_region_sync()
773 lc->sync_count++; in core_set_region_sync()
774 } else if (log_test_bit(lc->sync_bits, region)) { in core_set_region_sync()
775 lc->sync_count--; in core_set_region_sync()
776 log_clear_bit(lc, lc->sync_bits, region); in core_set_region_sync()
782 struct log_c *lc = log->context; in core_get_sync_count() local
784 return lc->sync_count; in core_get_sync_count()
789 if (lc->sync != DEFAULTSYNC) \
790 DMEMIT("%ssync ", lc->sync == NOSYNC ? "no" : ""); \
797 struct log_c *lc = log->context; in core_status() local
806 lc->sync == DEFAULTSYNC ? 1 : 2, lc->region_size); in core_status()
822 struct log_c *lc = log->context; in disk_status() local
826 DMEMIT("3 %s %s %c", log->type->name, lc->log_dev->name, in disk_status()
827 lc->log_dev_flush_failed ? 'F' : in disk_status()
828 lc->log_dev_failed ? 'D' : in disk_status()
834 lc->sync == DEFAULTSYNC ? 2 : 3, lc->log_dev->name, in disk_status()
835 lc->region_size); in disk_status()