コード例 #1
0
ファイル: pvfs2-showcoll.c プロジェクト: Goon83/SALB
static int print_dspaces(TROVE_coll_id coll_id,
			 TROVE_handle root_handle,
                         TROVE_context_id trove_context,
			 int no_root_handle)
{
    int ret, count;
    TROVE_ds_position pos;
    TROVE_handle harray[64];
    TROVE_op_id op_id;
    TROVE_ds_state state;

    pos = TROVE_ITERATE_START;
    count = 64;

    while (count > 0) {
	int opcount;

	ret = trove_dspace_iterate_handles(coll_id,
					   &pos,
					   harray,
					   &count,
					   0 /* flags */,
					   NULL /* vtag */,
					   NULL /* user ptr */,
                                           trove_context,
					   &op_id);
	while (ret == 0) ret = trove_dspace_test(
            coll_id, op_id, trove_context, &opcount, NULL, NULL, &state,
            TROVE_DEFAULT_TEST_TIMEOUT);
	if (ret != 1) return -1;

	if (count > 0) {
	    int i;
	    for (i = 0; i < count; i++) {
		ret = print_dspace(coll_id, harray[i], trove_context);
	    }
	}
    }

    return 0;
}
コード例 #2
0
ファイル: trove-handle-mgmt.c プロジェクト: snsl/pvfs2-osd
/* trove_check_handle_ranges:
 *  internal function to verify that handles
 *  on disk match our assigned handles.
 *  this function is *very* expensive.
 *
 * coll_id: id of collection which we will verify
 * extent_list: llist of legal handle ranges/extents
 * ledger: a book-keeping ledger object
 *
 * returns 0 on success; -1 otherwise
 */
static int trove_check_handle_ranges(TROVE_coll_id coll_id,
                                     TROVE_context_id context_id,
                                     PINT_llist *extent_list,
                                     struct handle_ledger *ledger)
{
    int ret = -1, i = 0, count = 0, op_count = 0;
    TROVE_op_id op_id = 0;
    TROVE_ds_state state = 0;
    TROVE_ds_position pos = TROVE_ITERATE_START;
    static TROVE_handle handles[MAX_NUM_VERIFY_HANDLE_COUNT] =
        {TROVE_HANDLE_NULL};

    if (extent_list && ledger)
    {
        count = MAX_NUM_VERIFY_HANDLE_COUNT;

        while(count > 0)
        {
            ret = trove_dspace_iterate_handles(coll_id,&pos,handles,
                                               &count,0,NULL,NULL,
                                               context_id,&op_id);
            while(ret == 0)
            {
                ret = trove_dspace_test(coll_id,op_id,context_id,
                                        &op_count,NULL,NULL,&state,
                                        TROVE_DEFAULT_TEST_TIMEOUT);
            }

            /* check result of testing */
            if (ret < 0)
            {
                gossip_debug(GOSSIP_TROVE_DEBUG,
                             "dspace test of iterate_handles failed\n");
                return ret;
            }

            ret = 0;

            /* also check result of actual operation, in this case,
             * trove_dspace_iterate_handles
             */
            if(state < 0)
            {
                gossip_debug(GOSSIP_TROVE_DEBUG,
                             "trove_dspace_iterate_handles failed\n");
                return state;
            }

            /* look for special case of a blank fs */
            if ((count == 1) && (handles[0] == 0))
            {
                gossip_debug(GOSSIP_TROVE_DEBUG,
                             "* Trove: Assuming a blank filesystem\n");
                return ret;
            }

            if (count > 0)
            {
                for(i = 0; i != count; i++)
                {
                    /* check every item in our range list */
                    if (!PINT_handle_in_extent_list(extent_list,
                                                    handles[i]))
                    {
                        gossip_err(
                            "Error: handle %llu is invalid "
                            "(out of bounds)\n", llu(handles[i]));
                        return -1;
                    }

		    /* remove handle from trove-handle-mgmt */
		    ret = trove_handle_remove(ledger, handles[i]);
		    if (ret != 0)
                    {
			gossip_err(
                            "WARNING: could not remove "
                            "handle %llu from ledger; continuing.\n", llu(handles[i]));
		    }
                }
                ret = ((i == count) ? 0 : -1);
            }
        }
    }
    return ret;
}