Re: [PATCH v5 04/10] block: Modify revalidate zones

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2020/04/10 1:54, Johannes Thumshirn wrote:
> From: Damien Le Moal <damien.lemoal@xxxxxxx>
> 
> Modify the interface of blk_revalidate_disk_zones() to add an optional
> revalidation callback function that a driver can use to extend checks and
> processing done during zone revalidation. The callback, if defined, is
> executed time after all zones are inspected and with the queue frozen.
> blk_revalidate_disk_zones() is renamed as __blk_revalidate_disk_zones()
> and blk_revalidate_disk_zones() implemented as an inline function calling
> __blk_revalidate_disk_zones() without no revalidation callback specified,
> resulting in an unchanged behavior for all callers of
> blk_revalidate_disk_zones().
> 
> Signed-off-by: Damien Le Moal <damien.lemoal@xxxxxxx>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@xxxxxxx>
> ---
>  block/blk-zoned.c      | 19 ++++++++++++++-----
>  include/linux/blkdev.h | 10 +++++++++-
>  2 files changed, 23 insertions(+), 6 deletions(-)
> 
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index 00b025b8b7c0..6c37fec6859b 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -437,20 +437,27 @@ static int blk_revalidate_zone_cb(struct blk_zone *zone, unsigned int idx,
>  }
>  
>  /**
> - * blk_revalidate_disk_zones - (re)allocate and initialize zone bitmaps
> - * @disk:	Target disk
> + * __blk_revalidate_disk_zones - (re)allocate and initialize zone bitmaps
> + * @disk:		Target disk
> + * @revalidate_cb:	LLD callback
> + * @revalidate_data:	LLD callback argument
>   *
>   * Helper function for low-level device drivers to (re) allocate and initialize
>   * a disk request queue zone bitmaps. This functions should normally be called
>   * within the disk ->revalidate method for blk-mq based drivers.  For BIO based
>   * drivers only q->nr_zones needs to be updated so that the sysfs exposed value
>   * is correct.
> + * If the @revalidate_cb callback function is not NULL, the callback will be
> + * executed with the device request queue frozen after all zones have been
> + * checked.
>   */
> -int blk_revalidate_disk_zones(struct gendisk *disk)
> +int __blk_revalidate_disk_zones(struct gendisk *disk,
> +				revalidate_zones_cb revalidate_cb,
> +				void *revalidate_data)
>  {
>  	struct request_queue *q = disk->queue;
>  	struct blk_revalidate_zone_args args = {
> -		.disk		= disk,
> +		.disk			= disk,

Ooops... whitespace change here.


>  	};
>  	unsigned int noio_flag;
>  	int ret;
> @@ -480,6 +487,8 @@ int blk_revalidate_disk_zones(struct gendisk *disk)
>  		q->nr_zones = args.nr_zones;
>  		swap(q->seq_zones_wlock, args.seq_zones_wlock);
>  		swap(q->conv_zones_bitmap, args.conv_zones_bitmap);
> +		if (revalidate_cb)
> +			revalidate_cb(disk, revalidate_data);
>  		ret = 0;
>  	} else {
>  		pr_warn("%s: failed to revalidate zones\n", disk->disk_name);
> @@ -491,4 +500,4 @@ int blk_revalidate_disk_zones(struct gendisk *disk)
>  	kfree(args.conv_zones_bitmap);
>  	return ret;
>  }
> -EXPORT_SYMBOL_GPL(blk_revalidate_disk_zones);
> +EXPORT_SYMBOL_GPL(__blk_revalidate_disk_zones);
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index e591b22ace03..a730cacda0f7 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -353,6 +353,8 @@ struct queue_limits {
>  typedef int (*report_zones_cb)(struct blk_zone *zone, unsigned int idx,
>  			       void *data);
>  
> +typedef void (*revalidate_zones_cb)(struct gendisk *disk, void *data);
> +
>  #ifdef CONFIG_BLK_DEV_ZONED
>  
>  #define BLK_ALL_ZONES  ((unsigned int)-1)
> @@ -362,7 +364,13 @@ unsigned int blkdev_nr_zones(struct gendisk *disk);
>  extern int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
>  			    sector_t sectors, sector_t nr_sectors,
>  			    gfp_t gfp_mask);
> -extern int blk_revalidate_disk_zones(struct gendisk *disk);
> +int __blk_revalidate_disk_zones(struct gendisk *disk,
> +				revalidate_zones_cb revalidate_cb,
> +				void *revalidate_data);
> +static inline int blk_revalidate_disk_zones(struct gendisk *disk)
> +{
> +	return __blk_revalidate_disk_zones(disk, NULL, NULL);
> +}
>  
>  extern int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
>  				     unsigned int cmd, unsigned long arg);
> 


-- 
Damien Le Moal
Western Digital Research




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux