linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* don't require a struct block_device to submit a bio
@ 2017-08-23 17:10 Christoph Hellwig
  2017-08-23 17:10 ` [PATCH 1/6] btrfs: index check-integrity state hash by a dev_t Christoph Hellwig
                   ` (7 more replies)
  0 siblings, 8 replies; 12+ messages in thread
From: Christoph Hellwig @ 2017-08-23 17:10 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, linux-raid, linux-btrfs

Hi Jens,

this series removes the need to have a struct block_device ready to
submit a bio.   We basically don't use it anywhere in the block stack
anyway - we always go for the gendisk or request_queue.  The only
exception is partition remapping for which we'll now need an additional
partition index.  This helps with cases where we submit I/O from a
character device (nvme or lightnvm passthrough) or a different block
device (upcoming nvme multipath support).

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/6] btrfs: index check-integrity state hash by a dev_t
  2017-08-23 17:10 don't require a struct block_device to submit a bio Christoph Hellwig
@ 2017-08-23 17:10 ` Christoph Hellwig
  2017-08-23 17:45   ` Liu Bo
  2017-08-23 17:10 ` [PATCH 2/6] raid5: remove a call to get_start_sect Christoph Hellwig
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 12+ messages in thread
From: Christoph Hellwig @ 2017-08-23 17:10 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, linux-raid, linux-btrfs

We won't have the struct block_device available in the bio soon, so switch
to the numerical dev_t instead of the block_device pointer for looking up
the check-integrity state.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/btrfs/check-integrity.c | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index 11d37c94ce05..9d3854839038 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -296,8 +296,7 @@ static void btrfsic_dev_state_hashtable_add(
 		struct btrfsic_dev_state *ds,
 		struct btrfsic_dev_state_hashtable *h);
 static void btrfsic_dev_state_hashtable_remove(struct btrfsic_dev_state *ds);
-static struct btrfsic_dev_state *btrfsic_dev_state_hashtable_lookup(
-		struct block_device *bdev,
+static struct btrfsic_dev_state *btrfsic_dev_state_hashtable_lookup(dev_t dev,
 		struct btrfsic_dev_state_hashtable *h);
 static struct btrfsic_stack_frame *btrfsic_stack_frame_alloc(void);
 static void btrfsic_stack_frame_free(struct btrfsic_stack_frame *sf);
@@ -385,8 +384,7 @@ static int btrfsic_process_superblock_dev_mirror(
 		int superblock_mirror_num,
 		struct btrfsic_dev_state **selected_dev_state,
 		struct btrfs_super_block *selected_super);
-static struct btrfsic_dev_state *btrfsic_dev_state_lookup(
-		struct block_device *bdev);
+static struct btrfsic_dev_state *btrfsic_dev_state_lookup(dev_t dev);
 static void btrfsic_cmp_log_and_dev_bytenr(struct btrfsic_state *state,
 					   u64 bytenr,
 					   struct btrfsic_dev_state *dev_state,
@@ -626,17 +624,15 @@ static void btrfsic_dev_state_hashtable_remove(struct btrfsic_dev_state *ds)
 	list_del(&ds->collision_resolving_node);
 }
 
-static struct btrfsic_dev_state *btrfsic_dev_state_hashtable_lookup(
-		struct block_device *bdev,
+static struct btrfsic_dev_state *btrfsic_dev_state_hashtable_lookup(dev_t dev,
 		struct btrfsic_dev_state_hashtable *h)
 {
 	const unsigned int hashval =
-	    (((unsigned int)((uintptr_t)bdev)) &
-	     (BTRFSIC_DEV2STATE_HASHTABLE_SIZE - 1));
+		dev & (BTRFSIC_DEV2STATE_HASHTABLE_SIZE - 1);
 	struct btrfsic_dev_state *ds;
 
 	list_for_each_entry(ds, h->table + hashval, collision_resolving_node) {
-		if (ds->bdev == bdev)
+		if (ds->bdev->bd_dev == dev)
 			return ds;
 	}
 
@@ -668,7 +664,7 @@ static int btrfsic_process_superblock(struct btrfsic_state *state,
 		if (!device->bdev || !device->name)
 			continue;
 
-		dev_state = btrfsic_dev_state_lookup(device->bdev);
+		dev_state = btrfsic_dev_state_lookup(device->bdev->bd_dev);
 		BUG_ON(NULL == dev_state);
 		for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) {
 			ret = btrfsic_process_superblock_dev_mirror(
@@ -1556,7 +1552,7 @@ static int btrfsic_map_block(struct btrfsic_state *state, u64 bytenr, u32 len,
 	}
 
 	device = multi->stripes[0].dev;
-	block_ctx_out->dev = btrfsic_dev_state_lookup(device->bdev);
+	block_ctx_out->dev = btrfsic_dev_state_lookup(device->bdev->bd_dev);
 	block_ctx_out->dev_bytenr = multi->stripes[0].physical;
 	block_ctx_out->start = bytenr;
 	block_ctx_out->len = len;
@@ -2654,7 +2650,7 @@ static struct btrfsic_block *btrfsic_block_lookup_or_add(
 			pr_info("btrfsic: error, kmalloc failed!\n");
 			return NULL;
 		}
-		dev_state = btrfsic_dev_state_lookup(block_ctx->dev->bdev);
+		dev_state = btrfsic_dev_state_lookup(block_ctx->dev->bdev->bd_dev);
 		if (NULL == dev_state) {
 			pr_info("btrfsic: error, lookup dev_state failed!\n");
 			btrfsic_block_free(block);
@@ -2734,10 +2730,9 @@ static void btrfsic_cmp_log_and_dev_bytenr(struct btrfsic_state *state,
 	}
 }
 
-static struct btrfsic_dev_state *btrfsic_dev_state_lookup(
-		struct block_device *bdev)
+static struct btrfsic_dev_state *btrfsic_dev_state_lookup(dev_t dev)
 {
-	return btrfsic_dev_state_hashtable_lookup(bdev,
+	return btrfsic_dev_state_hashtable_lookup(dev,
 						  &btrfsic_dev_state_hashtable);
 }
 
@@ -2751,7 +2746,7 @@ int btrfsic_submit_bh(int op, int op_flags, struct buffer_head *bh)
 	mutex_lock(&btrfsic_mutex);
 	/* since btrfsic_submit_bh() might also be called before
 	 * btrfsic_mount(), this might return NULL */
-	dev_state = btrfsic_dev_state_lookup(bh->b_bdev);
+	dev_state = btrfsic_dev_state_lookup(bh->b_bdev->bd_dev);
 
 	/* Only called to write the superblock (incl. FLUSH/FUA) */
 	if (NULL != dev_state &&
@@ -2808,7 +2803,7 @@ static void __btrfsic_submit_bio(struct bio *bio)
 	mutex_lock(&btrfsic_mutex);
 	/* since btrfsic_submit_bio() is also called before
 	 * btrfsic_mount(), this might return NULL */
-	dev_state = btrfsic_dev_state_lookup(bio->bi_bdev);
+	dev_state = btrfsic_dev_state_lookup(bio->bi_bdev->bd_dev);
 	if (NULL != dev_state &&
 	    (bio_op(bio) == REQ_OP_WRITE) && bio_has_data(bio)) {
 		unsigned int i = 0;
@@ -2998,7 +2993,7 @@ void btrfsic_unmount(struct btrfs_fs_devices *fs_devices)
 			continue;
 
 		ds = btrfsic_dev_state_hashtable_lookup(
-				device->bdev,
+				device->bdev->bd_dev,
 				&btrfsic_dev_state_hashtable);
 		if (NULL != ds) {
 			state = ds->state;
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/6] raid5: remove a call to get_start_sect
  2017-08-23 17:10 don't require a struct block_device to submit a bio Christoph Hellwig
  2017-08-23 17:10 ` [PATCH 1/6] btrfs: index check-integrity state hash by a dev_t Christoph Hellwig
