Commit 3c8a6228 authored by Andy Grover's avatar Andy Grover Committed by Nicholas Bellinger

target: Unify __core_scsi3_update_aptpl_buf and core_scsi3_update_aptpl_buf

The __ version is only ever called from the regular version, so just
inline it. It's not too much more complex to handle both spinlocks in the
same function.
Signed-off-by: default avatarAndy Grover <agrover@redhat.com>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent 0607decd
...@@ -1828,10 +1828,7 @@ core_scsi3_decode_spec_i_port( ...@@ -1828,10 +1828,7 @@ core_scsi3_decode_spec_i_port(
return ret; return ret;
} }
/* static int core_scsi3_update_aptpl_buf(
* Called with struct se_device->dev_reservation_lock held
*/
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)
...@@ -1842,13 +1839,15 @@ static int __core_scsi3_update_aptpl_buf( ...@@ -1842,13 +1839,15 @@ static int __core_scsi3_update_aptpl_buf(
unsigned char tmp[512], isid_buf[32]; unsigned char tmp[512], isid_buf[32];
ssize_t len = 0; ssize_t len = 0;
int reg_count = 0; int reg_count = 0;
int ret = 0;
memset(buf, 0, pr_aptpl_buf_len); memset(buf, 0, pr_aptpl_buf_len);
spin_lock(&dev->dev_reservation_lock);
spin_lock(&dev->t10_pr.registration_lock);
/* /*
* Walk the registration list.. * Walk the registration list..
*/ */
spin_lock(&dev->t10_pr.registration_lock);
list_for_each_entry(pr_reg, &dev->t10_pr.registration_list, list_for_each_entry(pr_reg, &dev->t10_pr.registration_list,
pr_reg_list) { pr_reg_list) {
...@@ -1894,8 +1893,8 @@ static int __core_scsi3_update_aptpl_buf( ...@@ -1894,8 +1893,8 @@ static int __core_scsi3_update_aptpl_buf(
if ((len + strlen(tmp) >= pr_aptpl_buf_len)) { if ((len + strlen(tmp) >= pr_aptpl_buf_len)) {
pr_err("Unable to update renaming" pr_err("Unable to update renaming"
" APTPL metadata\n"); " APTPL metadata\n");
spin_unlock(&dev->t10_pr.registration_lock); ret = -EMSGSIZE;
return -EMSGSIZE; goto out;
} }
len += sprintf(buf+len, "%s", tmp); len += sprintf(buf+len, "%s", tmp);
...@@ -1912,29 +1911,18 @@ static int __core_scsi3_update_aptpl_buf( ...@@ -1912,29 +1911,18 @@ static int __core_scsi3_update_aptpl_buf(
if ((len + strlen(tmp) >= pr_aptpl_buf_len)) { if ((len + strlen(tmp) >= pr_aptpl_buf_len)) {
pr_err("Unable to update renaming" pr_err("Unable to update renaming"
" APTPL metadata\n"); " APTPL metadata\n");
spin_unlock(&dev->t10_pr.registration_lock); ret = -EMSGSIZE;
return -EMSGSIZE; goto out;
} }
len += sprintf(buf+len, "%s", tmp); len += sprintf(buf+len, "%s", tmp);
reg_count++; reg_count++;
} }
spin_unlock(&dev->t10_pr.registration_lock);
if (!reg_count) if (!reg_count)
len += sprintf(buf+len, "No Registrations or Reservations"); len += sprintf(buf+len, "No Registrations or Reservations");
return 0; out:
} spin_unlock(&dev->t10_pr.registration_lock);
static int core_scsi3_update_aptpl_buf(
struct se_device *dev,
unsigned char *buf,
u32 pr_aptpl_buf_len)
{
int ret;
spin_lock(&dev->dev_reservation_lock);
ret = __core_scsi3_update_aptpl_buf(dev, buf, pr_aptpl_buf_len);
spin_unlock(&dev->dev_reservation_lock); spin_unlock(&dev->dev_reservation_lock);
return ret; return ret;
......
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