Lines Matching refs:lc
294 static int rw_header(struct log_c *lc, int rw) in rw_header() argument
296 lc->io_req.bi_rw = rw; in rw_header()
298 return dm_io(&lc->io_req, 1, &lc->header_location, NULL); in rw_header()
301 static int flush_header(struct log_c *lc) in flush_header() argument
304 .bdev = lc->header_location.bdev, in flush_header()
309 lc->io_req.bi_rw = WRITE_FLUSH; in flush_header()
311 return dm_io(&lc->io_req, 1, &null_location, NULL); in flush_header()
367 struct log_c *lc; in create_log_context() local
399 lc = kmalloc(sizeof(*lc), GFP_KERNEL); in create_log_context()
400 if (!lc) { in create_log_context()
405 lc->ti = ti; in create_log_context()
406 lc->touched_dirtied = 0; in create_log_context()
407 lc->touched_cleaned = 0; in create_log_context()
408 lc->flush_failed = 0; in create_log_context()
409 lc->region_size = region_size; in create_log_context()
410 lc->region_count = region_count; in create_log_context()
411 lc->sync = sync; in create_log_context()
417 sizeof(*lc->clean_bits) << BYTE_SHIFT); in create_log_context()
420 lc->bitset_uint32_count = bitset_size / sizeof(*lc->clean_bits); in create_log_context()
426 lc->clean_bits = vmalloc(bitset_size); in create_log_context()
427 if (!lc->clean_bits) { in create_log_context()
429 kfree(lc); in create_log_context()
432 lc->disk_header = NULL; in create_log_context()
434 lc->log_dev = dev; in create_log_context()
435 lc->log_dev_failed = 0; in create_log_context()
436 lc->log_dev_flush_failed = 0; in create_log_context()
437 lc->header_location.bdev = lc->log_dev->bdev; in create_log_context()
438 lc->header_location.sector = 0; in create_log_context()
445 bdev_logical_block_size(lc->header_location. in create_log_context()
451 kfree(lc); in create_log_context()
455 lc->header_location.count = buf_size >> SECTOR_SHIFT; in create_log_context()
457 lc->io_req.mem.type = DM_IO_VMA; in create_log_context()
458 lc->io_req.notify.fn = NULL; in create_log_context()
459 lc->io_req.client = dm_io_client_create(); in create_log_context()
460 if (IS_ERR(lc->io_req.client)) { in create_log_context()
461 r = PTR_ERR(lc->io_req.client); in create_log_context()
463 kfree(lc); in create_log_context()
467 lc->disk_header = vmalloc(buf_size); in create_log_context()
468 if (!lc->disk_header) { in create_log_context()
470 dm_io_client_destroy(lc->io_req.client); in create_log_context()
471 kfree(lc); in create_log_context()
475 lc->io_req.mem.ptr.vma = lc->disk_header; in create_log_context()
476 lc->clean_bits = (void *)lc->disk_header + in create_log_context()
480 memset(lc->clean_bits, -1, bitset_size); in create_log_context()
482 lc->sync_bits = vmalloc(bitset_size); in create_log_context()
483 if (!lc->sync_bits) { in create_log_context()
486 vfree(lc->clean_bits); in create_log_context()
488 dm_io_client_destroy(lc->io_req.client); in create_log_context()
489 vfree(lc->disk_header); in create_log_context()
490 kfree(lc); in create_log_context()
493 memset(lc->sync_bits, (sync == NOSYNC) ? -1 : 0, bitset_size); in create_log_context()
494 lc->sync_count = (sync == NOSYNC) ? region_count : 0; in create_log_context()
496 lc->recovering_bits = vzalloc(bitset_size); in create_log_context()
497 if (!lc->recovering_bits) { in create_log_context()
499 vfree(lc->sync_bits); in create_log_context()
501 vfree(lc->clean_bits); in create_log_context()
503 dm_io_client_destroy(lc->io_req.client); in create_log_context()
504 vfree(lc->disk_header); in create_log_context()
505 kfree(lc); in create_log_context()
508 lc->sync_search = 0; in create_log_context()
509 log->context = lc; in create_log_context()
520 static void destroy_log_context(struct log_c *lc) in destroy_log_context() argument
522 vfree(lc->sync_bits); in destroy_log_context()
523 vfree(lc->recovering_bits); in destroy_log_context()
524 kfree(lc); in destroy_log_context()
529 struct log_c *lc = (struct log_c *) log->context; in core_dtr() local
531 vfree(lc->clean_bits); in core_dtr()
532 destroy_log_context(lc); in core_dtr()
566 struct log_c *lc = (struct log_c *) log->context; in disk_dtr() local
568 dm_put_device(lc->ti, lc->log_dev); in disk_dtr()
569 vfree(lc->disk_header); in disk_dtr()
570 dm_io_client_destroy(lc->io_req.client); in disk_dtr()
571 destroy_log_context(lc); in disk_dtr()
574 static void fail_log_device(struct log_c *lc) in fail_log_device() argument
576 if (lc->log_dev_failed) in fail_log_device()
579 lc->log_dev_failed = 1; in fail_log_device()
580 dm_table_event(lc->ti->table); in fail_log_device()
587 struct log_c *lc = (struct log_c *) log->context; in disk_resume() local
588 size_t size = lc->bitset_uint32_count * sizeof(uint32_t); in disk_resume()
591 r = read_header(lc); in disk_resume()
594 lc->log_dev->name); in disk_resume()
595 fail_log_device(lc); in disk_resume()
603 lc->header.nr_regions = 0; in disk_resume()
607 if (lc->sync == NOSYNC) in disk_resume()
608 for (i = lc->header.nr_regions; i < lc->region_count; i++) in disk_resume()
610 log_set_bit(lc, lc->clean_bits, i); in disk_resume()
612 for (i = lc->header.nr_regions; i < lc->region_count; i++) in disk_resume()
614 log_clear_bit(lc, lc->clean_bits, i); in disk_resume()
617 for (i = lc->region_count; i % (sizeof(*lc->clean_bits) << BYTE_SHIFT); i++) in disk_resume()
618 log_clear_bit(lc, lc->clean_bits, i); in disk_resume()
621 memcpy(lc->sync_bits, lc->clean_bits, size); in disk_resume()
622 lc->sync_count = memweight(lc->clean_bits, in disk_resume()
623 lc->bitset_uint32_count * sizeof(uint32_t)); in disk_resume()
624 lc->sync_search = 0; in disk_resume()
627 lc->header.nr_regions = lc->region_count; in disk_resume()
629 header_to_disk(&lc->header, lc->disk_header); in disk_resume()
632 r = rw_header(lc, WRITE); in disk_resume()
634 r = flush_header(lc); in disk_resume()
636 lc->log_dev_flush_failed = 1; in disk_resume()
640 lc->log_dev->name); in disk_resume()
641 fail_log_device(lc); in disk_resume()
649 struct log_c *lc = (struct log_c *) log->context; in core_get_region_size() local
650 return lc->region_size; in core_get_region_size()
655 struct log_c *lc = (struct log_c *) log->context; in core_resume() local
656 lc->sync_search = 0; in core_resume()
662 struct log_c *lc = (struct log_c *) log->context; in core_is_clean() local
663 return log_test_bit(lc->clean_bits, region); in core_is_clean()
668 struct log_c *lc = (struct log_c *) log->context; in core_in_sync() local
669 return log_test_bit(lc->sync_bits, region); in core_in_sync()
681 struct log_c *lc = log->context; in disk_flush() local
684 if (!lc->touched_cleaned && !lc->touched_dirtied) in disk_flush()
687 if (lc->touched_cleaned && log->flush_callback_fn && in disk_flush()
688 log->flush_callback_fn(lc->ti)) { in disk_flush()
695 lc->flush_failed = 1; in disk_flush()
696 for (i = 0; i < lc->region_count; i++) in disk_flush()
697 log_clear_bit(lc, lc->clean_bits, i); in disk_flush()
700 r = rw_header(lc, WRITE); in disk_flush()
702 fail_log_device(lc); in disk_flush()
704 if (lc->touched_dirtied) { in disk_flush()
705 r = flush_header(lc); in disk_flush()
707 lc->log_dev_flush_failed = 1; in disk_flush()
708 fail_log_device(lc); in disk_flush()
710 lc->touched_dirtied = 0; in disk_flush()
712 lc->touched_cleaned = 0; in disk_flush()
720 struct log_c *lc = (struct log_c *) log->context; in core_mark_region() local
721 log_clear_bit(lc, lc->clean_bits, region); in core_mark_region()
726 struct log_c *lc = (struct log_c *) log->context; in core_clear_region() local
727 if (likely(!lc->flush_failed)) in core_clear_region()
728 log_set_bit(lc, lc->clean_bits, region); in core_clear_region()
733 struct log_c *lc = (struct log_c *) log->context; in core_get_resync_work() local
735 if (lc->sync_search >= lc->region_count) in core_get_resync_work()
739 *region = find_next_zero_bit_le(lc->sync_bits, in core_get_resync_work()
740 lc->region_count, in core_get_resync_work()
741 lc->sync_search); in core_get_resync_work()
742 lc->sync_search = *region + 1; in core_get_resync_work()
744 if (*region >= lc->region_count) in core_get_resync_work()
747 } while (log_test_bit(lc->recovering_bits, *region)); in core_get_resync_work()
749 log_set_bit(lc, lc->recovering_bits, *region); in core_get_resync_work()
756 struct log_c *lc = (struct log_c *) log->context; in core_set_region_sync() local
758 log_clear_bit(lc, lc->recovering_bits, region); in core_set_region_sync()
760 log_set_bit(lc, lc->sync_bits, region); in core_set_region_sync()
761 lc->sync_count++; in core_set_region_sync()
762 } else if (log_test_bit(lc->sync_bits, region)) { in core_set_region_sync()
763 lc->sync_count--; in core_set_region_sync()
764 log_clear_bit(lc, lc->sync_bits, region); in core_set_region_sync()
770 struct log_c *lc = (struct log_c *) log->context; in core_get_sync_count() local
772 return lc->sync_count; in core_get_sync_count()
776 if (lc->sync != DEFAULTSYNC) \
777 DMEMIT("%ssync ", lc->sync == NOSYNC ? "no" : "")
783 struct log_c *lc = log->context; in core_status() local
792 lc->sync == DEFAULTSYNC ? 1 : 2, lc->region_size); in core_status()
803 struct log_c *lc = log->context; in disk_status() local
807 DMEMIT("3 %s %s %c", log->type->name, lc->log_dev->name, in disk_status()
808 lc->log_dev_flush_failed ? 'F' : in disk_status()
809 lc->log_dev_failed ? 'D' : in disk_status()
815 lc->sync == DEFAULTSYNC ? 2 : 3, lc->log_dev->name, in disk_status()
816 lc->region_size); in disk_status()