@ 2017-08-23 17:10 ` Christoph Hellwig
  2017-08-23 18:23   ` Shaohua Li
  2017-08-23 17:10 ` [PATCH 3/6] block: reject attempts to allocate more than DISK_MAX_PARTS partitions Christoph Hellwig
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 12+ messages in thread
From: Christoph Hellwig @ 2017-08-23 17:10 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, linux-raid, linux-btrfs

The block layer always remaps partitions before calling into the
->make_request methods of drivers.  Thus the call to get_start_sect in
in_chunk_boundary will always return 0 and can be removed.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/md/raid5.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 0fc2748aaf95..d687aeb1b538 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -5092,10 +5092,12 @@ static int raid5_congested(struct mddev *mddev, int bits)
 static int in_chunk_boundary(struct mddev *mddev, struct bio *bio)
 {
 	struct r5conf *conf = mddev->private;
-	sector_t sector = bio->bi_iter.bi_sector + get_start_sect(bio->bi_bdev);
+	sector_t sector = bio->bi_iter.bi_sector;
 	unsigned int chunk_sectors;
 	unsigned int bio_sectors = bio_sectors(bio);
 
+	WARN_ON_ONCE(bio->bi_partno);
+
 	chunk_sectors = min(conf->chunk_sectors, conf->prev_chunk_sectors);
 	return  chunk_sectors >=
 		((sector & (chunk_sectors - 1)) + bio_sectors);
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/6] block: reject attempts to allocate more than DISK_MAX_PARTS partitions
  2017-08-23 17:10 don't require a struct block_device to submit a bio Christoph Hellwig
  2017-08-23 17:10 ` [PATCH 1/6] btrfs: index check-integrity state hash by a dev_t Christoph Hellwig
  2017-08-23 17:10 ` [PATCH 2/6] raid5: remove a call to get_start_sect Christoph Hellwig
@ 2017-08-23 17:10 ` Christoph Hellwig
  2017-08-23 17:10 ` [PATCH 4/6] block: add a __disk_get_part helper Christoph Hellwig
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Christoph Hellwig @ 2017-08-23 17:10 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, linux-raid, linux-btrfs

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/genhd.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/block/genhd.c b/block/genhd.c
index 2367087cdb7c..3380a1e73ea0 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1357,6 +1357,13 @@ struct gendisk *alloc_disk_node(int minors, int node_id)
 	struct gendisk *disk;
 	struct disk_part_tbl *ptbl;
 
+	if (minors > DISK_MAX_PARTS) {
+		printk(KERN_ERR
+			"block: can't allocated more than %d partitions\n",
+			DISK_MAX_PARTS);
+		minors = DISK_MAX_PARTS;
+	}
+
 	disk = kzalloc_node(sizeof(struct gendisk), GFP_KERNEL, node_id);
 	if (disk) {
 		if (!init_part_stats(&disk->part0)) {
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/6] block: add a __disk_get_part helper
  2017-08-23 17:10 don't require a struct block_device to submit a bio Christoph Hellwig
                   ` (2 preceding siblings ...)
  2017-08-23 17:10 ` [PATCH 3/6] block: reject attempts to allocate more than DISK_MAX_PARTS partitions Christoph Hellwig
@ 2017-08-23 17:10 ` Christoph Hellwig
  2017-08-23 17:10 ` [PATCH 5/6] block: cache the partition index in struct block_device Christoph Hellwig
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Christoph Hellwig @ 2017-08-23 17:10 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, linux-raid, linux-btrfs

This helper allows looking up a partion under RCU protection without
grabbing a reference to it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk.h   |  2 ++
 block/genhd.c | 26 +++++++++++++-------------
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/block/blk.h b/block/blk.h
index 3a3d715bd725..fde8b351c166 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -204,6 +204,8 @@ static inline void elv_deactivate_rq(struct request_queue *q, struct request *rq
 		e->type->ops.sq.elevator_deactivate_req_fn(q, rq);
 }
 
+struct hd_struct *__disk_get_part(struct gendisk *disk, int partno);
+
 #ifdef CONFIG_FAIL_IO_TIMEOUT
 int blk_should_fake_timeout(struct request_queue *);
 ssize_t part_timeout_show(struct device *, struct device_attribute *, char *);
diff --git a/block/genhd.c b/block/genhd.c
index 3380a1e73ea0..713b7d4fe7a1 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -82,6 +82,15 @@ void part_in_flight(struct request_queue *q, struct hd_struct *part,
 	}
 }
 
+struct hd_struct *__disk_get_part(struct gendisk *disk, int partno)
+{
+	struct disk_part_tbl *ptbl = rcu_dereference(disk->part_tbl);
+
+	if (unlikely(partno < 0 || partno >= ptbl->len))
+		return NULL;
+	return rcu_dereference(ptbl->part[partno]);
+}
+
 /**
  * disk_get_part - get partition
  * @disk: disk to look partition from
@@ -98,21 +107,12 @@ void part_in_flight(struct request_queue *q, struct hd_struct *part,
  */
 struct hd_struct *disk_get_part(struct gendisk *disk, int partno)
 {
-	struct hd_struct *part = NULL;
-	struct disk_part_tbl *ptbl;
-
-	if (unlikely(partno < 0))
-		return NULL;
+	struct hd_struct *part;
 
 	rcu_read_lock();
-
-	ptbl = rcu_dereference(disk->part_tbl);
-	if (likely(partno < ptbl->len)) {
-		part = rcu_dereference(ptbl->part[partno]);
-		if (part)
-			get_device(part_to_dev(part));
-	}
-
+	part = __disk_get_part(disk, partno);
+	if (part)
+		get_device(part_to_dev(part));
 	rcu_read_unlock();
 
 	return part;
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 5/6] block: cache the partition index in struct block_device
  2017-08-23 17:10 don't require a struct block_device to submit a bio Christoph Hellwig
                   ` (3 preceding siblings ...)
  2017-08-23 17:10 ` [PATCH 4/6] block: add a __disk_get_part helper Christoph Hellwig
@ 2017-08-23 17:10 ` Christoph Hellwig
  2017-08-23 18:01 ` don't require a struct block_device to submit a bio Christoph Hellwig
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Christoph Hellwig @ 2017-08-23 17:10 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, linux-raid, linux-btrfs

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/block_dev.c     | 1 +
 include/linux/fs.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 9941dc8342df..d29d1c70f833 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1451,6 +1451,7 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
 		bdev->bd_disk = disk;
 		bdev->bd_queue = disk->queue;
 		bdev->bd_contains = bdev;
+		bdev->bd_partno = partno;
 
 		if (!partno) {
 			ret = -ENXIO;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 6e1fd5d21248..706dd3a972d2 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -427,6 +427,7 @@ struct block_device {
 #endif
 	struct block_device *	bd_contains;
 	unsigned		bd_block_size;
+	u8			bd_partno;
 	struct hd_struct *	bd_part;
 	/* number of times partitions within this device have been opened. */
 	unsigned		bd_part_count;
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/6] btrfs: index check-integrity state hash by a dev_t
  2017-08-23 17:10 ` [PATCH 1/6] btrfs: index check-integrity state hash by a dev_t Christoph Hellwig
