Lines Matching refs:lc
294 static int rw_header(struct log_c *lc, enum req_op op) in rw_header() argument
296 lc->io_req.bi_opf = op; 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_opf = REQ_OP_WRITE | REQ_PREFLUSH; 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()
419 lc->bitset_uint32_count = bitset_size / sizeof(*lc->clean_bits); in create_log_context()
425 lc->clean_bits = vmalloc(bitset_size); in create_log_context()
426 if (!lc->clean_bits) { in create_log_context()
428 kfree(lc); in create_log_context()
431 lc->disk_header = NULL; in create_log_context()
433 lc->log_dev = dev; in create_log_context()
434 lc->log_dev_failed = 0; in create_log_context()
435 lc->log_dev_flush_failed = 0; in create_log_context()
436 lc->header_location.bdev = lc->log_dev->bdev; in create_log_context()
437 lc->header_location.sector = 0; in create_log_context()
444 bdev_logical_block_size(lc->header_location. in create_log_context()
450 kfree(lc); in create_log_context()
454 lc->header_location.count = buf_size >> SECTOR_SHIFT; in create_log_context()
456 lc->io_req.mem.type = DM_IO_VMA; in create_log_context()
457 lc->io_req.notify.fn = NULL; in create_log_context()
458 lc->io_req.client = dm_io_client_create(); in create_log_context()
459 if (IS_ERR(lc->io_req.client)) { in create_log_context()
460 r = PTR_ERR(lc->io_req.client); in create_log_context()
462 kfree(lc); in create_log_context()
466 lc->disk_header = vmalloc(buf_size); in create_log_context()
467 if (!lc->disk_header) { in create_log_context()
469 dm_io_client_destroy(lc->io_req.client); in create_log_context()
470 kfree(lc); in create_log_context()
474 lc->io_req.mem.ptr.vma = lc->disk_header; in create_log_context()
475 lc->clean_bits = (void *)lc->disk_header + in create_log_context()
479 memset(lc->clean_bits, -1, bitset_size); in create_log_context()
481 lc->sync_bits = vmalloc(bitset_size); in create_log_context()
482 if (!lc->sync_bits) { in create_log_context()
485 vfree(lc->clean_bits); in create_log_context()
487 dm_io_client_destroy(lc->io_req.client); in create_log_context()
488 vfree(lc->disk_header); in create_log_context()
489 kfree(lc); in create_log_context()
492 memset(lc->sync_bits, (sync == NOSYNC) ? -1 : 0, bitset_size); in create_log_context()
493 lc->sync_count = (sync == NOSYNC) ? region_count : 0; in create_log_context()
495 lc->recovering_bits = vzalloc(bitset_size); in create_log_context()
496 if (!lc->recovering_bits) { in create_log_context()
498 vfree(lc->sync_bits); in create_log_context()
500 vfree(lc->clean_bits); in create_log_context()
502 dm_io_client_destroy(lc->io_req.client); in create_log_context()
503 vfree(lc->disk_header); in create_log_context()
504 kfree(lc); in create_log_context()
507 lc->sync_search = 0; in create_log_context()
508 log->context = lc; in create_log_context()
519 static void destroy_log_context(struct log_c *lc) in destroy_log_context() argument
521 vfree(lc->sync_bits); in destroy_log_context()
522 vfree(lc->recovering_bits); in destroy_log_context()
523 kfree(lc); in destroy_log_context()
528 struct log_c *lc = (struct log_c *) log->context; in core_dtr() local
530 vfree(lc->clean_bits); in core_dtr()
531 destroy_log_context(lc); in core_dtr()
565 struct log_c *lc = (struct log_c *) log->context; in disk_dtr() local
567 dm_put_device(lc->ti, lc->log_dev); in disk_dtr()
568 vfree(lc->disk_header); in disk_dtr()
569 dm_io_client_destroy(lc->io_req.client); in disk_dtr()
570 destroy_log_context(lc); in disk_dtr()
573 static void fail_log_device(struct log_c *lc) in fail_log_device() argument
575 if (lc->log_dev_failed) in fail_log_device()
578 lc->log_dev_failed = 1; in fail_log_device()
579 dm_table_event(lc->ti->table); in fail_log_device()
586 struct log_c *lc = (struct log_c *) log->context; in disk_resume() local
587 size_t size = lc->bitset_uint32_count * sizeof(uint32_t); in disk_resume()
590 r = read_header(lc); in disk_resume()
593 lc->log_dev->name); in disk_resume()
594 fail_log_device(lc); in disk_resume()
602 lc->header.nr_regions = 0; in disk_resume()
606 if (lc->sync == NOSYNC) in disk_resume()
607 for (i = lc->header.nr_regions; i < lc->region_count; i++) in disk_resume()
609 log_set_bit(lc, lc->clean_bits, i); in disk_resume()
611 for (i = lc->header.nr_regions; i < lc->region_count; i++) in disk_resume()
613 log_clear_bit(lc, lc->clean_bits, i); in disk_resume()
616 for (i = lc->region_count; i % BITS_PER_LONG; i++) in disk_resume()
617 log_clear_bit(lc, lc->clean_bits, i); in disk_resume()
620 memcpy(lc->sync_bits, lc->clean_bits, size); in disk_resume()
621 lc->sync_count = memweight(lc->clean_bits, in disk_resume()
622 lc->bitset_uint32_count * sizeof(uint32_t)); in disk_resume()
623 lc->sync_search = 0; in disk_resume()
626 lc->header.nr_regions = lc->region_count; in disk_resume()
628 header_to_disk(&lc->header, lc->disk_header); in disk_resume()
631 r = rw_header(lc, REQ_OP_WRITE); in disk_resume()
633 r = flush_header(lc); in disk_resume()
635 lc->log_dev_flush_failed = 1; in disk_resume()
639 lc->log_dev->name); in disk_resume()
640 fail_log_device(lc); in disk_resume()
648 struct log_c *lc = (struct log_c *) log->context; in core_get_region_size() local
649 return lc->region_size; in core_get_region_size()
654 struct log_c *lc = (struct log_c *) log->context; in core_resume() local
655 lc->sync_search = 0; in core_resume()
661 struct log_c *lc = (struct log_c *) log->context; in core_is_clean() local
662 return log_test_bit(lc->clean_bits, region); in core_is_clean()
667 struct log_c *lc = (struct log_c *) log->context; in core_in_sync() local
668 return log_test_bit(lc->sync_bits, region); in core_in_sync()
680 struct log_c *lc = log->context; in disk_flush() local
683 if (!lc->touched_cleaned && !lc->touched_dirtied) in disk_flush()
686 if (lc->touched_cleaned && log->flush_callback_fn && in disk_flush()
687 log->flush_callback_fn(lc->ti)) { in disk_flush()
694 lc->flush_failed = 1; in disk_flush()
695 for (i = 0; i < lc->region_count; i++) in disk_flush()
696 log_clear_bit(lc, lc->clean_bits, i); in disk_flush()
699 r = rw_header(lc, REQ_OP_WRITE); in disk_flush()
701 fail_log_device(lc); in disk_flush()
703 if (lc->touched_dirtied) { in disk_flush()
704 r = flush_header(lc); in disk_flush()
706 lc->log_dev_flush_failed = 1; in disk_flush()
707 fail_log_device(lc); in disk_flush()
709 lc->touched_dirtied = 0; in disk_flush()
711 lc->touched_cleaned = 0; in disk_flush()
719 struct log_c *lc = (struct log_c *) log->context; in core_mark_region() local
720 log_clear_bit(lc, lc->clean_bits, region); in core_mark_region()
725 struct log_c *lc = (struct log_c *) log->context; in core_clear_region() local
726 if (likely(!lc->flush_failed)) in core_clear_region()
727 log_set_bit(lc, lc->clean_bits, region); in core_clear_region()
732 struct log_c *lc = (struct log_c *) log->context; in core_get_resync_work() local
734 if (lc->sync_search >= lc->region_count) in core_get_resync_work()
738 *region = find_next_zero_bit_le(lc->sync_bits, in core_get_resync_work()
739 lc->region_count, in core_get_resync_work()
740 lc->sync_search); in core_get_resync_work()
741 lc->sync_search = *region + 1; in core_get_resync_work()
743 if (*region >= lc->region_count) in core_get_resync_work()
746 } while (log_test_bit(lc->recovering_bits, *region)); in core_get_resync_work()
748 log_set_bit(lc, lc->recovering_bits, *region); in core_get_resync_work()
755 struct log_c *lc = (struct log_c *) log->context; in core_set_region_sync() local
757 log_clear_bit(lc, lc->recovering_bits, region); in core_set_region_sync()
759 log_set_bit(lc, lc->sync_bits, region); in core_set_region_sync()
760 lc->sync_count++; in core_set_region_sync()
761 } else if (log_test_bit(lc->sync_bits, region)) { in core_set_region_sync()
762 lc->sync_count--; in core_set_region_sync()
763 log_clear_bit(lc, lc->sync_bits, region); in core_set_region_sync()
769 struct log_c *lc = (struct log_c *) log->context; in core_get_sync_count() local
771 return lc->sync_count; in core_get_sync_count()
775 if (lc->sync != DEFAULTSYNC) \
776 DMEMIT("%ssync ", lc->sync == NOSYNC ? "no" : "")
782 struct log_c *lc = log->context; in core_status() local
791 lc->sync == DEFAULTSYNC ? 1 : 2, lc->region_size); in core_status()
807 struct log_c *lc = log->context; in disk_status() local
811 DMEMIT("3 %s %s %c", log->type->name, lc->log_dev->name, in disk_status()
812 lc->log_dev_flush_failed ? 'F' : in disk_status()
813 lc->log_dev_failed ? 'D' : in disk_status()
819 lc->sync == DEFAULTSYNC ? 2 : 3, lc->log_dev->name, in disk_status()
820 lc->region_size); in disk_status()