Commit d81e9d49 authored by Chaitanya Kulkarni's avatar Chaitanya Kulkarni Committed by Jens Axboe

scsi: implement REQ_OP_ZONE_RESET_ALL

This patch implements the zone reset all operation for sd_zbc.c. We add
a new boolean parameter for the sd_zbc_setup_reset_cmd() to indicate
REQ_OP_ZONE_RESET_ALL command setup. Along with that we add support in
the completion path for the zone reset all.
Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
Reviewed-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: default avatarChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Acked-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 6e33dbf2
...@@ -1293,7 +1293,9 @@ static blk_status_t sd_init_command(struct scsi_cmnd *cmd) ...@@ -1293,7 +1293,9 @@ static blk_status_t sd_init_command(struct scsi_cmnd *cmd)
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_RESET: case REQ_OP_ZONE_RESET:
return sd_zbc_setup_reset_cmnd(cmd); return sd_zbc_setup_reset_cmnd(cmd, false);
case REQ_OP_ZONE_RESET_ALL:
return sd_zbc_setup_reset_cmnd(cmd, true);
default: default:
WARN_ON_ONCE(1); WARN_ON_ONCE(1);
return BLK_STS_NOTSUPP; return BLK_STS_NOTSUPP;
...@@ -1959,6 +1961,7 @@ static int sd_done(struct scsi_cmnd *SCpnt) ...@@ -1959,6 +1961,7 @@ static int sd_done(struct scsi_cmnd *SCpnt)
case REQ_OP_WRITE_ZEROES: case REQ_OP_WRITE_ZEROES:
case REQ_OP_WRITE_SAME: case REQ_OP_WRITE_SAME:
case REQ_OP_ZONE_RESET: case REQ_OP_ZONE_RESET:
case REQ_OP_ZONE_RESET_ALL:
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);
......
...@@ -209,7 +209,7 @@ static inline int sd_is_zoned(struct scsi_disk *sdkp) ...@@ -209,7 +209,7 @@ static inline int sd_is_zoned(struct scsi_disk *sdkp)
extern int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buffer); extern int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buffer);
extern void sd_zbc_print_zones(struct scsi_disk *sdkp); extern void sd_zbc_print_zones(struct scsi_disk *sdkp);
extern blk_status_t sd_zbc_setup_reset_cmnd(struct scsi_cmnd *cmd); extern blk_status_t sd_zbc_setup_reset_cmnd(struct scsi_cmnd *cmd, bool all);
extern void sd_zbc_complete(struct scsi_cmnd *cmd, unsigned int good_bytes, extern void sd_zbc_complete(struct scsi_cmnd *cmd, unsigned int good_bytes,
struct scsi_sense_hdr *sshdr); struct scsi_sense_hdr *sshdr);
extern int sd_zbc_report_zones(struct gendisk *disk, sector_t sector, extern int sd_zbc_report_zones(struct gendisk *disk, sector_t sector,
...@@ -225,7 +225,8 @@ static inline int sd_zbc_read_zones(struct scsi_disk *sdkp, ...@@ -225,7 +225,8 @@ static inline int sd_zbc_read_zones(struct scsi_disk *sdkp,
static inline void sd_zbc_print_zones(struct scsi_disk *sdkp) {} static inline void sd_zbc_print_zones(struct scsi_disk *sdkp) {}
static inline blk_status_t sd_zbc_setup_reset_cmnd(struct scsi_cmnd *cmd) static inline blk_status_t sd_zbc_setup_reset_cmnd(struct scsi_cmnd *cmd,
bool all)
{ {
return BLK_STS_TARGET; return BLK_STS_TARGET;
} }
......
...@@ -209,10 +209,11 @@ static inline sector_t sd_zbc_zone_sectors(struct scsi_disk *sdkp) ...@@ -209,10 +209,11 @@ static inline sector_t sd_zbc_zone_sectors(struct scsi_disk *sdkp)
/** /**
* sd_zbc_setup_reset_cmnd - Prepare a RESET WRITE POINTER scsi command. * sd_zbc_setup_reset_cmnd - Prepare a RESET WRITE POINTER scsi command.
* @cmd: the command to setup * @cmd: the command to setup
* @all: Reset all zones control.
* *
* Called from sd_init_command() for a REQ_OP_ZONE_RESET request. * Called from sd_init_command() for a REQ_OP_ZONE_RESET request.
*/ */
blk_status_t sd_zbc_setup_reset_cmnd(struct scsi_cmnd *cmd) blk_status_t sd_zbc_setup_reset_cmnd(struct scsi_cmnd *cmd, bool all)
{ {
struct request *rq = cmd->request; struct request *rq = cmd->request;
struct scsi_disk *sdkp = scsi_disk(rq->rq_disk); struct scsi_disk *sdkp = scsi_disk(rq->rq_disk);
...@@ -234,6 +235,9 @@ blk_status_t sd_zbc_setup_reset_cmnd(struct scsi_cmnd *cmd) ...@@ -234,6 +235,9 @@ blk_status_t sd_zbc_setup_reset_cmnd(struct scsi_cmnd *cmd)
memset(cmd->cmnd, 0, cmd->cmd_len); memset(cmd->cmnd, 0, cmd->cmd_len);
cmd->cmnd[0] = ZBC_OUT; cmd->cmnd[0] = ZBC_OUT;
cmd->cmnd[1] = ZO_RESET_WRITE_POINTER; cmd->cmnd[1] = ZO_RESET_WRITE_POINTER;
if (all)
cmd->cmnd[14] = 0x1;
else
put_unaligned_be64(block, &cmd->cmnd[2]); put_unaligned_be64(block, &cmd->cmnd[2]);
rq->timeout = SD_TIMEOUT; rq->timeout = SD_TIMEOUT;
...@@ -261,6 +265,7 @@ void sd_zbc_complete(struct scsi_cmnd *cmd, unsigned int good_bytes, ...@@ -261,6 +265,7 @@ void sd_zbc_complete(struct scsi_cmnd *cmd, unsigned int good_bytes,
switch (req_op(rq)) { switch (req_op(rq)) {
case REQ_OP_ZONE_RESET: case REQ_OP_ZONE_RESET:
case REQ_OP_ZONE_RESET_ALL:
if (result && if (result &&
sshdr->sense_key == ILLEGAL_REQUEST && sshdr->sense_key == ILLEGAL_REQUEST &&
...@@ -487,6 +492,7 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buf) ...@@ -487,6 +492,7 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buf)
/* The drive satisfies the kernel restrictions: set it up */ /* The drive satisfies the kernel restrictions: set it up */
blk_queue_chunk_sectors(sdkp->disk->queue, blk_queue_chunk_sectors(sdkp->disk->queue,
logical_to_sectors(sdkp->device, zone_blocks)); logical_to_sectors(sdkp->device, zone_blocks));
blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, sdkp->disk->queue);
nr_zones = round_up(sdkp->capacity, zone_blocks) >> ilog2(zone_blocks); nr_zones = round_up(sdkp->capacity, zone_blocks) >> ilog2(zone_blocks);
/* READ16/WRITE16 is mandatory for ZBC disks */ /* READ16/WRITE16 is mandatory for ZBC disks */
......
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