Esempio n. 1
0
int rpc_getattr(int dir_ID, const char *path, struct stat *stbuf)
{
    int ret = 0;
    
    int dir_id = dir_ID; // update root server's bitmap
    struct giga_directory *dir = cache_fetch(&dir_id);
    if (dir == NULL) {
        logMessage(LOG_DEBUG, __func__, "Dir (id=%d) not in cache!", dir_id);
        ret = -EIO;
    }
    
    int server_id = 0;
    giga_getattr_reply_t rpc_reply;

retry:
    server_id = get_server_for_file(dir, path);
    CLIENT *rpc_clnt = getConnection(server_id);

    logMessage(LOG_TRACE, __func__, "RPC_getattr: {%s->srv=%d}", path, server_id);

    if (giga_rpc_getattr_1(dir_id, (char*)path, &rpc_reply, rpc_clnt) 
        != RPC_SUCCESS) {
        logMessage(LOG_FATAL, __func__, "RPC_error: rpc_getattr failed."); 
        clnt_perror(rpc_clnt,"(rpc_getattr failed)");
        exit(1);//TODO: retry again?
    }

    int errnum = rpc_reply.result.errnum;
    if (errnum == -EAGAIN) {
        update_client_mapping(dir, &rpc_reply.result.giga_result_t_u.bitmap); 
        goto retry;
    } else if (errnum < 0) {
        ret = errnum;
    } else {
        *stbuf = rpc_reply.statbuf;
        if (stbuf == NULL)
            logMessage(LOG_DEBUG, __func__, "getattr() stbuf is NULL!");
        ret = errnum;
    }

    logMessage(LOG_TRACE, __func__, "RPC_getattr: STATUS={%s}", strerror(ret));
    
    return ret;
}
Esempio n. 2
0
/** Updates parent_ref to point to the specified child */
static int lookup(PVFS_credentials *credentails, PVFS_object_ref* ref, char* pathname)
{
    int ret = 0, server_id;
	enum clnt_stat retval;
	skye_lookup result;

    if (strlen(pathname) >= MAX_FILENAME_LEN)
        return -ENAMETOOLONG;

    struct skye_directory *dir = cache_fetch(ref);
    if (!dir)
        return -EIO;
    
bitmap: 
    server_id = get_server_for_file(dir, pathname);
    CLIENT *rpc_client = get_connection(server_id);

	retval = skye_rpc_lookup_1(*credentails, *ref, pathname, &result, rpc_client);
	if (retval != RPC_SUCCESS) {
		clnt_perror (rpc_client, "RPC lookup failed");
        ret = -EIO;
        goto exit;
	}

    if (result.errnum == -EAGAIN){
        update_client_mapping(dir, &result.skye_lookup_u.bitmap);
        goto bitmap;
    } else if (result.errnum < 0){
        ret = result.errnum;
        goto exit;
    } else {
        ret = 0;
    }

    /* Giga+: Add a section here for reading out the bitmap */

    memcpy(ref, &result.skye_lookup_u.ref, sizeof(PVFS_object_ref));

 exit:
    cache_return(dir);

    return ret;
}
Esempio n. 3
0
int rpc_init()
{
    int ret = 0;
    int server_id = 0;

    CLIENT *rpc_clnt = getConnection(server_id);
    giga_result_t rpc_reply;
    
    logMessage(LOG_TRACE, __func__, "RPC_init: start.");

    if ((giga_rpc_init_1(giga_options_t.num_servers, &rpc_reply, rpc_clnt)) 
         != RPC_SUCCESS) {
        logMessage(LOG_FATAL, __func__, "RPC_error: rpc_init failed."); 
        clnt_perror(rpc_clnt,"(rpc_init failed)");
        exit(1);//TODO: retry again?
    }

    int errnum = rpc_reply.errnum;
    if (errnum == -EAGAIN) {
        int dir_id = 0; // update root server's bitmap
        struct giga_directory *dir = cache_fetch(&dir_id);
        if (dir == NULL) {
            logMessage(LOG_DEBUG, __func__, "Dir (id=%d) not in cache!", dir_id);
            ret = -EIO;
        }
        else {
            update_client_mapping(dir, &rpc_reply.giga_result_t_u.bitmap); 
            ret = 0;
        }
    } else if (errnum < 0) {
        ret = errnum;
    }

    logMessage(LOG_TRACE, __func__, "RPC_init: done.");

    return ret;
}