Skip to content

Commit

Permalink
fs: have submit_bh users pass in op and flags separately
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Reviewed-by: Hannes Reinecke <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Mike Christie authored and axboe committed Jun 7, 2016
1 parent f215082 commit 2a222ca
Show file tree
Hide file tree
Showing 30 changed files with 102 additions and 96 deletions.
4 changes: 2 additions & 2 deletions drivers/md/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ static void write_page(struct bitmap *bitmap, struct page *page, int wait)
atomic_inc(&bitmap->pending_writes);
set_buffer_locked(bh);
set_buffer_mapped(bh);
submit_bh(WRITE | REQ_SYNC, bh);
submit_bh(REQ_OP_WRITE, REQ_SYNC, bh);
bh = bh->b_this_page;
}

Expand Down Expand Up @@ -392,7 +392,7 @@ static int read_page(struct file *file, unsigned long index,
atomic_inc(&bitmap->pending_writes);
set_buffer_locked(bh);
set_buffer_mapped(bh);
submit_bh(READ, bh);
submit_bh(REQ_OP_READ, 0, bh);
}
block++;
bh = bh->b_this_page;
Expand Down
24 changes: 12 additions & 12 deletions fs/btrfs/check-integrity.c
Original file line number Diff line number Diff line change
Expand Up @@ -2856,12 +2856,12 @@ static struct btrfsic_dev_state *btrfsic_dev_state_lookup(
return ds;
}

