All of lore.kernel.org
 help / color / mirror / Atom feed
From: mchristi@redhat.com
To: linux-fsdevel@vger.kernel.org, dm-devel@redhat.com,
	linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-scsi@vger.kernel.org, drbd-dev@lists.linbit.com
Cc: Mike Christie <mchristi@redhat.com>
Subject: [PATCH 15/32] btrfs: prepare for bi_rw split
Date: Wed,  4 Nov 2015 16:08:12 -0600	[thread overview]
Message-ID: <1446674909-5371-16-git-send-email-mchristi@redhat.com> (raw)
In-Reply-To: <1446674909-5371-1-git-send-email-mchristi@redhat.com>

From: Mike Christie <mchristi@redhat.com>

This patch prepares btrfs's submit_bh use for the next
patches that split bi_rw into a operation and flags field.
Instead of passing in a bitmap with both the operation and
flags mixed in, the callers will now pass them in seperately.

This patch modifies the code related to the submit_bh calls
so the flags and operation are seperated. When this is done
for all code, one of the later patches in the series will
the actual submit_bh call, so the patches are bisectable.

Signed-off-by: Mike Christie <mchristi@redhat.com>
---
 fs/btrfs/check-integrity.c | 68 ++++++++++++++++++++++++++--------------------
 fs/btrfs/check-integrity.h |  2 +-
 fs/btrfs/disk-io.c         |  4 +--
 3 files changed, 41 insertions(+), 33 deletions(-)

diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index a5ff6e4..17eba2d 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -168,7 +168,8 @@ struct btrfsic_block {
 		bio_end_io_t *bio;
 		bh_end_io_t *bh;
 	} orig_bio_bh_end_io;
-	int submit_bio_bh_rw;
+	int submit_bio_bh_op;
+	int submit_bio_bh_op_flags;
 	u64 flush_gen; /* only valid if !never_written */
 };
 
@@ -338,7 +339,8 @@ static void btrfsic_process_written_block(struct btrfsic_dev_state *dev_state,
 					  unsigned int num_pages,
 					  struct bio *bio, int *bio_is_patched,
 					  struct buffer_head *bh,
-					  int submit_bio_bh_rw);
+					  int submit_bio_bh_op,
+					  int submit_bio_bh_op_flags);
 static int btrfsic_process_written_superblock(
 		struct btrfsic_state *state,
 		struct btrfsic_block *const block,
@@ -418,7 +420,8 @@ static void btrfsic_block_init(struct btrfsic_block *b)
 	INIT_LIST_HEAD(&b->all_blocks_node);
 	INIT_LIST_HEAD(&b->ref_to_list);
 	INIT_LIST_HEAD(&b->ref_from_list);
-	b->submit_bio_bh_rw = 0;
+	b->submit_bio_bh_op = 0;
+	b->submit_bio_bh_op_flags = 0;
 	b->flush_gen = 0;
 }
 
@@ -1820,7 +1823,8 @@ static void btrfsic_process_written_block(struct btrfsic_dev_state *dev_state,
 					  unsigned int num_pages,
 					  struct bio *bio, int *bio_is_patched,
 					  struct buffer_head *bh,
-					  int submit_bio_bh_rw)
+					  int submit_bio_bh_op,
+					  int submit_bio_bh_op_flags)
 {
 	int is_metadata;
 	struct btrfsic_block *block;
@@ -2038,7 +2042,8 @@ again:
 		}
 
 		block->flush_gen = dev_state->last_flush_gen + 1;
