block: Reduce the size of struct blk_integrity
authorMartin K. Petersen <martin.petersen@oracle.com>
Wed, 21 Oct 2015 17:19:38 +0000 (13:19 -0400)
committerJens Axboe <axboe@fb.com>
Wed, 21 Oct 2015 20:42:39 +0000 (14:42 -0600)
The per-device properties in the blk_integrity structure were previously
unsigned short. However, most of the values fit inside a char. The only
exception is the data interval size and we can work around that by
storing it as a power of two.

This cuts the size of the dynamic portion of blk_integrity in half.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Reported-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
block/bio-integrity.c
block/blk-integrity.c
include/linux/blkdev.h

index a10ffe19a8dd4fee668abd1de87accf1663f21fc..6a90eca9cea123c80b1584f39201117fbc9e0394 100644 (file)
@@ -202,7 +202,7 @@ EXPORT_SYMBOL(bio_integrity_enabled);
 static inline unsigned int bio_integrity_intervals(struct blk_integrity *bi,
                                                   unsigned int sectors)
 {
-       return sectors >> (ilog2(bi->interval) - 9);
+       return sectors >> (bi->interval_exp - 9);
 }
 
 static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi,
@@ -229,7 +229,7 @@ static int bio_integrity_process(struct bio *bio,
                bip->bip_vec->bv_offset;
 
        iter.disk_name = bio->bi_bdev->bd_disk->disk_name;
-       iter.interval = bi->interval;
+       iter.interval = 1 << bi->interval_exp;
        iter.seed = bip_get_seed(bip);
        iter.prot_buf = prot_buf;
 
index daf590ab3b4600c216d7ad6829ef953ee99c6867..c7508654faffb8b7d26779a4e6a50a20ae3a7aa5 100644 (file)
@@ -155,10 +155,10 @@ int blk_integrity_compare(struct gendisk *gd1, struct gendisk *gd2)
        if (!b1 || !b2)
                return -1;
 
-       if (b1->interval != b2->interval) {
+       if (b1->interval_exp != b2->interval_exp) {
                pr_err("%s: %s/%s protection interval %u != %u\n",
                       __func__, gd1->disk_name, gd2->disk_name,
-                      b1->interval, b2->interval);
+                      1 << b1->interval_exp, 1 << b2->interval_exp);
                return -1;
        }
 
@@ -440,7 +440,7 @@ int blk_integrity_register(struct gendisk *disk, struct blk_integrity *template)
                kobject_uevent(&disk->integrity_kobj, KOBJ_ADD);
 
                bi->flags |= BLK_INTEGRITY_VERIFY | BLK_INTEGRITY_GENERATE;
-               bi->interval = queue_logical_block_size(disk->queue);
+               bi->interval_exp = ilog2(queue_logical_block_size(disk->queue));
                disk->integrity = bi;
        } else
                bi = disk->integrity;
index f36c6476f1c728f8a787e92576545f921dcd7503..4f1968f15e3082da18ef541a95307b50e4fdba0e 100644 (file)
@@ -1470,10 +1470,10 @@ struct blk_integrity_profile {
 
 struct blk_integrity {
        struct blk_integrity_profile    *profile;
-       unsigned short                  flags;
-       unsigned short                  tuple_size;
-       unsigned short                  interval;
-       unsigned short                  tag_size;
+       unsigned char                   flags;
+       unsigned char                   tuple_size;
+       unsigned char                   interval_exp;
+       unsigned char                   tag_size;
 };
 
 extern bool blk_integrity_is_initialized(struct gendisk *);