Commit 89d94756 authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Jens Axboe

sd: Implement support for ZBC devices

Implement ZBC support functions to setup zoned disks, both
host-managed and host-aware models. Only zoned disks that satisfy
the following conditions are supported:
1) All zones are the same size, with the exception of an eventual
   last smaller runt zone.
2) For host-managed disks, reads are unrestricted (reads are not
   failed due to zone or write pointer alignement constraints).
Zoned disks that do not satisfy these 2 conditions are setup with
a capacity of 0 to prevent their use.

The function sd_zbc_read_zones, called from sd_revalidate_disk,
checks that the device satisfies the above two constraints. This
function may also change the disk capacity previously set by
sd_read_capacity for devices reporting only the capacity of
conventional zones at the beginning of the LBA range (i.e. devices
reporting rc_basis set to 0).

The capacity message output was moved out of sd_read_capacity into
a new function sd_print_capacity to include this eventual capacity
change by sd_zbc_read_zones. This new function also includes a call
to sd_zbc_print_zones to display the number of zones and zone size
of the device.
Signed-off-by: default avatarHannes Reinecke <hare@suse.de>

[Damien: * Removed zone cache support
         * Removed mapping of discard to reset write pointer command
         * Modified sd_zbc_read_zones to include checks that the
           device satisfies the kernel constraints
         * Implemeted REPORT ZONES setup and post-processing based
           on code from Shaun Tancheff <shaun.tancheff@seagate.com>
         * Removed confusing use of 512B sector units in functions
           interface]
