aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2010-09-16 14:51:46 -0400
committerJens Axboe <jaxboe@fusionio.com>2010-09-16 14:52:58 -0400
commitdd3932eddf428571762596e17b65f5dc92ca361b (patch)
tree57cec5ae2f862037f78b7e993323d77955bb6463 /block
parent8786fb70ccb36c7cff64680bb80c46d3a09d44db (diff)
block: remove BLKDEV_IFL_WAIT
All the blkdev_issue_* helpers can only sanely be used for synchronous caller. To issue cache flushes or barriers asynchronously the caller needs to set up a bio by itself with a completion callback to move the asynchronous state machine ahead. So drop the BLKDEV_IFL_WAIT flag that is always specified when calling blkdev_issue_* and also remove the now unused flags argument to blkdev_issue_flush and blkdev_issue_zeroout. For blkdev_issue_discard we need to keep it for the secure discard flag, which gains a more descriptive name and loses the bitops vs flag confusion. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Diffstat (limited to 'block')
-rw-r--r--block/blk-flush.c25
-rw-r--r--block/blk-lib.c21
-rw-r--r--block/ioctl.c4
3 files changed, 21 insertions, 29 deletions
diff --git a/block/blk-flush.c b/block/blk-flush.c
index 62b7df9bca9d..54b123d6563e 100644
--- a/block/blk-flush.c
+++ b/block/blk-flush.c
@@ -205,7 +205,6 @@ static void bio_end_flush(struct bio *bio, int err)
205 * @bdev: blockdev to issue flush for 205 * @bdev: blockdev to issue flush for
206 * @gfp_mask: memory allocation flags (for bio_alloc) 206 * @gfp_mask: memory allocation flags (for bio_alloc)
207 * @error_sector: error sector 207 * @error_sector: error sector
208 * @flags: BLKDEV_IFL_* flags to control behaviour
209 * 208 *
210 * Description: 209 * Description:
211 * Issue a flush for the block device in question. Caller can supply 210 * Issue a flush for the block device in question. Caller can supply
@@ -214,7 +213,7 @@ static void bio_end_flush(struct bio *bio, int err)
214 * request was pushed in some internal queue for later handling. 213 * request was pushed in some internal queue for later handling.
215 */ 214 */
216int blkdev_issue_flush(struct block_device *bdev, gfp_t gfp_mask, 215int blkdev_issue_flush(struct block_device *bdev, gfp_t gfp_mask,
217 sector_t *error_sector, unsigned long flags) 216 sector_t *error_sector)
218{ 217{
219 DECLARE_COMPLETION_ONSTACK(wait); 218 DECLARE_COMPLETION_ONSTACK(wait);
220 struct request_queue *q; 219 struct request_queue *q;
@@ -240,21 +239,19 @@ int blkdev_issue_flush(struct block_device *bdev, gfp_t gfp_mask,
240 bio = bio_alloc(gfp_mask, 0); 239 bio = bio_alloc(gfp_mask, 0);
241 bio->bi_end_io = bio_end_flush; 240 bio->bi_end_io = bio_end_flush;
242 bio->bi_bdev = bdev; 241 bio->bi_bdev = bdev;
243 if (test_bit(BLKDEV_WAIT, &flags)) 242 bio->bi_private = &wait;
244 bio->bi_private = &wait;
245 243
246 bio_get(bio); 244 bio_get(bio);
247 submit_bio(WRITE_FLUSH, bio); 245 submit_bio(WRITE_FLUSH, bio);
248 if (test_bit(BLKDEV_WAIT, &flags)) { 246 wait_for_completion(&wait);
249 wait_for_completion(&wait); 247
250 /* 248 /*
251 * The driver must store the error location in ->bi_sector, if 249 * The driver must store the error location in ->bi_sector, if
252 * it supports it. For non-stacked drivers, this should be 250 * it supports it. For non-stacked drivers, this should be
253 * copied from blk_rq_pos(rq). 251 * copied from blk_rq_pos(rq).
254 */ 252 */
255 if (error_sector) 253 if (error_sector)
256 *error_sector = bio->bi_sector; 254 *error_sector = bio->bi_sector;
257 }
258 255
259 if (!bio_flagged(bio, BIO_UPTODATE)) 256 if (!bio_flagged(bio, BIO_UPTODATE))
260 ret = -EIO; 257 ret = -EIO;
diff --git a/block/blk-lib.c b/block/blk-lib.c
index fe2e6ed0f510..1a320d2406b0 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -61,7 +61,7 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
61 max_discard_sectors &= ~(disc_sects - 1); 61 max_discard_sectors &= ~(disc_sects - 1);
62 } 62 }
63 63
64 if (flags & BLKDEV_IFL_SECURE) { 64 if (flags & BLKDEV_DISCARD_SECURE) {
65 if (!blk_queue_secdiscard(q)) 65 if (!blk_queue_secdiscard(q))
66 return -EOPNOTSUPP; 66 return -EOPNOTSUPP;
67 type |= REQ_SECURE; 67 type |= REQ_SECURE;
@@ -77,8 +77,7 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
77 bio->bi_sector = sector; 77 bio->bi_sector = sector;
78 bio->bi_end_io = blkdev_discard_end_io; 78 bio->bi_end_io = blkdev_discard_end_io;
79 bio->bi_bdev = bdev; 79 bio->bi_bdev = bdev;
80 if (flags & BLKDEV_IFL_WAIT) 80 bio->bi_private = &wait;
81 bio->bi_private = &wait;
82 81
83 if (nr_sects > max_discard_sectors) { 82 if (nr_sects > max_discard_sectors) {
84 bio->bi_size = max_discard_sectors << 9; 83 bio->bi_size = max_discard_sectors << 9;
@@ -92,8 +91,7 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
92 bio_get(bio); 91 bio_get(bio);
93 submit_bio(type, bio); 92 submit_bio(type, bio);
94 93
95 if (flags & BLKDEV_IFL_WAIT) 94 wait_for_completion(&wait);
96 wait_for_completion(&wait);
97 95
98 if (bio_flagged(bio, BIO_EOPNOTSUPP)) 96 if (bio_flagged(bio, BIO_EOPNOTSUPP))
99 ret = -EOPNOTSUPP; 97 ret = -EOPNOTSUPP;
@@ -139,7 +137,6 @@ static void bio_batch_end_io(struct bio *bio, int err)
139 * @sector: start sector 137 * @sector: start sector
140 * @nr_sects: number of sectors to write 138 * @nr_sects: number of sectors to write
141 * @gfp_mask: memory allocation flags (for bio_alloc) 139 * @gfp_mask: memory allocation flags (for bio_alloc)
142 * @flags: BLKDEV_IFL_* flags to control behaviour
143 * 140 *
144 * Description: 141 * Description:
145 * Generate and issue number of bios with zerofiled pages. 142 * Generate and issue number of bios with zerofiled pages.
@@ -148,7 +145,7 @@ static void bio_batch_end_io(struct bio *bio, int err)
148 */ 145 */
149 146
150int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector, 147int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,
151 sector_t nr_sects, gfp_t gfp_mask, unsigned long flags) 148 sector_t nr_sects, gfp_t gfp_mask)
152{ 149{
153 int ret; 150 int ret;
154 struct bio *bio; 151 struct bio *bio;
@@ -174,8 +171,7 @@ submit:
174 bio->bi_sector = sector; 171 bio->bi_sector = sector;
175 bio->bi_bdev = bdev; 172 bio->bi_bdev = bdev;
176 bio->bi_end_io = bio_batch_end_io; 173 bio->bi_end_io = bio_batch_end_io;
177 if (flags & BLKDEV_IFL_WAIT) 174 bio->bi_private = &bb;
178 bio->bi_private = &bb;
179 175
180 while (nr_sects != 0) { 176 while (nr_sects != 0) {
181 sz = min((sector_t) PAGE_SIZE >> 9 , nr_sects); 177 sz = min((sector_t) PAGE_SIZE >> 9 , nr_sects);
@@ -193,10 +189,9 @@ submit:
193 submit_bio(WRITE, bio); 189 submit_bio(WRITE, bio);
194 } 190 }
195 191
196 if (flags & BLKDEV_IFL_WAIT) 192 /* Wait for bios in-flight */
197 /* Wait for bios in-flight */ 193 while (issued != atomic_read(&bb.done))
198 while ( issued != atomic_read(&bb.done)) 194 wait_for_completion(&wait);
199 wait_for_completion(&wait);
200 195
201 if (!test_bit(BIO_UPTODATE, &bb.flags)) 196 if (!test_bit(BIO_UPTODATE, &bb.flags))
202 /* One of bios in the batch was completed with error.*/ 197 /* One of bios in the batch was completed with error.*/
diff --git a/block/ioctl.c b/block/ioctl.c
index d8052f0dabd3..cb2b9099862b 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -116,7 +116,7 @@ static int blkdev_reread_part(struct block_device *bdev)
116static int blk_ioctl_discard(struct block_device *bdev, uint64_t start, 116static int blk_ioctl_discard(struct block_device *bdev, uint64_t start,
117 uint64_t len, int secure) 117 uint64_t len, int secure)
118{ 118{
119 unsigned long flags = BLKDEV_IFL_WAIT; 119 unsigned long flags = 0;
120 120
121 if (start & 511) 121 if (start & 511)
122 return -EINVAL; 122 return -EINVAL;
@@ -128,7 +128,7 @@ static int blk_ioctl_discard(struct block_device *bdev, uint64_t start,
128 if (start + len > (bdev->bd_inode->i_size >> 9)) 128 if (start + len > (bdev->bd_inode->i_size >> 9))
129 return -EINVAL; 129 return -EINVAL;
130 if (secure) 130 if (secure)
131 flags |= BLKDEV_IFL_SECURE; 131 flags |= BLKDEV_DISCARD_SECURE;
132 return blkdev_issue_discard(bdev, start, len, GFP_KERNEL, flags); 132 return blkdev_issue_discard(bdev, start, len, GFP_KERNEL, flags);
133} 133}
134 134