Add a missing '\n' if no reservations found. Change update_aptpl_buf to return number of chars written. Signed-off-by: Andy Grover <agrover@xxxxxxxxxx> --- drivers/target/target_core_configfs.c | 2 +- drivers/target/target_core_pr.c | 8 +++++--- drivers/target/target_core_pr.h | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index 0cc5269..bb54617 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c @@ -1203,7 +1203,7 @@ static ssize_t target_core_dev_pr_show_attr_res_aptpl_metadata( if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV) return 0; - return sprintf(page, "Ready to process PR APTPL metadata..\n"); + return core_scsi3_update_aptpl_buf(dev, page, PAGE_SIZE); } enum { diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c index 3f2f740..ac34401 100644 --- a/drivers/target/target_core_pr.c +++ b/drivers/target/target_core_pr.c @@ -1816,7 +1816,8 @@ out: return ret; } -static int core_scsi3_update_aptpl_buf( +/* Returns number of bytes written or -err */ +int core_scsi3_update_aptpl_buf( struct se_device *dev, unsigned char *buf, u32 pr_aptpl_buf_len) @@ -1905,8 +1906,9 @@ static int core_scsi3_update_aptpl_buf( } if (!reg_count) - len += sprintf(buf+len, "No Registrations or Reservations"); + len += sprintf(buf+len, "No Registrations or Reservations\n"); + ret = len; out: spin_unlock(&dev->t10_pr.registration_lock); spin_unlock(&dev->dev_reservation_lock); @@ -1981,7 +1983,7 @@ static int core_scsi3_update_and_write_aptpl(struct se_device *dev, bool aptpl) } ret = __core_scsi3_write_aptpl_to_file(dev, buf); - if (ret != 0) { + if (ret < 0) { pr_err("SPC-3 PR: Could not update APTPL\n"); } else { dev->t10_pr.pr_aptpl_active = 1; diff --git a/drivers/target/target_core_pr.h b/drivers/target/target_core_pr.h index ed75cdd..e6ca2d6 100644 --- a/drivers/target/target_core_pr.h +++ b/drivers/target/target_core_pr.h @@ -60,6 +60,7 @@ extern void core_scsi3_free_pr_reg_from_nacl(struct se_device *, struct se_node_acl *); extern void core_scsi3_free_all_registrations(struct se_device *); extern unsigned char *core_scsi3_pr_dump_type(int); +extern int core_scsi3_update_aptpl_buf(struct se_device *, unsigned char *, u32); extern sense_reason_t target_scsi3_emulate_pr_in(struct se_cmd *); extern sense_reason_t target_scsi3_emulate_pr_out(struct se_cmd *); -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html