Signed-off-by: default avatarDamien Le Moal <damien.lemoal@hgst.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarShaun Tancheff <shaun.tancheff@seagate.com>
Tested-by: default avatarShaun Tancheff <shaun.tancheff@seagate.com>
Acked-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent 3ed05a98
...@@ -173,6 +173,7 @@ hv_storvsc-y := storvsc_drv.o ...@@ -173,6 +173,7 @@ hv_storvsc-y := storvsc_drv.o
sd_mod-objs := sd.o sd_mod-objs := sd.o
sd_mod-$(CONFIG_BLK_DEV_INTEGRITY) += sd_dif.o sd_mod-$(CONFIG_BLK_DEV_INTEGRITY) += sd_dif.o
sd_mod-$(CONFIG_BLK_DEV_ZONED) += sd_zbc.o
sr_mod-objs := sr.o sr_ioctl.o sr_vendor.o sr_mod-objs := sr.o sr_ioctl.o sr_vendor.o
ncr53c8xx-flags-$(CONFIG_SCSI_ZALON) \ ncr53c8xx-flags-$(CONFIG_SCSI_ZALON) \
......
...@@ -93,6 +93,7 @@ MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK15_MAJOR); ...@@ -93,6 +93,7 @@ MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK15_MAJOR);
MODULE_ALIAS_SCSI_DEVICE(TYPE_DISK); MODULE_ALIAS_SCSI_DEVICE(TYPE_DISK);
MODULE_ALIAS_SCSI_DEVICE(TYPE_MOD); MODULE_ALIAS_SCSI_DEVICE(TYPE_MOD);
MODULE_ALIAS_SCSI_DEVICE(TYPE_RBC); MODULE_ALIAS_SCSI_DEVICE(TYPE_RBC);
MODULE_ALIAS_SCSI_DEVICE(TYPE_ZBC);
#if !defined(CONFIG_DEBUG_BLOCK_EXT_DEVT) #if !defined(CONFIG_DEBUG_BLOCK_EXT_DEVT)
#define SD_MINORS 16 #define SD_MINORS 16
...@@ -163,7 +164,7 @@ cache_type_store(struct device *dev, struct device_attribute *attr, ...@@ -163,7 +164,7 @@ cache_type_store(struct device *dev, struct device_attribute *attr,
static const char temp[] = "temporary "; static const char temp[] = "temporary ";
int len; int len;
if (sdp->type != TYPE_DISK) if (sdp->type != TYPE_DISK && sdp->type != TYPE_ZBC)
/* no cache control on RBC devices; theoretically they /* no cache control on RBC devices; theoretically they
* can do it, but there's probably so many exceptions * can do it, but there's probably so many exceptions
* it's not worth the risk */ * it's not worth the risk */
...@@ -262,7 +263,7 @@ allow_restart_store(struct device *dev, struct device_attribute *attr, ...@@ -262,7 +263,7 @@ allow_restart_store(struct device *dev, struct device_attribute *attr,
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EACCES; return -EACCES;
if (sdp->type != TYPE_DISK) if (sdp->type != TYPE_DISK && sdp->type != TYPE_ZBC)
return -EINVAL; return -EINVAL;
sdp->allow_restart = simple_strtoul(buf, NULL, 10); sdp->allow_restart = simple_strtoul(buf, NULL, 10);
...@@ -392,6 +393,11 @@ provisioning_mode_store(struct device *dev, struct device_attribute *attr, ...@@ -392,6 +393,11 @@ provisioning_mode_store(struct device *dev, struct device_attribute *attr,
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EACCES; return -EACCES;
if (sd_is_zoned(sdkp)) {
sd_config_discard(sdkp, SD_LBP_DISABLE);
return count;
}
if (sdp->type != TYPE_DISK) if (sdp->type != TYPE_DISK)
return -EINVAL; return -EINVAL;
...@@ -459,7 +465,7 @@ max_write_same_blocks_store(struct device *dev, struct device_attribute *attr, ...@@ -459,7 +465,7 @@ max_write_same_blocks_store(struct device *dev, struct device_attribute *attr,
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EACCES; return -EACCES;
if (sdp->type != TYPE_DISK) if (sdp->type != TYPE_DISK && sdp->type != TYPE_ZBC)
return -EINVAL; return -EINVAL;
err = kstrtoul(buf, 10, &max); err = kstrtoul(buf, 10, &max);
...@@ -844,6 +850,12 @@ static int sd_setup_write_same_cmnd(struct scsi_cmnd *cmd) ...@@ -844,6 +850,12 @@ static int sd_setup_write_same_cmnd(struct scsi_cmnd *cmd)
BUG_ON(bio_offset(bio) || bio_iovec(bio).bv_len != sdp->sector_size); BUG_ON(bio_offset(bio) || bio_iovec(bio).bv_len != sdp->sector_size);
if (sd_is_zoned(sdkp)) {
ret = sd_zbc_setup_write_cmnd(cmd);
if (ret != BLKPREP_OK)
return ret;
}
sector >>= ilog2(sdp->sector_size) - 9; sector >>= ilog2(sdp->sector_size) - 9;
nr_sectors >>= ilog2(sdp->sector_size) - 9; nr_sectors >>= ilog2(sdp->sector_size) - 9;
...@@ -901,19 +913,25 @@ static int sd_setup_read_write_cmnd(struct scsi_cmnd *SCpnt) ...@@ -901,19 +913,25 @@ static int sd_setup_read_write_cmnd(struct scsi_cmnd *SCpnt)
struct request *rq = SCpnt->request; struct request *rq = SCpnt->request;
struct scsi_device *sdp = SCpnt->device; struct scsi_device *sdp = SCpnt->device;
struct gendisk *disk = rq->rq_disk; struct gendisk *disk = rq->rq_disk;
struct scsi_disk *sdkp; struct scsi_disk *sdkp = scsi_disk(disk);
sector_t block = blk_rq_pos(rq); sector_t block = blk_rq_pos(rq);
sector_t threshold; sector_t threshold;
unsigned int this_count = blk_rq_sectors(rq); unsigned int this_count = blk_rq_sectors(rq);
unsigned int dif, dix; unsigned int dif, dix;
bool zoned_write = sd_is_zoned(sdkp) && rq_data_dir(rq) == WRITE;
int ret; int ret;
unsigned char protect; unsigned char protect;
if (zoned_write) {
ret = sd_zbc_setup_write_cmnd(SCpnt);
if (ret != BLKPREP_OK)
return ret;
}
ret = scsi_init_io(SCpnt); ret = scsi_init_io(SCpnt);
if (ret != BLKPREP_OK) if (ret != BLKPREP_OK)
goto out; goto out;
SCpnt = rq->special; SCpnt = rq->special;
sdkp = scsi_disk(disk);
/* from here on until we're complete, any goto out /* from here on until we're complete, any goto out
* is used for a killable error condition */ * is used for a killable error condition */
...@@ -1132,6 +1150,9 @@ static int sd_setup_read_write_cmnd(struct scsi_cmnd *SCpnt) ...@@ -1132,6 +1150,9 @@ static int sd_setup_read_write_cmnd(struct scsi_cmnd *SCpnt)
*/ */
ret = BLKPREP_OK; ret = BLKPREP_OK;
out: out:
if (zoned_write && ret != BLKPREP_OK)
sd_zbc_cancel_write_cmnd(SCpnt);
return ret; return ret;
} }
...@@ -1149,6 +1170,10 @@ static int sd_init_command(struct scsi_cmnd *cmd) ...@@ -1149,6 +1170,10 @@ static int sd_init_command(struct scsi_cmnd *cmd)
case REQ_OP_READ: case REQ_OP_READ:
case REQ_OP_WRITE: case REQ_OP_WRITE:
return sd_setup_read_write_cmnd(cmd); return sd_setup_read_write_cmnd(cmd);
case REQ_OP_ZONE_REPORT:
return sd_zbc_setup_report_cmnd(cmd);
case REQ_OP_ZONE_RESET:
return sd_zbc_setup_reset_cmnd(cmd);
default: default:
BUG(); BUG();
} }
...@@ -1780,7 +1805,10 @@ static int sd_done(struct scsi_cmnd *SCpnt) ...@@ -1780,7 +1805,10 @@ static int sd_done(struct scsi_cmnd *SCpnt)
unsigned char op = SCpnt->cmnd[0]; unsigned char op = SCpnt->cmnd[0];
unsigned char unmap = SCpnt->cmnd[1] & 8; unsigned char unmap = SCpnt->cmnd[1] & 8;
if (req_op(req) == REQ_OP_DISCARD || req_op(req) == REQ_OP_WRITE_SAME) { switch (req_op(req)) {
case REQ_OP_DISCARD:
case REQ_OP_WRITE_SAME:
case REQ_OP_ZONE_RESET:
if (!result) { if (!result) {
good_bytes = blk_rq_bytes(req); good_bytes = blk_rq_bytes(req);
scsi_set_resid(SCpnt, 0); scsi_set_resid(SCpnt, 0);
...@@ -1788,6 +1816,17 @@ static int sd_done(struct scsi_cmnd *SCpnt) ...@@ -1788,6 +1816,17 @@ static int sd_done(struct scsi_cmnd *SCpnt)
good_bytes = 0; good_bytes = 0;
scsi_set_resid(SCpnt, blk_rq_bytes(req)); scsi_set_resid(SCpnt, blk_rq_bytes(req));
} }
break;
case REQ_OP_ZONE_REPORT:
if (!result) {
good_bytes = scsi_bufflen(SCpnt)
- scsi_get_resid(SCpnt);
scsi_set_resid(SCpnt, 0);
} else {
good_bytes = 0;
scsi_set_resid(SCpnt, blk_rq_bytes(req));
}
break;
} }
if (result) { if (result) {
...@@ -1848,7 +1887,11 @@ static int sd_done(struct scsi_cmnd *SCpnt) ...@@ -1848,7 +1887,11 @@ static int sd_done(struct scsi_cmnd *SCpnt)
default: default:
break; break;
} }
out: out:
if (sd_is_zoned(sdkp))
sd_zbc_complete(SCpnt, good_bytes, &sshdr);
SCSI_LOG_HLCOMPLETE(1, scmd_printk(KERN_INFO, SCpnt, SCSI_LOG_HLCOMPLETE(1, scmd_printk(KERN_INFO, SCpnt,
"sd_done: completed %d of %d bytes\n", "sd_done: completed %d of %d bytes\n",
good_bytes, scsi_bufflen(SCpnt))); good_bytes, scsi_bufflen(SCpnt)));
...@@ -1983,7 +2026,6 @@ sd_spinup_disk(struct scsi_disk *sdkp) ...@@ -1983,7 +2026,6 @@ sd_spinup_disk(struct scsi_disk *sdkp)
} }
} }
/* /*
* Determine whether disk supports Data Integrity Field. * Determine whether disk supports Data Integrity Field.
*/ */
...@@ -2133,6 +2175,9 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp, ...@@ -2133,6 +2175,9 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp,
/* Logical blocks per physical block exponent */ /* Logical blocks per physical block exponent */
sdkp->physical_block_size = (1 << (buffer[13] & 0xf)) * sector_size; sdkp->physical_block_size = (1 << (buffer[13] & 0xf)) * sector_size;
/* RC basis */
sdkp->rc_basis = (buffer[12] >> 4) & 0x3;
/* Lowest aligned logical block */ /* Lowest aligned logical block */
alignment = ((buffer[14] & 0x3f) << 8 | buffer[15]) * sector_size; alignment = ((buffer[14] & 0x3f) << 8 | buffer[15]) * sector_size;
blk_queue_alignment_offset(sdp->request_queue, alignment); blk_queue_alignment_offset(sdp->request_queue, alignment);
...@@ -2242,7 +2287,6 @@ sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer) ...@@ -2242,7 +2287,6 @@ sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer)
{ {
int sector_size; int sector_size;
struct scsi_device *sdp = sdkp->device; struct scsi_device *sdp = sdkp->device;
sector_t old_capacity = sdkp->capacity;
if (sd_try_rc16_first(sdp)) { if (sd_try_rc16_first(sdp)) {
sector_size = read_capacity_16(sdkp, sdp, buffer); sector_size = read_capacity_16(sdkp, sdp, buffer);
...@@ -2323,8 +2367,23 @@ sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer) ...@@ -2323,8 +2367,23 @@ sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer)
sector_size = 512; sector_size = 512;
} }
blk_queue_logical_block_size(sdp->request_queue, sector_size); blk_queue_logical_block_size(sdp->request_queue, sector_size);
blk_queue_physical_block_size(sdp->request_queue,
sdkp->physical_block_size);
sdkp->device->sector_size = sector_size;
if (sdkp->capacity > 0xffffffff)
sdp->use_16_for_rw = 1;
{ }
/*
* Print disk capacity
*/
static void
sd_print_capacity(struct scsi_disk *sdkp,
sector_t old_capacity)
{
int sector_size = sdkp->device->sector_size;
char cap_str_2[10], cap_str_10[10]; char cap_str_2[10], cap_str_10[10];
string_get_size(sdkp->capacity, sector_size, string_get_size(sdkp->capacity, sector_size,
...@@ -2343,15 +2402,9 @@ sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer) ...@@ -2343,15 +2402,9 @@ sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer)
sd_printk(KERN_NOTICE, sdkp, sd_printk(KERN_NOTICE, sdkp,
"%u-byte physical blocks\n", "%u-byte physical blocks\n",
sdkp->physical_block_size); sdkp->physical_block_size);
}
}
if (sdkp->capacity > 0xffffffff) sd_zbc_print_zones(sdkp);
sdp->use_16_for_rw = 1; }
blk_queue_physical_block_size(sdp->request_queue,
sdkp->physical_block_size);
sdkp->device->sector_size = sector_size;
} }
/* called with buffer of length 512 */ /* called with buffer of length 512 */
...@@ -2613,7 +2666,7 @@ static void sd_read_app_tag_own(struct scsi_disk *sdkp, unsigned char *buffer) ...@@ -2613,7 +2666,7 @@ static void sd_read_app_tag_own(struct scsi_disk *sdkp, unsigned char *buffer)
struct scsi_mode_data data; struct scsi_mode_data data;
struct scsi_sense_hdr sshdr; struct scsi_sense_hdr sshdr;
if (sdp->type != TYPE_DISK) if (sdp->type != TYPE_DISK && sdp->type != TYPE_ZBC)
return; return;
if (sdkp->protection_type == 0) if (sdkp->protection_type == 0)
...@@ -2720,6 +2773,7 @@ static void sd_read_block_limits(struct scsi_disk *sdkp) ...@@ -2720,6 +2773,7 @@ static void sd_read_block_limits(struct scsi_disk *sdkp)
*/ */
static void sd_read_block_characteristics(struct scsi_disk *sdkp) static void sd_read_block_characteristics(struct scsi_disk *sdkp)
{ {
struct request_queue *q = sdkp->disk->queue;
unsigned char *buffer; unsigned char *buffer;
u16 rot; u16 rot;
const int vpd_len = 64; const int vpd_len = 64;
...@@ -2734,10 +2788,21 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp) ...@@ -2734,10 +2788,21 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp)
rot = get_unaligned_be16(&buffer[4]); rot = get_unaligned_be16(&buffer[4]);
if (rot == 1) { if (rot == 1) {
queue_flag_set_unlocked(QUEUE_FLAG_NONROT, sdkp->disk->queue); queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q);
queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, sdkp->disk->queue); queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, q);
} }
sdkp->zoned = (buffer[8] >> 4) & 3;
if (sdkp->zoned == 1)
q->limits.zoned = BLK_ZONED_HA;
else if (sdkp->device->type == TYPE_ZBC)
q->limits.zoned = BLK_ZONED_HM;
else
q->limits.zoned = BLK_ZONED_NONE;
if (blk_queue_is_zoned(q) && sdkp->first_scan)
sd_printk(KERN_NOTICE, sdkp, "Host-%s zoned block device\n",
q->limits.zoned == BLK_ZONED_HM ? "managed" : "aware");
out: out:
kfree(buffer); kfree(buffer);
} }
...@@ -2809,6 +2874,7 @@ static int sd_revalidate_disk(struct gendisk *disk) ...@@ -2809,6 +2874,7 @@ static int sd_revalidate_disk(struct gendisk *disk)
struct scsi_disk *sdkp = scsi_disk(disk); struct scsi_disk *sdkp = scsi_disk(disk);
struct scsi_device *sdp = sdkp->device; struct scsi_device *sdp = sdkp->device;
struct request_queue *q = sdkp->disk->queue; struct request_queue *q = sdkp->disk->queue;
sector_t old_capacity = sdkp->capacity;
unsigned char *buffer; unsigned char *buffer;
unsigned int dev_max, rw_max; unsigned int dev_max, rw_max;
...@@ -2842,8 +2908,11 @@ static int sd_revalidate_disk(struct gendisk *disk) ...@@ -2842,8 +2908,11 @@ static int sd_revalidate_disk(struct gendisk *disk)
sd_read_block_provisioning(sdkp); sd_read_block_provisioning(sdkp);
sd_read_block_limits(sdkp); sd_read_block_limits(sdkp);
sd_read_block_characteristics(sdkp); sd_read_block_characteristics(sdkp);
sd_zbc_read_zones(sdkp, buffer);
} }
sd_print_capacity(sdkp, old_capacity);
sd_read_write_protect_flag(sdkp, buffer); sd_read_write_protect_flag(sdkp, buffer);
sd_read_cache_type(sdkp, buffer); sd_read_cache_type(sdkp, buffer);
sd_read_app_tag_own(sdkp, buffer); sd_read_app_tag_own(sdkp, buffer);
...@@ -3041,9 +3110,16 @@ static int sd_probe(struct device *dev) ...@@ -3041,9 +3110,16 @@ static int sd_probe(struct device *dev)
scsi_autopm_get_device(sdp); scsi_autopm_get_device(sdp);
error = -ENODEV; error = -ENODEV;
if (sdp->type != TYPE_DISK && sdp->type != TYPE_MOD && sdp->type != TYPE_RBC) if (sdp->type != TYPE_DISK &&
sdp->type != TYPE_ZBC &&
sdp->type != TYPE_MOD &&
sdp->type != TYPE_RBC)
goto out; goto out;
#ifndef CONFIG_BLK_DEV_ZONED
if (sdp->type == TYPE_ZBC)
goto out;
#endif
SCSI_LOG_HLQUEUE(3, sdev_printk(KERN_INFO, sdp, SCSI_LOG_HLQUEUE(3, sdev_printk(KERN_INFO, sdp,
"sd_probe\n")); "sd_probe\n"));
...@@ -3147,6 +3223,8 @@ static int sd_remove(struct device *dev) ...@@ -3147,6 +3223,8 @@ static int sd_remove(struct device *dev)
del_gendisk(sdkp->disk); del_gendisk(sdkp->disk);
sd_shutdown(dev); sd_shutdown(dev);
sd_zbc_remove(sdkp);
blk_register_region(devt, SD_MINORS, NULL, blk_register_region(devt, SD_MINORS, NULL,
sd_default_probe, NULL, NULL); sd_default_probe, NULL, NULL);
......
...@@ -64,6 +64,15 @@ struct scsi_disk { ...@@ -64,6 +64,15 @@ struct scsi_disk {
struct scsi_device *device; struct scsi_device *device;
struct device dev; struct device dev;
struct gendisk *disk; struct gendisk *disk;
#ifdef CONFIG_BLK_DEV_ZONED
unsigned int nr_zones;
unsigned int zone_blocks;
unsigned int zone_shift;
unsigned long *zones_wlock;
unsigned int zones_optimal_open;
unsigned int zones_optimal_nonseq;
unsigned int zones_max_open;
#endif
atomic_t openers; atomic_t openers;
sector_t capacity; /* size in logical blocks */ sector_t capacity; /* size in logical blocks */
u32 max_xfer_blocks; u32 max_xfer_blocks;
...@@ -94,6 +103,9 @@ struct scsi_disk { ...@@ -94,6 +103,9 @@ struct scsi_disk {
unsigned lbpvpd : 1; unsigned lbpvpd : 1;
unsigned ws10 : 1; unsigned ws10 : 1;
unsigned ws16 : 1; unsigned ws16 : 1;
unsigned rc_basis: 2;
unsigned zoned: 2;
unsigned urswrz : 1;
}; };
#define to_scsi_disk(obj) container_of(obj,struct scsi_disk,dev) #define to_scsi_disk(obj) container_of(obj,struct scsi_disk,dev)
...@@ -156,6 +168,11 @@ static inline unsigned int logical_to_bytes(struct scsi_device *sdev, sector_t b ...@@ -156,6 +168,11 @@ static inline unsigned int logical_to_bytes(struct scsi_device *sdev, sector_t b
return blocks * sdev->sector_size; return blocks * sdev->sector_size;
} }
static inline sector_t sectors_to_logical(struct scsi_device *sdev, sector_t sector)
{
return sector >> (ilog2(sdev->sector_size) - 9);
}
/* /*
* Look up the DIX operation based on whether the command is read or * Look up the DIX operation based on whether the command is read or
* write and whether dix and dif are enabled. * write and whether dix and dif are enabled.
...@@ -239,4 +256,57 @@ static inline void sd_dif_complete(struct scsi_cmnd *cmd, unsigned int a) ...@@ -239,4 +256,57 @@ static inline void sd_dif_complete(struct scsi_cmnd *cmd, unsigned int a)
#endif /* CONFIG_BLK_DEV_INTEGRITY */ #endif /* CONFIG_BLK_DEV_INTEGRITY */
static inline int sd_is_zoned(struct scsi_disk *sdkp)
{
return sdkp->zoned == 1 || sdkp->device->type == TYPE_ZBC;
}
#ifdef CONFIG_BLK_DEV_ZONED
extern int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buffer);
extern void sd_zbc_remove(struct scsi_disk *sdkp);
extern void sd_zbc_print_zones(struct scsi_disk *sdkp);
extern int sd_zbc_setup_write_cmnd(struct scsi_cmnd *cmd);
extern void sd_zbc_cancel_write_cmnd(struct scsi_cmnd *cmd);
extern int sd_zbc_setup_report_cmnd(struct scsi_cmnd *cmd);
extern int sd_zbc_setup_reset_cmnd(struct scsi_cmnd *cmd);
extern void sd_zbc_complete(struct scsi_cmnd *cmd, unsigned int good_bytes,
struct scsi_sense_hdr *sshdr);
#else /* CONFIG_BLK_DEV_ZONED */
static inline int sd_zbc_read_zones(struct scsi_disk *sdkp,
unsigned char *buf)
{
return 0;
}
static inline void sd_zbc_remove(struct scsi_disk *sdkp) {}
static inline void sd_zbc_print_zones(struct scsi_disk *sdkp) {}
static inline int sd_zbc_setup_write_cmnd(struct scsi_cmnd *cmd)
{
/* Let the drive fail requests */
return BLKPREP_OK;
}
static inline void sd_zbc_cancel_write_cmnd(struct scsi_cmnd *cmd) {}
static inline int sd_zbc_setup_report_cmnd(struct scsi_cmnd *cmd)
{
return BLKPREP_INVALID;
}
static inline int sd_zbc_setup_reset_cmnd(struct scsi_cmnd *cmd)
{
return BLKPREP_INVALID;
}
static inline void sd_zbc_complete(struct scsi_cmnd *cmd,
unsigned int good_bytes,
struct scsi_sense_hdr *sshdr) {}
#endif /* CONFIG_BLK_DEV_ZONED */
#endif /* _SCSI_DISK_H */ #endif /* _SCSI_DISK_H */
This diff is collapsed.
...@@ -299,4 +299,21 @@ struct scsi_lun { ...@@ -299,4 +299,21 @@ struct scsi_lun {
#define SCSI_ACCESS_STATE_MASK 0x0f #define SCSI_ACCESS_STATE_MASK 0x0f
#define SCSI_ACCESS_STATE_PREFERRED 0x80 #define SCSI_ACCESS_STATE_PREFERRED 0x80
/* Reporting options for REPORT ZONES */
enum zbc_zone_reporting_options {
ZBC_ZONE_REPORTING_OPTION_ALL = 0,
ZBC_ZONE_REPORTING_OPTION_EMPTY,
ZBC_ZONE_REPORTING_OPTION_IMPLICIT_OPEN,
ZBC_ZONE_REPORTING_OPTION_EXPLICIT_OPEN,
ZBC_ZONE_REPORTING_OPTION_CLOSED,
ZBC_ZONE_REPORTING_OPTION_FULL,
ZBC_ZONE_REPORTING_OPTION_READONLY,
ZBC_ZONE_REPORTING_OPTION_OFFLINE,
ZBC_ZONE_REPORTING_OPTION_NEED_RESET_WP = 0x10,
ZBC_ZONE_REPORTING_OPTION_NON_SEQWRITE,
ZBC_ZONE_REPORTING_OPTION_NON_WP = 0x3f,
};
#define ZBC_REPORT_ZONE_PARTIAL 0x80
#endif /* _SCSI_PROTO_H_ */ #endif /* _SCSI_PROTO_H_ */
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