summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMartin K. Petersen <martin.petersen@oracle.com>2010-01-11 09:21:48 +0100
committerJens Axboe <jens.axboe@oracle.com>2010-01-11 14:29:19 +0100
commitdd3d145d49c5816b79acc6761ebbd842bc50b0ee (patch)
tree107bdb2f46c6aa6bc482909d7ebdbb1da40b7b4f /include
parentblock: Correct handling of bottom device misaligment (diff)
downloadlinux-dd3d145d49c5816b79acc6761ebbd842bc50b0ee.tar.xz
linux-dd3d145d49c5816b79acc6761ebbd842bc50b0ee.zip
block: Fix discard alignment calculation and printing
Discard alignment reporting for partitions was incorrect. Update to match the algorithm used elsewhere. The alignment can be negative (misaligned). Fix format string accordingly. Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'include')
-rw-r--r--include/linux/blkdev.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 9b98173a8184..a41bcc8e140f 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1148,8 +1148,11 @@ static inline int queue_discard_alignment(struct request_queue *q)
static inline int queue_sector_discard_alignment(struct request_queue *q,
sector_t sector)
{
- return ((sector << 9) - q->limits.discard_alignment)
- & (q->limits.discard_granularity - 1);
+ struct queue_limits *lim = &q->limits;
+ unsigned int alignment = (sector << 9) & (lim->discard_granularity - 1);
+
+ return (lim->discard_granularity + lim->discard_alignment - alignment)
+ & (lim->discard_granularity - 1);
}
static inline unsigned int queue_discard_zeroes_data(struct request_queue *q)