@ 2017-08-23 17:45   ` Liu Bo
  0 siblings, 0 replies; 12+ messages in thread
From: Liu Bo @ 2017-08-23 17:45 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Jens Axboe, linux-block, linux-raid, linux-btrfs

On Wed, Aug 23, 2017 at 07:10:27PM +0200, Christoph Hellwig wrote:
> We won't have the struct block_device available in the bio soon, so switch
> to the numerical dev_t instead of the block_device pointer for looking up
> the check-integrity state.

Reviewed-by: Liu Bo <bo.li.liu@oracle.com>

Thanks,

-liubo

> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/btrfs/check-integrity.c | 31 +++++++++++++------------------
>  1 file changed, 13 insertions(+), 18 deletions(-)
> 
> diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
> index 11d37c94ce05..9d3854839038 100644
> --- a/fs/btrfs/check-integrity.c
> +++ b/fs/btrfs/check-integrity.c
> @@ -296,8 +296,7 @@ static void btrfsic_dev_state_hashtable_add(
>  		struct btrfsic_dev_state *ds,
>  		struct btrfsic_dev_state_hashtable *h);
>  static void btrfsic_dev_state_hashtable_remove(struct btrfsic_dev_state *ds);
> -static struct btrfsic_dev_state *btrfsic_dev_state_hashtable_lookup(
> -		struct block_device *bdev,
> +static struct btrfsic_dev_state *btrfsic_dev_state_hashtable_lookup(dev_t dev,
>  		struct btrfsic_dev_state_hashtable *h);
>  static struct btrfsic_stack_frame *btrfsic_stack_frame_alloc(void);
>  static void btrfsic_stack_frame_free(struct btrfsic_stack_frame *sf);
> @@ -385,8 +384,7 @@ static int btrfsic_process_superblock_dev_mirror(
>  		int superblock_mirror_num,
>  		struct btrfsic_dev_state **selected_dev_state,
>  		struct btrfs_super_block *selected_super);
> -static struct btrfsic_dev_state *btrfsic_dev_state_lookup(
> -		struct block_device *bdev);
> +static struct btrfsic_dev_state *btrfsic_dev_state_lookup(dev_t dev);
>  static void btrfsic_cmp_log_and_dev_bytenr(struct btrfsic_state *state,
>  					   u64 bytenr,
>  					   struct btrfsic_dev_state *dev_state,
> @@ -626,17 +624,15 @@ static void btrfsic_dev_state_hashtable_remove(struct btrfsic_dev_state *ds)
>  	list_del(&ds->collision_resolving_node);
>  }
>  
> -static struct btrfsic_dev_state *btrfsic_dev_state_hashtable_lookup(
> -		struct block_device *bdev,
> +static struct btrfsic_dev_state *btrfsic_dev_state_hashtable_lookup(dev_t dev,
>  		struct btrfsic_dev_state_hashtable *h)
>  {
>  	const unsigned int hashval =
> -	    (((unsigned int)((uintptr_t)bdev)) &
> -	     (BTRFSIC_DEV2STATE_HASHTABLE_SIZE - 1));
> +		dev & (BTRFSIC_DEV2STATE_HASHTABLE_SIZE - 1);
>  	struct btrfsic_dev_state *ds;
>  
>  	list_for_each_entry(ds, h->table + hashval, collision_resolving_node) {
> -		if (ds->bdev == bdev)
> +		if (ds->bdev->bd_dev == dev)
>  			return ds;
>  	}
>  
> @@ -668,7 +664,7 @@ static int btrfsic_process_superblock(struct btrfsic_state *state,
>  		if (!device->bdev || !device->name)
>  			continue;
>  
> -		dev_state = btrfsic_dev_state_lookup(device->bdev);
> +		dev_state = btrfsic_dev_state_lookup(device->bdev->bd_dev);
>  		BUG_ON(NULL == dev_state);
>  		for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) {
>  			ret = btrfsic_process_superblock_dev_mirror(
> @@ -1556,7 +1552,7 @@ static int btrfsic_map_block(struct btrfsic_state *state, u64 bytenr, u32 len,
>  	}
>  
>  	device = multi->stripes[0].dev;
> -	block_ctx_out->dev = btrfsic_dev_state_lookup(device->bdev);
> +	block_ctx_out->dev = btrfsic_dev_state_lookup(device->bdev->bd_dev);
>  	block_ctx_out->dev_bytenr = multi->stripes[0].physical;
>  	block_ctx_out->start = bytenr;
>  	block_ctx_out->len = len;
> @@ -2654,7 +2650,7 @@ static struct btrfsic_block *btrfsic_block_lookup_or_add(
>  			pr_info("btrfsic: error, kmalloc failed!\n");
>  			return NULL;
>  		}
> -		dev_state = btrfsic_dev_state_lookup(block_ctx->dev->bdev);
> +		dev_state = btrfsic_dev_state_lookup(block_ctx->dev->bdev->bd_dev);
>  		if (NULL == dev_state) {
>  			pr_info("btrfsic: error, lookup dev_state failed!\n");
>  			btrfsic_block_free(block);
> @@ -2734,10 +2730,9 @@ static void btrfsic_cmp_log_and_dev_bytenr(struct btrfsic_state *state,
>  	}
>  }
>  
> -static struct btrfsic_dev_state *btrfsic_dev_state_lookup(
> -		struct block_device *bdev)
> +static struct btrfsic_dev_state *btrfsic_dev_state_lookup(dev_t dev)
>  {
> -	return btrfsic_dev_state_hashtable_lookup(bdev,
> +	return btrfsic_dev_state_hashtable_lookup(dev,
>  						  &btrfsic_dev_state_hashtable);
>  }
>  
> @@ -2751,7 +2746,7 @@ int btrfsic_submit_bh(int op, int op_flags, struct buffer_head *bh)
>  	mutex_lock(&btrfsic_mutex);
>  	/* since btrfsic_submit_bh() might also be called before
>  	 * btrfsic_mount(), this might return NULL */
> -	dev_state = btrfsic_dev_state_lookup(bh->b_bdev);
> +	dev_state = btrfsic_dev_state_lookup(bh->b_bdev->bd_dev);
>  
>  	/* Only called to write the superblock (incl. FLUSH/FUA) */
>  	if (NULL != dev_state &&
> @@ -2808,7 +2803,7 @@ static void __btrfsic_submit_bio(struct bio *bio)
>  	mutex_lock(&btrfsic_mutex);
>  	/* since btrfsic_submit_bio() is also called before
>  	 * btrfsic_mount(), this might return NULL */
> -	dev_state = btrfsic_dev_state_lookup(bio->bi_bdev);
> +	dev_state = btrfsic_dev_state_lookup(bio->bi_bdev->bd_dev);
>  	if (NULL != dev_state &&
>  	    (bio_op(bio) == REQ_OP_WRITE) && bio_has_data(bio)) {
>  		unsigned int i = 0;
> @@ -2998,7 +2993,7 @@ void btrfsic_unmount(struct btrfs_fs_devices *fs_devices)
>  			continue;
>  
>  		ds = btrfsic_dev_state_hashtable_lookup(
> -				device->bdev,
> +				device->bdev->bd_dev,
>  				&btrfsic_dev_state_hashtable);
>  		if (NULL != ds) {
>  			state = ds->state;
> -- 
> 2.11.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: don't require a struct block_device to submit a bio
  2017-08-23 17:10 don't require a struct block_device to submit a bio Christoph Hellwig
                   ` (4 preceding siblings ...)
  2017-08-23 17:10 ` [PATCH 5/6] block: cache the partition index in struct block_device Christoph Hellwig
@ 2017-08-23 18:01 ` Christoph Hellwig
  2017-08-23 18:04 ` Jens Axboe
  2017-08-23 18:50 ` Jens Axboe
  7 siblings, 0 replies; 12+ messages in thread
