Skip to content

Commit

Permalink
Fixes to make the tests work - mainly to bring them up to OSD2r05
Browse files Browse the repository at this point in the history
  • Loading branch information
joc02012 committed May 26, 2012
1 parent 25b4f83 commit c6dbc75
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 58 deletions.
2 changes: 2 additions & 0 deletions osd-target/cdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

struct cdb_continuation_descriptor {
uint16_t type;
uint8_t reserved;
uint8_t pad_length;
uint32_t length;
union {
struct sg_list sglist;
Expand Down
8 changes: 5 additions & 3 deletions osd-target/osd-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@ enum {
MLE_MIN_ITEM_LEN = (LE_VAL_OFF + 0x7) & ~0x7
};

/* osd2r00 Section 7.1.3.1 tab 127 */
/* osd2r02 Section 7.1.3.1 tab 153 */
enum {
RTRV_ATTR_LIST = 0x01,
RTRVD_SET_ATTR_LIST = 0x09,
RTRVD_CREATE_MULTIOBJ_LIST = 0x0F
RTRVD_MULTIOBJ_LIST = 0x0E, /* added in osd2r02 */
RTRVD_CREATE_MULTIOBJ_LIST = 0x0F /* made obsolete in osd2r02 */
};

/*
Expand Down Expand Up @@ -245,7 +246,8 @@ struct copy_user_object_source {
struct cdb_continuation_descriptor_header {
uint16_t type;
uint8_t reserved;
uint8_t pad_length;
uint8_t reserved2:5;
uint8_t pad_length:3;
uint32_t length;
};

Expand Down
8 changes: 4 additions & 4 deletions osd-target/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ static int empty_dir(const char *dirname)
return 0;
}

static inline void get_dfile_name(char *path, const char *root,
uint64_t pid, uint64_t oid)
inline void get_dfile_name(char *path, const char *root,
uint64_t pid, uint64_t oid)
{
#ifdef PVFS_OSD_INTEGRATED
/* go look in PVFS bstreams for file data (eventually) */
Expand Down Expand Up @@ -2532,7 +2532,7 @@ int osd_list(struct osd_device *osd, uint8_t list_attr, uint64_t pid,
add_len = (uint64_t) -1;
set_htonll(outdata, add_len);
set_htonll(&outdata[8], cont_id);
osd_error("%s: add_len=%llu cont_id=0x%llx", __func__, add_len, cont_id);
osd_info("%s: add_len=%llu cont_id=0x%llx", __func__, add_len, cont_id);
} else if (list_attr == 1 && get_attr->sz != 0 && pid != 0) {
if (list_id)
initial_oid = cont_id;
Expand Down Expand Up @@ -2956,7 +2956,7 @@ static int contig_read(struct osd_device *osd, uint64_t pid, uint64_t oid,
pid, oid, readlen);
}

*used_outlen = len;
*used_outlen = readlen;

fill_ccap(&osd->ccap, NULL, USEROBJECT, pid, oid, 0);
return ret;
Expand Down
3 changes: 3 additions & 0 deletions osd-target/osd.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,7 @@ static inline uint64_t osd_get_created_oid(struct osd_device *osd,
return oid;
}

inline void get_dfile_name(char *path, const char *root,
uint64_t pid, uint64_t oid);

#endif /* __OSD_H */
18 changes: 9 additions & 9 deletions osd-target/tests/cdb-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ void test_query(struct osd_device *osd)

qll = MINQLISTLEN;
memset(buf, 0, 1024);
ret = osd_command_set_query(&cmd, pid, cid, qll, 4096);
ret = osd_command_set_query(&cmd, pid, cid, qll, 4096, 0);
assert(ret == 0);
ret = osdemu_cmd_submit(osd, cmd.cdb, buf, qll, &matches,
&matchlen, sense_out, &senselen_out);
Expand All @@ -628,7 +628,7 @@ void test_query(struct osd_device *osd)
set_qce(&cp[4], page, 2, 0, NULL, 0, NULL);
qll += 4 + (4+4+4+2+2);

ret = osd_command_set_query(&cmd, pid, cid, qll, 4096);
ret = osd_command_set_query(&cmd, pid, cid, qll, 4096, 0);
assert(ret == 0);
ret = osdemu_cmd_submit(osd, cmd.cdb, buf, qll, &matches,
&matchlen, sense_out, &senselen_out);
Expand All @@ -655,7 +655,7 @@ void test_query(struct osd_device *osd)
set_qce(&cp[4], page, 1, sizeof(min), &min, sizeof(max), &max);
qll += 4 + (4+4+4+2+sizeof(min)+2+sizeof(max));

ret = osd_command_set_query(&cmd, pid, cid, qll, 4096);
ret = osd_command_set_query(&cmd, pid, cid, qll, 4096, 0);
assert(ret == 0);
ret = osdemu_cmd_submit(osd, cmd.cdb, buf, qll, &matches,
&matchlen, sense_out, &senselen_out);
Expand Down Expand Up @@ -693,7 +693,7 @@ void test_query(struct osd_device *osd)
qll += (4+4+4+2+sizeof(min)+2+sizeof(max));
cp += (4+4+4+2+sizeof(min)+2+sizeof(max));

ret = osd_command_set_query(&cmd, pid, cid, qll, 4096);
ret = osd_command_set_query(&cmd, pid, cid, qll, 4096, 0);
assert(ret == 0);
ret = osdemu_cmd_submit(osd, cmd.cdb, buf, qll, &matches,
&matchlen, sense_out, &senselen_out);
Expand Down Expand Up @@ -729,7 +729,7 @@ void test_query(struct osd_device *osd)
qll += (4+4+4+2+sizeof(min)+2+sizeof(max));
cp += (4+4+4+2+sizeof(min)+2+sizeof(max));

ret = osd_command_set_query(&cmd, pid, cid, qll, 4096);
ret = osd_command_set_query(&cmd, pid, cid, qll, 4096, 0);
assert(ret == 0);
ret = osdemu_cmd_submit(osd, cmd.cdb, buf, qll, &matches,
&matchlen, sense_out, &senselen_out);
Expand Down Expand Up @@ -771,7 +771,7 @@ void test_query(struct osd_device *osd)
qll += (4+4+4+2+0+2+sizeof(max));
cp += (4+4+4+2+0+2+sizeof(max));

ret = osd_command_set_query(&cmd, pid, cid, qll, 4096);
ret = osd_command_set_query(&cmd, pid, cid, qll, 4096, 0);
assert(ret == 0);
ret = osdemu_cmd_submit(osd, cmd.cdb, buf, qll, &matches,
&matchlen, sense_out, &senselen_out);
Expand Down Expand Up @@ -822,7 +822,7 @@ void test_query(struct osd_device *osd)
qll += (4+4+4+2+2+2+5);
cp += (4+4+4+2+2+2+5);

ret = osd_command_set_query(&cmd, pid, cid, qll, 4096);
ret = osd_command_set_query(&cmd, pid, cid, qll, 4096, 0);
assert(ret == 0);
ret = osdemu_cmd_submit(osd, cmd.cdb, buf, qll, &matches,
&matchlen, sense_out, &senselen_out);
Expand Down Expand Up @@ -862,7 +862,7 @@ void test_query(struct osd_device *osd)
qll += (4+4+4+2+0+2+6);
cp += (4+4+4+2+0+2+6);

ret = osd_command_set_query(&cmd, pid, cid, qll, 4096);
ret = osd_command_set_query(&cmd, pid, cid, qll, 4096, 0);
assert(ret == 0);
ret = osdemu_cmd_submit(osd, cmd.cdb, buf, qll, &matches,
&matchlen, sense_out, &senselen_out);
Expand Down Expand Up @@ -894,7 +894,7 @@ void test_query(struct osd_device *osd)
qll += (4+4+4+2+sizeof(min)+2+sizeof(max));
cp += (4+4+4+2+sizeof(min)+2+sizeof(max));

ret = osd_command_set_query(&cmd, pid, cid, qll, 4096);
ret = osd_command_set_query(&cmd, pid, cid, qll, 4096, 0);
assert(ret == 0);
ret = osdemu_cmd_submit(osd, cmd.cdb, buf, qll, &matches,
&matchlen, sense_out, &senselen_out);
Expand Down
28 changes: 15 additions & 13 deletions osd-target/tests/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,15 @@ int osd_command_set_punch(struct osd_command *command, uint64_t pid,
}

int osd_command_set_query(struct osd_command *command, uint64_t pid,
uint64_t cid, uint32_t query_len, uint64_t alloc_len)
uint64_t cid, uint32_t cont_len, uint64_t alloc_len,
uint64_t matches_cid)
{
varlen_cdb_init(command, OSD_QUERY);
set_htonll(&command->cdb[16], pid);
set_htonll(&command->cdb[24], cid);
set_htonl(&command->cdb[48], query_len);
set_htonll(&command->cdb[32], alloc_len);
set_htonll(&command->cdb[40], matches_cid);
set_htonl(&command->cdb[48], cont_len);
return 0;
}

Expand Down Expand Up @@ -552,7 +554,7 @@ int osd_command_attr_build(struct osd_command *command,
for (i=0; i<numattr; i++) {
if (attr[i].type == ATTR_GET) {
++numget;
getsize += roundup8(10 + attr[i].len);
getsize += roundup8(16 + attr[i].len);
} else if (attr[i].type == ATTR_GET_PAGE) {
++numgetpage;
getpagesize += attr[i].len; /* no round */
Expand All @@ -562,10 +564,10 @@ int osd_command_attr_build(struct osd_command *command,
} else if (attr[i].type == ATTR_SET) {
++numset;
setattr_index = i;
setsize += roundup8(10 + attr[i].len);
setsize += roundup8(16 + attr[i].len);
} else if (attr[i].type == ATTR_RESULT) {
++numresult;
resultsize += roundup8(10 + attr[i].len);
resultsize += roundup8(16 + attr[i].len);
} else {
osd_error("%s: invalid attribute type %d", __func__,
attr[i].type);
Expand Down Expand Up @@ -838,9 +840,9 @@ int osd_command_attr_build(struct osd_command *command,
continue;
set_htonl(&q[0], attr[i].page);
set_htonl(&q[4], attr[i].number);
set_htons(&q[8], attr[i].len);
memcpy(&q[10], attr[i].val, attr[i].len);
len = 10 + attr[i].len;
set_htons(&q[14], attr[i].len);
memcpy(&q[16], attr[i].val, attr[i].len);
len = 16 + attr[i].len;
q += len;
while (len & 7) {
*q++ = 0;
Expand Down Expand Up @@ -1085,17 +1087,17 @@ int osd_command_attr_resolve(struct osd_command *command)
uint16_t item_len, pad;
uint16_t avail_len;

if (len < 10u + 8 * !!numgetmulti)
if (len < 16u + 8 * !!numgetmulti)
break;
if (numgetmulti) {
oid = get_ntohll(&p[0]);
p += 8;
}
page = get_ntohl(&p[0]);
number = get_ntohl(&p[4]);
item_len = get_ntohs(&p[8]);
p += 10;
len -= 10;
item_len = get_ntohs(&p[14]);
p += 16;
len -= 16;

for (i=0; i<numattr; i++) {
if (!(attr[i].type == ATTR_GET
Expand Down Expand Up @@ -1146,7 +1148,7 @@ int osd_command_attr_resolve(struct osd_command *command)
if (item_len == 0xffff)
item_len = 0;

pad = roundup8(10 + item_len) - (10 + item_len);
pad = roundup8(16 + item_len) - (16 + item_len);
if (item_len + pad >= len)
break;

Expand Down
3 changes: 2 additions & 1 deletion osd-target/tests/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ int osd_command_set_perform_task_mgmt_func(struct osd_command *command);
int osd_command_set_punch(struct osd_command *command, uint64_t pid,
uint64_t oid, uint64_t len, uint64_t offset);
int osd_command_set_query(struct osd_command *command, uint64_t pid,
uint64_t cid, uint32_t query_len, uint64_t alloc_len);
uint64_t cid, uint32_t cont_len, uint64_t alloc_len,
uint64_t matches_cid);
int osd_command_set_read(struct osd_command *command, uint64_t pid,
uint64_t oid, uint64_t len, uint64_t offset);
int osd_command_set_read_map(struct osd_command*command, uint64_t pid, uint64_t oid,
Expand Down
4 changes: 2 additions & 2 deletions osd-target/tests/db-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,15 @@ static void test_dir_page(struct osd_device *osd)
assert(j == (uint32_t)i);
len = get_ntohs(&cp[LE_LEN_OFF]);
assert(len == 40);
cp += 10;
cp += 16;
if (i == 1 || i == 2)
assert(strcmp((char *)cp, uid) == 0);
else if (i == 3)
assert(strcmp((char *)cp, pg3) == 0);
else if (i == 4)
assert(strcmp((char *)cp, pg4) == 0);
cp += len;
pad = (0x8 - ((10+len) & 0x7)) & 0x7;
pad = (0x8 - ((16+len) & 0x7)) & 0x7;
while (pad--)
assert(*cp == 0), cp++;
}
Expand Down
32 changes: 25 additions & 7 deletions osd-target/tests/osd-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ static void test_osd_clear(struct osd_device *osd)
ret=stat(path, &sb);
assert(ret == 0 && sb.st_size == (long)strlen(wrbuf)+6);

ret = osd_remove(osd, USEROBJECT_PID_LB, USEROBJECT_OID_LB, cdb_cont_len, sense);
assert(ret == 0);

ret = osd_remove_partition(osd, PARTITION_PID_LB, cdb_cont_len, sense);
assert(ret == 0);

free(sense);
free(wrbuf);

Expand Down Expand Up @@ -273,6 +279,12 @@ static void test_osd_punch(struct osd_device *osd)
ret = stat(path, &sb);
assert(ret == 0 && sb.st_size == (long)strlen(wrbuf)+1-8);

ret = osd_remove(osd, USEROBJECT_PID_LB, USEROBJECT_OID_LB, cdb_cont_len, sense);
assert(ret == 0);

ret = osd_remove_partition(osd, PARTITION_PID_LB, cdb_cont_len, sense);
assert(ret == 0);

free(sense);
free(wrbuf);
}
Expand Down Expand Up @@ -315,6 +327,12 @@ static void test_osd_flush(struct osd_device *osd)
ret = osd_flush(osd, USEROBJECT_PID_LB, USEROBJECT_OID_LB, 20, 10, 2, cdb_cont_len, sense);
assert(ret == 0);

ret = osd_remove(osd, USEROBJECT_PID_LB, USEROBJECT_OID_LB, cdb_cont_len, sense);
assert(ret == 0);

ret = osd_remove_partition(osd, PARTITION_PID_LB, cdb_cont_len, sense);
assert(ret == 0);

free(sense);
free(wrbuf);
}
Expand Down Expand Up @@ -660,7 +678,7 @@ static void test_osd_get_attributes(struct osd_device *osd)
assert(get_ntohl(&le->page) == USER_INFO_PG);
assert(get_ntohl(&le->number) == UIAP_LOGICAL_LEN);
assert(get_ntohs(&le->len) == UIAP_LOGICAL_LEN_LEN);
assert(get_ntohll(le + LE_VAL_OFF) == strlen(val)+1);
assert(get_ntohll(&le->val) == strlen(val)+1);
len = LE_VAL_OFF + UIAP_LOGICAL_LEN_LEN;
len += (0x8 - (len & 0x7)) & 0x7;
assert(used_len == len);
Expand Down Expand Up @@ -1060,8 +1078,8 @@ static void check_results(void *ml, uint64_t *idlist, uint64_t sz,
{
uint8_t *cp = ml;
uint32_t add_len = get_ntohll(&cp[0]);
assert(add_len == (5+8*sz));
assert(cp[12] == (0x21 << 2));
assert(add_len == (5+sz*sizeof(uint64_t)));
assert((cp[12]&0xfc) == (0x21 << 2));
assert(usedlen == add_len+8);
add_len -= 5;
cp += MIN_ML_LEN;
Expand Down Expand Up @@ -1428,14 +1446,14 @@ int main()
ret = osd_open(root, &osd);
assert(ret == 0);

test_osd_format(&osd);
test_osd_create_partition(&osd);
test_osd_create(&osd);
test_osd_io(&osd);
test_osd_clear(&osd);
test_osd_punch(&osd);
test_osd_flush(&osd);
test_osd_format(&osd);
test_osd_create(&osd);
test_osd_set_attributes(&osd);
test_osd_io(&osd);
test_osd_create_partition(&osd);
test_osd_get_attributes(&osd);
test_osd_get_ccap(&osd);
test_osd_get_utsap(&osd);
Expand Down
Loading

0 comments on commit c6dbc75

Please sign in to comment.