Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dm integrity: whitespace, coding style and dead code cleanup

Just some things that stood out like a sore thumb.
Also, converted some printk(KERN_CRIT, ...) to DMCRIT(...)

Signed-off-by: Mike Snitzer <snitzer@redhat.com>

+61 -43
+61 -43
drivers/md/dm-integrity.c
··· 488 488 #define BITMAP_OP_SET 2 489 489 #define BITMAP_OP_CLEAR 3 490 490 491 - static bool block_bitmap_op(struct dm_integrity_c *ic, struct page_list *bitmap, sector_t sector, sector_t n_sectors, int mode) 491 + static bool block_bitmap_op(struct dm_integrity_c *ic, struct page_list *bitmap, 492 + sector_t sector, sector_t n_sectors, int mode) 492 493 { 493 494 unsigned long bit, end_bit, this_end_bit, page, end_page; 494 495 unsigned long *data; 495 496 496 497 if (unlikely(((sector | n_sectors) & ((1 << ic->sb->log2_sectors_per_block) - 1)) != 0)) { 497 - DMCRIT("invalid bitmap access (%llx,%llx,%d,%d,%d)\n", 498 + DMCRIT("invalid bitmap access (%llx,%llx,%d,%d,%d)", 498 499 (unsigned long long)sector, 499 500 (unsigned long long)n_sectors, 500 501 ic->sb->log2_sectors_per_block, ··· 508 507 return true; 509 508 510 509 bit = sector >> (ic->sb->log2_sectors_per_block + ic->log2_blocks_per_bitmap_bit); 511 - end_bit = (sector + n_sectors - 1) >> (ic->sb->log2_sectors_per_block + ic->log2_blocks_per_bitmap_bit); 510 + end_bit = (sector + n_sectors - 1) >> 511 + (ic->sb->log2_sectors_per_block + ic->log2_blocks_per_bitmap_bit); 512 512 513 513 page = bit / (PAGE_SIZE * 8); 514 514 bit %= PAGE_SIZE * 8; ··· 622 620 623 621 if (unlikely(section >= ic->journal_sections) || 624 622 unlikely(offset >= limit)) { 625 - printk(KERN_CRIT "%s: invalid access at (%u,%u), limit (%u,%u)\n", 626 - function, section, offset, ic->journal_sections, limit); 623 + DMCRIT("%s: invalid access at (%u,%u), limit (%u,%u)", 624 + function, section, offset, ic->journal_sections, limit); 627 625 BUG(); 628 626 } 629 627 #endif ··· 1668 1666 else 1669 1667 wanted_tag_size *= ic->tag_size; 1670 1668 if (unlikely(wanted_tag_size != bip->bip_iter.bi_size)) { 1671 - DMERR("Invalid integrity data size %u, expected %u", bip->bip_iter.bi_size, wanted_tag_size); 1669 + DMERR("Invalid integrity data size %u, expected %u", 1670 + bip->bip_iter.bi_size, wanted_tag_size); 1672 1671 return DM_MAPIO_KILL; 1673 1672 } 1674 1673 } ··· 1957 1954 } 1958 1955 1959 1956 if (ic->mode == 'B' && dio->write) { 1960 - if (!block_bitmap_op(ic, ic->may_write_bitmap, dio->range.logical_sector, dio->range.n_sectors, BITMAP_OP_TEST_ALL_SET)) { 1961 - struct bitmap_block_status *bbs = sector_to_bitmap_block(ic, dio->range.logical_sector); 1957 + if (!block_bitmap_op(ic, ic->may_write_bitmap, dio->range.logical_sector, 1958 + dio->range.n_sectors, BITMAP_OP_TEST_ALL_SET)) { 1959 + struct bitmap_block_status *bbs; 1962 1960 1961 + bbs = sector_to_bitmap_block(ic, dio->range.logical_sector); 1963 1962 spin_lock(&bbs->bio_queue_lock); 1964 1963 bio_list_add(&bbs->bio_queue, bio); 1965 1964 spin_unlock(&bbs->bio_queue_lock); 1966 - 1967 1965 queue_work(ic->writer_wq, &bbs->work); 1968 - 1969 1966 return; 1970 1967 } 1971 1968 } ··· 2000 1997 dio->range.logical_sector + dio->range.n_sectors > le64_to_cpu(ic->sb->recalc_sector)) 2001 1998 goto skip_check; 2002 1999 if (ic->mode == 'B') { 2003 - if (!block_bitmap_op(ic, ic->recalc_bitmap, dio->range.logical_sector, dio->range.n_sectors, BITMAP_OP_TEST_ALL_CLEAR)) 2000 + if (!block_bitmap_op(ic, ic->recalc_bitmap, dio->range.logical_sector, 2001 + dio->range.n_sectors, BITMAP_OP_TEST_ALL_CLEAR)) 2004 2002 goto skip_check; 2005 2003 } 2006 2004 ··· 2043 2039 ic->n_uncommitted_sections++; 2044 2040 } 2045 2041 if (WARN_ON(ic->journal_sections * ic->journal_section_entries != 2046 - (ic->n_uncommitted_sections + ic->n_committed_sections) * ic->journal_section_entries + ic->free_sectors)) { 2047 - printk(KERN_CRIT "dm-integrity: " 2048 - "journal_sections %u, " 2049 - "journal_section_entries %u, " 2050 - "n_uncommitted_sections %u, " 2051 - "n_committed_sections %u, " 2052 - "journal_section_entries %u, " 2053 - "free_sectors %u\n", 2054 - ic->journal_sections, 2055 - ic->journal_section_entries, 2056 - ic->n_uncommitted_sections, 2057 - ic->n_committed_sections, 2058 - ic->journal_section_entries, 2059 - ic->free_sectors); 2042 + (ic->n_uncommitted_sections + ic->n_committed_sections) * 2043 + ic->journal_section_entries + ic->free_sectors)) { 2044 + DMCRIT("journal_sections %u, journal_section_entries %u, " 2045 + "n_uncommitted_sections %u, n_committed_sections %u, " 2046 + "journal_section_entries %u, free_sectors %u", 2047 + ic->journal_sections, ic->journal_section_entries, 2048 + ic->n_uncommitted_sections, ic->n_committed_sections, 2049 + ic->journal_section_entries, ic->free_sectors); 2060 2050 } 2061 2051 } 2062 2052 ··· 2376 2378 if (block_bitmap_op(ic, ic->recalc_bitmap, logical_sector, n_sectors, BITMAP_OP_TEST_ALL_CLEAR)) { 2377 2379 goto advance_and_next; 2378 2380 } 2379 - while (block_bitmap_op(ic, ic->recalc_bitmap, logical_sector, ic->sectors_per_block, BITMAP_OP_TEST_ALL_CLEAR)) { 2381 + while (block_bitmap_op(ic, ic->recalc_bitmap, logical_sector, 2382 + ic->sectors_per_block, BITMAP_OP_TEST_ALL_CLEAR)) { 2380 2383 logical_sector += ic->sectors_per_block; 2381 2384 n_sectors -= ic->sectors_per_block; 2382 2385 cond_resched(); 2383 2386 } 2384 - while (block_bitmap_op(ic, ic->recalc_bitmap, logical_sector + n_sectors - ic->sectors_per_block, ic->sectors_per_block, BITMAP_OP_TEST_ALL_CLEAR)) { 2387 + while (block_bitmap_op(ic, ic->recalc_bitmap, logical_sector + n_sectors - ic->sectors_per_block, 2388 + ic->sectors_per_block, BITMAP_OP_TEST_ALL_CLEAR)) { 2385 2389 n_sectors -= ic->sectors_per_block; 2386 2390 cond_resched(); 2387 2391 } ··· 2471 2471 2472 2472 dio = dm_per_bio_data(bio, sizeof(struct dm_integrity_io)); 2473 2473 2474 - if (block_bitmap_op(ic, ic->may_write_bitmap, dio->range.logical_sector, dio->range.n_sectors, BITMAP_OP_TEST_ALL_SET)) { 2474 + if (block_bitmap_op(ic, ic->may_write_bitmap, dio->range.logical_sector, 2475 + dio->range.n_sectors, BITMAP_OP_TEST_ALL_SET)) { 2475 2476 remove_range(ic, &dio->range); 2476 2477 INIT_WORK(&dio->work, integrity_bio_wait); 2477 2478 queue_work(ic->wait_wq, &dio->work); 2478 2479 } else { 2479 - block_bitmap_op(ic, ic->journal, dio->range.logical_sector, dio->range.n_sectors, BITMAP_OP_SET); 2480 + block_bitmap_op(ic, ic->journal, dio->range.logical_sector, 2481 + dio->range.n_sectors, BITMAP_OP_SET); 2480 2482 bio_list_add(&waiting, bio); 2481 2483 } 2482 2484 } ··· 2486 2484 if (bio_list_empty(&waiting)) 2487 2485 return; 2488 2486 2489 - rw_journal_sectors(ic, REQ_OP_WRITE, REQ_FUA | REQ_SYNC, bbs->idx * (BITMAP_BLOCK_SIZE >> SECTOR_SHIFT), BITMAP_BLOCK_SIZE >> SECTOR_SHIFT, NULL); 2487 + rw_journal_sectors(ic, REQ_OP_WRITE, REQ_FUA | REQ_SYNC, 2488 + bbs->idx * (BITMAP_BLOCK_SIZE >> SECTOR_SHIFT), 2489 + BITMAP_BLOCK_SIZE >> SECTOR_SHIFT, NULL); 2490 2490 2491 2491 while ((bio = bio_list_pop(&waiting))) { 2492 2492 struct dm_integrity_io *dio = dm_per_bio_data(bio, sizeof(struct dm_integrity_io)); 2493 2493 2494 - block_bitmap_op(ic, ic->may_write_bitmap, dio->range.logical_sector, dio->range.n_sectors, BITMAP_OP_SET); 2494 + block_bitmap_op(ic, ic->may_write_bitmap, dio->range.logical_sector, 2495 + dio->range.n_sectors, BITMAP_OP_SET); 2495 2496 2496 2497 remove_range(ic, &dio->range); 2497 2498 INIT_WORK(&dio->work, integrity_bio_wait); ··· 2534 2529 block_bitmap_op(ic, ic->journal, 0, limit, BITMAP_OP_CLEAR); 2535 2530 block_bitmap_op(ic, ic->may_write_bitmap, 0, limit, BITMAP_OP_CLEAR); 2536 2531 2537 - rw_journal_sectors(ic, REQ_OP_WRITE, REQ_FUA | REQ_SYNC, 0, ic->n_bitmap_blocks * (BITMAP_BLOCK_SIZE >> SECTOR_SHIFT), NULL); 2532 + rw_journal_sectors(ic, REQ_OP_WRITE, REQ_FUA | REQ_SYNC, 0, 2533 + ic->n_bitmap_blocks * (BITMAP_BLOCK_SIZE >> SECTOR_SHIFT), NULL); 2538 2534 2539 2535 spin_lock_irq(&ic->endio_wait.lock); 2540 2536 remove_range_unlocked(ic, &range); ··· 2799 2793 if (ic->mode == 'B') { 2800 2794 dm_integrity_flush_buffers(ic); 2801 2795 #if 1 2796 + /* set to 0 to test bitmap replay code */ 2802 2797 init_journal(ic, 0, ic->journal_sections, 0); 2803 2798 ic->sb->flags &= ~cpu_to_le32(SB_FLAG_DIRTY_BITMAP); 2804 2799 r = sync_rw_sb(ic, REQ_OP_WRITE, REQ_FUA); ··· 2823 2816 2824 2817 if (ic->sb->flags & cpu_to_le32(SB_FLAG_DIRTY_BITMAP)) { 2825 2818 DEBUG_print("resume dirty_bitmap\n"); 2826 - rw_journal_sectors(ic, REQ_OP_READ, 0, 0, ic->n_bitmap_blocks * (BITMAP_BLOCK_SIZE >> SECTOR_SHIFT), NULL); 2819 + rw_journal_sectors(ic, REQ_OP_READ, 0, 0, 2820 + ic->n_bitmap_blocks * (BITMAP_BLOCK_SIZE >> SECTOR_SHIFT), NULL); 2827 2821 if (ic->mode == 'B') { 2828 2822 if (ic->sb->log2_blocks_per_bitmap_bit == ic->log2_blocks_per_bitmap_bit) { 2829 2823 block_bitmap_copy(ic, ic->recalc_bitmap, ic->journal); 2830 2824 block_bitmap_copy(ic, ic->may_write_bitmap, ic->journal); 2831 - if (!block_bitmap_op(ic, ic->journal, 0, ic->provided_data_sectors, BITMAP_OP_TEST_ALL_CLEAR)) { 2825 + if (!block_bitmap_op(ic, ic->journal, 0, ic->provided_data_sectors, 2826 + BITMAP_OP_TEST_ALL_CLEAR)) { 2832 2827 ic->sb->flags |= cpu_to_le32(SB_FLAG_RECALCULATING); 2833 2828 ic->sb->recalc_sector = cpu_to_le64(0); 2834 2829 } 2835 2830 } else { 2836 - DEBUG_print("non-matching blocks_per_bitmap_bit: %u, %u\n", ic->sb->log2_blocks_per_bitmap_bit, ic->log2_blocks_per_bitmap_bit); 2831 + DEBUG_print("non-matching blocks_per_bitmap_bit: %u, %u\n", 2832 + ic->sb->log2_blocks_per_bitmap_bit, ic->log2_blocks_per_bitmap_bit); 2837 2833 ic->sb->log2_blocks_per_bitmap_bit = ic->log2_blocks_per_bitmap_bit; 2838 2834 block_bitmap_op(ic, ic->recalc_bitmap, 0, ic->provided_data_sectors, BITMAP_OP_SET); 2839 2835 block_bitmap_op(ic, ic->may_write_bitmap, 0, ic->provided_data_sectors, BITMAP_OP_SET); 2840 2836 block_bitmap_op(ic, ic->journal, 0, ic->provided_data_sectors, BITMAP_OP_SET); 2841 - rw_journal_sectors(ic, REQ_OP_WRITE, REQ_FUA | REQ_SYNC, 0, ic->n_bitmap_blocks * (BITMAP_BLOCK_SIZE >> SECTOR_SHIFT), NULL); 2837 + rw_journal_sectors(ic, REQ_OP_WRITE, REQ_FUA | REQ_SYNC, 0, 2838 + ic->n_bitmap_blocks * (BITMAP_BLOCK_SIZE >> SECTOR_SHIFT), NULL); 2842 2839 ic->sb->flags |= cpu_to_le32(SB_FLAG_RECALCULATING); 2843 2840 ic->sb->recalc_sector = cpu_to_le64(0); 2844 2841 } ··· 2873 2862 block_bitmap_op(ic, ic->journal, 0, ic->provided_data_sectors, mode); 2874 2863 block_bitmap_op(ic, ic->recalc_bitmap, 0, ic->provided_data_sectors, mode); 2875 2864 block_bitmap_op(ic, ic->may_write_bitmap, 0, ic->provided_data_sectors, mode); 2876 - rw_journal_sectors(ic, REQ_OP_WRITE, REQ_FUA | REQ_SYNC, 0, ic->n_bitmap_blocks * (BITMAP_BLOCK_SIZE >> SECTOR_SHIFT), NULL); 2865 + rw_journal_sectors(ic, REQ_OP_WRITE, REQ_FUA | REQ_SYNC, 0, 2866 + ic->n_bitmap_blocks * (BITMAP_BLOCK_SIZE >> SECTOR_SHIFT), NULL); 2877 2867 } 2878 2868 } 2879 2869 ··· 2896 2884 WARN_ON(register_reboot_notifier(&ic->reboot_notifier)); 2897 2885 2898 2886 #if 0 2887 + /* set to 1 to stress test synchronous mode */ 2899 2888 dm_integrity_enter_synchronous_mode(ic); 2900 2889 #endif 2901 2890 } ··· 3173 3160 kvfree(sl); 3174 3161 } 3175 3162 3176 - static struct scatterlist **dm_integrity_alloc_journal_scatterlist(struct dm_integrity_c *ic, struct page_list *pl) 3163 + static struct scatterlist **dm_integrity_alloc_journal_scatterlist(struct dm_integrity_c *ic, 3164 + struct page_list *pl) 3177 3165 { 3178 3166 struct scatterlist **sl; 3179 3167 unsigned i; ··· 3193 3179 unsigned idx; 3194 3180 3195 3181 page_list_location(ic, i, 0, &start_index, &start_offset); 3196 - page_list_location(ic, i, ic->journal_section_sectors - 1, &end_index, &end_offset); 3182 + page_list_location(ic, i, ic->journal_section_sectors - 1, 3183 + &end_index, &end_offset); 3197 3184 3198 3185 n_pages = (end_index - start_index + 1); 3199 3186 ··· 3395 3380 sg_set_buf(&sg[i], &ic->commit_ids, sizeof ic->commit_ids); 3396 3381 memset(crypt_iv, 0x00, ivsize); 3397 3382 3398 - skcipher_request_set_crypt(req, sg, sg, PAGE_SIZE * ic->journal_pages + sizeof ic->commit_ids, crypt_iv); 3383 + skcipher_request_set_crypt(req, sg, sg, 3384 + PAGE_SIZE * ic->journal_pages + sizeof ic->commit_ids, crypt_iv); 3399 3385 init_completion(&comp.comp); 3400 3386 comp.in_flight = (atomic_t)ATOMIC_INIT(1); 3401 3387 if (do_crypt(true, req, &comp)) ··· 3618 3602 } 3619 3603 } 3620 3604 3621 - if (!strcmp(argv[3], "J") || !strcmp(argv[3], "B") || !strcmp(argv[3], "D") || !strcmp(argv[3], "R")) { 3605 + if (!strcmp(argv[3], "J") || !strcmp(argv[3], "B") || 3606 + !strcmp(argv[3], "D") || !strcmp(argv[3], "R")) { 3622 3607 ic->mode = argv[3][0]; 3623 3608 } else { 3624 3609 ti->error = "Invalid mode (expecting J, B, D, R)"; ··· 3665 3648 dm_put_device(ti, ic->meta_dev); 3666 3649 ic->meta_dev = NULL; 3667 3650 } 3668 - r = dm_get_device(ti, strchr(opt_string, ':') + 1, dm_table_get_mode(ti->table), &ic->meta_dev); 3651 + r = dm_get_device(ti, strchr(opt_string, ':') + 1, 3652 + dm_table_get_mode(ti->table), &ic->meta_dev); 3669 3653 if (r) { 3670 3654 ti->error = "Device lookup failed"; 3671 3655 goto bad; ··· 3720 3702 3721 3703 if (!journal_sectors) { 3722 3704 journal_sectors = min((sector_t)DEFAULT_MAX_JOURNAL_SECTORS, 3723 - ic->data_device_sectors >> DEFAULT_JOURNAL_SIZE_FACTOR); 3705 + ic->data_device_sectors >> DEFAULT_JOURNAL_SIZE_FACTOR); 3724 3706 } 3725 3707 3726 3708 if (!buffer_sectors)