ZAC host-aware device support
cover ZAC host-aware device support
Hi all,
here is a patchset for adding ZAC host-aware device support to libata. Main bits are translations for ZBC IN and ZBC OUT; others are the required plumbing like generating the correct VPD pages. James, do you require a separate patch for adding ZBC IN and ZBC OUT or is it okay to have it queued here?
As usual, reviews and comments are welcome.
Hannes Reinecke (6):
libata: Do not retry commands with valid autosense
libata-scsi: use ata_scsi_set_sense when generating ATA sense
libata: implement ZBC IN translation
libata: Implement ZBC OUT translation
libata: support device-managed ZAC devices
libata: support host-aware ZAC devices
drivers/ata/libata-core.c | 50 +++++++ drivers/ata/libata-eh.c | 4 + drivers/ata/libata-scsi.c | 299 +++++++++++++++++++++++++++++++++++------- include/linux/ata.h | 17 +++ include/linux/libata.h | 7 + include/scsi/scsi_proto.h | 9 ++ include/trace/events/libata.h | 2 + 7 files changed, 344 insertions(+), 44 deletions(-)
Signature · 1 line
1.8.5.2
PATCH 1/6 libata: Do not retry commands with valid autosense
If a failed command has a valid autosense there is no need to retry it on the ATA level; at best we're incurring the same error again. So rather not retry it here, but leave it to the SCSI layer to decide if a retry is in order.
--- drivers/ata/libata-eh.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/ata/libata-eh.c +2 -0
@@ -2218,6 +2218,8 @@ static inline int ata_eh_worth_retry(struct ata_queued_cmd *qc)return 1 ;/* otherwise retry anything from fs stack */ if (qc->err_mask &AC_ERR_INVALID )return 0 ;/* don't retry these */ +if (qc->flags &ATA_QCFLAG_SENSE_VALID ) +return 0 ;/* Autosense, no need to retry here */ return qc->err_mask !=AC_ERR_DEV ;/* retry if not dev error */ }
Signature · 1 line
1.8.5.2
Re: [PATCH 1/6] libata: Do not retry commands with valid autosense
Hello,
Quoted 4 lines · Hannes Reinecke
If a failed command has a valid autosense there is no need to retry it on the ATA level; at best we're incurring the same error again. So rather not retry it here, but leave it to the SCSI layer to decide if a retry is in order.
Hmmm... I don't know. So, we change how we handle errors completely depending on how the device reports it? Doesn't seem like a particularly good idea to me.
Thanks.
Signature · 1 line
tejun
Re: [PATCH 1/6] libata: Do not retry commands with valid autosense
Quoted 12 lines · Tejun Heo
Hello,
Quoted 4 lines · Hannes Reinecke
If a failed command has a valid autosense there is no need to retry it on the ATA level; at best we're incurring the same error again. So rather not retry it here, but leave it to the SCSI layer to decide if a retry is in order.
Hmmm... I don't know. So, we change how we handle errors completely depending on how the device reports it? Doesn't seem like a particularly good idea to me.
The whole point of the autosense feature is that you do _not_ have to fall back to the original trial-and-error libata EH, but know exactly what the problem is. Plus any retry will be giving us (in most cases) exactly the same sense code.
_And_ the SCSI layer is actually able to understand the sense code, allowing him to make a better judgment on what to do with that error.
So any retry in the libata layer will only slow things down, leading to the same results eventually.
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
Re: [PATCH 1/6] libata: Do not retry commands with valid autosense
Hello,
Quoted 4 lines · Hannes Reinecke
The whole point of the autosense feature is that you do _not_ have to fall back to the original trial-and-error libata EH, but know exactly what the problem is. Plus any retry will be giving us (in most cases) exactly the same sense code.
Can you please give some examples? As lacking as ATA error reporting is, it still can tell whether retry is necessary or not in most cases.
Quoted 5 lines
_And_ the SCSI layer is actually able to understand the sense code, allowing him to make a better judgment on what to do with that error.
So any retry in the libata layer will only slow things down, leading to the same results eventually.
Have you tested actual error handling? I doubt this would work as you expect it to. libata EH takes over the entire error handling and when it determines that the command has failed and retrying won't do any good, it tells SCSI EH to not retry either.
Ugh... so this is from NCQ autosense thing. Now ATA devices reports sense data too which trumps AC_ERR_DEV so libata EH decides to retry even when the device indicates unrecoverable error. Urgh... we shouldn't be taking completely different error handling paths because a device chooses to report error conditions slightly differently. Please map them so that they behave in a consistent manner. I'm gonna plug autosense for now.
Thanks.
Signature · 1 line
tejun
PATCH 1/1 libata: disable NCQ autosense
Quoted 1 line
From
8c0fa3e7ca99b0d6d96cb2cf194a912f643da7c5Mon Sep 17 00:00:00 2001
From: Tejun Heo <[email protected]>
Date: Mon, 3 Aug 2015 11:10:45 -0400
fe7173c206de ("libata: Implement support for sense data reporting") and subsequent patches enabled NCQ autosense reporting; unfortunately, this breaks libata EH behavior for devices which support the feature because it assumes that only ATAPI devices report sense data and that sense data trumps explicit device error indication.
For now, disable NCQ autosense.
--- drivers/ata/libata-core.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/ata/libata-core.c +7 -0
@@ -2151,6 +2151,13 @@ static void ata_dev_config_sense_reporting(struct ata_device *dev) {unsigned int err_mask; +/* +* FIXME: This makes ATA devices report sense data on failure which +* in turn makes libata EH ignore AC_ERR_DEV leading to incorrect +* error handling behaviors. +*/ +return ; +if (!ata_id_has_sense_reporting (dev->id))return ;
Signature · 1 line
2.4.3
Re: [PATCH libata/for-4.2-fixes] libata: disable NCQ autosense
Quoted 9 lines · Tejun Heo
From
8c0fa3e7ca99b0d6d96cb2cf194a912f643da7c5Mon Sep 17 00:00:00 2001
From: Tejun Heo <[email protected]>
Date: Mon, 3 Aug 2015 11:10:45 -0400
fe7173c206de("libata: Implement support for sense data reporting") and subsequent patches enabled NCQ autosense reporting; unfortunately, this breaks libata EH behavior for devices which support the feature because it assumes that only ATAPI devices report sense data and that sense data trumps explicit device error indication.
So, this isn't enough and apparently you're bypassing the entire device side error analyzing when the device reports sense data. Sorry that I missed this on the first submission but I can't see how this would work. Even if you fix the immediate issue in this thread, how is it gonna handle link error reported by the device? Who's gonna tell libata EH that the link better be reset and may be sped down if errors keep occurring? This is a significant regression in EH behavior.
I'm gonna revert the whole ACS-4 sense thing. ATM, I'm pretty doubtful that this buys antying substantial for us and even if so we need to figure out a better way to integrate this.
Thanks.
Signature · 1 line
tejun
Re: [PATCH 1/6] libata: Do not retry commands with valid autosense
In reply to Tejun HeoAdding a bit.
Quoted 7 lines · Tejun Heo
Ugh... so this is from NCQ autosense thing. Now ATA devices reports sense data too which trumps
AC_ERR_DEVso libata EH decides to retry even when the device indicates unrecoverable error. Urgh... we shouldn't be taking completely different error handling paths because a device chooses to report error conditions slightly differently. Please map them so that they behave in a consistent manner. I'm gonna plug autosense for now.
Also, is there anything substantial we gain from NCQ autosense? Why do we want this in the first place? ATA error reporting is rudimentary but it more or less works and I'm not sure whether we'd want to overhaul its basic behaviors at this stage.
Thanks.
Signature · 1 line
tejun
James Bottomley
maintainerRe: [PATCH 1/6] libata: Do not retry commands with valid autosense
Quoted 11 lines · Tejun Heo
Adding a bit.
Quoted 7 lines · Tejun Heo
Ugh... so this is from NCQ autosense thing. Now ATA devices reports sense data too which trumps
AC_ERR_DEVso libata EH decides to retry even when the device indicates unrecoverable error. Urgh... we shouldn't be taking completely different error handling paths because a device chooses to report error conditions slightly differently. Please map them so that they behave in a consistent manner. I'm gonna plug autosense for now.
Quoted 4 lines
Also, is there anything substantial we gain from NCQ autosense? Why do we want this in the first place? ATA error reporting is rudimentary but it more or less works and I'm not sure whether we'd want to overhaul its basic behaviors at this stage.
I'd think it would be the same reason as all modern transports: it's faster and allows processing of sense data in-band. Under the old regime, the device is effectively frozen until you collect the data. Under autosense, the data is collected as part of the in-band command processing, so it doesn't stall the device.
Modern drives (and protocols) are moving towards being somewhat more chatty with sense data. It doesn't just signal an error, mostly it's just reporting about drive characteristics or other advisory stuff. This means that if you handle it the old way, you'll get more drive stalls and a corresponding reduction in throughput.
James
Re: [PATCH 1/6] libata: Do not retry commands with valid autosense
Hello, James.
Quoted 11 lines · James Bottomley
I'd think it would be the same reason as all modern transports: it's faster and allows processing of sense data in-band. Under the old regime, the device is effectively frozen until you collect the data. Under autosense, the data is collected as part of the in-band command processing, so it doesn't stall the device.
Modern drives (and protocols) are moving towards being somewhat more chatty with sense data. It doesn't just signal an error, mostly it's just reporting about drive characteristics or other advisory stuff. This means that if you handle it the old way, you'll get more drive stalls and a corresponding reduction in throughput.
The problem is not the "auto" part but the "sense" part, I guess. ATA devices (the harddisks) never reported sense data and instead had a more rudimentary error bits and for newer devices NCQ log pages, so libata EH decodes those error information and takes appropriate actions for the indicated error condition.
Hannes's patchset makes ATA devices mostly bypass libata EH when sense data is present. For, say, unrecoverable read errors, it'd be possible to make this scheme work (broken currently tho); however, libata and SCSI aren't that closely tied and there currently is no way for SCSI to tell libata that, e.g., link error was detected on the device side, so libata will fail to take link recovery actions on those cases.
This *can* be made to work in a couple different ways but what's implemented now is pretty broken and making it work properly in any other way than integrating sense decoding into libata EH would require major restructuring of the whole thing which I'm not sure would be worthwhile at this point.
Thanks.
Signature · 1 line
tejun
James Bottomley
maintainerRe: [PATCH 1/6] libata: Do not retry commands with valid autosense
Quoted 29 lines · Tejun Heo
Hello, James.
Quoted 11 lines · James Bottomley
I'd think it would be the same reason as all modern transports: it's faster and allows processing of sense data in-band. Under the old regime, the device is effectively frozen until you collect the data. Under autosense, the data is collected as part of the in-band command processing, so it doesn't stall the device.
Modern drives (and protocols) are moving towards being somewhat more chatty with sense data. It doesn't just signal an error, mostly it's just reporting about drive characteristics or other advisory stuff. This means that if you handle it the old way, you'll get more drive stalls and a corresponding reduction in throughput.
The problem is not the "auto" part but the "sense" part, I guess. ATA devices (the harddisks) never reported sense data and instead had a more rudimentary error bits and for newer devices NCQ log pages, so libata EH decodes those error information and takes appropriate actions for the indicated error condition.
Hannes's patchset makes ATA devices mostly bypass libata EH when sense data is present. For, say, unrecoverable read errors, it'd be possible to make this scheme work (broken currently tho); however, libata and SCSI aren't that closely tied and there currently is no way for SCSI to tell libata that, e.g., link error was detected on the device side, so libata will fail to take link recovery actions on those cases.
Quoted 5 lines
This *can* be made to work in a couple different ways but what's implemented now is pretty broken and making it work properly in any other way than integrating sense decoding into libata EH would require major restructuring of the whole thing which I'm not sure would be worthwhile at this point.
I'm not arguing that *this* patch is the best way to do it. You asked *why* autosense and that's what I answered. I think there's time to work out the implementation details to get them to be correct and well structured.
James
Re: [PATCH 1/6] libata: Do not retry commands with valid autosense
Hello, James.
Quoted 2 lines · James Bottomley
I'm not arguing that *this* patch is the best way to do it. You asked *why* autosense and that's what I answered. I think there's time to
Heh, that was mostly me being confused. I was thinking NCQ autosense was the only way ATA devices would report sense data.
Quoted 2 lines
work out the implementation details to get them to be correct and well structured.
Yeah, definitely.
Thanks.
Signature · 1 line
tejun
Re: [PATCH 1/6] libata: Do not retry commands with valid autosense
In reply to Tejun HeoQuoted 29 lines · Tejun Heo
Hello, James.
Quoted 11 lines · James Bottomley
I'd think it would be the same reason as all modern transports: it's faster and allows processing of sense data in-band. Under the old regime, the device is effectively frozen until you collect the data. Under autosense, the data is collected as part of the in-band command processing, so it doesn't stall the device.
Modern drives (and protocols) are moving towards being somewhat more chatty with sense data. It doesn't just signal an error, mostly it's just reporting about drive characteristics or other advisory stuff. This means that if you handle it the old way, you'll get more drive stalls and a corresponding reduction in throughput.
The problem is not the "auto" part but the "sense" part, I guess. ATA devices (the harddisks) never reported sense data and instead had a more rudimentary error bits and for newer devices NCQ log pages, so libata EH decodes those error information and takes appropriate actions for the indicated error condition.
Hannes's patchset makes ATA devices mostly bypass libata EH when sense data is present. For, say, unrecoverable read errors, it'd be possible to make this scheme work (broken currently tho); however, libata and SCSI aren't that closely tied and there currently is no way for SCSI to tell libata that, e.g., link error was detected on the device side, so libata will fail to take link recovery actions on those cases.
Quoted 6 lines
This *can* be made to work in a couple different ways but what's implemented now is pretty broken and making it work properly in any other way than integrating sense decoding into libata EH would require major restructuring of the whole thing which I'm not sure would be worthwhile at this point.
At the moment NCQ autosense is mostly used to provide the host with more details for a failed I/O. The typical case here is (no small surprise) ZAC disks, which use autosense to inform the host about
a malformed I/O.
It is _not_ being used as a replacement for existing error behaviour, (ie link errors are not being signalled with that; how could they if there is no link?); in fact, during testing I"ve seen both, autosense I/O failures and normal I/O failures for which autosense is not set, and the normal error handling kicks in.
It's not that I've disable the original error handler completely, it's only bypassed for I/O failure where a sense code is provided. And the drive surely knows which error occurs, so we'd be daft not be using that.
So I think disabling autosense completely is a bit extreme...
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
Re: [PATCH 1/6] libata: Do not retry commands with valid autosense
Hello, Hannes.
Quoted 8 lines · Hannes Reinecke
At the moment NCQ autosense is mostly used to provide the host with more details for a failed I/O. The typical case here is (no small surprise) ZAC disks, which use autosense to inform the host about
a malformed I/O.It is _not_ being used as a replacement for existing error behaviour, (ie link errors are not being signalled with that; how could they if there is no link?); in fact, during testing I"ve seen both, autosense
Hmmm? Devices can report link error via TF bits and you're bypassing TF analysis completley if sense data is present.
Quoted 7 lines
I/O failures and normal I/O failures for which autosense is not set, and the normal error handling kicks in.
It's not that I've disable the original error handler completely, it's only bypassed for I/O failure where a sense code is provided. And the drive surely knows which error occurs, so we'd be daft not be using that.
The patches are altering EH actions in a very subtle way depending on *how* an error is reported, not *what* is reported, which is a pretty silly thing to do. It makes things a lot more confusing to follow and predict. I really don't think this is an acceptable behavior.
Quoted 1 line
So I think disabling autosense completely is a bit extreme...
Please restructure the feature so that it doesn't interfere with the usual EH behavior. e.g. leave the EH actions alone unless explicitly necessary but report detailed error information upwards. If the extra error information can be helpful in determining what EH actions to take, factoring in that information can be helpful too but I'm not too convinced that'd make a huge difference.
Also, please consider that ATA_QCFLAG_SENSE_VALID handling assumes that the reporting device is an ATAPI device and the command in question is not a regular IO one. That's why EH ignores AC_ERR_DEV or AC_ERR_OTHER if ATA_QCFLAG_SENSE_VALID is set. This doesn't work out for the new ATA usage at all.
For now, I've reverted the changes as this is actively detrimental.
Thanks.
Signature · 1 line
tejun
Re: [PATCH 1/6] libata: Do not retry commands with valid autosense
Quoted 8 lines · Tejun Heo
Hello, Hannes.
Quoted 5 lines · Hannes Reinecke
At the moment NCQ autosense is mostly used to provide the host with more details for a failed I/O. The typical case here is (no small surprise) ZAC disks, which use autosense to inform the host about
a malformed I/O.
Quoted 7 lines
Quoted 3 lines
It is _not_ being used as a replacement for existing error behaviour, (ie link errors are not being signalled with that; how could they if there is no link?); in fact, during testing I"ve seen both, autosense
Hmmm? Devices can report link error via TF bits and you're bypassing TF analysis completley if sense data is present.
But sense data will never be present for a link error ... and I'm not disabling that.
Quoted 8 lines
Quoted 7 lines
I/O failures and normal I/O failures for which autosense is not set, and the normal error handling kicks in.
It's not that I've disable the original error handler completely, it's only bypassed for I/O failure where a sense code is provided. And the drive surely knows which error occurs, so we'd be daft not be using that.
Quoted 5 lines
The patches are altering EH actions in a very subtle way depending on *how* an error is reported, not *what* is reported, which is a pretty silly thing to do. It makes things a lot more confusing to follow and predict. I really don't think this is an acceptable behavior.
But if we were judging on _what_ is being reported we would have to know which sense code the drive will be reporting, in effect carrying a massive table of possible sense codes, and map this to the actions. Do you really want to go that way?
Quoted 9 lines
Quoted 1 line
So I think disabling autosense completely is a bit extreme...
Please restructure the feature so that it doesn't interfere with the usual EH behavior. e.g. leave the EH actions alone unless explicitly necessary but report detailed error information upwards. If the extra error information can be helpful in determining what EH actions to take, factoring in that information can be helpful too but I'm not too convinced that'd make a huge difference.
It does if we can avoid the retry on the libata layer.
Quoted 6 lines
Also, please consider that
ATA_QCFLAG_SENSE_VALIDhandling assumes that the reporting device is an ATAPI device and the command in question is not a regular IO one. That's why EH ignoresAC_ERR_DEVorAC_ERR_OTHERifATA_QCFLAG_SENSE_VALIDis set. This doesn't work out for the new ATA usage at all.
I've just mapped onto ATA_QCFLAGS_SENSE_VALID as I've found this to reasonably close to what I've been needing.
If that's the wrong choice of course I can modify this.
Quoted 2 lines
For now, I've reverted the changes as this is actively detrimental.
Oh. So you've tested this on a device with autosense enabled? I haven't seen any negative effects with this patchset, autosense enabled or not.
Cheers,
Hannes
Signature · 8 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg) -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/6 libata-scsi: use ata_scsi_set_sense when generating ATA sense
In reply to Hannes ReineckeWhen generating ATA sense we should be using 'ata_scsi_set_sense' and avoid the hand-crafted functions.
--- drivers/ata/libata-scsi.c | 41 ++++++++--------------------------------- 1 file changed, 8 insertions(+), 33 deletions(-)
drivers/ata/libata-scsi.c +8 -33
@@ -1064,45 +1064,26 @@ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc)*/ static void ata_gen_ata_sense (struct ata_queued_cmd *qc) { -struct ata_device *dev = qc->dev;struct scsi_cmnd *cmd = qc->scsicmd;struct ata_taskfile *tf = &qc->result_tf; -unsigned char *sb = cmd->sense_buffer; -unsigned char *desc = sb +8 ;int verbose = qc->ap->ops->error_handler ==NULL ; -u64 block; -memset (sb,0 ,SCSI_SENSE_BUFFERSIZE ); - - cmd->result = (DRIVER_SENSE <<24 ) |SAM_STAT_CHECK_CONDITION ; - -/* sense data is current and format is descriptor */ - sb[0 ] =0x72 ; +set_driver_byte (cmd,DRIVER_SENSE );/* Use ata_to_sense_error() to map status register bits * onto sense key, asc & ascq. */ if (qc->err_mask || tf->command & (ATA_BUSY |ATA_DF |ATA_ERR |ATA_DRQ )) { -ata_to_sense_error (qc->ap->print_id, tf->command, tf->feature, - &sb[1 ], &sb[2 ], &sb[3 ], verbose); - sb[1 ] &=0x0f ; - } +u8 sense_key, asc, ascq; - block =ata_tf_read_block (&qc->result_tf, dev); - -/* information sense data descriptor */ - sb[7 ] =12 ; - desc[0 ] =0x00 ; - desc[1 ] =10 ; +ata_to_sense_error (qc->ap->print_id, tf->command, tf->feature, + &sense_key, &asc, &ascq, verbose); - desc[2 ] |=0x80 ;/* valid */ - desc[6 ] = block >>40 ; - desc[7 ] = block >>32 ; - desc[8 ] = block >>24 ; - desc[9 ] = block >>16 ; - desc[10 ] = block >>8 ; - desc[11 ] = block; +ata_scsi_set_sense (cmd, sense_key, asc, ascq); +ata_scsi_set_sense_information (cmd, &qc->result_tf); + }else +ata_scsi_set_sense (cmd,ABORTED_COMMAND ,0 ,0 ); }static void ata_scsi_sdev_config (struct scsi_device *sdev)
@@ -1797,12 +1778,6 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) }else if (!need_sense) { cmd->result =SAM_STAT_GOOD ; }else { -/* TODO: decide which descriptor format to use -* for 48b LBA devices and call that here -* instead of the fixed desc, which is only -* good for smaller LBA (and maybe CHS?) -* devices. -*/ ata_gen_ata_sense (qc); } }
Signature · 1 line
1.8.5.2
PATCH 3/6 libata: implement ZBC IN translation
In reply to Hannes ReineckeZAC drives implement 'zac management in' command template, which maps onto the ZBC IN command.
--- drivers/ata/libata-eh.c | 1 + drivers/ata/libata-scsi.c | 141 ++++++++++++++++++++++++++++++++++++++++++ include/linux/ata.h | 4 ++ include/scsi/scsi_proto.h | 3 + include/trace/events/libata.h | 1 + 5 files changed, 150 insertions(+)
drivers/ata/libata-eh.c +1 -0
@@ -2492,6 +2492,7 @@ const char *ata_get_cmd_descript(u8 command) { ATA_CMD_CFA_WRITE_MULT_NE, "CFA WRITE MULTIPLE WITHOUT ERASE" }, { ATA_CMD_REQ_SENSE_DATA, "REQUEST SENSE DATA EXT" }, { ATA_CMD_SANITIZE_DEVICE, "SANITIZE DEVICE" }, + { ATA_CMD_ZAC_MGMT_IN, "ZAC MANAGEMENT IN" }, { ATA_CMD_READ_LONG, "READ LONG (with retries)" }, { ATA_CMD_READ_LONG_ONCE, "READ LONG (without retries)" }, { ATA_CMD_WRITE_LONG, "WRITE LONG (with retries)" },
drivers/ata/libata-scsi.c +141 -0
153 lines not on this page · raw message
include/linux/ata.h +4 -0
@@ -301,6 +301,7 @@ enum {ATA_CMD_CFA_WRITE_MULT_NE =0xCD ,ATA_CMD_REQ_SENSE_DATA =0x0B ,ATA_CMD_SANITIZE_DEVICE =0xB4 , +ATA_CMD_ZAC_MGMT_IN =0x4A ,/* marked obsolete in the ATA/ATAPI-7 spec */ ATA_CMD_RESTORE = 0x10,
@@ -309,6 +310,9 @@ enum {ATA_SUBCMD_FPDMA_SEND_DSM =0x00 ,ATA_SUBCMD_FPDMA_SEND_WR_LOG_DMA_EXT =0x02 , +/* Subcmds for ATA_CMD_ZAC_MGMT_IN */ +ATA_SUBCMD_ZAC_MGMT_IN_REPORT_ZONES =0x00 , +/* READ_LOG_EXT pages */ ATA_LOG_SATA_NCQ =0x10 , ATA_LOG_NCQ_SEND_RECV = 0x13,
include/scsi/scsi_proto.h +3 -0
@@ -115,6 +115,7 @@#define VERIFY_16 0x8f#define SYNCHRONIZE_CACHE_16 0x91#define WRITE_SAME_16 0x93 +#define ZBC_IN 0x95#define SERVICE_ACTION_BIDIRECTIONAL 0x9d#define SERVICE_ACTION_IN_16 0x9e#define SERVICE_ACTION_OUT_16 0x9f
@@ -143,6 +144,8 @@#define MO_SET_PRIORITY 0x0e#define MO_SET_TIMESTAMP 0x0f#define MO_MANAGEMENT_PROTOCOL_OUT 0x10 +/* values for ZBC_IN */ +#define ZI_REPORT_ZONES 0x00/* values for variable length command */ #define XDREAD_32 0x03#define XDWRITE_32 0x04
include/trace/events/libata.h +1 -0
@@ -97,6 +97,7 @@ata_opcode_name (ATA_CMD_CFA_WRITE_MULT_NE ), \ata_opcode_name (ATA_CMD_REQ_SENSE_DATA ), \ata_opcode_name (ATA_CMD_SANITIZE_DEVICE ), \ +ata_opcode_name (ATA_CMD_ZAC_MGMT_IN ), \ata_opcode_name (ATA_CMD_RESTORE ), \ata_opcode_name (ATA_CMD_READ_LONG ), \ ata_opcode_name(ATA_CMD_READ_LONG_ONCE), \
Signature · 1 line
1.8.5.2
PATCH 4/6 libata: Implement ZBC OUT translation
In reply to Hannes ReineckeZAC drives implement a 'zac management out' command template, which maps onto the ZBC OUT command.
--- drivers/ata/libata-eh.c | 1 + drivers/ata/libata-scsi.c | 65 +++++++++++++++++++++++++++++++++++++++++++ include/linux/ata.h | 7 +++++ include/scsi/scsi_proto.h | 6 ++++ include/trace/events/libata.h | 1 + 5 files changed, 80 insertions(+)
drivers/ata/libata-eh.c +1 -0
@@ -2493,6 +2493,7 @@ const char *ata_get_cmd_descript(u8 command) { ATA_CMD_REQ_SENSE_DATA, "REQUEST SENSE DATA EXT" }, { ATA_CMD_SANITIZE_DEVICE, "SANITIZE DEVICE" }, { ATA_CMD_ZAC_MGMT_IN, "ZAC MANAGEMENT IN" }, + { ATA_CMD_ZAC_MGMT_OUT, "ZAC MANAGEMENT OUT" }, { ATA_CMD_READ_LONG, "READ LONG (with retries)" }, { ATA_CMD_READ_LONG_ONCE, "READ LONG (without retries)" }, { ATA_CMD_WRITE_LONG, "WRITE LONG (with retries)" },
drivers/ata/libata-scsi.c +65 -0
77 lines not on this page · raw message
include/linux/ata.h +7 -0
@@ -302,6 +302,7 @@ enum {ATA_CMD_REQ_SENSE_DATA =0x0B ,ATA_CMD_SANITIZE_DEVICE =0xB4 ,ATA_CMD_ZAC_MGMT_IN =0x4A , +ATA_CMD_ZAC_MGMT_OUT =0x9F ,/* marked obsolete in the ATA/ATAPI-7 spec */ ATA_CMD_RESTORE = 0x10,
@@ -313,6 +314,12 @@ enum {/* Subcmds for ATA_CMD_ZAC_MGMT_IN */ ATA_SUBCMD_ZAC_MGMT_IN_REPORT_ZONES =0x00 , +/* Subcmds for ATA_CMD_ZAC_MGMT_OUT */ +ATA_SUBCMD_ZAC_MGMT_OUT_CLOSE_ZONE =0x01 , +ATA_SUBCMD_ZAC_MGMT_OUT_FINISH_ZONE =0x02 , +ATA_SUBCMD_ZAC_MGMT_OUT_OPEN_ZONE =0x03 , +ATA_SUBCMD_ZAC_MGMT_OUT_RESET_WRITE_POINTER =0x04 , +/* READ_LOG_EXT pages */ ATA_LOG_SATA_NCQ =0x10 , ATA_LOG_NCQ_SEND_RECV = 0x13,
include/scsi/scsi_proto.h +6 -0
@@ -115,6 +115,7 @@#define VERIFY_16 0x8f#define SYNCHRONIZE_CACHE_16 0x91#define WRITE_SAME_16 0x93 +#define ZBC_OUT 0x94#define ZBC_IN 0x95#define SERVICE_ACTION_BIDIRECTIONAL 0x9d#define SERVICE_ACTION_IN_16 0x9e
@@ -146,6 +147,11 @@#define MO_MANAGEMENT_PROTOCOL_OUT 0x10/* values for ZBC_IN */ #define ZI_REPORT_ZONES 0x00 +/* values for ZBC_OUT */ +#define ZO_CLOSE_ZONE 0x01 +#define ZO_OPEN_ZONE 0x02 +#define ZO_FINISH_ZONE 0x03 +#define ZO_RESET_WRITE_POINTER 0x04/* values for variable length command */ #define XDREAD_32 0x03#define XDWRITE_32 0x04
include/trace/events/libata.h +1 -0
@@ -98,6 +98,7 @@ata_opcode_name (ATA_CMD_REQ_SENSE_DATA ), \ata_opcode_name (ATA_CMD_SANITIZE_DEVICE ), \ata_opcode_name (ATA_CMD_ZAC_MGMT_IN ), \ +ata_opcode_name (ATA_CMD_ZAC_MGMT_OUT ), \ata_opcode_name (ATA_CMD_RESTORE ), \ata_opcode_name (ATA_CMD_READ_LONG ), \ ata_opcode_name(ATA_CMD_READ_LONG_ONCE), \
Signature · 1 line
1.8.5.2
PATCH 5/6 libata: support device-managed ZAC devices
In reply to Hannes ReineckeDevice-managed ZAC devices just set the zoned capabilities field in INQUIRY byte 69 (cf ACS-4). This corresponds to the 'zoned' field in the block device characteristics VPD page.
As this is only defined in SPC-5/SBC-4 we also need to update the supported SCSI version descriptor.
--- drivers/ata/libata-scsi.c | 19 ++++++++++--------- include/linux/ata.h | 5 +++++ 2 files changed, 15 insertions(+), 9 deletions(-)
drivers/ata/libata-scsi.c +10 -9
@@ -1987,14 +1987,14 @@ static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf)0x00 ,0xA0 ,/* SAM-5 (no version claimed) */ -0x04 , -0xC0 ,/* SBC-3 (no version claimed) */ +0x06 , +0x00 ,/* SBC-4 (no version claimed) */ -0x04 , -0x60 ,/* SPC-4 (no version claimed) */ +0x05 , +0xC0 ,/* SPC-5 (no version claimed) */ 0x60 , - 0x20, /* ZBC (no version claimed) */ + 0x22, /* ZBC r02 */ }; u8 hdr[] = {
@@ -2011,10 +2011,8 @@ static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf)if (ata_id_removable (args->id)) hdr[1 ] |= (1 <<7 ); -if (args->dev->class ==ATA_DEV_ZAC ) { +if (args->dev->class ==ATA_DEV_ZAC ) hdr[0 ] =TYPE_ZBC ; - hdr[2 ] =0x6 ;/* ZBC is defined in SPC-4 */ - }memcpy (rbuf, hdr,sizeof (hdr));memcpy (&rbuf[8 ],"ATA " ,8 );
@@ -2028,7 +2026,7 @@ static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf)if (rbuf[32 ] ==0 || rbuf[32 ] ==' ' )memcpy (&rbuf[32 ],"n/a " ,4 ); -if (args->dev->class ==ATA_DEV_ZAC ) +if (ata_id_zoned_cap (args->id) || args->dev->class ==ATA_DEV_ZAC )memcpy (rbuf +58 , versions_zbc,sizeof (versions_zbc));else memcpy (rbuf +58 , versions,sizeof (versions));
@@ -2224,12 +2222,15 @@ static unsigned int ata_scsiop_inq_b1(struct ata_scsi_args *args, u8 *rbuf) {int form_factor =ata_id_form_factor (args->id);int media_rotation_rate =ata_id_rotation_rate (args->id); +u8 zoned =ata_id_zoned_cap (args->id); rbuf[1 ] =0xb1 ; rbuf[3 ] =0x3c ; rbuf[4 ] = media_rotation_rate >>8 ; rbuf[5 ] = media_rotation_rate; rbuf[7 ] = form_factor; +if (zoned) + rbuf[8 ] = (zoned <<4 );return 0 ; }
include/linux/ata.h +5 -0
@@ -900,6 +900,11 @@ static inline bool ata_id_is_ssd(const u16 *id)return id[ATA_ID_ROT_SPEED ] ==0x01 ; } +static inline u8 ata_id_zoned_cap (const u16 *id) +{ +return (id[ATA_ID_ADDITIONAL_SUPP ] &0x3 ); +} +static inline bool ata_id_pio_need_iordy (const u16 *id,const u8 pio) {/* CF spec. r4.1 Table 22 says no IORDY on PIO5 and PIO6. */
Signature · 1 line
1.8.5.2
PATCH 6/6 libata: support host-aware ZAC devices
In reply to Hannes ReineckeByte 69 bits 0:1 in the IDENTIFY DEVICE data indicate a host-aware ZAC device.
And whenever we detect a ZAC-compatible device we should be displaying the zoned block characteristics VPD page.
--- drivers/ata/libata-core.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/ata/libata-scsi.c | 33 +++++++++++++++++++++++++++++-- include/linux/ata.h | 1 + include/linux/libata.h | 7 +++++++ 4 files changed, 89 insertions(+), 2 deletions(-)
drivers/ata/libata-core.c +50 -0
@@ -65,6 +65,7 @@#include <scsi/scsi_host.h> #include <linux/libata.h> #include <asm/byteorder.h> +#include <asm/unaligned.h> #include <linux/cdrom.h> #include <linux/ratelimit.h> #include <linux/pm_runtime.h>
@@ -2165,6 +2166,54 @@ static void ata_dev_config_sense_reporting(struct ata_device *dev) } } +static void ata_dev_config_zac (struct ata_device *dev) +{ +struct ata_port *ap = dev->link->ap; +unsigned int err_mask; +u8 *identify_buf = ap->sector_buf; + + dev->zac_zones_optimal_open = (u32)-1 ; + dev->zac_zones_optimal_nonseq = (u32)-1 ; + dev->zac_zones_max_open = (u32)-1 ; + +/* +* Always set the 'ZAC' flag for Host-managed devices. +*/ +if (dev->class ==ATA_DEV_ZAC ) + dev->flags |=ATA_DFLAG_ZAC ; +else if (ata_id_zoned_cap (dev->id) ==0x01 ) +/* +* Check for host-aware devices. +*/ + dev->flags |=ATA_DFLAG_ZAC ; + +if (!(dev->flags &ATA_DFLAG_ZAC )) +return ; + +/* +* Read IDENTIFY DEVICE data log, page 9 (Zoned-device information) +*/ + err_mask =ata_read_log_page (dev,ATA_LOG_SATA_ID_DEV_DATA , +ATA_LOG_ZONED_INFORMATION , + identify_buf,1 ); +if (!err_mask) { +u64 zoned_cap, opt_open, opt_nonseq, max_open; + + zoned_cap =get_unaligned_le64 (&identify_buf[8 ]); +if ((zoned_cap >>63 )) + dev->zac_zoned_cap = (zoned_cap &1 ); + opt_open =get_unaligned_le64 (&identify_buf[24 ]); +if ((opt_open >>63 )) + dev->zac_zones_optimal_open = (u32 )opt_open; + opt_nonseq =get_unaligned_le64 (&identify_buf[32 ]); +if ((opt_nonseq >>63 )) + dev->zac_zones_optimal_nonseq = (u32 )opt_nonseq; + max_open =get_unaligned_le64 (&identify_buf[40 ]); +if ((max_open >>63 )) + dev->zac_zones_max_open = (u32 )max_open; + } +} +/** * ata_dev_configure - Configure the specified ATA/ATAPI device * @dev: Target device to configure
@@ -2388,6 +2437,7 @@ int ata_dev_configure(struct ata_device *dev) } }ata_dev_config_sense_reporting (dev); +ata_dev_config_zac (dev); dev->cdb_len =16 ; }
drivers/ata/libata-scsi.c +31 -2
@@ -2046,6 +2046,7 @@ static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf)*/ static unsigned int ata_scsiop_inq_00 (struct ata_scsi_args *args,u8 *rbuf) { +int num_pages;const u8 pages[] = {0x00 ,/* page 0x00, this page */ 0x80 ,/* page 0x80, unit serial no page */
@@ -2054,10 +2055,14 @@ static unsigned int ata_scsiop_inq_00(struct ata_scsi_args *args, u8 *rbuf)0xb0 ,/* page 0xb0, block limits page */ 0xb1 ,/* page 0xb1, block device characteristics page */ 0xb2 ,/* page 0xb2, thin provisioning page */ +0xb6 ,/* page 0xb6, zoned block device characteristics */ }; - rbuf[3 ] =sizeof (pages);/* number of supported VPD pages */ -memcpy (rbuf +4 , pages,sizeof (pages)); + num_pages =sizeof (pages); +if (!(args->dev->flags &ATA_DFLAG_ZAC )) + num_pages--; + rbuf[3 ] = num_pages;/* number of supported VPD pages */ +memcpy (rbuf +4 , pages, num_pages);return 0 ; }
@@ -2245,6 +2250,24 @@ static unsigned int ata_scsiop_inq_b2(struct ata_scsi_args *args, u8 *rbuf)return 0 ; } +static unsigned int ata_scsiop_inq_b6 (struct ata_scsi_args *args,u8 *rbuf) +{ +/* +* SCSI Zoned Block device characteristics VPD page: +* ZBC rev 02 or later. +*/ + rbuf[1 ] =0xb6 ; + rbuf[3 ] =0x3C ; + +if (args->dev->zac_zoned_cap &1 ) + rbuf[4 ] |=1 ; +put_unaligned_be32 (args->dev->zac_zones_optimal_open, &rbuf[8 ]); +put_unaligned_be32 (args->dev->zac_zones_optimal_nonseq, &rbuf[12 ]); +put_unaligned_be32 (args->dev->zac_zones_max_open, &rbuf[16 ]); + +return 0 ; +} +/** * ata_scsiop_noop - Command handler that simply returns success. * @args: device IDENTIFY data / SCSI command of interest.
@@ -3793,6 +3816,12 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd)case 0xb2 :ata_scsi_rbuf_fill (&args, ata_scsiop_inq_b2);break ; +case 0xb6 : +if (dev->flags &ATA_DFLAG_ZAC ) { +ata_scsi_rbuf_fill (&args, ata_scsiop_inq_b6); +break ; + } +/* Fallthrough */ default :ata_scsi_invalid_field (cmd);break ;
include/linux/ata.h +1 -0
@@ -325,6 +325,7 @@ enum {ATA_LOG_NCQ_SEND_RECV =0x13 ,ATA_LOG_SATA_ID_DEV_DATA =0x30 ,ATA_LOG_SATA_SETTINGS =0x08 , +ATA_LOG_ZONED_INFORMATION =0x09 ,ATA_LOG_DEVSLP_OFFSET =0x30 ,ATA_LOG_DEVSLP_SIZE =0x08 , ATA_LOG_DEVSLP_MDAT = 0x00,
include/linux/libata.h +7 -0
@@ -180,6 +180,7 @@ enum {ATA_DFLAG_DA = (1 <<26 ),/* device supports Device Attention */ ATA_DFLAG_DEVSLP = (1 <<27 ),/* device supports Device Sleep */ ATA_DFLAG_ACPI_DISABLED = (1 <<28 ),/* ACPI for the device is disabled */ +ATA_DFLAG_ZAC = (1 <<29 ),/* ZAC device */ ATA_DEV_UNKNOWN =0 ,/* unknown device */ ATA_DEV_ATA = 1, /* ATA device */
@@ -724,6 +725,12 @@ struct ata_device {/* NCQ send and receive log subcommand support */ u8 ncq_send_recv_cmds[ATA_LOG_NCQ_SEND_RECV_SIZE ]; +/* ZAC zone configuration */ +u32 zac_zoned_cap; +u32 zac_zones_optimal_open; +u32 zac_zones_optimal_nonseq; +u32 zac_zones_max_open; +/* error history */ int spdn_cnt;/* ering is CLEAR_END, read comment above CLEAR_END */
Signature · 1 line
1.8.5.2
Quoted 9 lines · Hannes Reinecke
Hi all,
here is a patchset for adding ZAC host-aware device support to libata. Main bits are translations for ZBC IN and ZBC OUT; others are the required plumbing like generating the correct VPD pages. James, do you require a separate patch for adding ZBC IN and ZBC OUT or is it okay to have it queued here?
As usual, reviews and comments are welcome.
Can you please give an overview of why we would want this?
Thanks.
Signature · 1 line
tejun
James Bottomley
maintainerQuoted 7 lines · Hannes Reinecke
Hi all,
here is a patchset for adding ZAC host-aware device support to libata. Main bits are translations for ZBC IN and ZBC OUT; others are the required plumbing like generating the correct VPD pages. James, do you require a separate patch for adding ZBC IN and ZBC OUT or is it okay to have it queued here?
This really belongs in the ZBC patch set, doesn't it? Why isn't it there. You can't avoid the dependency. If it goes with the ZAC patch set, then the ZBC one depends on ZAC. If it goes properly with ZBC then you need an additional patch adding the ATA translations after the ZBC one. On the whole, I'd prefer the latter so we always have the required consumers of the API.
In fact, if I read the dependencies correctly, you need the ZBC patches first, don't you ... otherwise there's nothing to drive host aware ZAC?
James
James
Quoted 19 lines
As usual, reviews and comments are welcome.
Hannes Reinecke (6):
libata: Do not retry commands with valid autosense
libata-scsi: useata_scsi_set_sensewhen generating ATA sense
libata: implement ZBC IN translation
libata: Implement ZBC OUT translation
libata: support device-managed ZAC devices
libata: support host-aware ZAC devicesdrivers/ata/libata-core.c | 50 +++++++ drivers/ata/libata-eh.c | 4 + drivers/ata/libata-scsi.c | 299 +++++++++++++++++++++++++++++++++++------- include/linux/ata.h | 17 +++ include/linux/libata.h | 7 + include/scsi/scsi_proto.h | 9 ++ include/trace/events/libata.h | 2 + 7 files changed, 344 insertions(+), 44 deletions(-)
Quoted 16 lines · James Bottomley
Quoted 7 lines · Hannes Reinecke
Hi all,
here is a patchset for adding ZAC host-aware device support to libata. Main bits are translations for ZBC IN and ZBC OUT; others are the required plumbing like generating the correct VPD pages. James, do you require a separate patch for adding ZBC IN and ZBC OUT or is it okay to have it queued here?
This really belongs in the ZBC patch set, doesn't it? Why isn't it there. You can't avoid the dependency. If it goes with the ZAC patch set, then the ZBC one depends on ZAC. If it goes properly with ZBC then you need an additional patch adding the ATA translations after the ZBC one. On the whole, I'd prefer the latter so we always have the required consumers of the API.
Quoted 3 lines
In fact, if I read the dependencies correctly, you need the ZBC patches first, don't you ... otherwise there's nothing to drive host aware ZAC?
No. These patches just implement a proper SATL for ZAC drives. So in effect they just bring libata support on par with 'real' ZBC drives, allowing things like 'sg_rep_zones' to work properly there.
As such I've considered those patches to be a precursor for ZBC support.
But then, I don't mind how it's being handled.
I surely can turn things around, ZBC support first, and ZAC as an add-on to that.
Just say the word.
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
James Bottomley
maintainerQuoted 17 lines · Hannes Reinecke
Quoted 16 lines · James Bottomley
Quoted 7 lines · Hannes Reinecke
Hi all,
here is a patchset for adding ZAC host-aware device support to libata. Main bits are translations for ZBC IN and ZBC OUT; others are the required plumbing like generating the correct VPD pages. James, do you require a separate patch for adding ZBC IN and ZBC OUT or is it okay to have it queued here?
This really belongs in the ZBC patch set, doesn't it? Why isn't it there. You can't avoid the dependency. If it goes with the ZAC patch set, then the ZBC one depends on ZAC. If it goes properly with ZBC then you need an additional patch adding the ATA translations after the ZBC one. On the whole, I'd prefer the latter so we always have the required consumers of the API.
Quoted 6 lines
Quoted 3 lines
In fact, if I read the dependencies correctly, you need the ZBC patches first, don't you ... otherwise there's nothing to drive host aware ZAC?
No. These patches just implement a proper SATL for ZAC drives. So in effect they just bring libata support on par with 'real' ZBC drives, allowing things like '
sg_rep_zones' to work properly there.
But that was my point: the Linux SATL exists to support our ULDs on ATA devices. Until that support exists within SCSI, we don't really need the SATL to support it. You can argue it's for SG_IO, but really, if you're doing user level control of ZAC devices, you'd use ATA commands.
Quoted 6 lines
As such I've considered those patches to be a precursor for ZBC support.
But then, I don't mind how it's being handled.
I surely can turn things around, ZBC support first, and ZAC as an add-on to that.
Just say the word.
Well, um, since there's no ATA ULD, there is no real kernel handling of ZAC devices, so doesn't that mean we have to at least have the reporting done via block and sd before the ATA bits will do anything meaningful?
So to me, this looks very like supporting 512e: agree what parameters block exposes and how userspace uses them, then plumb into block, then SCSI then ATA (i.e. work down the stack, not up).
James