int btrfsic_submit_bh(int rw, struct buffer_head *bh)
int btrfsic_submit_bh(int op, int op_flags, struct buffer_head *bh)
{
struct btrfsic_dev_state *dev_state;

if (!btrfsic_is_initialized)
return submit_bh(rw, bh);
return submit_bh(op, op_flags, bh);

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

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

dev_bytenr = 4096 * bh->b_blocknr;
if (dev_state->state->print_mask &
BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH)
printk(KERN_INFO
"submit_bh(rw=0x%x, blocknr=%llu (bytenr %llu),"
" size=%zu, data=%p, bdev=%p)\n",
rw, (unsigned long long)bh->b_blocknr,
"submit_bh(op=0x%x,0x%x, blocknr=%llu "
"(bytenr %llu), size=%zu, data=%p, bdev=%p)\n",
op, op_flags, (unsigned long long)bh->b_blocknr,
dev_bytenr, bh->b_size, bh->b_data, bh->b_bdev);
btrfsic_process_written_block(dev_state, dev_bytenr,
&bh->b_data, 1, NULL,
NULL, bh, rw);
} else if (NULL != dev_state && (rw & REQ_FLUSH)) {
NULL, bh, op_flags);
} else if (NULL != dev_state && (op_flags & REQ_FLUSH)) {
if (dev_state->state->print_mask &
BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH)
printk(KERN_INFO
"submit_bh(rw=0x%x FLUSH, bdev=%p)\n",
rw, bh->b_bdev);
"submit_bh(op=0x%x,0x%x FLUSH, bdev=%p)\n",
op, op_flags, bh->b_bdev);
if (!dev_state->dummy_block_for_bio_bh_flush.is_iodone) {
if ((dev_state->state->print_mask &
(BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH |
Expand All @@ -2907,7 +2907,7 @@ int btrfsic_submit_bh(int rw, struct buffer_head *bh)
block->never_written = 0;
block->iodone_w_error = 0;
block->flush_gen = dev_state->last_flush_gen + 1;
block->submit_bio_bh_rw = rw;
block->submit_bio_bh_rw = op_flags;
block->orig_bio_bh_private = bh->b_private;
block->orig_bio_bh_end_io.bh = bh->b_end_io;
block->next_in_same_bio = NULL;
Expand All @@ -2916,7 +2916,7 @@ int btrfsic_submit_bh(int rw, struct buffer_head *bh)
}
}
mutex_unlock(&btrfsic_mutex);
return submit_bh(rw, bh);
return submit_bh(op, op_flags, bh);
}

static void __btrfsic_submit_bio(struct bio *bio)
Expand Down
2 changes: 1 addition & 1 deletion fs/btrfs/check-integrity.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define __BTRFS_CHECK_INTEGRITY__

#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY
int btrfsic_submit_bh(int rw, struct buffer_head *bh);
int btrfsic_submit_bh(int op, int op_flags, struct buffer_head *bh);
void btrfsic_submit_bio(struct bio *bio);
int btrfsic_submit_bio_wait(struct bio *bio);
#else
Expand Down
4 changes: 2 additions & 2 deletions fs/btrfs/disk-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -3420,9 +3420,9 @@ static int write_dev_supers(struct btrfs_device *device,
* to go down lazy.
*/
if (i == 0)
ret = btrfsic_submit_bh(WRITE_FUA, bh);
ret = btrfsic_submit_bh(REQ_OP_WRITE, WRITE_FUA, bh);
else
ret = btrfsic_submit_bh(WRITE_SYNC, bh);
ret = btrfsic_submit_bh(REQ_OP_WRITE, WRITE_SYNC, bh);
if (ret)
errors++;
}
Expand Down
53 changes: 27 additions & 26 deletions fs/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#include <trace/events/block.h>

static int fsync_buffers_list(spinlock_t *lock, struct list_head *list);
static int submit_bh_wbc(int rw, struct buffer_head *bh,
static int submit_bh_wbc(int op, int op_flags, struct buffer_head *bh,
unsigned long bio_flags,
struct writeback_control *wbc);

Expand Down Expand Up @@ -1225,7 +1225,7 @@ static struct buffer_head *__bread_slow(struct buffer_head *bh)
} else {
get_bh(bh);
bh->b_end_io = end_buffer_read_sync;
submit_bh(READ, bh);
submit_bh(REQ_OP_READ, 0, bh);
wait_on_buffer(bh);
if (buffer_uptodate(bh))
return bh;
Expand Down Expand Up @@ -1697,7 +1697,7 @@ static int __block_write_full_page(struct inode *inode, struct page *page,
struct buffer_head *bh, *head;
unsigned int blocksize, bbits;
int nr_underway = 0;
int write_op = (wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : WRITE);
int write_flags = (wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : 0);

head = create_page_buffers(page, inode,
(1 << BH_Dirty)|(1 << BH_Uptodate));
Expand Down Expand Up @@ -1786,7 +1786,7 @@ static int __block_write_full_page(struct inode *inode, struct page *page,
do {
struct buffer_head *next = bh->b_this_page;
if (buffer_async_write(bh)) {
submit_bh_wbc(write_op, bh, 0, wbc);
submit_bh_wbc(REQ_OP_WRITE, write_flags, bh, 0, wbc);
nr_underway++;
}
bh = next;
Expand Down Expand Up @@ -1840,7 +1840,7 @@ static int __block_write_full_page(struct inode *inode, struct page *page,
struct buffer_head *next = bh->b_this_page;
if (buffer_async_write(bh)) {
clear_buffer_dirty(bh);
submit_bh_wbc(write_op, bh, 0, wbc);
submit_bh_wbc(REQ_OP_WRITE, write_flags, bh, 0, wbc);
nr_underway++;
}
bh = next;
Expand Down Expand Up @@ -2248,7 +2248,7 @@ int block_read_full_page(struct page *page, get_block_t *get_block)
if (buffer_uptodate(bh))
end_buffer_async_read(bh, 1);
else
submit_bh(READ, bh);
submit_bh(REQ_OP_READ, 0, bh);
}
return 0;
}
Expand Down Expand Up @@ -2582,7 +2582,7 @@ int nobh_write_begin(struct address_space *mapping,
if (block_start < from || block_end > to) {
lock_buffer(bh);
bh->b_end_io = end_buffer_read_nobh;
submit_bh(READ, bh);
submit_bh(REQ_OP_READ, 0, bh);
nr_reads++;
}
}
Expand Down Expand Up @@ -2949,7 +2949,7 @@ static void end_bio_bh_io_sync(struct bio *bio)
* errors, this only handles the "we need to be able to
* do IO at the final sector" case.
*/
void guard_bio_eod(int rw, struct bio *bio)
void guard_bio_eod(int op, struct bio *bio)
{
sector_t maxsector;
struct bio_vec *bvec = &bio->bi_io_vec[bio->bi_vcnt - 1];
Expand Down Expand Up @@ -2979,13 +2979,13 @@ void guard_bio_eod(int rw, struct bio *bio)
bvec->bv_len -= truncated_bytes;

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

static int submit_bh_wbc(int rw, struct buffer_head *bh,
static int submit_bh_wbc(int op, int op_flags, struct buffer_head *bh,
unsigned long bio_flags, struct writeback_control *wbc)
{
struct bio *bio;
Expand All @@ -2999,7 +2999,7 @@ static int submit_bh_wbc(int rw, struct buffer_head *bh,
/*
* Only clear out a write error when rewriting
*/
if (test_set_buffer_req(bh) && (rw & WRITE))
if (test_set_buffer_req(bh) && (op == REQ_OP_WRITE))
clear_buffer_write_io_error(bh);

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

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

if (buffer_meta(bh))
rw |= REQ_META;
op_flags |= REQ_META;
if (buffer_prio(bh))
rw |= REQ_PRIO;
bio->bi_rw = rw;
op_flags |= REQ_PRIO;
bio_set_op_attrs(bio, op, op_flags);

submit_bio(bio);
return 0;
}

int _submit_bh(int rw, struct buffer_head *bh, unsigned long bio_flags)
int _submit_bh(int op, int op_flags, struct buffer_head *bh,
unsigned long bio_flags)
{
return submit_bh_wbc(rw, bh, bio_flags, NULL);
return submit_bh_wbc(op, op_flags, bh, bio_flags, NULL);
}
EXPORT_SYMBOL_GPL(_submit_bh);

int submit_bh(int rw, struct buffer_head *bh)
int submit_bh(int op, int op_flags, struct buffer_head *bh)
{
return submit_bh_wbc(rw, bh, 0, NULL);
return submit_bh_wbc(op, op_flags, bh, 0, NULL);
}
EXPORT_SYMBOL(submit_bh);

Expand Down Expand Up @@ -3086,14 +3087,14 @@ void ll_rw_block(int rw, int nr, struct buffer_head *bhs[])
if (test_clear_buffer_dirty(bh)) {
bh->b_end_io = end_buffer_write_sync;
get_bh(bh);
submit_bh(WRITE, bh);
submit_bh(rw, 0, bh);
continue;
}
} else {
if (!buffer_uptodate(bh)) {
bh->b_end_io = end_buffer_read_sync;
get_bh(bh);
submit_bh(rw, bh);
submit_bh(rw, 0, bh);
continue;
}
}
Expand All @@ -3102,7 +3103,7 @@ void ll_rw_block(int rw, int nr, struct buffer_head *bhs[])
}
EXPORT_SYMBOL(ll_rw_block);

void write_dirty_buffer(struct buffer_head *bh, int rw)
void write_dirty_buffer(struct buffer_head *bh, int op_flags)
{
lock_buffer(bh);
if (!test_clear_buffer_dirty(bh)) {
Expand All @@ -3111,7 +3112,7 @@ void write_dirty_buffer(struct buffer_head *bh, int rw)
}
bh->b_end_io = end_buffer_write_sync;
get_bh(bh);
submit_bh(rw, bh);
submit_bh(REQ_OP_WRITE, op_flags, bh);
}
EXPORT_SYMBOL(write_dirty_buffer);

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

Expand All @@ -3129,7 +3130,7 @@ int __sync_dirty_buffer(struct buffer_head *bh, int rw)
if (test_clear_buffer_dirty(bh)) {
get_bh(bh);
bh->b_end_io = end_buffer_write_sync;
ret = submit_bh(rw, bh);
ret = submit_bh(REQ_OP_WRITE, op_flags, bh);
wait_on_buffer(bh);
if (!ret && !buffer_uptodate(bh))
ret = -EIO;
Expand Down Expand Up @@ -3392,7 +3393,7 @@ int bh_submit_read(struct buffer_head *bh)

get_bh(bh);
bh->b_end_io = end_buffer_read_sync;
submit_bh(READ, bh);
submit_bh(REQ_OP_READ, 0, bh);
wait_on_buffer(bh);
if (buffer_uptodate(bh))
return 0;
Expand Down
2 changes: 1 addition & 1 deletion fs/ext4/balloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ ext4_read_block_bitmap_nowait(struct super_block *sb, ext4_group_t block_group)
trace_ext4_read_block_bitmap_load(sb, block_group);
bh->b_end_io = ext4_end_bitmap_read;
get_bh(bh);
submit_bh(READ | REQ_META | REQ_PRIO, bh);
submit_bh(REQ_OP_READ, REQ_META | REQ_PRIO, bh);
return bh;
verify:
err = ext4_validate_block_bitmap(sb, desc, block_group, bh);
Expand Down
2 changes: 1 addition & 1 deletion fs/ext4/ialloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group)
trace_ext4_load_inode_bitmap(sb, block_group);
bh->b_end_io = ext4_end_bitmap_read;
get_bh(bh);
submit_bh(READ | REQ_META | REQ_PRIO, bh);
submit_bh(REQ_OP_READ, REQ_META | REQ_PRIO, bh);
wait_on_buffer(bh);
if (!buffer_uptodate(bh)) {
put_bh(bh);
Expand Down
2 changes: 1 addition & 1 deletion fs/ext4/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -4281,7 +4281,7 @@ static int __ext4_get_inode_loc(struct inode *inode,
trace_ext4_load_inode(inode);
get_bh(bh);
bh->b_end_io = end_buffer_read_sync;
submit_bh(READ | REQ_META | REQ_PRIO, bh);
submit_bh(REQ_OP_READ, REQ_META | REQ_PRIO, bh);
wait_on_buffer(bh);
if (!buffer_uptodate(bh)) {
EXT4_ERROR_INODE_BLOCK(inode, block,
Expand Down
4 changes: 2 additions & 2 deletions fs/ext4/mmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static int write_mmp_block(struct super_block *sb, struct buffer_head *bh)
lock_buffer(bh);
bh->b_end_io = end_buffer_write_sync;
get_bh(bh);
submit_bh(WRITE_SYNC | REQ_META | REQ_PRIO, bh);
submit_bh(REQ_OP_WRITE, WRITE_SYNC | REQ_META | REQ_PRIO, bh);
wait_on_buffer(bh);
sb_end_write(sb);
if (unlikely(!buffer_uptodate(bh)))
Expand Down Expand Up @@ -88,7 +88,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
get_bh(*bh);
lock_buffer(*bh);
(*bh)->b_end_io = end_buffer_read_sync;
submit_bh(READ_SYNC | REQ_META | REQ_PRIO, *bh);
submit_bh(REQ_OP_READ, READ_SYNC | REQ_META | REQ_PRIO, *bh);
wait_on_buffer(*bh);
if (!buffer_uptodate(*bh)) {
ret = -EIO;
Expand Down
2 changes: 1 addition & 1 deletion fs/fat/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ int fat_sync_bhs(struct buffer_head **bhs, int nr_bhs)
int i, err = 0;

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

for (i = 0; i < nr_bhs; i++) {
wait_on_buffer(bhs[i]);
Expand Down
2 changes: 1 addition & 1 deletion fs/gfs2/bmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ static void gfs2_metapath_ra(struct gfs2_glock *gl,
if (trylock_buffer(rabh)) {
if (!buffer_uptodate(rabh)) {
rabh->b_end_io = end_buffer_read_sync;
submit_bh(READA | REQ_META, rabh);
submit_bh(REQ_OP_READ, READA | REQ_META, rabh);
continue;
}
unlock_buffer(rabh);
Expand Down
2 changes: 1 addition & 1 deletion fs/gfs2/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1513,7 +1513,7 @@ static void gfs2_dir_readahead(struct inode *inode, unsigned hsize, u32 index,
continue;
}
bh->b_end_io = end_buffer_read_sync;
submit_bh(READA | REQ_META, bh);
submit_bh(REQ_OP_READ, READA | REQ_META, bh);
continue;
}
brelse(bh);
Expand Down
6 changes: 3 additions & 3 deletions fs/gfs2/meta_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ static int gfs2_aspace_writepage(struct page *page, struct writeback_control *wb
{
struct buffer_head *bh, *head;
int nr_underway = 0;
int write_op = REQ_META | REQ_PRIO |
(wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : WRITE);
int write_flags = REQ_META | REQ_PRIO |
(wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : 0);

BUG_ON(!PageLocked(page));
BUG_ON(!page_has_buffers(page));
Expand Down Expand Up @@ -79,7 +79,7 @@ static int gfs2_aspace_writepage(struct page *page, struct writeback_control *wb
do {
struct buffer_head *next = bh->b_this_page;
if (buffer_async_write(bh)) {
submit_bh(write_op, bh);
submit_bh(REQ_OP_WRITE, write_flags, bh);
nr_underway++;
}
bh = next;
Expand Down
Loading

0 comments on commit 2a222ca

Please sign in to comment.