md/raid5: round discard alignment up to power of 2.
authorNeilBrown <neilb@suse.de>
Mon, 19 Nov 2012 02:11:26 +0000 (13:11 +1100)
committerNeilBrown <neilb@suse.de>
Tue, 20 Nov 2012 08:42:56 +0000 (19:42 +1100)
blkdev_issue_discard currently assumes that the granularity
is a power of 2.  So in raid5, round the chosen number up to
avoid embarrassment.

Cc: Shaohua Li <shli@kernel.org>
Signed-off-by: NeilBrown <neilb@suse.de>
drivers/md/raid5.c

index c5439dce0295078ecf82094af5474a649284ce61..baea94f0670a365324ea19345f4b540617cc81ca 100644 (file)
@@ -5529,6 +5529,10 @@ static int run(struct mddev *mddev)
                 * discard data disk but write parity disk
                 */
                stripe = stripe * PAGE_SIZE;
+               /* Round up to power of 2, as discard handling
+                * currently assumes that */
+               while ((stripe-1) & stripe)
+                       stripe = (stripe | (stripe-1)) + 1;
                mddev->queue->limits.discard_alignment = stripe;
                mddev->queue->limits.discard_granularity = stripe;
                /*