[Gs-commits] r604 - in trunk/code/src/gsl/resources/storage: . osd-target test
Author: carns Date: 2009-07-01 09:40:49 -0500 (Wed, 01 Jul 2009) New Revision: 604 Modified: trunk/code/src/gsl/resources/storage/gs-storage.c trunk/code/src/gsl/resources/storage/gs-storage.gsh trunk/code/src/gsl/resources/storage/osd-target/gs-osd.c trunk/code/src/gsl/resources/storage/osd-target/gs-osd.h trunk/code/src/gsl/resources/storage/test/storage1.gs Log: setattr list operation; works only in polling mode right now for some reason Modified: trunk/code/src/gsl/resources/storage/gs-storage.c =================================================================== --- trunk/code/src/gsl/resources/storage/gs-storage.c 2009-06-29 19:29:26 UTC (rev 603) +++ trunk/code/src/gsl/resources/storage/gs-storage.c 2009-07-01 14:40:49 UTC (rev 604) @@ -35,6 +35,14 @@ struct remove_op{ uint64_t oid; } remove; + struct setattr_list_op{ + uint64_t oid; + int count; + const uint32_t* page_array; + const uint32_t* number_array; + const void** val_array; + const int* len_array; + } setattr_list; } u; gs_op_id_t op_id; struct gs_op op; @@ -85,6 +93,31 @@ return(1); } +/* setattr_list_op_worker() + * + * sets multiple attributes on an object + */ +static int setattr_list_op_worker(struct gs_op* op) +{ + struct storage_op *sto_op; + + sto_op = gs_op_entry(op, struct storage_op, op); + assert(sto_op); + + gs_mutex_lock(&osd_mutex); + + sto_op->error_code = gs_osd_setattr_list(&osd, GS_OSD_PARTITION, + sto_op->u.setattr_list.oid, + sto_op->u.setattr_list.count, + sto_op->u.setattr_list.page_array, + sto_op->u.setattr_list.number_array, + sto_op->u.setattr_list.val_array, + sto_op->u.setattr_list.len_array); + + gs_mutex_unlock(&osd_mutex); + + return(1); +} static void* thread_fn(void* foo) { struct gs_op* op = foo; @@ -214,6 +247,47 @@ return 0; } +gs_ret_t gs_storage_setattr_list_post( + uint64_t oid, + int count, + const uint32_t* page_array, + const uint32_t* number_array, + const void** val_array, + const int* len_array, + void (*callback)(void *ptr, int ret), + void *user_ptr, + gs_hints_t hints, + gs_context_t ctx, + gs_op_id_t *op_id) +{ + struct gs_op *op; + struct storage_op *sto_op; + + op = gs_opcache_get(storage_opcache); + gs_op_fill(op, callback, user_ptr, hints, ctx); + + sto_op = gs_op_entry(op, struct storage_op, op); + sto_op->op_id = gs_id_gen(gs_storage_resource_id, (uint64_t)(op->cache_id)); + sto_op->u.setattr_list.oid = oid; + sto_op->u.setattr_list.count = count; + sto_op->u.setattr_list.page_array = page_array; + sto_op->u.setattr_list.number_array = number_array; + sto_op->u.setattr_list.val_array = val_array; + sto_op->u.setattr_list.len_array = len_array; + + *op_id = sto_op->op_id; + + /* TODO: put this in the fill function if we keep it? */ + op->op_worker = setattr_list_op_worker; + + gs_storage_launch_op(op, gs_storage_progress_mode); + + return 0; + + return(0); +} + + static int gs_storage_poll(gs_context_t context, int millisecs) { struct gs_op *gop; Modified: trunk/code/src/gsl/resources/storage/gs-storage.gsh =================================================================== --- trunk/code/src/gsl/resources/storage/gs-storage.gsh 2009-06-29 19:29:26 UTC (rev 603) +++ trunk/code/src/gsl/resources/storage/gs-storage.gsh 2009-07-01 14:40:49 UTC (rev 604) @@ -63,12 +63,34 @@ /** * Removes an object + * \return 0 on success, -errno on failure */ __blocking int gs_storage_remove( - uint64_t oid); /**< identifier to remove */ + uint64_t oid); /**< identifier of object to remove */ +/** + * Sets an array of 1 or more attributes on a single object + * \return 0 on success, -errno if any attributes fail + */ +__blocking int gs_storage_setattr_list( uint64_t oid, int count, const uint32_t* page_array, const uint32_t* number_array, const void** val_array, const int* len_array); + +#if 0 +/** + * Sets an array of 1 or more attributes on a single object + * \return 0 on success, -errno if any attributes fail + */ +__blocking int gs_storage_setattr_list( + uint64_t oid, /**< object to operate on */ + int count, /**< number of attrs to set */ + const uint32_t* page_array, /**< array of attr pages */ + const uint32_t* number_array, /**< array of attr numbers */ + const void** val_array, /**< array of attr values */ + const int* len_array /**< array of attr value lengths */ +); #endif +#endif + /* @} */ /* Modified: trunk/code/src/gsl/resources/storage/osd-target/gs-osd.c =================================================================== --- trunk/code/src/gsl/resources/storage/osd-target/gs-osd.c 2009-06-29 19:29:26 UTC (rev 603) +++ trunk/code/src/gsl/resources/storage/osd-target/gs-osd.c 2009-07-01 14:40:49 UTC (rev 604) @@ -154,6 +154,43 @@ return(ret); } +int gs_osd_setattr_list(struct osd_device *osd, uint64_t pid, uint64_t oid, + int count, const uint32_t* page_array, const uint32_t* number_array, + const void** val_array, const int* len_array) +{ + int ret; + uint8_t sense[OSD_MAX_SENSE]; + uint16_t newlen = 0; + int i; + + /* check attribute value sizes up front */ + for(i=0; i<count; i++) + { + if(len_array[i] > ATTR_LEN_UB) + { + return(-EINVAL); + } + } + + /* service each set attr separately */ + for(i=0; i<count; i++) + { + newlen = 0; + newlen += len_array[i]; + + ret = osd_set_attributes(osd, pid, oid, page_array[i], + number_array[i], val_array[i], len_array[i], + 1, 0, sense); + if(ret != OSD_OK) + { + ret = gs_sense_to_errno(sense); + break; + } + } + + return(ret); +} + /* * Local variables: * c-indent-level: 4 Modified: trunk/code/src/gsl/resources/storage/osd-target/gs-osd.h =================================================================== --- trunk/code/src/gsl/resources/storage/osd-target/gs-osd.h 2009-06-29 19:29:26 UTC (rev 603) +++ trunk/code/src/gsl/resources/storage/osd-target/gs-osd.h 2009-07-01 14:40:49 UTC (rev 604) @@ -14,6 +14,9 @@ int gs_osd_create(struct osd_device *osd, uint64_t pid, uint64_t requested_oid, uint64_t* out_oid); int gs_osd_remove(struct osd_device *osd, uint64_t pid, uint64_t oid); +int gs_osd_setattr_list(struct osd_device *osd, uint64_t pid, uint64_t oid, + int count, const uint32_t* page_array, const uint32_t* number_array, + const void** val_array, const int* len_array); #define gs_osd_open osd_open #define gs_osd_close osd_close Modified: trunk/code/src/gsl/resources/storage/test/storage1.gs =================================================================== --- trunk/code/src/gsl/resources/storage/test/storage1.gs 2009-06-29 19:29:26 UTC (rev 603) +++ trunk/code/src/gsl/resources/storage/test/storage1.gs 2009-07-01 14:40:49 UTC (rev 604) @@ -28,6 +28,11 @@ { int ret1, ret2, ret3; uint64_t out_oid1, out_oid2, out_oid3; + uint32_t page = 5; + uint32_t number = 1; + char *test = "foo"; + const void* val = test; + int len = 4; pwait { @@ -41,6 +46,14 @@ pbreak; } + ret1 = gs_storage_setattr_list(OID1, 1, &page, &number, + &val, &len); + if(ret1 != 0) + { + printf("Error settattr on oid=%llu: %d\n", llu(OID1), ret1); + pbreak; + } + ret1 = gs_storage_remove(OID1); if(ret1 != 0) {
participants (1)
-
carns@mcs.anl.gov