From: Christoph Hellwig @ 2017-08-23 18:01 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, linux-raid, linux-btrfs

Patch 6 didn't seem to make it through to the list, so here is a
link to the git tree:

http://git.infradead.org/users/hch/block.git/shortlog/refs/heads/bi_bdev

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: don't require a struct block_device to submit a bio
  2017-08-23 17:10 don't require a struct block_device to submit a bio Christoph Hellwig
                   ` (5 preceding siblings ...)
  2017-08-23 18:01 ` don't require a struct block_device to submit a bio Christoph Hellwig
@ 2017-08-23 18:04 ` Jens Axboe
  2017-08-23 18:50 ` Jens Axboe
  7 siblings, 0 replies; 12+ messages in thread
From: Jens Axboe @ 2017-08-23 18:04 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-block, linux-raid, linux-btrfs

On 08/23/2017 11:10 AM, Christoph Hellwig wrote:
> Hi Jens,
> 
> this series removes the need to have a struct block_device ready to
> submit a bio.   We basically don't use it anywhere in the block stack
> anyway - we always go for the gendisk or request_queue.  The only
> exception is partition remapping for which we'll now need an additional
> partition index.  This helps with cases where we submit I/O from a
> character device (nvme or lightnvm passthrough) or a different block
> device (upcoming nvme multipath support).

