Skip to content

Commit 2a222ca

Browse files
Mike Christieaxboe
authored andcommitted
fs: have submit_bh users pass in op and flags separately
This has submit_bh users pass in the operation and flags separately, so submit_bh_wbc can setup the bio op and bi_rw flags on the bio that is submitted. Signed-off-by: Mike Christie <mchristi@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.com> Signed-off-by: Jens Axboe <axboe@fb.com>
1 parent f215082 commit 2a222ca

30 files changed

Lines changed: 102 additions & 96 deletions

‎drivers/md/bitmap.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ static void write_page(struct bitmap *bitmap, struct page *page, int wait)
297297
atomic_inc(&bitmap->pending_writes);
298298
set_buffer_locked(bh);
299299
set_buffer_mapped(bh);
300-
submit_bh(WRITE | REQ_SYNC, bh);
300+
submit_bh(REQ_OP_WRITE, REQ_SYNC, bh);
301301
bh = bh->b_this_page;
302302
}
303303

@@ -392,7 +392,7 @@ static int read_page(struct file *file, unsigned long index,
392392
atomic_inc(&bitmap->pending_writes);
393393
set_buffer_locked(bh);
394394
set_buffer_mapped(bh);
395-
submit_bh(READ, bh);
395+
submit_bh(REQ_OP_READ, 0, bh);
396396
}
397397
block++;
398398
bh = bh->b_this_page;

‎fs/btrfs/check-integrity.c‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2856,12 +2856,12 @@ static struct btrfsic_dev_state *btrfsic_dev_state_lookup(
28562856
return ds;
28572857
}
28582858

