aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/bio.h
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2008-08-05 13:01:53 -0400
committerJens Axboe <jens.axboe@oracle.com>2008-10-09 02:56:01 -0400
commitfb2dce862d9f9a68e6b9374579056ec9eca02a63 (patch)
tree888e0fd7248c9329fa1aa3981043a2dc2457d488 /include/linux/bio.h
parentd628eaef310533767ce68664873869c2d7f78f09 (diff)
Add 'discard' request handling
Some block devices benefit from a hint that they can forget the contents of certain sectors. Add basic support for this to the block core, along with a 'blkdev_issue_discard()' helper function which issues such requests. The caller doesn't get to provide an end_io functio, since blkdev_issue_discard() will automatically split the request up into multiple bios if appropriate. Neither does the function wait for completion -- it's expected that callers won't care about when, or even _if_, the request completes. It's only a hint to the device anyway. By definition, the file system doesn't _care_ about these sectors any more. [With feedback from OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> and Jens Axboe <jens.axboe@oracle.com] Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'include/linux/bio.h')
-rw-r--r--include/linux/bio.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 17f1fbdb31bf..1fdfc5621c83 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -149,6 +149,8 @@ struct bio {
149 * bit 2 -- barrier 149 * bit 2 -- barrier
150 * bit 3 -- fail fast, don't want low level driver retries 150 * bit 3 -- fail fast, don't want low level driver retries
151 * bit 4 -- synchronous I/O hint: the block layer will unplug immediately 151 * bit 4 -- synchronous I/O hint: the block layer will unplug immediately
152 * bit 5 -- metadata request
153 * bit 6 -- discard sectors
152 */ 154 */
153#define BIO_RW 0 /* Must match RW in req flags (blkdev.h) */ 155#define BIO_RW 0 /* Must match RW in req flags (blkdev.h) */
154#define BIO_RW_AHEAD 1 /* Must match FAILFAST in req flags */ 156#define BIO_RW_AHEAD 1 /* Must match FAILFAST in req flags */
@@ -156,6 +158,7 @@ struct bio {
156#define BIO_RW_FAILFAST 3 158#define BIO_RW_FAILFAST 3
157#define BIO_RW_SYNC 4 159#define BIO_RW_SYNC 4
158#define BIO_RW_META 5 160#define BIO_RW_META 5
161#define BIO_RW_DISCARD 6
159 162
160/* 163/*
161 * upper 16 bits of bi_rw define the io priority of this bio 164 * upper 16 bits of bi_rw define the io priority of this bio
@@ -186,13 +189,14 @@ struct bio {
186#define bio_rw_ahead(bio) ((bio)->bi_rw & (1 << BIO_RW_AHEAD)) 189#define bio_rw_ahead(bio) ((bio)->bi_rw & (1 << BIO_RW_AHEAD))
187#define bio_rw_meta(bio) ((bio)->bi_rw & (1 << BIO_RW_META)) 190#define bio_rw_meta(bio) ((bio)->bi_rw & (1 << BIO_RW_META))
188#define bio_empty_barrier(bio) (bio_barrier(bio) && !bio_has_data(bio)) 191#define bio_empty_barrier(bio) (bio_barrier(bio) && !bio_has_data(bio))
192#define bio_discard(bio) ((bio)->bi_rw & (1 << BIO_RW_DISCARD))
189 193
190static inline unsigned int bio_cur_sectors(struct bio *bio) 194static inline unsigned int bio_cur_sectors(struct bio *bio)
191{ 195{
192 if (bio->bi_vcnt) 196 if (bio->bi_vcnt)
193 return bio_iovec(bio)->bv_len >> 9; 197 return bio_iovec(bio)->bv_len >> 9;
194 198 else /* dataless requests such as discard */
195 return 0; 199 return bio->bi_size >> 9;
196} 200}
197 201
198static inline void *bio_data(struct bio *bio) 202static inline void *bio_data(struct bio *bio)