Commit 804e498e authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

sd: convert to the atomic queue limits API

Assign all queue limits through a local queue_limits variable and
queue_limits_commit_update so that we can't race updating them from
multiple places, and freeze the queue when updating them so that
in-progress I/O submissions don't see half-updated limits.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDamien Le Moal <dlemoal@kernel.org>
Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20240531074837.1648501-12-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 9c1d339a
This diff is collapsed.
...@@ -239,7 +239,8 @@ static inline int sd_is_zoned(struct scsi_disk *sdkp) ...@@ -239,7 +239,8 @@ static inline int sd_is_zoned(struct scsi_disk *sdkp)
#ifdef CONFIG_BLK_DEV_ZONED #ifdef CONFIG_BLK_DEV_ZONED
int sd_zbc_read_zones(struct scsi_disk *sdkp, u8 buf[SD_BUF_SIZE]); int sd_zbc_read_zones(struct scsi_disk *sdkp, struct queue_limits *lim,
u8 buf[SD_BUF_SIZE]);
int sd_zbc_revalidate_zones(struct scsi_disk *sdkp); int sd_zbc_revalidate_zones(struct scsi_disk *sdkp);
blk_status_t sd_zbc_setup_zone_mgmt_cmnd(struct scsi_cmnd *cmd, blk_status_t sd_zbc_setup_zone_mgmt_cmnd(struct scsi_cmnd *cmd,
unsigned char op, bool all); unsigned char op, bool all);
...@@ -250,7 +251,8 @@ int sd_zbc_report_zones(struct gendisk *disk, sector_t sector, ...@@ -250,7 +251,8 @@ int sd_zbc_report_zones(struct gendisk *disk, sector_t sector,
#else /* CONFIG_BLK_DEV_ZONED */ #else /* CONFIG_BLK_DEV_ZONED */
static inline int sd_zbc_read_zones(struct scsi_disk *sdkp, u8 buf[SD_BUF_SIZE]) static inline int sd_zbc_read_zones(struct scsi_disk *sdkp,
struct queue_limits *lim, u8 buf[SD_BUF_SIZE])
{ {
return 0; return 0;
} }
......
...@@ -582,13 +582,15 @@ int sd_zbc_revalidate_zones(struct scsi_disk *sdkp) ...@@ -582,13 +582,15 @@ int sd_zbc_revalidate_zones(struct scsi_disk *sdkp)
/** /**
* sd_zbc_read_zones - Read zone information and update the request queue * sd_zbc_read_zones - Read zone information and update the request queue
* @sdkp: SCSI disk pointer. * @sdkp: SCSI disk pointer.
* @lim: queue limits to read into
* @buf: 512 byte buffer used for storing SCSI command output. * @buf: 512 byte buffer used for storing SCSI command output.
* *
* Read zone information and update the request queue zone characteristics and * Read zone information and update the request queue zone characteristics and
* also the zoned device information in *sdkp. Called by sd_revalidate_disk() * also the zoned device information in *sdkp. Called by sd_revalidate_disk()
* before the gendisk capacity has been set. * before the gendisk capacity has been set.
*/ */
int sd_zbc_read_zones(struct scsi_disk *sdkp, u8 buf[SD_BUF_SIZE]) int sd_zbc_read_zones(struct scsi_disk *sdkp, struct queue_limits *lim,
u8 buf[SD_BUF_SIZE])
{ {
struct gendisk *disk = sdkp->disk; struct gendisk *disk = sdkp->disk;
struct request_queue *q = disk->queue; struct request_queue *q = disk->queue;
...@@ -626,14 +628,13 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, u8 buf[SD_BUF_SIZE]) ...@@ -626,14 +628,13 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, u8 buf[SD_BUF_SIZE])
/* The drive satisfies the kernel restrictions: set it up */ /* The drive satisfies the kernel restrictions: set it up */
blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q); blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
if (sdkp->zones_max_open == U32_MAX) if (sdkp->zones_max_open == U32_MAX)
disk_set_max_open_zones(disk, 0); lim->max_open_zones = 0;
else else
disk_set_max_open_zones(disk, sdkp->zones_max_open); lim->max_open_zones = sdkp->zones_max_open;
disk_set_max_active_zones(disk, 0); lim->max_active_zones = 0;
blk_queue_chunk_sectors(q, lim->chunk_sectors = logical_to_sectors(sdkp->device, zone_blocks);
logical_to_sectors(sdkp->device, zone_blocks));
/* Enable block layer zone append emulation */ /* Enable block layer zone append emulation */
blk_queue_max_zone_append_sectors(q, 0); lim->max_zone_append_sectors = 0;
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment