Commit 0607decd authored by Andy Grover's avatar Andy Grover Committed by Nicholas Bellinger

target: Simplify metadata handling when clearing aptpl metadata

Simpler to just set buf in update_and_write_aptpl(), rather than passing
down to ____core_scsi3_update_aptpl_buf().
Signed-off-by: default avatarAndy Grover <agrover@redhat.com>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent 1f070cc2
...@@ -1834,8 +1834,7 @@ core_scsi3_decode_spec_i_port( ...@@ -1834,8 +1834,7 @@ core_scsi3_decode_spec_i_port(
static int __core_scsi3_update_aptpl_buf( static int __core_scsi3_update_aptpl_buf(
struct se_device *dev, struct se_device *dev,
unsigned char *buf, unsigned char *buf,
u32 pr_aptpl_buf_len, u32 pr_aptpl_buf_len)
int clear_aptpl_metadata)
{ {
struct se_lun *lun; struct se_lun *lun;
struct se_portal_group *tpg; struct se_portal_group *tpg;
...@@ -1845,14 +1844,7 @@ static int __core_scsi3_update_aptpl_buf( ...@@ -1845,14 +1844,7 @@ static int __core_scsi3_update_aptpl_buf(
int reg_count = 0; int reg_count = 0;
memset(buf, 0, pr_aptpl_buf_len); memset(buf, 0, pr_aptpl_buf_len);
/*
* Called to clear metadata once APTPL has been deactivated.
*/
if (clear_aptpl_metadata) {
snprintf(buf, pr_aptpl_buf_len,
"No Registrations or Reservations\n");
return 0;
}
/* /*
* Walk the registration list.. * Walk the registration list..
*/ */
...@@ -1937,14 +1929,12 @@ static int __core_scsi3_update_aptpl_buf( ...@@ -1937,14 +1929,12 @@ static int __core_scsi3_update_aptpl_buf(
static int core_scsi3_update_aptpl_buf( static int core_scsi3_update_aptpl_buf(
struct se_device *dev, struct se_device *dev,
unsigned char *buf, unsigned char *buf,
u32 pr_aptpl_buf_len, u32 pr_aptpl_buf_len)
int clear_aptpl_metadata)
{ {
int ret; int ret;
spin_lock(&dev->dev_reservation_lock); spin_lock(&dev->dev_reservation_lock);
ret = __core_scsi3_update_aptpl_buf(dev, buf, pr_aptpl_buf_len, ret = __core_scsi3_update_aptpl_buf(dev, buf, pr_aptpl_buf_len);
clear_aptpl_metadata);
spin_unlock(&dev->dev_reservation_lock); spin_unlock(&dev->dev_reservation_lock);
return ret; return ret;
...@@ -1997,32 +1987,21 @@ core_scsi3_update_and_write_aptpl(struct se_device *dev, unsigned char *in_buf, ...@@ -1997,32 +1987,21 @@ core_scsi3_update_and_write_aptpl(struct se_device *dev, unsigned char *in_buf,
u32 in_pr_aptpl_buf_len) u32 in_pr_aptpl_buf_len)
{ {
unsigned char null_buf[64], *buf; unsigned char null_buf[64], *buf;
u32 pr_aptpl_buf_len;
int clear_aptpl_metadata = 0;
int ret; int ret;
/* /*
* Can be called with a NULL pointer from PROUT service action CLEAR * Can be called with a NULL pointer from PROUT service action CLEAR
*/ */
if (!in_buf) { if (!in_buf) {
memset(null_buf, 0, 64); snprintf(null_buf, 64, "No Registrations or Reservations\n");
buf = &null_buf[0]; buf = null_buf;
/*
* This will clear the APTPL metadata to:
* "No Registrations or Reservations" status
*/
pr_aptpl_buf_len = 64;
clear_aptpl_metadata = 1;
} else { } else {
ret = core_scsi3_update_aptpl_buf(dev, in_buf, in_pr_aptpl_buf_len);
if (ret != 0)
return ret;
buf = in_buf; buf = in_buf;
pr_aptpl_buf_len = in_pr_aptpl_buf_len;
} }
ret = core_scsi3_update_aptpl_buf(dev, buf, pr_aptpl_buf_len,
clear_aptpl_metadata);
if (ret != 0)
return ret;
/* /*
* __core_scsi3_write_aptpl_to_file() will call strlen() * __core_scsi3_write_aptpl_to_file() will call strlen()
* on the passed buf to determine pr_aptpl_buf_len. * on the passed buf to determine pr_aptpl_buf_len.
......
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