diff options
Diffstat (limited to 'block/blk-lib.c')
-rw-r--r-- | block/blk-lib.c | 39 |
1 files changed, 10 insertions, 29 deletions
diff --git a/block/blk-lib.c b/block/blk-lib.c index c392029a104e..1a320d2406b0 100644 --- a/block/blk-lib.c +++ b/block/blk-lib.c | |||
@@ -39,8 +39,7 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector, | |||
39 | { | 39 | { |
40 | DECLARE_COMPLETION_ONSTACK(wait); | 40 | DECLARE_COMPLETION_ONSTACK(wait); |
41 | struct request_queue *q = bdev_get_queue(bdev); | 41 | struct request_queue *q = bdev_get_queue(bdev); |
42 | int type = flags & BLKDEV_IFL_BARRIER ? | 42 | int type = REQ_WRITE | REQ_DISCARD; |
43 | DISCARD_BARRIER : DISCARD_NOBARRIER; | ||
44 | unsigned int max_discard_sectors; | 43 | unsigned int max_discard_sectors; |
45 | struct bio *bio; | 44 | struct bio *bio; |
46 | int ret = 0; | 45 | int ret = 0; |
@@ -62,10 +61,10 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector, | |||
62 | max_discard_sectors &= ~(disc_sects - 1); | 61 | max_discard_sectors &= ~(disc_sects - 1); |
63 | } | 62 | } |
64 | 63 | ||
65 | if (flags & BLKDEV_IFL_SECURE) { | 64 | if (flags & BLKDEV_DISCARD_SECURE) { |
66 | if (!blk_queue_secdiscard(q)) | 65 | if (!blk_queue_secdiscard(q)) |
67 | return -EOPNOTSUPP; | 66 | return -EOPNOTSUPP; |
68 | type |= DISCARD_SECURE; | 67 | type |= REQ_SECURE; |
69 | } | 68 | } |
70 | 69 | ||
71 | while (nr_sects && !ret) { | 70 | while (nr_sects && !ret) { |
@@ -78,8 +77,7 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector, | |||
78 | bio->bi_sector = sector; | 77 | bio->bi_sector = sector; |
79 | bio->bi_end_io = blkdev_discard_end_io; | 78 | bio->bi_end_io = blkdev_discard_end_io; |
80 | bio->bi_bdev = bdev; | 79 | bio->bi_bdev = bdev; |
81 | if (flags & BLKDEV_IFL_WAIT) | 80 | bio->bi_private = &wait; |
82 | bio->bi_private = &wait; | ||
83 | 81 | ||
84 | if (nr_sects > max_discard_sectors) { | 82 | if (nr_sects > max_discard_sectors) { |
85 | bio->bi_size = max_discard_sectors << 9; | 83 | bio->bi_size = max_discard_sectors << 9; |
@@ -93,8 +91,7 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector, | |||
93 | bio_get(bio); | 91 | bio_get(bio); |
94 | submit_bio(type, bio); | 92 | submit_bio(type, bio); |
95 | 93 | ||
96 | if (flags & BLKDEV_IFL_WAIT) | 94 | wait_for_completion(&wait); |
97 | wait_for_completion(&wait); | ||
98 | 95 | ||
99 | if (bio_flagged(bio, BIO_EOPNOTSUPP)) | 96 | if (bio_flagged(bio, BIO_EOPNOTSUPP)) |
100 | ret = -EOPNOTSUPP; | 97 | ret = -EOPNOTSUPP; |
@@ -140,7 +137,6 @@ static void bio_batch_end_io(struct bio *bio, int err) | |||
140 | * @sector: start sector | 137 | * @sector: start sector |
141 | * @nr_sects: number of sectors to write | 138 | * @nr_sects: number of sectors to write |
142 | * @gfp_mask: memory allocation flags (for bio_alloc) | 139 | * @gfp_mask: memory allocation flags (for bio_alloc) |
143 | * @flags: BLKDEV_IFL_* flags to control behaviour | ||
144 | * | 140 | * |
145 | * Description: | 141 | * Description: |
146 | * Generate and issue number of bios with zerofiled pages. | 142 | * Generate and issue number of bios with zerofiled pages. |
@@ -149,7 +145,7 @@ static void bio_batch_end_io(struct bio *bio, int err) | |||
149 | */ | 145 | */ |
150 | 146 | ||
151 | int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector, | 147 | int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector, |
152 | sector_t nr_sects, gfp_t gfp_mask, unsigned long flags) | 148 | sector_t nr_sects, gfp_t gfp_mask) |
153 | { | 149 | { |
154 | int ret; | 150 | int ret; |
155 | struct bio *bio; | 151 | struct bio *bio; |
@@ -162,12 +158,6 @@ int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector, | |||
162 | bb.wait = &wait; | 158 | bb.wait = &wait; |
163 | bb.end_io = NULL; | 159 | bb.end_io = NULL; |
164 | 160 | ||
165 | if (flags & BLKDEV_IFL_BARRIER) { | ||
166 | /* issue async barrier before the data */ | ||
167 | ret = blkdev_issue_flush(bdev, gfp_mask, NULL, 0); | ||
168 | if (ret) | ||
169 | return ret; | ||
170 | } | ||
171 | submit: | 161 | submit: |
172 | ret = 0; | 162 | ret = 0; |
173 | while (nr_sects != 0) { | 163 | while (nr_sects != 0) { |
@@ -181,8 +171,7 @@ submit: | |||
181 | bio->bi_sector = sector; | 171 | bio->bi_sector = sector; |
182 | bio->bi_bdev = bdev; | 172 | bio->bi_bdev = bdev; |
183 | bio->bi_end_io = bio_batch_end_io; | 173 | bio->bi_end_io = bio_batch_end_io; |
184 | if (flags & BLKDEV_IFL_WAIT) | 174 | bio->bi_private = &bb; |
185 | bio->bi_private = &bb; | ||
186 | 175 | ||
187 | while (nr_sects != 0) { | 176 | while (nr_sects != 0) { |
188 | sz = min((sector_t) PAGE_SIZE >> 9 , nr_sects); | 177 | sz = min((sector_t) PAGE_SIZE >> 9 , nr_sects); |
@@ -199,18 +188,10 @@ submit: | |||
199 | issued++; | 188 | issued++; |
200 | submit_bio(WRITE, bio); | 189 | submit_bio(WRITE, bio); |
201 | } | 190 | } |
202 | /* | ||
203 | * When all data bios are in flight. Send final barrier if requeted. | ||
204 | */ | ||
205 | if (nr_sects == 0 && flags & BLKDEV_IFL_BARRIER) | ||
206 | ret = blkdev_issue_flush(bdev, gfp_mask, NULL, | ||
207 | flags & BLKDEV_IFL_WAIT); | ||
208 | |||
209 | 191 | ||
210 | if (flags & BLKDEV_IFL_WAIT) | 192 | /* Wait for bios in-flight */ |
211 | /* Wait for bios in-flight */ | 193 | while (issued != atomic_read(&bb.done)) |
212 | while ( issued != atomic_read(&bb.done)) | 194 | wait_for_completion(&wait); |
213 | wait_for_completion(&wait); | ||
214 | 195 | ||
215 | if (!test_bit(BIO_UPTODATE, &bb.flags)) | 196 | if (!test_bit(BIO_UPTODATE, &bb.flags)) |
216 | /* One of bios in the batch was completed with error.*/ | 197 | /* One of bios in the batch was completed with error.*/ |