From c6dbc752c6789f884f8a26cf073f0dcf45e7bb90 Mon Sep 17 00:00:00 2001 From: "John A. Chandy" Date: Sat, 26 May 2012 08:16:51 -0400 Subject: [PATCH] Fixes to make the tests work - mainly to bring them up to OSD2r05 --- osd-target/cdb.c | 2 ++ osd-target/osd-types.h | 8 +++++--- osd-target/osd.c | 8 ++++---- osd-target/osd.h | 3 +++ osd-target/tests/cdb-test.c | 18 ++++++++-------- osd-target/tests/command.c | 28 +++++++++++++------------ osd-target/tests/command.h | 3 ++- osd-target/tests/db-test.c | 4 ++-- osd-target/tests/osd-test.c | 32 ++++++++++++++++++++++------- osd-target/tests/query.c | 41 +++++++++++++++++++++++-------------- osd-target/tests/time-db.c | 8 ++++---- 11 files changed, 97 insertions(+), 58 deletions(-) diff --git a/osd-target/cdb.c b/osd-target/cdb.c index 3eaec33..d9ea231 100644 --- a/osd-target/cdb.c +++ b/osd-target/cdb.c @@ -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; diff --git a/osd-target/osd-types.h b/osd-target/osd-types.h index 65285f4..1a10661 100644 --- a/osd-target/osd-types.h +++ b/osd-target/osd-types.h @@ -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 */ }; /* @@ -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; }; diff --git a/osd-target/osd.c b/osd-target/osd.c index 6e280a5..5f49387 100644 --- a/osd-target/osd.c +++ b/osd-target/osd.c @@ -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) */ @@ -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; @@ -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; diff --git a/osd-target/osd.h b/osd-target/osd.h index 84df6d2..c297075 100644 --- a/osd-target/osd.h +++ b/osd-target/osd.h @@ -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 */ diff --git a/osd-target/tests/cdb-test.c b/osd-target/tests/cdb-test.c index 4ce42cd..4971570 100644 --- a/osd-target/tests/cdb-test.c +++ b/osd-target/tests/cdb-test.c @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); diff --git a/osd-target/tests/command.c b/osd-target/tests/command.c index c0a5820..ae3a7d0 100644 --- a/osd-target/tests/command.c +++ b/osd-target/tests/command.c @@ -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; } @@ -552,7 +554,7 @@ int osd_command_attr_build(struct osd_command *command, for (i=0; i= len) break; diff --git a/osd-target/tests/command.h b/osd-target/tests/command.h index 296a115..115f893 100644 --- a/osd-target/tests/command.h +++ b/osd-target/tests/command.h @@ -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, diff --git a/osd-target/tests/db-test.c b/osd-target/tests/db-test.c index 82fee27..2ecdb02 100644 --- a/osd-target/tests/db-test.c +++ b/osd-target/tests/db-test.c @@ -254,7 +254,7 @@ 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) @@ -262,7 +262,7 @@ static void test_dir_page(struct osd_device *osd) 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++; } diff --git a/osd-target/tests/osd-test.c b/osd-target/tests/osd-test.c index 369df3e..15ee427 100644 --- a/osd-target/tests/osd-test.c +++ b/osd-target/tests/osd-test.c @@ -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); @@ -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); } @@ -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); } @@ -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); @@ -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; @@ -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); diff --git a/osd-target/tests/query.c b/osd-target/tests/query.c index a8c5071..18da781 100644 --- a/osd-target/tests/query.c +++ b/osd-target/tests/query.c @@ -36,11 +36,11 @@ static void query_speed(struct osd_device *osd, int numiter, int numobj, double *v; uint64_t pid = PARTITION_PID_LB; uint64_t cid = COLLECTION_OID_LB; - uint8_t *results, *query; + uint8_t *results, *query, *cont; double mu, sd; struct attribute_list *attr; uint8_t *attr_val_lo, *attr_val_match, *attr_val_nomatch, *attr_val_hi; - uint64_t alloc_len, query_len, criterion_len; + uint64_t alloc_len, query_len, criterion_len, cont_len; uint8_t cidn[8], *cp; if (numobj_in_coll > numobj) @@ -111,17 +111,28 @@ static void query_speed(struct osd_device *osd, int numiter, int numobj, osd_command_attr_free(&c); } + /* build up continuation */ criterion_len = 12 + 2 + ATTR_LEN + 2 + ATTR_LEN; - if (numcriteria == 0) - query_len = 8; /* special case, just one empty criterion */ - else - query_len = 4 + numcriteria * criterion_len; - query = Malloc(query_len); - if (!query) + /* add 8 for continuation descriptor header, 4 for query header, and + 4 for padding */ + query_len = 8 + 4 + numcriteria * criterion_len + 4; + + cont_len = query_len + 40; /* continuation header is 40 bytes */ + cont = Malloc(cont_len); + if (!cont) return; - memset(query, 0, query_len); - query[0] = 1; /* intersection */ - cp = query + 4; + memset(cont, 0, cont_len); + cont[0] = 1; /* CDB continuation format */ + set_htons(&cont[2], OSD_QUERY); + /* need to set continuation integrity check value */ + + query = cont + 40; + set_htons(query, QUERY_LIST); + query[3] = 4; /* pad length */ + set_htonl(query+4, query_len-8); + query[8] = 1; /* intersection */ + + cp = query + 12; for (i=0; i] [-p ]" " [-a numattr] [-i ]" - " \n\t\t [-t ]\n\n", osd_get_progname()); - fprintf(stderr, "Option -t takes following values:\n"); + " \n\t\t-t \n\n", osd_get_progname()); + fprintf(stderr, "timing-test takes following values:\n"); fprintf(stderr, "%16s: cumulative time for numobj insert in coll\n", "collinsert"); fprintf(stderr, "%16s: cumulative time for numobj delete in coll\n",