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()
421 lc->bitset_uint32_count = bitset_size / sizeof(*lc->clean_bits); in create_log_context()
427 lc->clean_bits = vmalloc(bitset_size); in create_log_context()
428 if (!lc->clean_bits) { in create_log_context()
430 kfree(lc); in create_log_context()
433 lc->disk_header = NULL; in create_log_context()
435 lc->log_dev = dev; in create_log_context()
436 lc->log_dev_failed = 0; in create_log_context()
437 lc->log_dev_flush_failed = 0; in create_log_context()
438 lc->header_location.bdev = lc->log_dev->bdev; in create_log_context()
439 lc->header_location.sector = 0; in create_log_context()
446 bdev_logical_block_size(lc->header_location. in create_log_context()
452 kfree(lc); in create_log_context()
456 lc->header_location.count = buf_size >> SECTOR_SHIFT; in create_log_context()
458 lc->io_req.mem.type = DM_IO_VMA; in create_log_context()
459 lc->io_req.notify.fn = NULL; in create_log_context()
460 lc->io_req.client = dm_io_client_create(); in create_log_context()
461 if (IS_ERR(lc->io_req.client)) { in create_log_context()
462 r = PTR_ERR(lc->io_req.client); in create_log_context()
464 kfree(lc); in create_log_context()
468 lc->disk_header = vmalloc(buf_size); in create_log_context()
469 if (!lc->disk_header) { in create_log_context()
471 dm_io_client_destroy(lc->io_req.client); in create_log_context()
472 kfree(lc); in create_log_context()
476 lc->io_req.mem.ptr.vma = lc->disk_header; in create_log_context()
477 lc->clean_bits = (void *)lc->disk_header + in create_log_context()
481 memset(lc->clean_bits, -1, bitset_size); in create_log_context()
483 lc->sync_bits = vmalloc(bitset_size); in create_log_context()
484 if (!lc->sync_bits) { in create_log_context()
487 vfree(lc->clean_bits); in create_log_context()
489 dm_io_client_destroy(lc->io_req.client); in create_log_context()
490 vfree(lc->disk_header); in create_log_context()
491 kfree(lc); in create_log_context()
494 memset(lc->sync_bits, (sync == NOSYNC) ? -1 : 0, bitset_size); in create_log_context()
495 lc->sync_count = (sync == NOSYNC) ? region_count : 0; in create_log_context()
497 lc->recovering_bits = vzalloc(bitset_size); in create_log_context()
498 if (!lc->recovering_bits) { in create_log_context()
500 vfree(lc->sync_bits); in create_log_context()
502 vfree(lc->clean_bits); in create_log_context()
504 dm_io_client_destroy(lc->io_req.client); in create_log_context()
505 vfree(lc->disk_header); in create_log_context()
506 kfree(lc); in create_log_context()
509 lc->sync_search = 0; in create_log_context()
510 log->context = lc; in create_log_context()
521 static void destroy_log_context(struct log_c *lc) in destroy_log_context() argument
523 vfree(lc->sync_bits); in destroy_log_context()
524 vfree(lc->recovering_bits); in destroy_log_context()
525 kfree(lc); in destroy_log_context()
530 struct log_c *lc = (struct log_c *) log->context; in core_dtr() local
532 vfree(lc->clean_bits); in core_dtr()
533 destroy_log_context(lc); in core_dtr()
567 struct log_c *lc = (struct log_c *) log->context; in disk_dtr() local
569 dm_put_device(lc->ti, lc->log_dev); in disk_dtr()
570 vfree(lc->disk_header); in disk_dtr()
571 dm_io_client_destroy(lc->io_req.client); in disk_dtr()
572 destroy_log_context(lc); in disk_dtr()
575 static void fail_log_device(struct log_c *lc) in fail_log_device() argument
577 if (lc->log_dev_failed) in fail_log_device()
580 lc->log_dev_failed = 1; in fail_log_device()
581 dm_table_event(lc->ti->table); in fail_log_device()
588 struct log_c *lc = (struct log_c *) log->context; in disk_resume() local
589 size_t size = lc->bitset_uint32_count * sizeof(uint32_t); in disk_resume()
592 r = read_header(lc); in disk_resume()
595 lc->log_dev->name); in disk_resume()
596 fail_log_device(lc); in disk_resume()
604 lc->header.nr_regions = 0; in disk_resume()
608 if (lc->sync == NOSYNC) in disk_resume()
609 for (i = lc->header.nr_regions; i < lc->region_count; i++) in disk_resume()
611 log_set_bit(lc, lc->clean_bits, i); in disk_resume()
613 for (i = lc->header.nr_regions; i < lc->region_count; i++) in disk_resume()
615 log_clear_bit(lc, lc->clean_bits, i); in disk_resume()
618 for (i = lc->region_count; i % BITS_PER_LONG; i++) in disk_resume()
619 log_clear_bit(lc, lc->clean_bits, i); in disk_resume()
622 memcpy(lc->sync_bits, lc->clean_bits, size); in disk_resume()
623 lc->sync_count = memweight(lc->clean_bits, in disk_resume()
624 lc->bitset_uint32_count * sizeof(uint32_t)); in disk_resume()
625 lc->sync_search = 0; in disk_resume()
628 lc->header.nr_regions = lc->region_count; in disk_resume()
630 header_to_disk(&lc->header, lc->disk_header); in disk_resume()
633 r = rw_header(lc, REQ_OP_WRITE); in disk_resume()
635 r = flush_header(lc); in disk_resume()
637 lc->log_dev_flush_failed = 1; in disk_resume()
641 lc->log_dev->name); in disk_resume()
642 fail_log_device(lc); in disk_resume()
650 struct log_c *lc = (struct log_c *) log->context; in core_get_region_size() local
651 return lc->region_size; in core_get_region_size()
656 struct log_c *lc = (struct log_c *) log->context; in core_resume() local
657 lc->sync_search = 0; in core_resume()
663 struct log_c *lc = (struct log_c *) log->context; in core_is_clean() local
664 return log_test_bit(lc->clean_bits, region); in core_is_clean()
669 struct log_c *lc = (struct log_c *) log->context; in core_in_sync() local
670 return log_test_bit(lc->sync_bits, region); in core_in_sync()
682 struct log_c *lc = log->context; in disk_flush() local
685 if (!lc->touched_cleaned && !lc->touched_dirtied) in disk_flush()
688 if (lc->touched_cleaned && log->flush_callback_fn && in disk_flush()
689 log->flush_callback_fn(lc->ti)) { in disk_flush()
696 lc->flush_failed = 1; in disk_flush()
697 for (i = 0; i < lc->region_count; i++) in disk_flush()
698 log_clear_bit(lc, lc->clean_bits, i); in disk_flush()
701 r = rw_header(lc, REQ_OP_WRITE); in disk_flush()
703 fail_log_device(lc); in disk_flush()
705 if (lc->touched_dirtied) { in disk_flush()
706 r = flush_header(lc); in disk_flush()
708 lc->log_dev_flush_failed = 1; in disk_flush()
709 fail_log_device(lc); in disk_flush()
711 lc->touched_dirtied = 0; in disk_flush()
713 lc->touched_cleaned = 0; in disk_flush()
721 struct log_c *lc = (struct log_c *) log->context; in core_mark_region() local
722 log_clear_bit(lc, lc->clean_bits, region); in core_mark_region()
727 struct log_c *lc = (struct log_c *) log->context; in core_clear_region() local
728 if (likely(!lc->flush_failed)) in core_clear_region()
729 log_set_bit(lc, lc->clean_bits, region); in core_clear_region()
734 struct log_c *lc = (struct log_c *) log->context; in core_get_resync_work() local
736 if (lc->sync_search >= lc->region_count) in core_get_resync_work()
740 *region = find_next_zero_bit_le(lc->sync_bits, in core_get_resync_work()
741 lc->region_count, in core_get_resync_work()
742 lc->sync_search); in core_get_resync_work()
743 lc->sync_search = *region + 1; in core_get_resync_work()
745 if (*region >= lc->region_count) in core_get_resync_work()
748 } while (log_test_bit(lc->recovering_bits, *region)); in core_get_resync_work()
750 log_set_bit(lc, lc->recovering_bits, *region); in core_get_resync_work()
757 struct log_c *lc = (struct log_c *) log->context; in core_set_region_sync() local
759 log_clear_bit(lc, lc->recovering_bits, region); in core_set_region_sync()
761 log_set_bit(lc, lc->sync_bits, region); in core_set_region_sync()
762 lc->sync_count++; in core_set_region_sync()
763 } else if (log_test_bit(lc->sync_bits, region)) { in core_set_region_sync()
764 lc->sync_count--; in core_set_region_sync()
765 log_clear_bit(lc, lc->sync_bits, region); in core_set_region_sync()
771 struct log_c *lc = (struct log_c *) log->context; in core_get_sync_count() local
773 return lc->sync_count; in core_get_sync_count()
777 if (lc->sync != DEFAULTSYNC) \
778 DMEMIT("%ssync ", lc->sync == NOSYNC ? "no" : "")
784 struct log_c *lc = log->context; in core_status() local
793 lc->sync == DEFAULTSYNC ? 1 : 2, lc->region_size); in core_status()
804 struct log_c *lc = log->context; in disk_status() local
808 DMEMIT("3 %s %s %c", log->type->name, lc->log_dev->name, in disk_status()
809 lc->log_dev_flush_failed ? 'F' : in disk_status()
810 lc->log_dev_failed ? 'D' : in disk_status()
816 lc->sync == DEFAULTSYNC ? 2 : 3, lc->log_dev->name, in disk_status()
817 lc->region_size); in disk_status()