diff options
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/scsi_debug.c | 27 | ||||
-rw-r--r-- | drivers/scsi/sd.c | 49 | ||||
-rw-r--r-- | drivers/scsi/sd_zbc.c | 16 |
3 files changed, 37 insertions, 55 deletions
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 6d8218a44122..d03d66f11493 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -339,7 +339,7 @@ struct sdebug_dev_info { bool used; /* For ZBC devices */ - enum blk_zoned_model zmodel; + bool zoned; unsigned int zcap; unsigned int zsize; unsigned int zsize_shift; @@ -844,8 +844,11 @@ static bool write_since_sync; static bool sdebug_statistics = DEF_STATISTICS; static bool sdebug_wp; static bool sdebug_allow_restart; -/* Following enum: 0: no zbc, def; 1: host aware; 2: host managed */ -static enum blk_zoned_model sdeb_zbc_model = BLK_ZONED_NONE; +static enum { + BLK_ZONED_NONE = 0, + BLK_ZONED_HA = 1, + BLK_ZONED_HM = 2, +} sdeb_zbc_model = BLK_ZONED_NONE; static char *sdeb_zbc_model_s; enum sam_lun_addr_method {SAM_LUN_AM_PERIPHERAL = 0x0, @@ -1815,8 +1818,6 @@ static int inquiry_vpd_b1(struct sdebug_dev_info *devip, unsigned char *arr) arr[1] = 1; /* non rotating medium (e.g. solid state) */ arr[2] = 0; arr[3] = 5; /* less than 1.8" */ - if (devip->zmodel == BLK_ZONED_HA) - arr[4] = 1 << 4; /* zoned field = 01b */ return 0x3c; } @@ -1883,7 +1884,7 @@ static int resp_inquiry(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) if (! arr) return DID_REQUEUE << 16; is_disk = (sdebug_ptype == TYPE_DISK); - is_zbc = (devip->zmodel != BLK_ZONED_NONE); + is_zbc = devip->zoned; is_disk_zbc = (is_disk || is_zbc); have_wlun = scsi_is_wlun(scp->device->lun); if (have_wlun) @@ -2195,7 +2196,7 @@ static int resp_readcap16(struct scsi_cmnd *scp, * Since the scsi_debug READ CAPACITY implementation always reports the * total disk capacity, set RC BASIS = 1 for host-managed ZBC devices. */ - if (devip->zmodel == BLK_ZONED_HM) + if (devip->zoned) arr[12] |= 1 << 4; arr[15] = sdebug_lowest_aligned & 0xff; @@ -2648,7 +2649,7 @@ static int resp_mode_sense(struct scsi_cmnd *scp, msense_6 = (MODE_SENSE == cmd[0]); llbaa = msense_6 ? false : !!(cmd[1] & 0x10); is_disk = (sdebug_ptype == TYPE_DISK); - is_zbc = (devip->zmodel != BLK_ZONED_NONE); + is_zbc = devip->zoned; if ((is_disk || is_zbc) && !dbd) bd_len = llbaa ? 16 : 8; else @@ -3194,8 +3195,6 @@ static int check_zbc_access_params(struct scsi_cmnd *scp, struct sdeb_zone_state *zsp_end = zbc_zone(devip, lba + num - 1); if (!write) { - if (devip->zmodel == BLK_ZONED_HA) - return 0; /* For host-managed, reads cannot cross zone types boundaries */ if (zsp->z_type != zsp_end->z_type) { mk_sense_buffer(scp, ILLEGAL_REQUEST, @@ -5322,7 +5321,7 @@ static int sdebug_device_create_zones(struct sdebug_dev_info *devip) if (devip->zcap < devip->zsize) devip->nr_zones += devip->nr_seq_zones; - if (devip->zmodel == BLK_ZONED_HM) { + if (devip->zoned) { /* zbc_max_open_zones can be 0, meaning "not reported" */ if (sdeb_zbc_max_open >= devip->nr_zones - 1) devip->max_open = (devip->nr_zones - 1) / 2; @@ -5347,7 +5346,7 @@ static int sdebug_device_create_zones(struct sdebug_dev_info *devip) zsp->z_size = min_t(u64, devip->zsize, capacity - zstart); } else if ((zstart & (devip->zsize - 1)) == 0) { - if (devip->zmodel == BLK_ZONED_HM) + if (devip->zoned) zsp->z_type = ZBC_ZTYPE_SWR; else zsp->z_type = ZBC_ZTYPE_SWP; @@ -5390,13 +5389,13 @@ static struct sdebug_dev_info *sdebug_device_create( } devip->sdbg_host = sdbg_host; if (sdeb_zbc_in_use) { - devip->zmodel = sdeb_zbc_model; + devip->zoned = sdeb_zbc_model == BLK_ZONED_HM; if (sdebug_device_create_zones(devip)) { kfree(devip); return NULL; } } else { - devip->zmodel = BLK_ZONED_NONE; + devip->zoned = false; } devip->create_ts = ktime_get_boottime(); atomic_set(&devip->stopped, (sdeb_tur_ms_to_ready > 0 ? 2 : 0)); diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 542a4bbb21bc..0833b3e6aa6e 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3117,7 +3117,6 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp) struct request_queue *q = sdkp->disk->queue; struct scsi_vpd *vpd; u16 rot; - u8 zoned; rcu_read_lock(); vpd = rcu_dereference(sdkp->device->vpd_pgb1); @@ -3128,7 +3127,7 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp) } rot = get_unaligned_be16(&vpd->data[4]); - zoned = (vpd->data[8] >> 4) & 3; + sdkp->zoned = (vpd->data[8] >> 4) & 3; rcu_read_unlock(); if (rot == 1) { @@ -3136,39 +3135,37 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp) blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, q); } + +#ifdef CONFIG_BLK_DEV_ZONED /* sd_probe rejects ZBD devices early otherwise */ if (sdkp->device->type == TYPE_ZBC) { /* - * Host-managed: Per ZBC and ZAC specifications, writes in - * sequential write required zones of host-managed devices must - * be aligned to the device physical block size. + * Host-managed. + */ + disk_set_zoned(sdkp->disk); + + /* + * Per ZBC and ZAC specifications, writes in sequential write + * required zones of host-managed devices must be aligned to + * the device physical block size. */ - disk_set_zoned(sdkp->disk, BLK_ZONED_HM); blk_queue_zone_write_granularity(q, sdkp->physical_block_size); } else { - sdkp->zoned = zoned; - if (sdkp->zoned == 1) { - /* Host-aware */ - disk_set_zoned(sdkp->disk, BLK_ZONED_HA); - } else { - /* Regular disk or drive managed disk */ - disk_set_zoned(sdkp->disk, BLK_ZONED_NONE); - } + /* + * Host-aware devices are treated as conventional. + */ + WARN_ON_ONCE(blk_queue_is_zoned(q)); } +#endif /* CONFIG_BLK_DEV_ZONED */ if (!sdkp->first_scan) return; - if (blk_queue_is_zoned(q)) { - sd_printk(KERN_NOTICE, sdkp, "Host-%s zoned block device\n", - q->limits.zoned == BLK_ZONED_HM ? "managed" : "aware"); - } else { - if (sdkp->zoned == 1) - sd_printk(KERN_NOTICE, sdkp, - "Host-aware SMR disk used as regular disk\n"); - else if (sdkp->zoned == 2) - sd_printk(KERN_NOTICE, sdkp, - "Drive-managed SMR disk\n"); - } + if (blk_queue_is_zoned(q)) + sd_printk(KERN_NOTICE, sdkp, "Host-managed zoned block device\n"); + else if (sdkp->zoned == 1) + sd_printk(KERN_NOTICE, sdkp, "Host-aware SMR disk used as regular disk\n"); + else if (sdkp->zoned == 2) + sd_printk(KERN_NOTICE, sdkp, "Drive-managed SMR disk\n"); } /** @@ -3502,7 +3499,7 @@ static int sd_revalidate_disk(struct gendisk *disk) } else { q->limits.io_opt = 0; rw_max = min_not_zero(logical_to_sectors(sdp, dev_max), - (sector_t)BLK_DEF_MAX_SECTORS); + (sector_t)BLK_DEF_MAX_SECTORS_CAP); } /* diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c index a25215507668..26af5ab7d7c1 100644 --- a/drivers/scsi/sd_zbc.c +++ b/drivers/scsi/sd_zbc.c @@ -836,10 +836,7 @@ int sd_zbc_revalidate_zones(struct scsi_disk *sdkp) /* * For all zoned disks, initialize zone append emulation data if not - * already done. This is necessary also for host-aware disks used as - * regular disks due to the presence of partitions as these partitions - * may be deleted and the disk zoned model changed back from - * BLK_ZONED_NONE to BLK_ZONED_HA. + * already done. */ if (sd_is_zoned(sdkp) && !sdkp->zone_wp_update_buf) { ret = sd_zbc_init_disk(sdkp); @@ -932,17 +929,6 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, u8 buf[SD_BUF_SIZE]) sdkp->device->use_10_for_rw = 0; sdkp->device->use_16_for_sync = 1; - if (!blk_queue_is_zoned(q)) { - /* - * This can happen for a host aware disk with partitions. - * The block device zone model was already cleared by - * disk_set_zoned(). Only free the scsi disk zone - * information and exit early. - */ - sd_zbc_free_zone_info(sdkp); - return 0; - } - /* Check zoned block device characteristics (unconstrained reads) */ ret = sd_zbc_check_zoned_characteristics(sdkp, buf); if (ret) |