Skip to content

Commit

Permalink
osd-target: extension: Let in a system_ID set on LUN format
Browse files Browse the repository at this point in the history
system_ID is a, factory set, unique identifier of an osd-lun.
Since osd-target is a software solution we should enable
a system administrator setting of the system_id.

The solution proposed here is to let a system_id attribute-
set while an OSD_FORMAT is preformed on the osd-lun. Rational
is: since we are initializing a new backing storage to host
the osd-lun we can at this time set it's name, and by that
lock it permanently until a new format initializes a new osd.

Thous, regular osd utilities can be used to set the system_id
and no special command line or config files magic is needed.

The system_id set can be up to RIAP_OSD_SYSTEM_ID_LEN bytes in
size, and if smaller is zero left-padded.

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
  • Loading branch information
Boaz Harrosh committed Oct 19, 2009
1 parent 73105a3 commit 3e92d24
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions osd-target/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,8 +701,15 @@ static int get_riap(struct osd_device *osd, uint64_t pid, uint64_t oid,
val = name;
break;
case RIAP_OSD_SYSTEM_ID:
len = RIAP_OSD_SYSTEM_ID_LEN;
val = "\xf1\x81\x00\x0eOSC OSDEMU\x00\x00";
ret = attr_get_attr(osd->dbc, pid, oid, ROOT_INFO_PG,
RIAP_OSD_SYSTEM_ID_LEN, outlen, outbuf,
listfmt, used_outlen);
if (ret == -ENOENT) {
len = RIAP_OSD_SYSTEM_ID_LEN;
val = "\xf1\x81\x00\x0eOSC OSDEMU\x00\x00";
} else {
return ret;
}
break;
case RIAP_VENDOR_IDENTIFICATION:
len = sizeof("OSC");
Expand Down Expand Up @@ -781,7 +788,6 @@ static int set_riap(struct osd_device *osd, uint64_t pid, uint64_t oid,
{
switch (number) {
/* read only */
case RIAP_OSD_SYSTEM_ID:
case RIAP_VENDOR_IDENTIFICATION:
case RIAP_PRODUCT_IDENTIFICATION:
case RIAP_PRODUCT_MODEL:
Expand All @@ -793,6 +799,27 @@ static int set_riap(struct osd_device *osd, uint64_t pid, uint64_t oid,
default:
return OSD_ERROR;

/* osd-target extension: We let in a system_ID set on LUN
* format command.
*/
case RIAP_OSD_SYSTEM_ID:
if (osd->ccap.cdb_srvc_act == OSD_FORMAT_OSD) {
char system_id[RIAP_OSD_SYSTEM_ID_LEN];

if (len > RIAP_OSD_SYSTEM_ID_LEN)
return -EINVAL;

if (len < RIAP_OSD_SYSTEM_ID_LEN) {
memcpy(system_id, val, len);
memset(system_id + len, 0,
RIAP_OSD_SYSTEM_ID_LEN - len);
val = system_id;
}
return attr_set_attr(osd->dbc, 0, 0, ROOT_INFO_PG,
RIAP_OSD_SYSTEM_ID, val,
RIAP_OSD_SYSTEM_ID_LEN);
} else
return OSD_ERROR;

case RIAP_OSD_NAME: {
char osdname[64];
Expand Down

0 comments on commit 3e92d24

Please sign in to comment.