Lines Matching refs:lc
294 static int rw_header(struct log_c *lc, int op) in rw_header() argument
296 lc->io_req.bi_op = op; in rw_header()
297 lc->io_req.bi_op_flags = 0; in rw_header()
299 return dm_io(&lc->io_req, 1, &lc->header_location, NULL); in rw_header()
302 static int flush_header(struct log_c *lc) in flush_header() argument
305 .bdev = lc->header_location.bdev, in flush_header()
310 lc->io_req.bi_op = REQ_OP_WRITE; in flush_header()
311 lc->io_req.bi_op_flags = REQ_PREFLUSH; in flush_header()
313 return dm_io(&lc->io_req, 1, &null_location, NULL); in flush_header()
369 struct log_c *lc; in create_log_context() local
401 lc = kmalloc(sizeof(*lc), GFP_KERNEL); in create_log_context()
402 if (!lc) { in create_log_context()
407 lc->ti = ti; in create_log_context()
408 lc->touched_dirtied = 0; in create_log_context()
409 lc->touched_cleaned = 0; in create_log_context()
410 lc->flush_failed = 0; in create_log_context()
411 lc->region_size = region_size; in create_log_context()
412 lc->region_count = region_count; in create_log_context()
413 lc->sync = sync; in create_log_context()
419 sizeof(*lc->clean_bits) << BYTE_SHIFT); in create_log_context()
422 lc->bitset_uint32_count = bitset_size / sizeof(*lc->clean_bits); in create_log_context()
428 lc->clean_bits = vmalloc(bitset_size); in create_log_context()
429 if (!lc->clean_bits) { in create_log_context()
431 kfree(lc); in create_log_context()
434 lc->disk_header = NULL; in create_log_context()
436 lc->log_dev = dev; in create_log_context()
437 lc->log_dev_failed = 0; in create_log_context()
438 lc->log_dev_flush_failed = 0; in create_log_context()
439 lc->header_location.bdev = lc->log_dev->bdev; in create_log_context()
440 lc->header_location.sector = 0; in create_log_context()
447 bdev_logical_block_size(lc->header_location. in create_log_context()
453 kfree(lc); in create_log_context()
457 lc->header_location.count = buf_size >> SECTOR_SHIFT; in create_log_context()
459 lc->io_req.mem.type = DM_IO_VMA; in create_log_context()
460 lc->io_req.notify.fn = NULL; in create_log_context()
461 lc->io_req.client = dm_io_client_create(); in create_log_context()
462 if (IS_ERR(lc->io_req.client)) { in create_log_context()
463 r = PTR_ERR(lc->io_req.client); in create_log_context()
465 kfree(lc); in create_log_context()
469 lc->disk_header = vmalloc(buf_size); in create_log_context()
470 if (!lc->disk_header) { in create_log_context()
472 dm_io_client_destroy(lc->io_req.client); in create_log_context()
473 kfree(lc); in create_log_context()
477 lc->io_req.mem.ptr.vma = lc->disk_header; in create_log_context()
478 lc->clean_bits = (void *)lc->disk_header + in create_log_context()
482 memset(lc->clean_bits, -1, bitset_size); in create_log_context()
484 lc->sync_bits = vmalloc(bitset_size); in create_log_context()
485 if (!lc->sync_bits) { in create_log_context()
488 vfree(lc->clean_bits); in create_log_context()
490 dm_io_client_destroy(lc->io_req.client); in create_log_context()
491 vfree(lc->disk_header); in create_log_context()
492 kfree(lc); in create_log_context()
495 memset(lc->sync_bits, (sync == NOSYNC) ? -1 : 0, bitset_size); in create_log_context()
496 lc->sync_count = (sync == NOSYNC) ? region_count : 0; in create_log_context()
498 lc->recovering_bits = vzalloc(bitset_size); in create_log_context()
499 if (!lc->recovering_bits) { in create_log_context()
501 vfree(lc->sync_bits); in create_log_context()
503 vfree(lc->clean_bits); in create_log_context()
505 dm_io_client_destroy(lc->io_req.client); in create_log_context()
506 vfree(lc->disk_header); in create_log_context()
507 kfree(lc); in create_log_context()
510 lc->sync_search = 0; in create_log_context()
511 log->context = lc; in create_log_context()
522 static void destroy_log_context(struct log_c *lc) in destroy_log_context() argument
524 vfree(lc->sync_bits); in destroy_log_context()
525 vfree(lc->recovering_bits); in destroy_log_context()
526 kfree(lc); in destroy_log_context()
531 struct log_c *lc = (struct log_c *) log->context; in core_dtr() local
533 vfree(lc->clean_bits); in core_dtr()
534 destroy_log_context(lc); in core_dtr()
568 struct log_c *lc = (struct log_c *) log->context; in disk_dtr() local
570 dm_put_device(lc->ti, lc->log_dev); in disk_dtr()
571 vfree(lc->disk_header); in disk_dtr()
572 dm_io_client_destroy(lc->io_req.client); in disk_dtr()
573 destroy_log_context(lc); in disk_dtr()
576 static void fail_log_device(struct log_c *lc) in fail_log_device() argument
578 if (lc->log_dev_failed) in fail_log_device()
581 lc->log_dev_failed = 1; in fail_log_device()
582 dm_table_event(lc->ti->table); in fail_log_device()
589 struct log_c *lc = (struct log_c *) log->context; in disk_resume() local
590 size_t size = lc->bitset_uint32_count * sizeof(uint32_t); in disk_resume()
593 r = read_header(lc); in disk_resume()
596 lc->log_dev->name); in disk_resume()
597 fail_log_device(lc); in disk_resume()
605 lc->header.nr_regions = 0; in disk_resume()
609 if (lc->sync == NOSYNC) in disk_resume()
610 for (i = lc->header.nr_regions; i < lc->region_count; i++) in disk_resume()
612 log_set_bit(lc, lc->clean_bits, i); in disk_resume()
614 for (i = lc->header.nr_regions; i < lc->region_count; i++) in disk_resume()
616 log_clear_bit(lc, lc->clean_bits, i); in disk_resume()
619 for (i = lc->region_count; i % (sizeof(*lc->clean_bits) << BYTE_SHIFT); i++) in disk_resume()
620 log_clear_bit(lc, lc->clean_bits, i); in disk_resume()
623 memcpy(lc->sync_bits, lc->clean_bits, size); in disk_resume()
624 lc->sync_count = memweight(lc->clean_bits, in disk_resume()
625 lc->bitset_uint32_count * sizeof(uint32_t)); in disk_resume()
626 lc->sync_search = 0; in disk_resume()
629 lc->header.nr_regions = lc->region_count; in disk_resume()
631 header_to_disk(&lc->header, lc->disk_header); in disk_resume()
634 r = rw_header(lc, REQ_OP_WRITE); in disk_resume()
636 r = flush_header(lc); in disk_resume()
638 lc->log_dev_flush_failed = 1; in disk_resume()
642 lc->log_dev->name); in disk_resume()
643 fail_log_device(lc); in disk_resume()
651 struct log_c *lc = (struct log_c *) log->context; in core_get_region_size() local
652 return lc->region_size; in core_get_region_size()
657 struct log_c *lc = (struct log_c *) log->context; in core_resume() local
658 lc->sync_search = 0; in core_resume()
664 struct log_c *lc = (struct log_c *) log->context; in core_is_clean() local
665 return log_test_bit(lc->clean_bits, region); in core_is_clean()
670 struct log_c *lc = (struct log_c *) log->context; in core_in_sync() local
671 return log_test_bit(lc->sync_bits, region); in core_in_sync()
683 struct log_c *lc = log->context; in disk_flush() local
686 if (!lc->touched_cleaned && !lc->touched_dirtied) in disk_flush()
689 if (lc->touched_cleaned && log->flush_callback_fn && in disk_flush()
690 log->flush_callback_fn(lc->ti)) { in disk_flush()
697 lc->flush_failed = 1; in disk_flush()
698 for (i = 0; i < lc->region_count; i++) in disk_flush()
699 log_clear_bit(lc, lc->clean_bits, i); in disk_flush()
702 r = rw_header(lc, REQ_OP_WRITE); in disk_flush()
704 fail_log_device(lc); in disk_flush()
706 if (lc->touched_dirtied) { in disk_flush()
707 r = flush_header(lc); in disk_flush()
709 lc->log_dev_flush_failed = 1; in disk_flush()
710 fail_log_device(lc); in disk_flush()
712 lc->touched_dirtied = 0; in disk_flush()
714 lc->touched_cleaned = 0; in disk_flush()
722 struct log_c *lc = (struct log_c *) log->context; in core_mark_region() local
723 log_clear_bit(lc, lc->clean_bits, region); in core_mark_region()
728 struct log_c *lc = (struct log_c *) log->context; in core_clear_region() local
729 if (likely(!lc->flush_failed)) in core_clear_region()
730 log_set_bit(lc, lc->clean_bits, region); in core_clear_region()
735 struct log_c *lc = (struct log_c *) log->context; in core_get_resync_work() local
737 if (lc->sync_search >= lc->region_count) in core_get_resync_work()
741 *region = find_next_zero_bit_le(lc->sync_bits, in core_get_resync_work()
742 lc->region_count, in core_get_resync_work()
743 lc->sync_search); in core_get_resync_work()
744 lc->sync_search = *region + 1; in core_get_resync_work()
746 if (*region >= lc->region_count) in core_get_resync_work()
749 } while (log_test_bit(lc->recovering_bits, *region)); in core_get_resync_work()
751 log_set_bit(lc, lc->recovering_bits, *region); in core_get_resync_work()
758 struct log_c *lc = (struct log_c *) log->context; in core_set_region_sync() local
760 log_clear_bit(lc, lc->recovering_bits, region); in core_set_region_sync()
762 log_set_bit(lc, lc->sync_bits, region); in core_set_region_sync()
763 lc->sync_count++; in core_set_region_sync()
764 } else if (log_test_bit(lc->sync_bits, region)) { in core_set_region_sync()
765 lc->sync_count--; in core_set_region_sync()
766 log_clear_bit(lc, lc->sync_bits, region); in core_set_region_sync()
772 struct log_c *lc = (struct log_c *) log->context; in core_get_sync_count() local
774 return lc->sync_count; in core_get_sync_count()
778 if (lc->sync != DEFAULTSYNC) \
779 DMEMIT("%ssync ", lc->sync == NOSYNC ? "no" : "")
785 struct log_c *lc = log->context; in core_status() local
794 lc->sync == DEFAULTSYNC ? 1 : 2, lc->region_size); in core_status()
805 struct log_c *lc = log->context; in disk_status() local
809 DMEMIT("3 %s %s %c", log->type->name, lc->log_dev->name, in disk_status()
810 lc->log_dev_flush_failed ? 'F' : in disk_status()
811 lc->log_dev_failed ? 'D' : in disk_status()
817 lc->sync == DEFAULTSYNC ? 2 : 3, lc->log_dev->name, in disk_status()
818 lc->region_size); in disk_status()