diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-07-26 18:03:07 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-07-26 18:03:07 -0400 |
commit | d05d7f40791ccbb6e543cc5dd6a6aa08fc71d635 (patch) | |
tree | dc0039fe490a41a70de10d58fe8e6136db46463a /block/blk-lib.c | |
parent | 75a442efb1ca613f8d1cc71a32c2c9b0aefae4a5 (diff) | |
parent | 17007f3994cdb4643355c73f54f0adad006cf59e (diff) |
Merge branch 'for-4.8/core' of git://git.kernel.dk/linux-block
Pull core block updates from Jens Axboe:
- the big change is the cleanup from Mike Christie, cleaning up our
uses of command types and modified flags. This is what will throw
some merge conflicts
- regression fix for the above for btrfs, from Vincent
- following up to the above, better packing of struct request from
Christoph
- a 2038 fix for blktrace from Arnd
- a few trivial/spelling fixes from Bart Van Assche
- a front merge check fix from Damien, which could cause issues on
SMR drives
- Atari partition fix from Gabriel
- convert cfq to highres timers, since jiffies isn't granular enough
for some devices these days. From Jan and Jeff
- CFQ priority boost fix idle classes, from me
- cleanup series from Ming, improving our bio/bvec iteration
- a direct issue fix for blk-mq from Omar
- fix for plug merging not involving the IO scheduler, like we do for
other types of merges. From Tahsin
- expose DAX type internally and through sysfs. From Toshi and Yigal
* 'for-4.8/core' of git://git.kernel.dk/linux-block: (76 commits)
block: Fix front merge check
block: do not merge requests without consulting with io scheduler
block: Fix spelling in a source code comment
block: expose QUEUE_FLAG_DAX in sysfs
block: add QUEUE_FLAG_DAX for devices to advertise their DAX support
Btrfs: fix comparison in __btrfs_map_block()
block: atari: Return early for unsupported sector size
Doc: block: Fix a typo in queue-sysfs.txt
cfq-iosched: Charge at least 1 jiffie instead of 1 ns
cfq-iosched: Fix regression in bonnie++ rewrite performance
cfq-iosched: Convert slice_resid from u64 to s64
block: Convert fifo_time from ulong to u64
blktrace: avoid using timespec
block/blk-cgroup.c: Declare local symbols static
block/bio-integrity.c: Add #include "blk.h"
block/partition-generic.c: Remove a set-but-not-used variable
block: bio: kill BIO_MAX_SIZE
cfq-iosched: temporarily boost queue priority for idle classes
block: drbd: avoid to use BIO_MAX_SIZE
block: bio: remove BIO_MAX_SECTORS
...
Diffstat (limited to 'block/blk-lib.c')
-rw-r--r-- | block/blk-lib.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/block/blk-lib.c b/block/blk-lib.c index 9e29dc351695..9031d2af0b47 100644 --- a/block/blk-lib.c +++ b/block/blk-lib.c | |||
@@ -9,21 +9,22 @@ | |||
9 | 9 | ||
10 | #include "blk.h" | 10 | #include "blk.h" |
11 | 11 | ||
12 | static struct bio *next_bio(struct bio *bio, int rw, unsigned int nr_pages, | 12 | static struct bio *next_bio(struct bio *bio, unsigned int nr_pages, |
13 | gfp_t gfp) | 13 | gfp_t gfp) |
14 | { | 14 | { |
15 | struct bio *new = bio_alloc(gfp, nr_pages); | 15 | struct bio *new = bio_alloc(gfp, nr_pages); |
16 | 16 | ||
17 | if (bio) { | 17 | if (bio) { |
18 | bio_chain(bio, new); | 18 | bio_chain(bio, new); |
19 | submit_bio(rw, bio); | 19 | submit_bio(bio); |
20 | } | 20 | } |
21 | 21 | ||
22 | return new; | 22 | return new; |
23 | } | 23 | } |
24 | 24 | ||
25 | int __blkdev_issue_discard(struct block_device *bdev, sector_t sector, | 25 | int __blkdev_issue_discard(struct block_device *bdev, sector_t sector, |
26 | sector_t nr_sects, gfp_t gfp_mask, int type, struct bio **biop) | 26 | sector_t nr_sects, gfp_t gfp_mask, int op_flags, |
27 | struct bio **biop) | ||
27 | { | 28 | { |
28 | struct request_queue *q = bdev_get_queue(bdev); | 29 | struct request_queue *q = bdev_get_queue(bdev); |
29 | struct bio *bio = *biop; | 30 | struct bio *bio = *biop; |
@@ -34,7 +35,7 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector, | |||
34 | return -ENXIO; | 35 | return -ENXIO; |
35 | if (!blk_queue_discard(q)) | 36 | if (!blk_queue_discard(q)) |
36 | return -EOPNOTSUPP; | 37 | return -EOPNOTSUPP; |
37 | if ((type & REQ_SECURE) && !blk_queue_secdiscard(q)) | 38 | if ((op_flags & REQ_SECURE) && !blk_queue_secdiscard(q)) |
38 | return -EOPNOTSUPP; | 39 | return -EOPNOTSUPP; |
39 | 40 | ||
40 | /* Zero-sector (unknown) and one-sector granularities are the same. */ | 41 | /* Zero-sector (unknown) and one-sector granularities are the same. */ |
@@ -62,9 +63,10 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector, | |||
62 | req_sects = end_sect - sector; | 63 | req_sects = end_sect - sector; |
63 | } | 64 | } |
64 | 65 | ||
65 | bio = next_bio(bio, type, 1, gfp_mask); | 66 | bio = next_bio(bio, 1, gfp_mask); |
66 | bio->bi_iter.bi_sector = sector; | 67 | bio->bi_iter.bi_sector = sector; |
67 | bio->bi_bdev = bdev; | 68 | bio->bi_bdev = bdev; |
69 | bio_set_op_attrs(bio, REQ_OP_DISCARD, op_flags); | ||
68 | 70 | ||
69 | bio->bi_iter.bi_size = req_sects << 9; | 71 | bio->bi_iter.bi_size = req_sects << 9; |
70 | nr_sects -= req_sects; | 72 | nr_sects -= req_sects; |
@@ -98,19 +100,19 @@ EXPORT_SYMBOL(__blkdev_issue_discard); | |||
98 | int blkdev_issue_discard(struct block_device *bdev, sector_t sector, | 100 | int blkdev_issue_discard(struct block_device *bdev, sector_t sector, |
99 | sector_t nr_sects, gfp_t gfp_mask, unsigned long flags) | 101 | sector_t nr_sects, gfp_t gfp_mask, unsigned long flags) |
100 | { | 102 | { |
101 | int type = REQ_WRITE | REQ_DISCARD; | 103 | int op_flags = 0; |
102 | struct bio *bio = NULL; | 104 | struct bio *bio = NULL; |
103 | struct blk_plug plug; | 105 | struct blk_plug plug; |
104 | int ret; | 106 | int ret; |
105 | 107 | ||
106 | if (flags & BLKDEV_DISCARD_SECURE) | 108 | if (flags & BLKDEV_DISCARD_SECURE) |
107 | type |= REQ_SECURE; | 109 | op_flags |= REQ_SECURE; |
108 | 110 | ||
109 | blk_start_plug(&plug); | 111 | blk_start_plug(&plug); |
110 | ret = __blkdev_issue_discard(bdev, sector, nr_sects, gfp_mask, type, | 112 | ret = __blkdev_issue_discard(bdev, sector, nr_sects, gfp_mask, op_flags, |
111 | &bio); | 113 | &bio); |
112 | if (!ret && bio) { | 114 | if (!ret && bio) { |
113 | ret = submit_bio_wait(type, bio); | 115 | ret = submit_bio_wait(bio); |
114 | if (ret == -EOPNOTSUPP) | 116 | if (ret == -EOPNOTSUPP) |
115 | ret = 0; | 117 | ret = 0; |
116 | bio_put(bio); | 118 | bio_put(bio); |
@@ -148,13 +150,14 @@ int blkdev_issue_write_same(struct block_device *bdev, sector_t sector, | |||
148 | max_write_same_sectors = UINT_MAX >> 9; | 150 | max_write_same_sectors = UINT_MAX >> 9; |
149 | 151 | ||
150 | while (nr_sects) { | 152 | while (nr_sects) { |
151 | bio = next_bio(bio, REQ_WRITE | REQ_WRITE_SAME, 1, gfp_mask); | 153 | bio = next_bio(bio, 1, gfp_mask); |
152 | bio->bi_iter.bi_sector = sector; | 154 | bio->bi_iter.bi_sector = sector; |
153 | bio->bi_bdev = bdev; | 155 | bio->bi_bdev = bdev; |
154 | bio->bi_vcnt = 1; | 156 | bio->bi_vcnt = 1; |
155 | bio->bi_io_vec->bv_page = page; | 157 | bio->bi_io_vec->bv_page = page; |
156 | bio->bi_io_vec->bv_offset = 0; | 158 | bio->bi_io_vec->bv_offset = 0; |
157 | bio->bi_io_vec->bv_len = bdev_logical_block_size(bdev); | 159 | bio->bi_io_vec->bv_len = bdev_logical_block_size(bdev); |
160 | bio_set_op_attrs(bio, REQ_OP_WRITE_SAME, 0); | ||
158 | 161 | ||
159 | if (nr_sects > max_write_same_sectors) { | 162 | if (nr_sects > max_write_same_sectors) { |
160 | bio->bi_iter.bi_size = max_write_same_sectors << 9; | 163 | bio->bi_iter.bi_size = max_write_same_sectors << 9; |
@@ -167,7 +170,7 @@ int blkdev_issue_write_same(struct block_device *bdev, sector_t sector, | |||
167 | } | 170 | } |
168 | 171 | ||
169 | if (bio) { | 172 | if (bio) { |
170 | ret = submit_bio_wait(REQ_WRITE | REQ_WRITE_SAME, bio); | 173 | ret = submit_bio_wait(bio); |
171 | bio_put(bio); | 174 | bio_put(bio); |
172 | } | 175 | } |
173 | return ret != -EOPNOTSUPP ? ret : 0; | 176 | return ret != -EOPNOTSUPP ? ret : 0; |
@@ -193,11 +196,11 @@ static int __blkdev_issue_zeroout(struct block_device *bdev, sector_t sector, | |||
193 | unsigned int sz; | 196 | unsigned int sz; |
194 | 197 | ||
195 | while (nr_sects != 0) { | 198 | while (nr_sects != 0) { |
196 | bio = next_bio(bio, WRITE, | 199 | bio = next_bio(bio, min(nr_sects, (sector_t)BIO_MAX_PAGES), |
197 | min(nr_sects, (sector_t)BIO_MAX_PAGES), | ||
198 | gfp_mask); | 200 | gfp_mask); |
199 | bio->bi_iter.bi_sector = sector; | 201 | bio->bi_iter.bi_sector = sector; |
200 | bio->bi_bdev = bdev; | 202 | bio->bi_bdev = bdev; |
203 | bio_set_op_attrs(bio, REQ_OP_WRITE, 0); | ||
201 | 204 | ||
202 | while (nr_sects != 0) { | 205 | while (nr_sects != 0) { |
203 | sz = min((sector_t) PAGE_SIZE >> 9 , nr_sects); | 206 | sz = min((sector_t) PAGE_SIZE >> 9 , nr_sects); |
@@ -210,7 +213,7 @@ static int __blkdev_issue_zeroout(struct block_device *bdev, sector_t sector, | |||
210 | } | 213 | } |
211 | 214 | ||
212 | if (bio) { | 215 | if (bio) { |
213 | ret = submit_bio_wait(WRITE, bio); | 216 | ret = submit_bio_wait(bio); |
214 | bio_put(bio); | 217 | bio_put(bio); |
215 | return ret; | 218 | return ret; |
216 | } | 219 | } |