Skip to content

Commit

Permalink
osd-target: Process attributes in OSD_FORNAT
Browse files Browse the repository at this point in the history
Set/Get attributes are perfectly valid while formatting an osd-lun,
directed to the osd root object. Call attribute processing also
in OSD_FORMAT.

Print to log output that osd_name was changed. This is an important
global attribute that identifies the osd-device on the network.

Fix the attribute-page name.

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
  • Loading branch information
Boaz Harrosh committed Oct 19, 2009
1 parent 531b08c commit 73105a3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
5 changes: 4 additions & 1 deletion osd-target/cdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1397,7 +1397,10 @@ static void exec_service_action(struct command *cmd)
case OSD_FORMAT_OSD: {
uint64_t capacity = get_ntohll(&cdb[32]);
ret = osd_format_osd(osd, capacity, cdb_cont_len, sense);
/* TODO: what is corresponding get/set attr? */

if (ret == OSD_OK)
ret = std_get_set_attr(cmd, 0, 0, cdb_cont_len);

break;
}
case OSD_GET_ATTRIBUTES: {
Expand Down
21 changes: 17 additions & 4 deletions osd-target/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
#include "osd-util/osd-sense.h"
#include "list-entry.h"

#define min(x,y) ({ \
typeof(x) _x = (x); \
typeof(y) _y = (y); \
(void) (&_x == &_y); \
_x < _y ? _x : _y; })

#ifdef __MAKE_BSD_BUILD__
static int os_sync_file_range(int fd, __off64_t offset, __off64_t bytes,
unsigned int flags)
Expand Down Expand Up @@ -691,7 +697,7 @@ static int get_riap(struct osd_device *osd, uint64_t pid, uint64_t oid,
case 0:
/*{ROOT_PG + 1, 0, "INCITS T10 Root Information"},*/
len = ATTR_PAGE_ID_LEN;
sprintf(name, "INCITS T10 User Object Information");
sprintf(name, "INCITS T10 Root Information");
val = name;
break;
case RIAP_OSD_SYSTEM_ID:
Expand Down Expand Up @@ -787,10 +793,17 @@ static int set_riap(struct osd_device *osd, uint64_t pid, uint64_t oid,
default:
return OSD_ERROR;

case RIAP_OSD_NAME:
return attr_set_attr(osd->dbc, pid, oid, ROOT_INFO_PG,
RIAP_OSD_NAME, val, len);

case RIAP_OSD_NAME: {
char osdname[64];

snprintf(osdname, min((uint16_t)64U, len), "%s",
(const char *)val);
osd_info("RIAP_OSD_NAME [%s]\n", osdname);

return attr_set_attr(osd->dbc, 0, 0, ROOT_INFO_PG,
RIAP_OSD_NAME, val, len);
}
case RIAP_CLOCK:
/* FIXME: Save an offset from current time.
return time + offset */
Expand Down

0 comments on commit 73105a3

Please sign in to comment.