diff mbox series

[1/2] block: move ->ia_ranges from the request_queue to the gendisk

Message ID 20220629062013.1331068-2-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [1/2] block: move ->ia_ranges from the request_queue to the gendisk | expand

Commit Message

Christoph Hellwig June 29, 2022, 6:20 a.m. UTC
Independent access ranges only matter for file system I/O and are only
valid with a registered gendisk, so move them there.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-ia-ranges.c  | 18 +++++++++---------
 include/linux/blkdev.h | 12 ++++++------
 2 files changed, 15 insertions(+), 15 deletions(-)

Comments

Damien Le Moal June 29, 2022, 7:08 a.m. UTC | #1
On 6/29/22 15:20, Christoph Hellwig wrote:
> Independent access ranges only matter for file system I/O and are only
> valid with a registered gendisk, so move them there.

Would this potentially affect the use of ranges in DM ? E.g. exposing a
dm-linear device targets as ranges. I do not think so but I did not check
the details.

> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  block/blk-ia-ranges.c  | 18 +++++++++---------
>  include/linux/blkdev.h | 12 ++++++------
>  2 files changed, 15 insertions(+), 15 deletions(-)
> 
> diff --git a/block/blk-ia-ranges.c b/block/blk-ia-ranges.c
> index 47c89e65b57fa..c1bf14bcd15f4 100644
> --- a/block/blk-ia-ranges.c
> +++ b/block/blk-ia-ranges.c
> @@ -106,7 +106,7 @@ static struct kobj_type blk_ia_ranges_ktype = {
>   *
>   * Register with sysfs a set of independent access ranges for @disk.
>   * If @new_iars is not NULL, this set of ranges is registered and the old set
> - * specified by q->ia_ranges is unregistered. Otherwise, q->ia_ranges is
> + * specified by disk->ia_ranges is unregistered. Otherwise, disk->ia_ranges is
>   * registered if it is not already.
>   */
>  int disk_register_independent_access_ranges(struct gendisk *disk,
> @@ -121,12 +121,12 @@ int disk_register_independent_access_ranges(struct gendisk *disk,
>  
>  	/* If a new range set is specified, unregister the old one */
>  	if (new_iars) {
> -		if (q->ia_ranges)
> +		if (disk->ia_ranges)
>  			disk_unregister_independent_access_ranges(disk);
> -		q->ia_ranges = new_iars;
> +		disk->ia_ranges = new_iars;
>  	}
>  
> -	iars = q->ia_ranges;
> +	iars = disk->ia_ranges;
>  	if (!iars)
>  		return 0;
>  
> @@ -138,7 +138,7 @@ int disk_register_independent_access_ranges(struct gendisk *disk,
>  	ret = kobject_init_and_add(&iars->kobj, &blk_ia_ranges_ktype,
>  				   &q->kobj, "%s", "independent_access_ranges");
>  	if (ret) {
> -		q->ia_ranges = NULL;
> +		disk->ia_ranges = NULL;
>  		kobject_put(&iars->kobj);
>  		return ret;
>  	}
> @@ -164,7 +164,7 @@ int disk_register_independent_access_ranges(struct gendisk *disk,
>  void disk_unregister_independent_access_ranges(struct gendisk *disk)
>  {
>  	struct request_queue *q = disk->queue;
> -	struct blk_independent_access_ranges *iars = q->ia_ranges;
> +	struct blk_independent_access_ranges *iars = disk->ia_ranges;
>  	int i;
>  
>  	lockdep_assert_held(&q->sysfs_dir_lock);
> @@ -182,7 +182,7 @@ void disk_unregister_independent_access_ranges(struct gendisk *disk)
>  		kfree(iars);
>  	}
>  
> -	q->ia_ranges = NULL;
> +	disk->ia_ranges = NULL;
>  }
>  
>  static struct blk_independent_access_range *
> @@ -242,7 +242,7 @@ static bool disk_check_ia_ranges(struct gendisk *disk,
>  static bool disk_ia_ranges_changed(struct gendisk *disk,
>  				   struct blk_independent_access_ranges *new)
>  {
> -	struct blk_independent_access_ranges *old = disk->queue->ia_ranges;
> +	struct blk_independent_access_ranges *old = disk->ia_ranges;
>  	int i;
>  
>  	if (!old)
> @@ -331,7 +331,7 @@ void disk_set_independent_access_ranges(struct gendisk *disk,
>  	if (blk_queue_registered(q)) {
>  		disk_register_independent_access_ranges(disk, iars);
>  	} else {
> -		swap(q->ia_ranges, iars);
> +		swap(disk->ia_ranges, iars);
>  		kfree(iars);
>  	}
>  
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index 22b12531aeb71..b9a94c53c6cd3 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -171,6 +171,12 @@ struct gendisk {
>  	struct badblocks *bb;
>  	struct lockdep_map lockdep_map;
>  	u64 diskseq;
> +
> +	/*
> +	 * Independent sector access ranges. This is always NULL for
> +	 * devices that do not have multiple independent access ranges.
> +	 */
> +	struct blk_independent_access_ranges *ia_ranges;
>  };
>  
>  static inline bool disk_live(struct gendisk *disk)
> @@ -539,12 +545,6 @@ struct request_queue {
>  
>  	bool			mq_sysfs_init_done;
>  
> -	/*
> -	 * Independent sector access ranges. This is always NULL for
> -	 * devices that do not have multiple independent access ranges.
> -	 */
> -	struct blk_independent_access_ranges *ia_ranges;
> -
>  	/**
>  	 * @srcu: Sleepable RCU. Use as lock when type of the request queue
>  	 * is blocking (BLK_MQ_F_BLOCKING). Must be the last member
Christoph Hellwig June 29, 2022, 7:22 a.m. UTC | #2
On Wed, Jun 29, 2022 at 04:08:29PM +0900, Damien Le Moal wrote:
> On 6/29/22 15:20, Christoph Hellwig wrote:
> > Independent access ranges only matter for file system I/O and are only
> > valid with a registered gendisk, so move them there.
> 
> Would this potentially affect the use of ranges in DM ? E.g. exposing a
> dm-linear device targets as ranges. I do not think so but I did not check
> the details.

Device mapper only ever does file system I/O.  Passthrough I/O must
be initiated by the actual driver like scsi or nvme.
Damien Le Moal June 29, 2022, 8:35 a.m. UTC | #3
On 6/29/22 15:20, Christoph Hellwig wrote:
> Independent access ranges only matter for file system I/O and are only
> valid with a registered gendisk, so move them there.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>

> ---
>  block/blk-ia-ranges.c  | 18 +++++++++---------
>  include/linux/blkdev.h | 12 ++++++------
>  2 files changed, 15 insertions(+), 15 deletions(-)
> 
> diff --git a/block/blk-ia-ranges.c b/block/blk-ia-ranges.c
> index 47c89e65b57fa..c1bf14bcd15f4 100644
> --- a/block/blk-ia-ranges.c
> +++ b/block/blk-ia-ranges.c
> @@ -106,7 +106,7 @@ static struct kobj_type blk_ia_ranges_ktype = {
>   *
>   * Register with sysfs a set of independent access ranges for @disk.
>   * If @new_iars is not NULL, this set of ranges is registered and the old set
> - * specified by q->ia_ranges is unregistered. Otherwise, q->ia_ranges is
> + * specified by disk->ia_ranges is unregistered. Otherwise, disk->ia_ranges is
>   * registered if it is not already.
>   */
>  int disk_register_independent_access_ranges(struct gendisk *disk,
> @@ -121,12 +121,12 @@ int disk_register_independent_access_ranges(struct gendisk *disk,
>  
>  	/* If a new range set is specified, unregister the old one */
>  	if (new_iars) {
> -		if (q->ia_ranges)
> +		if (disk->ia_ranges)
>  			disk_unregister_independent_access_ranges(disk);
> -		q->ia_ranges = new_iars;
> +		disk->ia_ranges = new_iars;
>  	}
>  
> -	iars = q->ia_ranges;
> +	iars = disk->ia_ranges;
>  	if (!iars)
>  		return 0;
>  
> @@ -138,7 +138,7 @@ int disk_register_independent_access_ranges(struct gendisk *disk,
>  	ret = kobject_init_and_add(&iars->kobj, &blk_ia_ranges_ktype,
>  				   &q->kobj, "%s", "independent_access_ranges");
>  	if (ret) {
> -		q->ia_ranges = NULL;
> +		disk->ia_ranges = NULL;
>  		kobject_put(&iars->kobj);
>  		return ret;
>  	}
> @@ -164,7 +164,7 @@ int disk_register_independent_access_ranges(struct gendisk *disk,
>  void disk_unregister_independent_access_ranges(struct gendisk *disk)
>  {
>  	struct request_queue *q = disk->queue;
> -	struct blk_independent_access_ranges *iars = q->ia_ranges;
> +	struct blk_independent_access_ranges *iars = disk->ia_ranges;
>  	int i;
>  
>  	lockdep_assert_held(&q->sysfs_dir_lock);
> @@ -182,7 +182,7 @@ void disk_unregister_independent_access_ranges(struct gendisk *disk)
>  		kfree(iars);
>  	}
>  
> -	q->ia_ranges = NULL;
> +	disk->ia_ranges = NULL;
>  }
>  
>  static struct blk_independent_access_range *
> @@ -242,7 +242,7 @@ static bool disk_check_ia_ranges(struct gendisk *disk,
>  static bool disk_ia_ranges_changed(struct gendisk *disk,
>  				   struct blk_independent_access_ranges *new)
>  {
> -	struct blk_independent_access_ranges *old = disk->queue->ia_ranges;
> +	struct blk_independent_access_ranges *old = disk->ia_ranges;
>  	int i;
>  
>  	if (!old)
> @@ -331,7 +331,7 @@ void disk_set_independent_access_ranges(struct gendisk *disk,
>  	if (blk_queue_registered(q)) {
>  		disk_register_independent_access_ranges(disk, iars);
>  	} else {
> -		swap(q->ia_ranges, iars);
> +		swap(disk->ia_ranges, iars);
>  		kfree(iars);
>  	}
>  
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index 22b12531aeb71..b9a94c53c6cd3 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -171,6 +171,12 @@ struct gendisk {
>  	struct badblocks *bb;
>  	struct lockdep_map lockdep_map;
>  	u64 diskseq;
> +
> +	/*
> +	 * Independent sector access ranges. This is always NULL for
> +	 * devices that do not have multiple independent access ranges.
> +	 */
> +	struct blk_independent_access_ranges *ia_ranges;
>  };
>  
>  static inline bool disk_live(struct gendisk *disk)
> @@ -539,12 +545,6 @@ struct request_queue {
>  
>  	bool			mq_sysfs_init_done;
>  
> -	/*
> -	 * Independent sector access ranges. This is always NULL for
> -	 * devices that do not have multiple independent access ranges.
> -	 */
> -	struct blk_independent_access_ranges *ia_ranges;
> -
>  	/**
>  	 * @srcu: Sleepable RCU. Use as lock when type of the request queue
>  	 * is blocking (BLK_MQ_F_BLOCKING). Must be the last member
diff mbox series

Patch

diff --git a/block/blk-ia-ranges.c b/block/blk-ia-ranges.c
index 47c89e65b57fa..c1bf14bcd15f4 100644
--- a/block/blk-ia-ranges.c
+++ b/block/blk-ia-ranges.c
@@ -106,7 +106,7 @@  static struct kobj_type blk_ia_ranges_ktype = {
  *
  * Register with sysfs a set of independent access ranges for @disk.
  * If @new_iars is not NULL, this set of ranges is registered and the old set
- * specified by q->ia_ranges is unregistered. Otherwise, q->ia_ranges is
+ * specified by disk->ia_ranges is unregistered. Otherwise, disk->ia_ranges is
  * registered if it is not already.
  */
 int disk_register_independent_access_ranges(struct gendisk *disk,
@@ -121,12 +121,12 @@  int disk_register_independent_access_ranges(struct gendisk *disk,
 
 	/* If a new range set is specified, unregister the old one */
 	if (new_iars) {
-		if (q->ia_ranges)
+		if (disk->ia_ranges)
 			disk_unregister_independent_access_ranges(disk);
-		q->ia_ranges = new_iars;
+		disk->ia_ranges = new_iars;
 	}
 
-	iars = q->ia_ranges;
+	iars = disk->ia_ranges;
 	if (!iars)
 		return 0;
 
@@ -138,7 +138,7 @@  int disk_register_independent_access_ranges(struct gendisk *disk,
 	ret = kobject_init_and_add(&iars->kobj, &blk_ia_ranges_ktype,
 				   &q->kobj, "%s", "independent_access_ranges");
 	if (ret) {
-		q->ia_ranges = NULL;
+		disk->ia_ranges = NULL;
 		kobject_put(&iars->kobj);
 		return ret;
 	}
@@ -164,7 +164,7 @@  int disk_register_independent_access_ranges(struct gendisk *disk,
 void disk_unregister_independent_access_ranges(struct gendisk *disk)
 {
 	struct request_queue *q = disk->queue;
-	struct blk_independent_access_ranges *iars = q->ia_ranges;
+	struct blk_independent_access_ranges *iars = disk->ia_ranges;
 	int i;
 
 	lockdep_assert_held(&q->sysfs_dir_lock);
@@ -182,7 +182,7 @@  void disk_unregister_independent_access_ranges(struct gendisk *disk)
 		kfree(iars);
 	}
 
-	q->ia_ranges = NULL;
+	disk->ia_ranges = NULL;
 }
 
 static struct blk_independent_access_range *
@@ -242,7 +242,7 @@  static bool disk_check_ia_ranges(struct gendisk *disk,
 static bool disk_ia_ranges_changed(struct gendisk *disk,
 				   struct blk_independent_access_ranges *new)
 {
-	struct blk_independent_access_ranges *old = disk->queue->ia_ranges;
+	struct blk_independent_access_ranges *old = disk->ia_ranges;
 	int i;
 
 	if (!old)
@@ -331,7 +331,7 @@  void disk_set_independent_access_ranges(struct gendisk *disk,
 	if (blk_queue_registered(q)) {
 		disk_register_independent_access_ranges(disk, iars);
 	} else {
-		swap(q->ia_ranges, iars);
+		swap(disk->ia_ranges, iars);
 		kfree(iars);
 	}
 
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 22b12531aeb71..b9a94c53c6cd3 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -171,6 +171,12 @@  struct gendisk {
 	struct badblocks *bb;
 	struct lockdep_map lockdep_map;
 	u64 diskseq;
+
+	/*
+	 * Independent sector access ranges. This is always NULL for
+	 * devices that do not have multiple independent access ranges.
+	 */
+	struct blk_independent_access_ranges *ia_ranges;
 };
 
 static inline bool disk_live(struct gendisk *disk)
@@ -539,12 +545,6 @@  struct request_queue {
 
 	bool			mq_sysfs_init_done;
 
-	/*
-	 * Independent sector access ranges. This is always NULL for
-	 * devices that do not have multiple independent access ranges.
-	 */
-	struct blk_independent_access_ranges *ia_ranges;
-
 	/**
 	 * @srcu: Sleepable RCU. Use as lock when type of the request queue
 	 * is blocking (BLK_MQ_F_BLOCKING). Must be the last member