aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-barrier.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2009-09-30 07:54:20 -0400
committerJens Axboe <jens.axboe@oracle.com>2009-10-01 15:19:34 -0400
commit67efc9258010da35b27b3854d0880c7e193004ed (patch)
treed98ad032d8c701084539d5673c2d7d7ca5962a3f /block/blk-barrier.c
parentc15227de132f1295f3db6b7df9079956b1020fd8 (diff)
block: allow large discard requests
Currently we set the bio size to the byte equivalent of the blocks to be trimmed when submitting the initial DISCARD ioctl. That means it is subject to the max_hw_sectors limitation of the HBA which is much lower than the size of a DISCARD request we can support. Add a separate max_discard_sectors tunable to limit the size for discard requests. We limit the max discard request size in bytes to 32bit as that is the limit for bio->bi_size. This could be much larger if we had a way to pass that information through the block layer. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block/blk-barrier.c')
-rw-r--r--block/blk-barrier.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/block/blk-barrier.c b/block/blk-barrier.c
index 21f5025c394..8873b9b439f 100644
--- a/block/blk-barrier.c
+++ b/block/blk-barrier.c
@@ -385,6 +385,8 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
385 385
386 while (nr_sects && !ret) { 386 while (nr_sects && !ret) {
387 unsigned int sector_size = q->limits.logical_block_size; 387 unsigned int sector_size = q->limits.logical_block_size;
388 unsigned int max_discard_sectors =
389 min(q->limits.max_discard_sectors, UINT_MAX >> 9);
388 390
389 bio = bio_alloc(gfp_mask, 1); 391 bio = bio_alloc(gfp_mask, 1);
390 if (!bio) 392 if (!bio)
@@ -411,10 +413,10 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
411 * touch many more blocks on disk than the actual payload 413 * touch many more blocks on disk than the actual payload
412 * length. 414 * length.
413 */ 415 */
414 if (nr_sects > queue_max_hw_sectors(q)) { 416 if (nr_sects > max_discard_sectors) {
415 bio->bi_size = queue_max_hw_sectors(q) << 9; 417 bio->bi_size = max_discard_sectors << 9;
416 nr_sects -= queue_max_hw_sectors(q); 418 nr_sects -= max_discard_sectors;
417 sector += queue_max_hw_sectors(q); 419 sector += max_discard_sectors;
418 } else { 420 } else {
419 bio->bi_size = nr_sects << 9; 421 bio->bi_size = nr_sects << 9;
420 nr_sects = 0; 422 nr_sects = 0;