Opal: Add clean response buffer process

For nvme Opal, most of the commands are a combination
of security send and receive. There are cases that
application send the security send command and is
shutdown before sending security receive command.
In these cases, when the application restarts, an opal
command will send security send command again and will
cause command sequence error.

Thus, we do a receive first and memset the response
buffer before security send and receive.

Change-Id: Iba02c8074457919816ca576cd00ef9eee6d6dadf
Signed-off-by: Chunyang Hui <chunyang.hui@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/472591
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: yidong0635 <dongx.yi@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Chunyang Hui 2019-10-24 18:14:19 +08:00 committed by Tomasz Zawadzki
parent f1d0fc75cf
commit 2938dc14b0

View File

@ -55,6 +55,23 @@ opal_error_to_human(int error)
return spdk_opal_errors[error];
}
static int
opal_flush_response_buffer(struct spdk_opal_dev *dev)
{
void *response = dev->resp;
int ret = 0;
ret = spdk_nvme_ctrlr_security_receive(dev->dev_handler, SPDK_SCSI_SECP_TCG, dev->comid,
0, response, IO_BUFFER_LENGTH);
if (ret) {
SPDK_ERRLOG("Security Receive Error on dev = %p\n", dev);
return ret;
}
memset(response, 0, IO_BUFFER_LENGTH);
return 0;
}
static int
opal_send_cmd(struct spdk_opal_dev *dev)
{
@ -104,6 +121,11 @@ opal_send_recv(struct spdk_opal_dev *dev, spdk_opal_cb cb, void *data)
{
int ret;
ret = opal_flush_response_buffer(dev);
if (ret) {
return ret;
}
ret = opal_send_cmd(dev);
if (ret) {
return ret;