2859-
int btrfsic_submit_bh(int rw, struct buffer_head *bh)
2859+
int btrfsic_submit_bh(int op, int op_flags, struct buffer_head *bh)
28602860
{
28612861
struct btrfsic_dev_state *dev_state;
28622862

28632863
if (!btrfsic_is_initialized)
2864-
return submit_bh(rw, bh);
2864+
return submit_bh(op, op_flags, bh);
28652865

28662866
mutex_lock(&btrfsic_mutex);
28672867
/* since btrfsic_submit_bh() might also be called before
@@ -2870,26 +2870,26 @@ int btrfsic_submit_bh(int rw, struct buffer_head *bh)
28702870

28712871
/* Only called to write the superblock (incl. FLUSH/FUA) */
28722872
if (NULL != dev_state &&
2873-
(rw & WRITE) && bh->b_size > 0) {
2873+
(op == REQ_OP_WRITE) && bh->b_size > 0) {
28742874
u64 dev_bytenr;
28752875

28762876
dev_bytenr = 4096 * bh->b_blocknr;
28772877
if (dev_state->state->print_mask &
28782878
BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH)
28792879
printk(KERN_INFO
2880-
"submit_bh(rw=0x%x, blocknr=%llu (bytenr %llu),"
2881-
" size=%zu, data=%p, bdev=%p)\n",
2882-
rw, (unsigned long long)bh->b_blocknr,
2880+
"submit_bh(op=0x%x,0x%x, blocknr=%llu "
2881+
"(bytenr %llu), size=%zu, data=%p, bdev=%p)\n",
2882+
op, op_flags, (unsigned long long)bh->b_blocknr,
28832883
dev_bytenr, bh->b_size, bh->b_data, bh->b_bdev);
28842884
btrfsic_process_written_block(dev_state, dev_bytenr,
28852885
&bh->b_data, 1, NULL,
2886-
NULL, bh, rw);
2887-
} else if (NULL != dev_state && (rw & REQ_FLUSH)) {
2886+
NULL, bh, op_flags);
2887+
} else if (NULL != dev_state && (op_flags & REQ_FLUSH)) {
28882888
if (dev_state->state->print_mask &
28892889
BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH)
28902890
printk(KERN_INFO
2891-
"submit_bh(rw=0x%x FLUSH, bdev=%p)\n",
2892-
rw, bh->b_bdev);
2891+
"submit_bh(op=0x%x,0x%x FLUSH, bdev=%p)\n",
2892+
op, op_flags, bh->b_bdev);
28932893
if (!dev_state->dummy_block_for_bio_bh_flush.is_iodone) {
28942894
if ((dev_state->state->print_mask &
28952895
(BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH |
@@ -2907,7 +2907,7 @@ int btrfsic_submit_bh(int rw, struct buffer_head *bh)
29072907
block->never_written = 0;
29082908
block->iodone_w_error = 0;
29092909
block->flush_gen = dev_state->last_flush_gen + 1;
2910-
block->submit_bio_bh_rw = rw;
2910+
block->submit_bio_bh_rw = op_flags;
29112911
block->orig_bio_bh_private = bh->b_private;
29122912
block->orig_bio_bh_end_io.bh = bh->b_end_io;
29132913
block->next_in_same_bio = NULL;
@@ -2916,7 +2916,7 @@ int btrfsic_submit_bh(int rw, struct buffer_head *bh)
29162916
}
29172917
}
29182918
mutex_unlock(&btrfsic_mutex);
2919-
return submit_bh(rw, bh);
2919+
return submit_bh(op, op_flags, bh);
29202920
}
29212921

29222922
static void __btrfsic_submit_bio(struct bio *bio)

‎fs/btrfs/check-integrity.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#define __BTRFS_CHECK_INTEGRITY__
2121

2222
#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY
23-
int btrfsic_submit_bh(int rw, struct buffer_head *bh);
23+
int btrfsic_submit_bh(int op, int op_flags, struct buffer_head *bh);
2424
void btrfsic_submit_bio(struct bio *bio);
2525
int btrfsic_submit_bio_wait(struct bio *bio);
2626
#else

‎fs/btrfs/disk-io.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3420,9 +3420,9 @@ static int write_dev_supers(struct btrfs_device *device,
34203420
* to go down lazy.
34213421
*/
34223422
if (i == 0)
3423-
ret = btrfsic_submit_bh(WRITE_FUA, bh);
3423+
ret = btrfsic_submit_bh(REQ_OP_WRITE, WRITE_FUA, bh);
34243424
else
3425-
ret = btrfsic_submit_bh(WRITE_SYNC, bh);
3425+
ret = btrfsic_submit_bh(REQ_OP_WRITE, WRITE_SYNC, bh);
34263426
if (ret)
34273427
errors++;
34283428
}

‎fs/buffer.c‎

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#include <trace/events/block.h>
4646

4747
static int fsync_buffers_list(spinlock_t *lock, struct list_head *list);
48-
static int submit_bh_wbc(int rw, struct buffer_head *bh,
48+
static int submit_bh_wbc(int op, int op_flags, struct buffer_head *bh,
4949
unsigned long bio_flags,
5050
struct writeback_control *wbc);
5151

@@ -1225,7 +1225,7 @@ static struct buffer_head *__bread_slow(struct buffer_head *bh)
12251225
} else {
12261226
get_bh(bh);
12271227
bh->b_end_io = end_buffer_read_sync;
1228-
submit_bh(READ, bh);
1228+
submit_bh(REQ_OP_READ, 0, bh);
12291229
wait_on_buffer(bh);
12301230
if (buffer_uptodate(bh))
12311231
return bh;
@@ -1697,7 +1697,7 @@ static int __block_write_full_page(struct inode *inode, struct page *page,
16971697
struct buffer_head *bh, *head;
16981698
unsigned int blocksize, bbits;
16991699
int nr_underway = 0;
1700-
int write_op = (wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : WRITE);
1700+
int write_flags = (wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : 0);
17011701

17021702
head = create_page_buffers(page, inode,
17031703
(1 << BH_Dirty)|(1 << BH_Uptodate));
@@ -1786,7 +1786,7 @@ static int __block_write_full_page(struct inode *inode, struct page *page,
17861786
do {
17871787
struct buffer_head *next = bh->b_this_page;
17881788
if (buffer_async_write(bh)) {
1789-
submit_bh_wbc(write_op, bh, 0, wbc);
1789+
submit_bh_wbc(REQ_OP_WRITE, write_flags, bh, 0, wbc);
17901790
nr_underway++;
17911791
}
17921792
bh = next;
@@ -1840,7 +1840,7 @@ static int __block_write_full_page(struct inode *inode, struct page *page,
18401840
struct buffer_head *next = bh->b_this_page;
18411841
if (buffer_async_write(bh)) {
18421842
clear_buffer_dirty(bh);
1843-
submit_bh_wbc(write_op, bh, 0, wbc);
1843+
submit_bh_wbc(REQ_OP_WRITE, write_flags, bh, 0, wbc);
18441844
nr_underway++;
18451845
}
18461846
bh = next;
@@ -2248,7 +2248,7 @@ int block_read_full_page(struct page *page, get_block_t *get_block)
22482248
if (buffer_uptodate(bh))
22492249
end_buffer_async_read(bh, 1);
22502250
else
2251-
submit_bh(READ, bh);
2251+
submit_bh(REQ_OP_READ, 0, bh);
22522252
}
22532253
return 0;
22542254
}
@@ -2582,7 +2582,7 @@ int nobh_write_begin(struct address_space *mapping,
25822582
if (block_start < from || block_end > to) {
25832583
lock_buffer(bh);
25842584
bh->b_end_io = end_buffer_read_nobh;
2585-
submit_bh(READ, bh);
2585+
submit_bh(REQ_OP_READ, 0, bh);
25862586
nr_reads++;
25872587
}
25882588
}
@@ -2949,7 +2949,7 @@ static void end_bio_bh_io_sync(struct bio *bio)
29492949
* errors, this only handles the "we need to be able to
29502950
* do IO at the final sector" case.
29512951
*/
2952-
void guard_bio_eod(int rw, struct bio *bio)
2952+
void guard_bio_eod(int op, struct bio *bio)
29532953
{
29542954
sector_t maxsector;
29552955
struct bio_vec *bvec = &bio->bi_io_vec[bio->bi_vcnt - 1];
@@ -2979,13 +2979,13 @@ void guard_bio_eod(int rw, struct bio *bio)
29792979
bvec->bv_len -= truncated_bytes;
29802980

29812981
/* ..and clear the end of the buffer for reads */
2982-
if ((rw & RW_MASK) == READ) {
2982+
if (op == REQ_OP_READ) {
29832983
zero_user(bvec->bv_page, bvec->bv_offset + bvec->bv_len,
29842984
truncated_bytes);
29852985
}
29862986
}
29872987

2988-
static int submit_bh_wbc(int rw, struct buffer_head *bh,
2988+
static int submit_bh_wbc(int op, int op_flags, struct buffer_head *bh,
29892989
unsigned long bio_flags, struct writeback_control *wbc)
29902990
{
29912991
struct bio *bio;
@@ -2999,7 +2999,7 @@ static int submit_bh_wbc(int rw, struct buffer_head *bh,
29992999
/*
30003000
* Only clear out a write error when rewriting
30013001
*/
3002-
if (test_set_buffer_req(bh) && (rw & WRITE))
3002+
if (test_set_buffer_req(bh) && (op == REQ_OP_WRITE))
30033003
clear_buffer_write_io_error(bh);
30043004

30053005
/*
@@ -3024,27 +3024,28 @@ static int submit_bh_wbc(int rw, struct buffer_head *bh,
30243024
bio->bi_flags |= bio_flags;
30253025

30263026
/* Take care of bh's that straddle the end of the device */
3027-
guard_bio_eod(rw, bio);
3027+
guard_bio_eod(op, bio);
30283028

30293029
if (buffer_meta(bh))
3030-
rw |= REQ_META;
3030+
op_flags |= REQ_META;
30313031
if (buffer_prio(bh))
3032-
rw |= REQ_PRIO;
3033-
bio->bi_rw = rw;
3032+
op_flags |= REQ_PRIO;
3033+
bio_set_op_attrs(bio, op, op_flags);
30343034

30353035
submit_bio(bio);
30363036
return 0;
30373037
}
30383038

3039-
int _submit_bh(int rw, struct buffer_head *bh, unsigned long bio_flags)
3039+
int _submit_bh(int op, int op_flags, struct buffer_head *bh,
3040+
unsigned long bio_flags)
30403041
{
3041-
return submit_bh_wbc(rw, bh, bio_flags, NULL);
3042+
return submit_bh_wbc(op, op_flags, bh, bio_flags, NULL);
30423043
}
30433044
EXPORT_SYMBOL_GPL(_submit_bh);
30443045

3045-
int submit_bh(int rw, struct buffer_head *bh)
3046+
int submit_bh(int op, int op_flags, struct buffer_head *bh)
30463047
{
3047-
return submit_bh_wbc(rw, bh, 0, NULL);
3048+
return submit_bh_wbc(op, op_flags, bh, 0, NULL);
30483049
}
30493050
EXPORT_SYMBOL(submit_bh);
30503051

@@ -3086,14 +3087,14 @@ void ll_rw_block(int rw, int nr, struct buffer_head *bhs[])
30863087
if (test_clear_buffer_dirty(bh)) {
30873088
bh->b_end_io = end_buffer_write_sync;
30883089
get_bh(bh);
3089-
submit_bh(WRITE, bh);
3090+
submit_bh(rw, 0, bh);
30903091
continue;
30913092
}
30923093
} else {
30933094
if (!buffer_uptodate(bh)) {
30943095
bh->b_end_io = end_buffer_read_sync;
30953096
get_bh(bh);
3096-
submit_bh(rw, bh);
3097+
submit_bh(rw, 0, bh);
30973098
continue;
30983099
}
30993100
}
@@ -3102,7 +3103,7 @@ void ll_rw_block(int rw, int nr, struct buffer_head *bhs[])
31023103
}
31033104
EXPORT_SYMBOL(ll_rw_block);
31043105

3105-
void write_dirty_buffer(struct buffer_head *bh, int rw)
3106+
void write_dirty_buffer(struct buffer_head *bh, int op_flags)
31063107
{
31073108
lock_buffer(bh);
31083109
if (!test_clear_buffer_dirty(bh)) {
@@ -3111,7 +3112,7 @@ void write_dirty_buffer(struct buffer_head *bh, int rw)
31113112
}
31123113
bh->b_end_io = end_buffer_write_sync;
31133114
get_bh(bh);
3114-
submit_bh(rw, bh);
3115+
submit_bh(REQ_OP_WRITE, op_flags, bh);
31153116
}
31163117
EXPORT_SYMBOL(write_dirty_buffer);
31173118

@@ -3120,7 +3121,7 @@ EXPORT_SYMBOL(write_dirty_buffer);
31203121
* and then start new I/O and then wait upon it. The caller must have a ref on
31213122
* the buffer_head.
31223123
*/
3123-
int __sync_dirty_buffer(struct buffer_head *bh, int rw)
3124+
int __sync_dirty_buffer(struct buffer_head *bh, int op_flags)
31243125
{
31253126
int ret = 0;
31263127

@@ -3129,7 +3130,7 @@ int __sync_dirty_buffer(struct buffer_head *bh, int rw)
31293130
if (test_clear_buffer_dirty(bh)) {
31303131
get_bh(bh);
31313132
bh->b_end_io = end_buffer_write_sync;
3132-
ret = submit_bh(rw, bh);
3133+
ret = submit_bh(REQ_OP_WRITE, op_flags, bh);
31333134
wait_on_buffer(bh);
31343135
if (!ret && !buffer_uptodate(bh))
31353136
ret = -EIO;
@@ -3392,7 +3393,7 @@ int bh_submit_read(struct buffer_head *bh)
33923393

33933394
get_bh(bh);
33943395
bh->b_end_io = end_buffer_read_sync;
3395-
submit_bh(READ, bh);
3396+
submit_bh(REQ_OP_READ, 0, bh);
33963397
wait_on_buffer(bh);
33973398
if (buffer_uptodate(bh))
33983399
return 0;

‎fs/ext4/balloc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ ext4_read_block_bitmap_nowait(struct super_block *sb, ext4_group_t block_group)
470470
trace_ext4_read_block_bitmap_load(sb, block_group);
471471
bh->b_end_io = ext4_end_bitmap_read;
472472
get_bh(bh);
473-
submit_bh(READ | REQ_META | REQ_PRIO, bh);
473+
submit_bh(REQ_OP_READ, REQ_META | REQ_PRIO, bh);
474474
return bh;
475475
verify:
476476
err = ext4_validate_block_bitmap(sb, desc, block_group, bh);

‎fs/ext4/ialloc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group)
214214
trace_ext4_load_inode_bitmap(sb, block_group);
215215
bh->b_end_io = ext4_end_bitmap_read;
216216
get_bh(bh);
217-
submit_bh(READ | REQ_META | REQ_PRIO, bh);
217+
submit_bh(REQ_OP_READ, REQ_META | REQ_PRIO, bh);
218218
wait_on_buffer(bh);
219219
if (!buffer_uptodate(bh)) {
220220
put_bh(bh);

‎fs/ext4/inode.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4281,7 +4281,7 @@ static int __ext4_get_inode_loc(struct inode *inode,
42814281
trace_ext4_load_inode(inode);
42824282
get_bh(bh);
42834283
bh->b_end_io = end_buffer_read_sync;
4284-
submit_bh(READ | REQ_META | REQ_PRIO, bh);
4284+
submit_bh(REQ_OP_READ, REQ_META | REQ_PRIO, bh);
42854285
wait_on_buffer(bh);
42864286
if (!buffer_uptodate(bh)) {
42874287
EXT4_ERROR_INODE_BLOCK(inode, block,

‎fs/ext4/mmp.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static int write_mmp_block(struct super_block *sb, struct buffer_head *bh)
5252
lock_buffer(bh);
5353
bh->b_end_io = end_buffer_write_sync;
5454
get_bh(bh);
55-
submit_bh(WRITE_SYNC | REQ_META | REQ_PRIO, bh);
55+
submit_bh(REQ_OP_WRITE, WRITE_SYNC | REQ_META | REQ_PRIO, bh);
5656
wait_on_buffer(bh);
5757
sb_end_write(sb);
5858
if (unlikely(!buffer_uptodate(bh)))
@@ -88,7 +88,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
8888
get_bh(*bh);
8989
lock_buffer(*bh);
9090
(*bh)->b_end_io = end_buffer_read_sync;
91-
submit_bh(READ_SYNC | REQ_META | REQ_PRIO, *bh);
91+
submit_bh(REQ_OP_READ, READ_SYNC | REQ_META | REQ_PRIO, *bh);
9292
wait_on_buffer(*bh);
9393
if (!buffer_uptodate(*bh)) {
9494
ret = -EIO;

‎fs/fat/misc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ int fat_sync_bhs(struct buffer_head **bhs, int nr_bhs)
267267
int i, err = 0;
268268

269269
for (i = 0; i < nr_bhs; i++)
270-
write_dirty_buffer(bhs[i], WRITE);
270+
write_dirty_buffer(bhs[i], 0);
271271

272272
for (i = 0; i < nr_bhs; i++) {
273273
wait_on_buffer(bhs[i]);

0 commit comments

Comments
 (0)