Looks fine to me. I can take it through the block tree, when the md/btrfs
parts are reviewed by the right parties.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/6] raid5: remove a call to get_start_sect
  2017-08-23 17:10 ` [PATCH 2/6] raid5: remove a call to get_start_sect Christoph Hellwig
@ 2017-08-23 18:23   ` Shaohua Li
  2017-08-24  9:18     ` Christoph Hellwig
  0 siblings, 1 reply; 12+ messages in thread
From: Shaohua Li @ 2017-08-23 18:23 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Jens Axboe, linux-block, linux-raid, linux-btrfs

On Wed, Aug 23, 2017 at 07:10:28PM +0200, Christoph Hellwig wrote:
> The block layer always remaps partitions before calling into the
> ->make_request methods of drivers.  Thus the call to get_start_sect in
> in_chunk_boundary will always return 0 and can be removed.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  drivers/md/raid5.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> index 0fc2748aaf95..d687aeb1b538 100644
> --- a/drivers/md/raid5.c
> +++ b/drivers/md/raid5.c
> @@ -5092,10 +5092,12 @@ static int raid5_congested(struct mddev *mddev, int bits)
>  static int in_chunk_boundary(struct mddev *mddev, struct bio *bio)
>  {
>  	struct r5conf *conf = mddev->private;
> -	sector_t sector = bio->bi_iter.bi_sector + get_start_sect(bio->bi_bdev);
> +	sector_t sector = bio->bi_iter.bi_sector;
>  	unsigned int chunk_sectors;
>  	unsigned int bio_sectors = bio_sectors(bio);
>  
> +	WARN_ON_ONCE(bio->bi_partno);
> +
>  	chunk_sectors = min(conf->chunk_sectors, conf->prev_chunk_sectors);
>  	return  chunk_sectors >=
>  		((sector & (chunk_sectors - 1)) + bio_sectors);

Reviewed-by: Shaohua Li <shli@fb.com>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: don't require a struct block_device to submit a bio
  2017-08-23 17:10 don't require a struct block_device to submit a bio Christoph Hellwig
                   ` (6 preceding siblings ...)
  2017-08-23 18:04 ` Jens Axboe
@ 2017-08-23 18:50 ` Jens Axboe
  7 siblings, 0 replies; 12+ messages in thread