-		block->submit_bio_bh_rw = submit_bio_bh_rw;
+		block->submit_bio_bh_op = submit_bio_bh_op;
+		block->submit_bio_bh_op_flags = submit_bio_bh_op_flags;
 		if (is_metadata) {
 			block->logical_bytenr = bytenr;
 			block->is_metadata = 1;
@@ -2141,7 +2146,8 @@ again:
 		block->iodone_w_error = 0;
 		block->mirror_num = 0;	/* unknown */
 		block->flush_gen = dev_state->last_flush_gen + 1;
-		block->submit_bio_bh_rw = submit_bio_bh_rw;
+		block->submit_bio_bh_op = submit_bio_bh_op;
+		block->submit_bio_bh_op_flags = submit_bio_bh_op_flags;
 		if (NULL != bio) {
 			block->is_iodone = 0;
 			BUG_ON(NULL == bio_is_patched);
@@ -2236,7 +2242,7 @@ static void btrfsic_bio_end_io(struct bio *bp)
 			       block->dev_bytenr, block->mirror_num);
 		next_block = block->next_in_same_bio;
 		block->iodone_w_error = iodone_w_error;
-		if (block->submit_bio_bh_rw & REQ_FLUSH) {
+		if (block->submit_bio_bh_op_flags & REQ_FLUSH) {
 			dev_state->last_flush_gen++;
 			if ((dev_state->state->print_mask &
 			     BTRFSIC_PRINT_MASK_END_IO_BIO_BH))
@@ -2245,7 +2251,7 @@ static void btrfsic_bio_end_io(struct bio *bp)
 				       dev_state->name,
 				       dev_state->last_flush_gen);
 		}
-		if (block->submit_bio_bh_rw & REQ_FUA)
+		if (block->submit_bio_bh_op_flags & REQ_FUA)
 			block->flush_gen = 0; /* FUA completed means block is
 					       * on disk */
 		block->is_iodone = 1; /* for FLUSH, this releases the block */
@@ -2272,7 +2278,7 @@ static void btrfsic_bh_end_io(struct buffer_head *bh, int uptodate)
 		       block->dev_bytenr, block->mirror_num);
 
 	block->iodone_w_error = iodone_w_error;
-	if (block->submit_bio_bh_rw & REQ_FLUSH) {
+	if (block->submit_bio_bh_op_flags & REQ_FLUSH) {
 		dev_state->last_flush_gen++;
 		if ((dev_state->state->print_mask &
 		     BTRFSIC_PRINT_MASK_END_IO_BIO_BH))
@@ -2280,7 +2286,7 @@ static void btrfsic_bh_end_io(struct buffer_head *bh, int uptodate)
 			       "bh_end_io() new %s flush_gen=%llu\n",
 			       dev_state->name, dev_state->last_flush_gen);
 	}
-	if (block->submit_bio_bh_rw & REQ_FUA)
+	if (block->submit_bio_bh_op_flags & REQ_FUA)
 		block->flush_gen = 0; /* FUA completed means block is on disk */
 
 	bh->b_private = block->orig_bio_bh_private;
