Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2a222ca9 authored by Mike Christie's avatar Mike Christie Committed by Jens Axboe
Browse files

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: default avatarMike Christie <mchristi@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent f2150821
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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;
		}

@@ -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;
+12 −12
Original line number Diff line number Diff line
@@ -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
@@ -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 |
@@ -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;
@@ -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)
+1 −1
Original line number Diff line number Diff line
@@ -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
+2 −2
Original line number Diff line number Diff line
@@ -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++;
	}
+27 −26
Original line number Diff line number Diff line
@@ -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);

@@ -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;
@@ -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));
@@ -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;
@@ -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;
@@ -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;
}
@@ -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++;
		}
	}
@@ -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];
@@ -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;
@@ -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);

	/*
@@ -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);

@@ -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;
			}
		}
@@ -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)) {
@@ -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);

@@ -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;

@@ -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;
@@ -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;
Loading