Skip to content

Commit

Permalink
open-osd: osd-target: OSD2r05 draft support
Browse files Browse the repository at this point in the history
* OSD CDB Size and some elements have changed.
  Must of the changes did not really affected OSC's code since they where
  mostly in capabilities and data signatures, which are ignored by current
  implementation. So what changed is only the total size
* OSD_CRYPTO_KEYID_SIZE grew from 20 bytes to 32 bytes
  This affected some attribute pages layout and functions API. The different
  arrays where hard coded 20, define an OSD_CRYPTO_KEYID_SIZE and use that
  everywhere.

  - Since now osd-util/osd-defs.h must be included by osd-target/osd-types.h
    because of OSD_CRYPTO_KEYID_SIZE above. All files that included both are
    fixed to only include the later.

* Attributes-list-element header changed
  Attributes-list-element header is now 6 bytes bigger and all attributes-list
  values are 8 bytes aliened. This is actually what caused most of the changes.

* Bump up the Product level and revision to reflect new target wire
  format (Fix handling off)

After this patch the OSC's OSD2 target is wire compatible to latest OSD2 draft
revision 5. There are no more expected wire changes to OSD2 standard.

PLEASE NOTE:
  This target version will not longer work with OSC's osd-initiator. For
  Latest target the still supports osd-initiator, one needs to:

  []$ git checkout CDB_VER_OSD2r01

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
  • Loading branch information
Boaz Harrosh committed Apr 16, 2009
1 parent 7bb16ac commit 94de663
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 37 deletions.
1 change: 0 additions & 1 deletion osd-target/attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <sys/stat.h>

#include "osd-types.h"
#include "osd-util/osd-defs.h"
#include "db.h"
#include "attr.h"
#include "osd-util/osd-util.h"
Expand Down
9 changes: 4 additions & 5 deletions osd-target/cdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

