Skip to content

Commit 4e49ea4

Browse files
Mike Christieaxboe
authored andcommitted
block/fs/drivers: remove rw argument from submit_bio
This has callers of submit_bio/submit_bio_wait set the bio->bi_rw instead of passing it in. This makes that use the same as generic_make_request and how we set the other bio fields. Signed-off-by: Mike Christie <mchristi@redhat.com> Fixed up fs/ext4/crypto.c Signed-off-by: Jens Axboe <axboe@fb.com>
1 parent af8c34c commit 4e49ea4

53 files changed

Lines changed: 221 additions & 148 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎block/bio.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -854,21 +854,20 @@ static void submit_bio_wait_endio(struct bio *bio)
854854

855855
/**
856856
* submit_bio_wait - submit a bio, and wait until it completes
857-
* @rw: whether to %READ or %WRITE, or maybe to %READA (read ahead)
858857
* @bio: The &struct bio which describes the I/O
859858
*
860859
* Simple wrapper around submit_bio(). Returns 0 on success, or the error from
861860
* bio_endio() on failure.
862861
*/
863-
int submit_bio_wait(int rw, struct bio *bio)
862+
int submit_bio_wait(struct bio *bio)
864863
{
865864
struct submit_bio_ret ret;
866865

867-
rw |= REQ_SYNC;
868866
init_completion(&ret.event);
869867
bio->bi_private = &ret;
870868
bio->bi_end_io = submit_bio_wait_endio;
871-
submit_bio(rw, bio);
869+
bio->bi_rw |= REQ_SYNC;
870+
submit_bio(bio);
872871
wait_for_completion_io(&ret.event);
873872

874873
return ret.error;

‎block/blk-core.c‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,31 +2094,28 @@ EXPORT_SYMBOL(generic_make_request);
20942094

20952095
/**
20962096
* submit_bio - submit a bio to the block device layer for I/O
2097-
* @rw: whether to %READ or %WRITE, or maybe to %READA (read ahead)
20982097
* @bio: The &struct bio which describes the I/O
20992098
*
21002099
* submit_bio() is very similar in purpose to generic_make_request(), and
21012100
* uses that function to do most of the work. Both are fairly rough
21022101
* interfaces; @bio must be presetup and ready for I/O.
21032102
*
21042103
*/
2105-
blk_qc_t submit_bio(int rw, struct bio *bio)
2104+
blk_qc_t submit_bio(struct bio *bio)
21062105
{
2107-
bio->bi_rw |= rw;
2108-
21092106
/*
21102107
* If it's a regular read/write or a barrier with data attached,
21112108
* go through the normal accounting stuff before submission.
21122109
*/
21132110
if (bio_has_data(bio)) {
21142111
unsigned int count;
21152112

2116-
if (unlikely(rw & REQ_WRITE_SAME))
2113+
if (unlikely(bio->bi_rw & REQ_WRITE_SAME))
21172114
count = bdev_logical_block_size(bio->bi_bdev) >> 9;
21182115
else
21192116
count = bio_sectors(bio);
21202117

2121-
if (rw & WRITE) {
2118+
if (bio->bi_rw & WRITE) {
21222119
count_vm_events(PGPGOUT, count);
21232120
} else {
21242121
task_io_account_read(bio->bi_iter.bi_size);
@@ -2129,7 +2126,7 @@ blk_qc_t submit_bio(int rw, struct bio *bio)
21292126
char b[BDEVNAME_SIZE];
21302127
printk(KERN_DEBUG "%s(%d): %s block %Lu on %s (%u sectors)\n",
21312128
current->comm, task_pid_nr(current),
2132-
(rw & WRITE) ? "WRITE" : "READ",
2129+
(bio->bi_rw & WRITE) ? "WRITE" : "READ",
21332130
(unsigned long long)bio->bi_iter.bi_sector,
21342131
bdevname(bio->bi_bdev, b),
21352132
count);

‎block/blk-flush.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,9 @@ int blkdev_issue_flush(struct block_device *bdev, gfp_t gfp_mask,
485485

486486
bio = bio_alloc(gfp_mask, 0);
487487
bio->bi_bdev = bdev;
488+
bio->bi_rw = WRITE_FLUSH;
488489

489-
ret = submit_bio_wait(WRITE_FLUSH, bio);
490+
ret = submit_bio_wait(bio);
490491

491492
/*
492493
* The driver must store the error location in ->bi_sector, if

‎block/blk-lib.c‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99

1010
#include "blk.h"
1111

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,
1313
gfp_t gfp)
1414
{
1515
struct bio *new = bio_alloc(gfp, nr_pages);
1616

1717
if (bio) {
1818
bio_chain(bio, new);
19-
submit_bio(rw, bio);
19+
submit_bio(bio);
2020
}
2121

2222
return new;
@@ -62,9 +62,10 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
6262
req_sects = end_sect - sector;
6363
}
6464

65-
bio = next_bio(bio, type, 1, gfp_mask);
65+
bio = next_bio(bio, 1, gfp_mask);
6666
bio->bi_iter.bi_sector = sector;
6767
bio->bi_bdev = bdev;
68+
bio->bi_rw = type;
6869

6970
bio->bi_iter.bi_size = req_sects << 9;
7071
nr_sects -= req_sects;
@@ -110,7 +111,7 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
110111
ret = __blkdev_issue_discard(bdev, sector, nr_sects, gfp_mask, type,
111112
&bio);
112113
if (!ret && bio) {
113-
ret = submit_bio_wait(type, bio);
114+
ret = submit_bio_wait(bio);
114115
if (ret == -EOPNOTSUPP)
115116
ret = 0;
116117
}
@@ -147,13 +148,14 @@ int blkdev_issue_write_same(struct block_device *bdev, sector_t sector,
147148
max_write_same_sectors = UINT_MAX >> 9;
148149

149150
while (nr_sects) {
150-
bio = next_bio(bio, REQ_WRITE | REQ_WRITE_SAME, 1, gfp_mask);
151+
bio = next_bio(bio, 1, gfp_mask);
151152
bio->bi_iter.bi_sector = sector;
152153
bio->bi_bdev = bdev;
153154
bio->bi_vcnt = 1;
154155
bio->bi_io_vec->bv_page = page;
155156
bio->bi_io_vec->bv_offset = 0;
156157
bio->bi_io_vec->bv_len = bdev_logical_block_size(bdev);
158+
bio->bi_rw = REQ_WRITE | REQ_WRITE_SAME;
157159

158160
if (nr_sects > max_write_same_sectors) {
159161
bio->bi_iter.bi_size = max_write_same_sectors << 9;
@@ -166,7 +168,7 @@ int blkdev_issue_write_same(struct block_device *bdev, sector_t sector,
166168
}
167169

168170
if (bio)
169-
ret = submit_bio_wait(REQ_WRITE | REQ_WRITE_SAME, bio);
171+
ret = submit_bio_wait(bio);
170172
return ret != -EOPNOTSUPP ? ret : 0;
171173
}
172174
EXPORT_SYMBOL(blkdev_issue_write_same);
@@ -190,11 +192,11 @@ static int __blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,
190192
unsigned int sz;
191193

192194
while (nr_sects != 0) {
193-
bio = next_bio(bio, WRITE,
194-
min(nr_sects, (sector_t)BIO_MAX_PAGES),
195+
bio = next_bio(bio, min(nr_sects, (sector_t)BIO_MAX_PAGES),
195196
gfp_mask);
196197
bio->bi_iter.bi_sector = sector;
197198
bio->bi_bdev = bdev;
199+
bio->bi_rw = REQ_WRITE;
198200

199201
while (nr_sects != 0) {
200202
sz = min((sector_t) PAGE_SIZE >> 9 , nr_sects);
@@ -207,7 +209,7 @@ static int __blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,
207209
}
208210

209211
if (bio)
210-
return submit_bio_wait(WRITE, bio);
212+
return submit_bio_wait(bio);
211213
return 0;
212214
}
213215

‎drivers/block/drbd/drbd_actlog.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ static int _drbd_md_sync_page_io(struct drbd_device *device,
177177
if (drbd_insert_fault(device, (rw & WRITE) ? DRBD_FAULT_MD_WR : DRBD_FAULT_MD_RD))
178178
bio_io_error(bio);
179179
else
180-
submit_bio(rw, bio);
180+
submit_bio(bio);
181181
wait_until_done_or_force_detached(device, bdev, &device->md_io.done);
182182
if (!bio->bi_error)
183183
err = device->md_io.error;

‎drivers/block/drbd/drbd_bitmap.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,12 +1011,12 @@ static void bm_page_io_async(struct drbd_bm_aio_ctx *ctx, int page_nr) __must_ho
10111011
bio_add_page(bio, page, len, 0);
10121012
bio->bi_private = ctx;
10131013
bio->bi_end_io = drbd_bm_endio;
1014+
bio->bi_rw = rw;
10141015

10151016
if (drbd_insert_fault(device, (rw & WRITE) ? DRBD_FAULT_MD_WR : DRBD_FAULT_MD_RD)) {
1016-
bio->bi_rw |= rw;
10171017
bio_io_error(bio);
10181018
} else {
1019-
submit_bio(rw, bio);
1019+
submit_bio(bio);
10201020
/* this should not count as user activity and cause the
10211021
* resync to throttle -- see drbd_rs_should_slow_down(). */
10221022
atomic_add(len >> 9, &device->rs_sect_ev);

‎drivers/block/floppy.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3822,8 +3822,9 @@ static int __floppy_read_block_0(struct block_device *bdev, int drive)
38223822
bio.bi_flags |= (1 << BIO_QUIET);
38233823
bio.bi_private = &cbdata;
38243824
bio.bi_end_io = floppy_rb0_cb;
3825+
bio.bi_rw = READ;
38253826

3826-
submit_bio(READ, &bio);
3827+
submit_bio(&bio);
38273828
process_fd_request();
38283829

38293830
init_completion(&cbdata.complete);

‎drivers/block/xen-blkback/blkback.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1369,6 +1369,7 @@ static int dispatch_rw_block_io(struct xen_blkif_ring *ring,
13691369
bio->bi_private = pending_req;
13701370
bio->bi_end_io = end_block_io_op;
13711371
bio->bi_iter.bi_sector = preq.sector_number;
1372+
bio->bi_rw = operation;
13721373
}
13731374

13741375
preq.sector_number += seg[i].nsec;
@@ -1386,13 +1387,14 @@ static int dispatch_rw_block_io(struct xen_blkif_ring *ring,
13861387
bio->bi_bdev = preq.bdev;
13871388
bio->bi_private = pending_req;
13881389
bio->bi_end_io = end_block_io_op;
1390+
bio->bi_rw = operation;
13891391
}
13901392

13911393
atomic_set(&pending_req->pendcnt, nbio);
13921394
blk_start_plug(&plug);
13931395

13941396
for (i = 0; i < nbio; i++)
1395-
submit_bio(operation, biolist[i]);
1397+
submit_bio(biolist[i]);
13961398

13971399
/* Let the I/Os go.. */
13981400
blk_finish_plug(&plug);

‎drivers/block/xen-blkfront.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2114,7 +2114,7 @@ static int blkif_recover(struct blkfront_info *info)
21142114
bio_trim(cloned_bio, offset, size);
21152115
cloned_bio->bi_private = split_bio;
21162116
cloned_bio->bi_end_io = split_bio_end;
2117-
submit_bio(cloned_bio->bi_rw, cloned_bio);
2117+
submit_bio(cloned_bio);
21182118
}
21192119
/*
21202120
* Now we have to wait for all those smaller bios to
@@ -2123,7 +2123,7 @@ static int blkif_recover(struct blkfront_info *info)
21232123
continue;
21242124
}
21252125
/* We don't need to split this bio */
2126-
submit_bio(bio->bi_rw, bio);
2126+
submit_bio(bio);
21272127
}
21282128

21292129
return 0;

‎drivers/md/bcache/debug.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ void bch_btree_verify(struct btree *b)
5252
bio->bi_bdev = PTR_CACHE(b->c, &b->key, 0)->bdev;
5353
bio->bi_iter.bi_sector = PTR_OFFSET(&b->key, 0);
5454
bio->bi_iter.bi_size = KEY_SIZE(&v->key) << 9;
55+
bio->bi_rw = REQ_META|READ_SYNC;
5556
bch_bio_map(bio, sorted);
5657

57-
submit_bio_wait(REQ_META|READ_SYNC, bio);
58+
submit_bio_wait(bio);
5859
bch_bbio_free(bio, b->c);
5960

6061
memcpy(ondisk, sorted, KEY_SIZE(&v->key) << 9);
@@ -113,11 +114,12 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio)
113114
check = bio_clone(bio, GFP_NOIO);
114115
if (!check)
115116
return;
117+
check->bi_rw |= READ_SYNC;
116118

117119
if (bio_alloc_pages(check, GFP_NOIO))
118120
goto out_put;
119121

120-
submit_bio_wait(READ_SYNC, check);
122+
submit_bio_wait(check);
121123

122124
bio_for_each_segment(bv, bio, iter) {
123125
void *p1 = kmap_atomic(bv.bv_page);

0 commit comments

Comments
 (0)