block: Make protection interval calculation generic
authorMartin K. Petersen <martin.petersen@oracle.com>
Fri, 26 Sep 2014 23:20:00 +0000 (19:20 -0400)
committerJens Axboe <axboe@fb.com>
Sat, 27 Sep 2014 15:14:50 +0000 (09:14 -0600)
Now that the protection interval has been detached from the sector size
we need to be able to handle sizes that are different from 4K and
512. Make the interval calculation generic.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
block/bio-integrity.c

index 6a3aacf57b199ed404001b9e9add380030482e27..cf40837e77103c7ecc03076dfb80cd676ac2978d 100644 (file)
@@ -197,11 +197,7 @@ EXPORT_SYMBOL(bio_integrity_enabled);
 static inline unsigned int bio_integrity_intervals(struct blk_integrity *bi,
                                                   unsigned int sectors)
 {
-       /* At this point there are only 512b or 4096b DIF/EPP devices */
-       if (bi->interval == 4096)
-               return sectors >>= 3;
-
-       return sectors;
+       return sectors >> (ilog2(bi->interval) - 9);
 }
 
 static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi,