diff options
author | Hugh Dickins <hugh@veritas.com> | 2008-09-11 04:57:55 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2008-10-09 02:56:17 -0400 |
commit | 3e6053d76dcbd92b2f9f4ad5ece9bce83149523e (patch) | |
tree | 0e7ab62872071c39e2475decb769b9715de75376 | |
parent | 4677735f03f5b6b6f2182f457a921855cadfb85b (diff) |
block: adjust blkdev_issue_discard for swap
Two mods to blkdev_issue_discard(), thinking ahead to its use on swap:
1. Add gfp_mask argument, so swap allocation can use it where GFP_KERNEL
might deadlock but GFP_NOIO is safe.
2. Enlarge nr_sects argument from unsigned to sector_t: unsigned long is
enough to cover a whole swap area, but sector_t suits any partition.
Change sb_issue_discard()'s nr_blocks to sector_t too; but no need seen
for a gfp_mask there, just pass GFP_KERNEL down to blkdev_issue_discard().
Signed-off-by: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rw-r--r-- | block/blk-barrier.c | 7 | ||||
-rw-r--r-- | include/linux/blkdev.h | 9 |
2 files changed, 9 insertions, 7 deletions
diff --git a/block/blk-barrier.c b/block/blk-barrier.c index 988b63479b2f..5c99ff8d2db8 100644 --- a/block/blk-barrier.c +++ b/block/blk-barrier.c | |||
@@ -332,12 +332,13 @@ static void blkdev_discard_end_io(struct bio *bio, int err) | |||
332 | * @bdev: blockdev to issue discard for | 332 | * @bdev: blockdev to issue discard for |
333 | * @sector: start sector | 333 | * @sector: start sector |
334 | * @nr_sects: number of sectors to discard | 334 | * @nr_sects: number of sectors to discard |
335 | * @gfp_mask: memory allocation flags (for bio_alloc) | ||
335 | * | 336 | * |
336 | * Description: | 337 | * Description: |
337 | * Issue a discard request for the sectors in question. Does not wait. | 338 | * Issue a discard request for the sectors in question. Does not wait. |
338 | */ | 339 | */ |
339 | int blkdev_issue_discard(struct block_device *bdev, sector_t sector, | 340 | int blkdev_issue_discard(struct block_device *bdev, |
340 | unsigned nr_sects) | 341 | sector_t sector, sector_t nr_sects, gfp_t gfp_mask) |
341 | { | 342 | { |
342 | struct request_queue *q; | 343 | struct request_queue *q; |
343 | struct bio *bio; | 344 | struct bio *bio; |
@@ -354,7 +355,7 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector, | |||
354 | return -EOPNOTSUPP; | 355 | return -EOPNOTSUPP; |
355 | 356 | ||
356 | while (nr_sects && !ret) { | 357 | while (nr_sects && !ret) { |
357 | bio = bio_alloc(GFP_KERNEL, 0); | 358 | bio = bio_alloc(gfp_mask, 0); |
358 | if (!bio) | 359 | if (!bio) |
359 | return -ENOMEM; | 360 | return -ENOMEM; |
360 | 361 | ||
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 37781d6fe045..b47767c72ce3 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/bio.h> | 16 | #include <linux/bio.h> |
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/stringify.h> | 18 | #include <linux/stringify.h> |
19 | #include <linux/gfp.h> | ||
19 | #include <linux/bsg.h> | 20 | #include <linux/bsg.h> |
20 | #include <linux/smp.h> | 21 | #include <linux/smp.h> |
21 | 22 | ||
@@ -873,15 +874,15 @@ static inline struct request *blk_map_queue_find_tag(struct blk_queue_tag *bqt, | |||
873 | } | 874 | } |
874 | 875 | ||
875 | extern int blkdev_issue_flush(struct block_device *, sector_t *); | 876 | extern int blkdev_issue_flush(struct block_device *, sector_t *); |
876 | extern int blkdev_issue_discard(struct block_device *, sector_t sector, | 877 | extern int blkdev_issue_discard(struct block_device *, |
877 | unsigned nr_sects); | 878 | sector_t sector, sector_t nr_sects, gfp_t); |
878 | 879 | ||
879 | static inline int sb_issue_discard(struct super_block *sb, | 880 | static inline int sb_issue_discard(struct super_block *sb, |
880 | sector_t block, unsigned nr_blocks) | 881 | sector_t block, sector_t nr_blocks) |
881 | { | 882 | { |
882 | block <<= (sb->s_blocksize_bits - 9); | 883 | block <<= (sb->s_blocksize_bits - 9); |
883 | nr_blocks <<= (sb->s_blocksize_bits - 9); | 884 | nr_blocks <<= (sb->s_blocksize_bits - 9); |
884 | return blkdev_issue_discard(sb->s_bdev, block, nr_blocks); | 885 | return blkdev_issue_discard(sb->s_bdev, block, nr_blocks, GFP_KERNEL); |
885 | } | 886 | } |
886 | 887 | ||
887 | /* | 888 | /* |