#include "osd.h"
#include "osd-util/osd-sense.h"
#include "osd-util/osd-defs.h"
#include "target-sense.h"
#include "cdb.h"
#include "osd-util/osd-util.h"
Expand Down Expand Up @@ -312,15 +311,15 @@ static int set_attr_list(struct command *cmd, uint64_t pid, uint64_t oid,

list_hdr = &list_hdr[8]; /* XXX: osd errata */
while (list_len > 0) {
uint32_t page = get_ntohl(&list_hdr[0]);
uint32_t number = get_ntohl(&list_hdr[4]);
uint32_t len = get_ntohs(&list_hdr[8]);
uint32_t page = get_ntohl(&list_hdr[LE_PAGE_OFF]);
uint32_t number = get_ntohl(&list_hdr[LE_NUMBER_OFF]);
uint32_t len = get_ntohs(&list_hdr[LE_LEN_OFF]);
uint32_t pad = 0;

/* set attr on multiple objects if that is the case */
for (i = oid; i < oid+numoid; i++) {
ret = osd_set_attributes(cmd->osd, pid, i, page,
number, &list_hdr[10], len,
number, &list_hdr[LE_VAL_OFF], len,
isembedded, cdb_cont_len, cmd->sense);
if (ret != 0) {
cmd->senselen = ret;
Expand Down
1 change: 0 additions & 1 deletion osd-target/coll.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <sys/stat.h>

#include "osd-types.h"
#include "osd-util/osd-defs.h"
#include "db.h"
#include "coll.h"
#include "osd-util/osd-util.h"
Expand Down
1 change: 0 additions & 1 deletion osd-target/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <sys/stat.h>
#include <assert.h>

#include "osd-util/osd-defs.h"
#include "osd-types.h"
#include "osd.h"
#include "db.h"
Expand Down
1 change: 0 additions & 1 deletion osd-target/list-entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <assert.h>
#include <string.h>

#include "osd-util/osd-defs.h"
#include "osd.h"
#include "list-entry.h"
#include "osd-util/osd-util.h"
Expand Down
1 change: 0 additions & 1 deletion osd-target/mtq.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <sys/stat.h>

#include "osd-types.h"
#include "osd-util/osd-defs.h"
#include "db.h"
#include "obj.h"
#include "attr.h"
Expand Down
2 changes: 0 additions & 2 deletions osd-target/obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#include <sqlite3.h>
#include <assert.h>

#include "osd-types.h"
#include "osd-util/osd-defs.h"
#include "osd.h"
#include "osd-util/osd-util.h"
#include "obj.h"
Expand Down
7 changes: 5 additions & 2 deletions osd-target/osd-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <stddef.h>
#include <sqlite3.h>

#include "osd-util/osd-defs.h"

struct getattr_list_entry {
uint32_t page;
uint32_t number;
Expand All @@ -36,6 +38,7 @@ struct getattr_list_entry {
struct list_entry {
uint32_t page;
uint32_t number;
uint8_t reserved[6];
uint16_t len;
union {
void *val;
Expand All @@ -48,7 +51,7 @@ enum {
LE_NUMBER_OFF = offsetof(struct list_entry, number),
LE_LEN_OFF = offsetof(struct list_entry, len),
LE_VAL_OFF = offsetof(struct list_entry, val),
LE_MIN_ITEM_LEN = (LE_VAL_OFF + 0x7) & ~0x7
LE_MIN_ITEM_LEN = LE_VAL_OFF,
};

struct multiobj_list_entry {
Expand Down Expand Up @@ -105,7 +108,7 @@ struct setattr_list {

struct __attribute__((packed)) cur_cmd_attr_pg {
uint16_t cdb_srvc_act; /* current cmd */
uint8_t ricv[20]; /* response integrity check value */
uint8_t ricv[OSD_CRYPTO_KEYID_SIZE]; /* response integrity check value */
uint8_t obj_type;
uint8_t reserved[3];
uint64_t pid;
Expand Down
15 changes: 7 additions & 8 deletions osd-target/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <linux/fs.h>

#include "osd.h"
#include "osd-util/osd-defs.h"
#include "target-sense.h"
#include "db.h"
#include "attr.h"
Expand Down Expand Up @@ -700,25 +699,25 @@ static int get_riap(struct osd_device *osd, uint64_t pid, uint64_t oid,
val = "\xf1\x81\x00\x0eOSC OSDEMU\x00\x00";
break;
case RIAP_VENDOR_IDENTIFICATION:
len = 4;
len = sizeof("OSC");
val = "OSC";
break;
case RIAP_PRODUCT_IDENTIFICATION:
len = 8;
val = "OSDEMU ";
len = sizeof("OSDEMU");
val = "OSDEMU";
break;
case RIAP_PRODUCT_MODEL:
len = 5;
val = "9002";
len = sizeof("OSD2r05");
val = "OSD2r05";
break;
case RIAP_PRODUCT_REVISION_LEVEL:
len = RIAP_PRODUCT_REVISION_LEVEL_LEN;
set_htonl(ll, 117);
val = ll;
break;
case RIAP_PRODUCT_SERIAL_NUMBER:
len = 2;
val = "1";
len = sizeof("2");
val = "2";
break;
case RIAP_TOTAL_CAPACITY:
/*FIXME: return capacity of osd->root device*/
Expand Down
3 changes: 2 additions & 1 deletion osd-target/osd.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ int osd_set_attributes(struct osd_device *osd, uint64_t pid, uint64_t oid,
uint32_t page, uint32_t number, const void *val,
uint16_t len, uint8_t cmd_type, uint32_t cdb_cont_len, uint8_t *sense);
int osd_set_key(struct osd_device *osd, int key_to_set, uint64_t pid,
uint64_t key, uint8_t seed[20], uint8_t *sense);
uint64_t key, uint8_t seed[OSD_CRYPTO_KEYID_SIZE],
uint8_t *sense);
int osd_set_master_key(struct osd_device *osd, int dh_step, uint64_t key,
uint32_t param_len, uint32_t alloc_len,
uint8_t *outdata, uint64_t *outlen, uint32_t cdb_cont_len, uint8_t *sense);
Expand Down
1 change: 0 additions & 1 deletion osd-target/tests/cdb-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "osd-types.h"
#include "osd.h"
#include "cdb.h"
#include "osd-util/osd-defs.h"
#include "osd-util/osd-util.h"
#include "osd-util/osd-sense.h"
#include "osd-initiator/command.h"
Expand Down
2 changes: 0 additions & 2 deletions osd-target/tests/db-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
#include <string.h>
#include <assert.h>

#include "osd-util/osd-defs.h"
#include "osd-types.h"
#include "osd.h"
#include "db.h"
#include "attr.h"
Expand Down
2 changes: 0 additions & 2 deletions osd-target/tests/osd-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#include <sys/stat.h>
#include <unistd.h>

#include "osd-util/osd-defs.h"
#include "osd-types.h"
#include "osd.h"
#include "db.h"
#include "attr.h"
Expand Down
1 change: 0 additions & 1 deletion osd-target/tests/time-db.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <string.h>
#include <assert.h>

#include "osd-util/osd-defs.h"
#include "osd-types.h"
#include "osd.h"
#include "db.h"
Expand Down
18 changes: 10 additions & 8 deletions osd-util/osd-defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
* Shared defitions for OSD target and initiator.
*/
#define VARLEN_CDB 0x7f
#define OSD_CDB_SIZE 200
#define OSD_CDB_SIZE 236
#define OSD_MAX_SENSE 252
#define OSD_CRYPTO_KEYID_SIZE 32
#define OSD_SYS_ID_SIZE 20

/* varlen cdb service actions for osd2r01 */
#define OSD_APPEND 0x8887
Expand Down Expand Up @@ -210,19 +212,19 @@ enum {
CCAP_APPADDR = 0x5,

/* lengths of the items */
CCAP_RICV_LEN = 20,
CCAP_RICV_LEN = OSD_CRYPTO_KEYID_SIZE,
CCAP_OBJT_LEN = 1,
CCAP_PID_LEN = 8,
CCAP_OID_LEN = 8,
CCAP_APPADDR_LEN = 8,

/* offsets when retrieved in page format (page num and len at 0) */
CCAP_RICV_OFF = 8,
CCAP_OBJT_OFF = 28,
CCAP_PID_OFF = 32,
CCAP_OID_OFF = 40,
CCAP_APPADDR_OFF = 48,
CCAP_TOTAL_LEN = 56,
CCAP_OBJT_OFF = 28+12,
CCAP_PID_OFF = 32+12,
CCAP_OID_OFF = 40+12,
CCAP_APPADDR_OFF = 48+12,
CCAP_TOTAL_LEN = 56+12,
};

/* userobject timestamp attribute page osd2r01 sec 7.1.2.18 */
Expand Down Expand Up @@ -282,7 +284,7 @@ enum {
RIAP_CLOCK = 0x100, /* 6 */

/* lengths */
RIAP_OSD_SYSTEM_ID_LEN = 20,
RIAP_OSD_SYSTEM_ID_LEN = OSD_SYS_ID_SIZE,
RIAP_VENDOR_IDENTIFICATION_LEN = 8,
RIAP_PRODUCT_IDENTIFICATION_LEN = 16,
RIAP_PRODUCT_MODEL_LEN = 32,
Expand Down

0 comments on commit 94de663

Please sign in to comment.