@@ -2897,12 +2903,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
@@ -2911,26 +2917,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=%d rw=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, 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);
+			       op, 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 |
@@ -2948,7 +2954,8 @@ 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_op = op;
+			block->submit_bio_bh_op_flags = 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;
@@ -2957,10 +2964,10 @@ 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(int rw, struct bio *bio)
+static void __btrfsic_submit_bio(int op, int op_flags, struct bio *bio)
 {
 	struct btrfsic_dev_state *dev_state;
 
@@ -2972,7 +2979,7 @@ static void __btrfsic_submit_bio(int rw, struct bio *bio)
 	 * btrfsic_mount(), this might return NULL */
 	dev_state = btrfsic_dev_state_lookup(bio->bi_bdev);
 	if (NULL != dev_state &&
-	    (rw & WRITE) && NULL != bio->bi_io_vec) {
+	    (op == REQ_OP_WRITE) && NULL != bio->bi_io_vec) {
 		unsigned int i;
 		u64 dev_bytenr;
 		u64 cur_bytenr;
@@ -2986,7 +2993,7 @@ static void __btrfsic_submit_bio(int rw, struct bio *bio)
 			printk(KERN_INFO
 			       "submit_bio(rw=0x%x, bi_vcnt=%u,"
 			       " bi_sector=%llu (bytenr %llu), bi_bdev=%p)\n",
-			       rw, bio->bi_vcnt,
+			       op, bio->bi_vcnt,
 			       (unsigned long long)bio->bi_iter.bi_sector,
 			       dev_bytenr, bio->bi_bdev);
 
@@ -3017,18 +3024,18 @@ static void __btrfsic_submit_bio(int rw, struct bio *bio)
 		btrfsic_process_written_block(dev_state, dev_bytenr,
 					      mapped_datav, bio->bi_vcnt,
 					      bio, &bio_is_patched,
-					      NULL, rw);
+					      NULL, op, op_flags);
 		while (i > 0) {
 			i--;
 			kunmap(bio->bi_io_vec[i].bv_page);
 		}
 		kfree(mapped_datav);
-	} else if (NULL != dev_state && (rw & REQ_FLUSH)) {
+	} 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_bio(rw=0x%x FLUSH, bdev=%p)\n",
-			       rw, bio->bi_bdev);
+			       op, bio->bi_bdev);
 		if (!dev_state->dummy_block_for_bio_bh_flush.is_iodone) {
 			if ((dev_state->state->print_mask &
 			     (BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH |
@@ -3046,7 +3053,8 @@ static void __btrfsic_submit_bio(int rw, struct bio *bio)
 			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_op = op;
+			block->submit_bio_bh_op_flags = op_flags;
 			block->orig_bio_bh_private = bio->bi_private;
 			block->orig_bio_bh_end_io.bio = bio->bi_end_io;
 			block->next_in_same_bio = NULL;
@@ -3060,13 +3068,13 @@ leave:
 
 void btrfsic_submit_bio(int op, int op_flags, struct bio *bio)
 {
-	__btrfsic_submit_bio(op | op_flags, bio);
+	__btrfsic_submit_bio(op, op_flags, bio);
 	submit_bio(op, op_flags, bio);
 }
 
 int btrfsic_submit_bio_wait(int op, int op_flags, struct bio *bio)
 {
-	__btrfsic_submit_bio(op | op_flags, bio);
+	__btrfsic_submit_bio(op, op_flags, bio);
 	return submit_bio_wait(op, op_flags, bio);
 }
 
diff --git a/fs/btrfs/check-integrity.h b/fs/btrfs/check-integrity.h
index a8edc424..97f7d49 100644
--- a/fs/btrfs/check-integrity.h
+++ b/fs/btrfs/check-integrity.h
@@ -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(int op, int op_flags, struct bio *bio);
 int btrfsic_submit_bio_wait(int op, int op_flags, struct bio *bio);
 #else
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 6c17d5d..f1262e6 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3323,9 +3323,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++;
 	}
-- 
1.8.3.1

  parent reply	other threads:[~2015-11-04 22:08 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-04 22:07 [RESEND RFC PATCH 00/32] separate operations from flags in the bio/request structs mchristi
2015-11-04 22:07 ` [PATCH 01/32] block/fs: add REQ_OP definitions mchristi
2015-11-04 22:07 ` [PATCH 02/32] block/fs/mm: prepare submit_bio_wait users for bi_rw split mchristi
2015-11-05  7:14   ` Hannes Reinecke
2015-11-04 22:08 ` [PATCH 03/32] dio/btrfs: prep dio->submit_bio " mchristi
2015-11-04 22:08 ` [PATCH 04/32] block: prepare blkdev_issue_discard " mchristi
2015-11-04 22:08 ` [PATCH 05/32] drbd: prepare drbd " mchristi
2015-11-04 22:08 ` [PATCH 06/32] xen blkback: prepare " mchristi
     [not found]   ` <1446674909-5371-7-git-send-email-mchristi-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-11-07 10:17     ` Christoph Hellwig
2015-11-07 10:17       ` Christoph Hellwig
2015-11-07 14:04       ` Konrad Rzeszutek Wilk
2015-11-07 14:04         ` Konrad Rzeszutek Wilk
2015-11-09  4:00       ` Bob Liu
2015-11-09  4:00         ` Bob Liu
2015-11-07 10:17   ` Christoph Hellwig
2015-11-04 22:08 ` [PATCH 07/32] dm: " mchristi
2015-11-04 22:08 ` [PATCH 08/32] target: " mchristi
2015-11-04 22:08 ` [PATCH 09/32] btrfs: " mchristi
2015-11-04 22:08 ` [PATCH 10/32] f2fs: " mchristi
2015-11-04 22:08 ` [PATCH 11/32] gfs2: " mchristi
2015-11-04 22:08 ` [PATCH 12/32] xfs: " mchristi
2015-11-04 22:08 ` [PATCH 13/32] mm: " mchristi
2015-11-04 22:08 ` [PATCH 14/32] block/fs/mm: pass in op and flags to submit_bio mchristi
2015-11-04 22:08 ` mchristi [this message]
2015-11-04 22:08 ` [PATCH 16/32] block/fs/md: pass in op and flags to submit_bh mchristi
2015-11-04 22:08 ` [PATCH 17/32] block: add operation field to bio struct mchristi
2015-11-04 22:08 ` [PATCH 18/32] drbd: set bio bi_op to REQ_OP mchristi
2015-11-04 22:08 ` [PATCH 19/32] block: add helper to get data dir from op mchristi
     [not found]   ` <1446674909-5371-20-git-send-email-mchristi-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-11-04 22:44     ` [dm-devel] " Bart Van Assche
2015-11-04 22:44       ` Bart Van Assche
2015-11-04 22:44       ` Bart Van Assche
2015-11-05 17:34       ` Mike Christie
     [not found]         ` <563B930F.7040705-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-11-07 10:19           ` Christoph Hellwig
2015-11-07 10:19             ` Christoph Hellwig
2015-11-04 22:08 ` [PATCH 20/32] md: set bi_op to REQ_OP mchristi
2015-11-04 22:08 ` [PATCH 21/32] bcache: " mchristi
2015-11-04 22:08 ` [PATCH 22/32] block/fs/drivers: " mchristi
2015-11-04 22:08 ` [PATCH 23/32] block/fs: pass in op and flags to ll_rw_block mchristi
2015-11-04 22:08 ` [PATCH 24/32] dm: pass dm stats data dir instead of bi_rw mchristi
2015-11-04 22:08 ` [PATCH 25/32] block: add operation field to request struct mchristi
2015-11-04 22:08 ` [PATCH 26/32] ide cd: do not set REQ_WRITE on requests mchristi
2015-11-04 22:08 ` [PATCH 27/32] cfq/cgroup: pass operation and flags seperately mchristi
2015-11-04 22:08 ` [PATCH 28/32] block/fs/drivers: use bio/rq_data_dir helpers mchristi
2015-11-04 22:08 ` [PATCH 29/32] block/drivers: rm request cmd_flags REQ_OP use mchristi
2015-11-04 22:08 ` [PATCH 30/32] drbd: don't use bi_rw for operations mchristi
2015-11-04 22:08 ` [PATCH 31/32] block/fs/driver: rm bio bi_rw REQ_OP use mchristi
2015-11-04 22:08 ` [PATCH 32/32] block: remove __REQ op defs and reduce bi_op/bi_rw sizes mchristi
     [not found]   ` <1446674909-5371-33-git-send-email-mchristi-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-11-07 10:21     ` Christoph Hellwig
2015-11-07 10:21       ` Christoph Hellwig
2015-11-05 16:44 ` [RESEND RFC PATCH 00/32] separate operations from flags in the bio/request structs Bob Peterson
2015-11-07 10:10 ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1446674909-5371-16-git-send-email-mchristi@redhat.com \
    --to=mchristi@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=drbd-dev@lists.linbit.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.