[Stgt-devel] [Patch 2/2] Move lu_phy_attr struct into scsi_lu struct.
Mark Harvey
markh794
Wed Jun 13 10:04:31 CEST 2007
Re-arrange lu_phy_attr structure into scsi_lu struct.
Signed-off-by: Mark Harvey <markh794 at gmail.com>
diff --git a/usr/mmc.c b/usr/mmc.c
index a8aced5..0ac5f72 100644
--- a/usr/mmc.c
+++ b/usr/mmc.c
@@ -126,11 +126,11 @@ static int mmc_lu_init(struct scsi_lu *lu)
if (spc_lu_init(lu))
return -ENOMEM;
- memcpy(lu->attrs->product_id, "VIRTUAL-CDROM", 16);
- lu->attrs->sense_format = 0;
- lu->attrs->version_desc[0] = 0x02A0; /* MMC3, no version claimed */
- lu->attrs->version_desc[1] = 0x0960; /* iSCSI */
- lu->attrs->version_desc[2] = 0x0300; /* SPC-3 */
+ memcpy(lu->attrs.product_id, "VIRTUAL-CDROM", 16);
+ lu->attrs.sense_format = 0;
+ lu->attrs.version_desc[0] = 0x02A0; /* MMC3, no version claimed */
+ lu->attrs.version_desc[1] = 0x0960; /* iSCSI */
+ lu->attrs.version_desc[2] = 0x0300; /* SPC-3 */
return 0;
}
diff --git a/usr/osd.c b/usr/osd.c
index ac33168..33d6455 100644
--- a/usr/osd.c
+++ b/usr/osd.c
@@ -56,11 +56,11 @@ static int osd_lu_init(struct scsi_lu *lu)
if (spc_lu_init(lu))
return -ENOMEM;
- memcpy(lu->attrs->product_id, "OSD", 16);
- lu->attrs->sense_format = 1;
- lu->attrs->version_desc[0] = 0x0340; /* OSD */
- lu->attrs->version_desc[1] = 0x0960; /* iSCSI */
- lu->attrs->version_desc[2] = 0x0300; /* SPC-3 */
+ memcpy(lu->attrs.product_id, "OSD", 16);
+ lu->attrs.sense_format = 1;
+ lu->attrs.version_desc[0] = 0x0340; /* OSD */
+ lu->attrs.version_desc[1] = 0x0960; /* iSCSI */
+ lu->attrs.version_desc[2] = 0x0300; /* SPC-3 */
return 0;
}
diff --git a/usr/sbc.c b/usr/sbc.c
index 2924cc6..8fe39e7 100644
--- a/usr/sbc.c
+++ b/usr/sbc.c
@@ -342,10 +342,10 @@ static int sbc_lu_init(struct scsi_lu *lu)
if (spc_lu_init(lu))
return -ENOMEM;
- memcpy(lu->attrs->product_id, "VIRTUAL-DISK", 16);
- lu->attrs->version_desc[0] = 0x04C0; /* SBC-3 no version claimed */
- lu->attrs->version_desc[1] = 0x0960; /* iSCSI */
- lu->attrs->version_desc[2] = 0x0300; /* SPC-3 */
+ memcpy(lu->attrs.product_id, "VIRTUAL-DISK", 16);
+ lu->attrs.version_desc[0] = 0x04C0; /* SBC-3 no version claimed */
+ lu->attrs.version_desc[1] = 0x0960; /* iSCSI */
+ lu->attrs.version_desc[2] = 0x0300; /* SPC-3 */
return 0;
}
diff --git a/usr/scsi.c b/usr/scsi.c
index 50e2080..c9fb7b6 100644
--- a/usr/scsi.c
+++ b/usr/scsi.c
@@ -40,7 +40,7 @@
void sense_data_build(struct scsi_cmd *cmd, uint8_t key, uint8_t asc, uint8_t asq)
{
- if (cmd->dev && cmd->dev->attrs->sense_format) {
+ if (cmd->dev && cmd->dev->attrs.sense_format) {
/* descriptor format */
cmd->sense_buffer[0] = 0x72; /* current, not deferred */
diff --git a/usr/spc.c b/usr/spc.c
index b9f4e16..bf30a16 100644
--- a/usr/spc.c
+++ b/usr/spc.c
@@ -64,19 +64,19 @@ int spc_inquiry(int host_no, struct scsi_cmd *cmd)
uint16_t *desc;
data[0] = device_type;
- data[1] = (cmd->dev->attrs->removable) ? 0x80 : 0;
+ data[1] = (cmd->dev->attrs.removable) ? 0x80 : 0;
data[2] = 5; /* SPC-3 */
data[3] = 0x42;
data[7] = 0x02;
memset(data + 8, 0x20, 28);
- strncpy((char *)data + 8, cmd->dev->attrs->vendor_id, 8);
- strncpy((char *)data + 16, cmd->dev->attrs->product_id, 16);
- strncpy((char *)data + 32, cmd->dev->attrs->product_rev, 4);
+ strncpy((char *)data + 8, cmd->dev->attrs.vendor_id, 8);
+ strncpy((char *)data + 16, cmd->dev->attrs.product_id, 16);
+ strncpy((char *)data + 32, cmd->dev->attrs.product_rev, 4);
desc = (uint16_t *)(data + 58);
- for (i = 0; i < ARRAY_SIZE(cmd->dev->attrs->version_desc); i++)
- *desc++ = __cpu_to_be16(cmd->dev->attrs->version_desc[i]);
+ for (i = 0; i < ARRAY_SIZE(cmd->dev->attrs.version_desc); i++)
+ *desc++ = __cpu_to_be16(cmd->dev->attrs.version_desc[i]);
len = 66;
data[4] = len - 5; /* Additional Length */
@@ -108,12 +108,12 @@ int spc_inquiry(int host_no, struct scsi_cmd *cmd)
len = 4 + SCSI_SN_LEN;
ret = SAM_STAT_GOOD;
- if (cmd->dev && strlen(cmd->dev->attrs->scsi_sn)) {
+ if (cmd->dev && strlen(cmd->dev->attrs.scsi_sn)) {
uint8_t *p;
char *q;
p = data + 4 + tmp - 1;
- q = cmd->dev->attrs->scsi_sn + SCSI_SN_LEN - 1;
+ q = cmd->dev->attrs.scsi_sn + SCSI_SN_LEN - 1;
for (; tmp > 0; tmp--, q)
*(p--) = *(q--);
}
@@ -127,7 +127,7 @@ int spc_inquiry(int host_no, struct scsi_cmd *cmd)
data[7] = tmp;
if (cmd->dev)
strncpy((char *) data + 8,
- cmd->dev->attrs->scsi_id, SCSI_ID_LEN);
+ cmd->dev->attrs.scsi_id, SCSI_ID_LEN);
len = tmp + 8;
ret = SAM_STAT_GOOD;
@@ -322,36 +322,36 @@ int spc_lu_config(struct scsi_lu *lu, char *params) {
token = match_token(p, tokens, args);
switch (token) {
case Opt_scsiid:
- match_strncpy(lu->attrs->scsi_id, &args[0],
- sizeof(lu->attrs->scsi_id) - 1);
+ match_strncpy(lu->attrs.scsi_id, &args[0],
+ sizeof(lu->attrs.scsi_id) - 1);
break;
case Opt_scsisn:
- match_strncpy(lu->attrs->scsi_sn, &args[0],
- sizeof(lu->attrs->scsi_sn) - 1);
+ match_strncpy(lu->attrs.scsi_sn, &args[0],
+ sizeof(lu->attrs.scsi_sn) - 1);
break;
case Opt_vendorid:
- match_strncpy(lu->attrs->vendor_id, &args[0],
- sizeof(lu->attrs->vendor_id));
+ match_strncpy(lu->attrs.vendor_id, &args[0],
+ sizeof(lu->attrs.vendor_id));
break;
case Opt_productid:
- match_strncpy(lu->attrs->product_id, &args[0],
- sizeof(lu->attrs->product_id));
+ match_strncpy(lu->attrs.product_id, &args[0],
+ sizeof(lu->attrs.product_id));
break;
case Opt_productrev:
- match_strncpy(lu->attrs->product_rev, &args[0],
- sizeof(lu->attrs->product_rev));
+ match_strncpy(lu->attrs.product_rev, &args[0],
+ sizeof(lu->attrs.product_rev));
break;
case Opt_sense_format:
match_strncpy(buf, &args[0], sizeof(buf));
- lu->attrs->sense_format = atoi(buf);
+ lu->attrs.sense_format = atoi(buf);
break;
case Opt_removable:
match_strncpy(buf, &args[0], sizeof(buf));
- lu->attrs->removable = atoi(buf);
+ lu->attrs.removable = atoi(buf);
break;
case Opt_online:
match_strncpy(buf, &args[0], sizeof(buf));
- lu->attrs->online = atoi(buf);
+ lu->attrs.online = atoi(buf);
break;
default:
err = TGTADM_INVALID_REQUEST;
@@ -362,16 +362,12 @@ int spc_lu_config(struct scsi_lu *lu, char *params) {
int spc_lu_init(struct scsi_lu *lu)
{
- lu->attrs = zalloc(sizeof(struct lu_phy_attr));
- if (!lu->attrs)
- return -ENOMEM;
-
- memcpy(lu->attrs->vendor_id, VENDOR_ID, 8);
- memcpy(lu->attrs->product_rev, "0001", 4);
- lu->attrs->removable = 0;
- lu->attrs->sense_format = 0;
- lu->attrs->online = 0;
- lu->attrs->reset = 1;
+ memcpy(lu->attrs.vendor_id, VENDOR_ID, 8);
+ memcpy(lu->attrs.product_rev, "0001", 4);
+ lu->attrs.removable = 0;
+ lu->attrs.sense_format = 0;
+ lu->attrs.online = 0;
+ lu->attrs.reset = 1;
return 0;
}
diff --git a/usr/target.c b/usr/target.c
index 5b74be1..9170310 100644
--- a/usr/target.c
+++ b/usr/target.c
@@ -252,9 +252,9 @@ int tgt_device_create(int tid, uint64_t lun, char *args)
err = target->dev_type_template.lu_init(lu);
if (!err) {
- snprintf(lu->attrs->scsi_id, sizeof(lu->attrs->scsi_id),
+ snprintf(lu->attrs.scsi_id, sizeof(lu->attrs.scsi_id),
"deadbeaf%d:%" PRIu64, tid, lun);
- snprintf(lu->attrs->scsi_sn, sizeof(lu->attrs->scsi_sn),
+ snprintf(lu->attrs.scsi_sn, sizeof(lu->attrs.scsi_sn),
"beaf%d%" PRIu64, tid, lun);
}
@@ -1126,8 +1126,8 @@ int tgt_target_show_all(char *buf, int rest)
_TAB3 "Size: %s\n"
_TAB3 "Backing store: %s\n",
lu->lun,
- lu->attrs->scsi_id,
- lu->attrs->scsi_sn,
+ lu->attrs.scsi_id,
+ lu->attrs.scsi_sn,
print_disksize(lu->size),
lu->path);
diff --git a/usr/tgtd.h b/usr/tgtd.h
index 35645b1..addd5a0 100644
--- a/usr/tgtd.h
+++ b/usr/tgtd.h
@@ -63,7 +63,7 @@ struct scsi_lu {
uint64_t reserve_id;
/* TODO: needs a structure for lots of device parameters */
- struct lu_phy_attr *attrs;
+ struct lu_phy_attr attrs;
};
struct scsi_cmd {
More information about the stgt
mailing list