From: Jens Axboe @ 2017-08-23 18:50 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-block, linux-raid, linux-btrfs

On 08/23/2017 11:10 AM, Christoph Hellwig wrote:
> Hi Jens,
> 
> this series removes the need to have a struct block_device ready to
> submit a bio.   We basically don't use it anywhere in the block stack
> anyway - we always go for the gendisk or request_queue.  The only
> exception is partition remapping for which we'll now need an additional
> partition index.  This helps with cases where we submit I/O from a
> character device (nvme or lightnvm passthrough) or a different block
> device (upcoming nvme multipath support).

Added for 4.14, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/6] raid5: remove a call to get_start_sect
  2017-08-23 18:23   ` Shaohua Li
@ 2017-08-24  9:18     ` Christoph Hellwig
  0 siblings, 0 replies; 12+ messages in thread
From: Christoph Hellwig @ 2017-08-24  9:18 UTC (permalink / raw)
  To: Shaohua Li
  Cc: Christoph Hellwig, Jens Axboe, linux-block, linux-raid,
	linux-btrfs

On Wed, Aug 23, 2017 at 11:23:38AM -0700, Shaohua Li wrote:
> On Wed, Aug 23, 2017 at 07:10:28PM +0200, Christoph Hellwig wrote:
> > The block layer always remaps partitions before calling into the
> > ->make_request methods of drivers.  Thus the call to get_start_sect in
> > in_chunk_boundary will always return 0 and can be removed.
> > 
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> > ---
> >  drivers/md/raid5.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> > index 0fc2748aaf95..d687aeb1b538 100644
> > --- a/drivers/md/raid5.c
> > +++ b/drivers/md/raid5.c
> > @@ -5092,10 +5092,12 @@ static int raid5_congested(struct mddev *mddev, int bits)
> >  static int in_chunk_boundary(struct mddev *mddev, struct bio *bio)
> >  {
> >  	struct r5conf *conf = mddev->private;
> > -	sector_t sector = bio->bi_iter.bi_sector + get_start_sect(bio->bi_bdev);
> > +	sector_t sector = bio->bi_iter.bi_sector;
> >  	unsigned int chunk_sectors;
> >  	unsigned int bio_sectors = bio_sectors(bio);
> >  
> > +	WARN_ON_ONCE(bio->bi_partno);
> > +

Meh, of course bi_partno is only added a few patches later, so this
breaks bisectability.  But given that the patch is already in there's
probably nothing I can do here.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2017-08-24  9:18 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-23 17:10 don't require a struct block_device to submit a bio Christoph Hellwig
2017-08-23 17:10 ` [PATCH 1/6] btrfs: index check-integrity state hash by a dev_t Christoph Hellwig
2017-08-23 17:45   ` Liu Bo
2017-08-23 17:10 ` [PATCH 2/6] raid5: remove a call to get_start_sect Christoph Hellwig
2017-08-23 18:23   ` Shaohua Li
2017-08-24  9:18     ` Christoph Hellwig
2017-08-23 17:10 ` [PATCH 3/6] block: reject attempts to allocate more than DISK_MAX_PARTS partitions Christoph Hellwig
2017-08-23 17:10 ` [PATCH 4/6] block: add a __disk_get_part helper Christoph Hellwig
2017-08-23 17:10 ` [PATCH 5/6] block: cache the partition index in struct block_device Christoph Hellwig
2017-08-23 18:01 ` don't require a struct block_device to submit a bio Christoph Hellwig
2017-08-23 18:04 ` Jens Axboe
2017-08-23 18:50 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).