aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2009-09-12 01:35:43 -0400
committerJens Axboe <jens.axboe@oracle.com>2009-09-14 02:24:53 -0400
commit746cd1e7e4a555ddaee53b19a46e05c9c61eaf09 (patch)
treed129194669e0122113a5cc86003a4a7711450284 /include/linux
parent3d2257f157c2324acbc0fa0fa54e8626a987edd2 (diff)
block: use blkdev_issue_discard in blk_ioctl_discard
blk_ioctl_discard duplicates large amounts of code from blkdev_issue_discard, the only difference between the two is that blkdev_issue_discard needs to send a barrier discard request and blk_ioctl_discard a non-barrier one, and blk_ioctl_discard needs to wait on the request. To facilitates this add a flags argument to blkdev_issue_discard to control both aspects of the behaviour. This will be very useful later on for using the waiting funcitonality for other callers. Based on an earlier patch from Matthew Wilcox <matthew@wil.cx>. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/blkdev.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 86c2bdff3b89..e23a86cae5ac 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -998,15 +998,18 @@ static inline struct request *blk_map_queue_find_tag(struct blk_queue_tag *bqt,
998} 998}
999 999
1000extern int blkdev_issue_flush(struct block_device *, sector_t *); 1000extern int blkdev_issue_flush(struct block_device *, sector_t *);
1001extern int blkdev_issue_discard(struct block_device *, 1001#define DISCARD_FL_WAIT 0x01 /* wait for completion */
1002 sector_t sector, sector_t nr_sects, gfp_t); 1002#define DISCARD_FL_BARRIER 0x02 /* issue DISCARD_BARRIER request */
1003extern int blkdev_issue_discard(struct block_device *, sector_t sector,
1004 sector_t nr_sects, gfp_t, int flags);
1003 1005
1004static inline int sb_issue_discard(struct super_block *sb, 1006static inline int sb_issue_discard(struct super_block *sb,
1005 sector_t block, sector_t nr_blocks) 1007 sector_t block, sector_t nr_blocks)
1006{ 1008{
1007 block <<= (sb->s_blocksize_bits - 9); 1009 block <<= (sb->s_blocksize_bits - 9);
1008 nr_blocks <<= (sb->s_blocksize_bits - 9); 1010 nr_blocks <<= (sb->s_blocksize_bits - 9);
1009 return blkdev_issue_discard(sb->s_bdev, block, nr_blocks, GFP_KERNEL); 1011 return blkdev_issue_discard(sb->s_bdev, block, nr_blocks, GFP_KERNEL,
1012 DISCARD_FL_BARRIER);
1010} 1013}
1011 1014
1012extern int blk_verify_command(unsigned char *cmd, fmode_t has_write_perm); 1015extern int blk_verify_command(unsigned char *cmd, fmode_t has_write_perm);