コード例 #1
0
ファイル: ncache.c プロジェクト: snsl/pvfs2-osd
/**
 * Enables perf counter instrumentation of the ncache
 */
void PINT_ncache_enable_perf_counter(
    struct PINT_perf_counter* pc)     /**< perf counter instance to use */
{
    gen_mutex_lock(&ncache_mutex);

    ncache_pc = pc;
    assert(ncache_pc);

    /* set initial values */
    PINT_perf_count(ncache_pc, PERF_NCACHE_SOFT_LIMIT,
        ncache->soft_limit, PINT_PERF_SET);
    PINT_perf_count(ncache_pc, PERF_NCACHE_HARD_LIMIT,
        ncache->hard_limit, PINT_PERF_SET);
    PINT_perf_count(ncache_pc, PERF_NCACHE_ENABLED,
        ncache->enable, PINT_PERF_SET);

    gen_mutex_unlock(&ncache_mutex);

    return;
}
コード例 #2
0
ファイル: ncache.c プロジェクト: snsl/pvfs2-osd
/**
 * Sets optional parameters in the ncache
 * @see PINT_tcache_options
 * @return 0 on success, -PVFS_error on failure
 */
int PINT_ncache_set_info(
    enum PINT_ncache_options option, /**< option to modify */
    unsigned int arg)                /**< input value */
{
    int ret = -1;
  
    gen_mutex_lock(&ncache_mutex);
    ret = PINT_tcache_set_info(ncache, option, arg);

    /* record any resulting parameter changes */
    PINT_perf_count(ncache_pc, PERF_NCACHE_SOFT_LIMIT,
        ncache->soft_limit, PINT_PERF_SET);
    PINT_perf_count(ncache_pc, PERF_NCACHE_HARD_LIMIT,
        ncache->hard_limit, PINT_PERF_SET);
    PINT_perf_count(ncache_pc, PERF_NCACHE_ENABLED,
        ncache->enable, PINT_PERF_SET);
    PINT_perf_count(ncache_pc, PERF_NCACHE_NUM_ENTRIES,
        ncache->num_entries, PINT_PERF_SET);

    gen_mutex_unlock(&ncache_mutex);

    return(ret);
}
コード例 #3
0
ファイル: ncache.c プロジェクト: snsl/pvfs2-osd
/**
 * Invalidates a cache entry (if present)
 */
void PINT_ncache_invalidate(
    const char* entry,                  /**< path of obect */
    const PVFS_object_ref* parent_ref)  /**< Parent of PVFS2 object */
{
    int ret = -1;
    struct PINT_tcache_entry* tmp_entry;
    struct ncache_key entry_key;
    int tmp_status;
  
    gossip_debug(GOSSIP_NCACHE_DEBUG, "ncache: invalidate(): entry=%s\n",
                 entry);
  
    gen_mutex_lock(&ncache_mutex);
  
    entry_key.entry_name = entry;
    entry_key.parent_ref.handle = parent_ref->handle;
    entry_key.parent_ref.fs_id = parent_ref->fs_id;

    /* find out if the entry is in the cache */
    ret = PINT_tcache_lookup(ncache, 
                             &entry_key,
                             &tmp_entry,
                             &tmp_status);
    if(ret == 0)
    {
        PINT_tcache_delete(ncache, tmp_entry);
        PINT_perf_count(ncache_pc, PERF_NCACHE_DELETIONS, 1,
                        PINT_PERF_ADD);
    }

    PINT_perf_count(ncache_pc, PERF_NCACHE_NUM_ENTRIES,
                    ncache->num_entries, PINT_PERF_SET);

    gen_mutex_unlock(&ncache_mutex);
    return;
}
コード例 #4
0
ファイル: prelude.c プロジェクト: Goon83/SALB
/* prelude_req_sched()
 *
 * posts a request scheduler job
 */
static PINT_sm_action prelude_req_sched(
        struct PINT_smcb *smcb, job_status_s *js_p)
{
    struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
    int ret = -PVFS_EINVAL;

    gossip_debug(GOSSIP_SERVER_DEBUG,
        "(%p) %s (prelude sm) state: req_sched\n", s_op,
        PINT_map_server_op_to_string(s_op->req->op));

    PINT_ACCESS_DEBUG(s_op, GOSSIP_ACCESS_DETAIL_DEBUG, "request\n");

    ret = job_req_sched_post(s_op->op, s_op->target_fs_id, s_op->target_handle,
                             s_op->access_type, s_op->sched_policy,
                             smcb, 0, js_p,
                             &(s_op->scheduled_id), server_job_context);

    PINT_perf_count(PINT_server_pc, PINT_PERF_REQSCHED, 1, PINT_PERF_ADD);
    return ret;
}
コード例 #5
0
ファイル: ncache.c プロジェクト: snsl/pvfs2-osd
/** 
 * Adds a name to the cache, or updates it if already present.  
 * The given name is _copied_ into the cache.   
 *
 * \note NOTE: All previous information for the object will be discarded,
 * even if there is still time remaining before it expires.
 *
 * \return 0 on success, -PVFS_error on failure
 */
int PINT_ncache_update(
    const char* entry,                     /**< entry to update */
    const PVFS_object_ref* entry_ref,      /**< entry ref to update */
    const PVFS_object_ref* parent_ref)     /**< parent ref to update */
{
    int ret = -1;
    struct PINT_tcache_entry* tmp_entry;
    struct ncache_payload* tmp_payload;
    struct ncache_key entry_key;
    int status;
    int purged;
    unsigned int enabled;

    /* skip out immediately if the cache is disabled */
    PINT_tcache_get_info(ncache, TCACHE_ENABLE, &enabled);
    if(!enabled)
    {
        return(0);
    }
    
    gossip_debug(GOSSIP_NCACHE_DEBUG, "ncache: update(): name [%s]\n",entry);
  
    if(!entry_ref->handle)
    {
        return(-PVFS_EINVAL);
    }
  
    /* create new payload with updated information */
    tmp_payload = (struct ncache_payload*) 
                        calloc(1,sizeof(struct ncache_payload));
    if(tmp_payload == NULL)
    {
        return(-PVFS_ENOMEM);
    }

    tmp_payload->parent_ref.handle = parent_ref->handle;
    tmp_payload->parent_ref.fs_id = parent_ref->fs_id;
    tmp_payload->entry_ref.handle = entry_ref->handle;
    tmp_payload->entry_ref.fs_id = entry_ref->fs_id;

    tmp_payload->entry_status = 0;
    tmp_payload->entry_name = (char*) calloc(1, strlen(entry) + 1);
    if(tmp_payload->entry_name == NULL)
    {
        free(tmp_payload);
        return(-PVFS_ENOMEM);
    }
    memcpy(tmp_payload->entry_name, entry, strlen(entry) + 1);

    gen_mutex_lock(&ncache_mutex);

    entry_key.entry_name = entry;
    entry_key.parent_ref.handle = parent_ref->handle;
    entry_key.parent_ref.fs_id = parent_ref->fs_id;

    /* find out if the entry is already in the cache */
    ret = PINT_tcache_lookup(ncache, 
                             &entry_key,
                             &tmp_entry,
                             &status);
    if(ret == 0)
    {
        /* found match in cache; destroy old payload, replace, and
         * refresh time stamp
         */
        ncache_free_payload(tmp_entry->payload);
        tmp_entry->payload = tmp_payload;
        ret = PINT_tcache_refresh_entry(ncache, tmp_entry);
        PINT_perf_count(ncache_pc, PERF_NCACHE_UPDATES, 1, PINT_PERF_ADD);
    }
    else
    {
        /* not found in cache; insert new payload*/
        ret = PINT_tcache_insert_entry(ncache, 
                                       &entry_key,
                                       tmp_payload, 
                                       &purged);
        /* the purged variable indicates how many entries had to be purged
         * from the tcache to make room for this new one
         */
        if(purged == 1)
        {
            /* since only one item was purged, we count this as one item being
             * replaced rather than as a purge and an insert
             */
            PINT_perf_count(ncache_pc, PERF_NCACHE_REPLACEMENTS,purged,
                PINT_PERF_ADD);
        }
        else
        {
            /* otherwise we just purged as part of reclaimation */
            /* if we didn't purge anything, then the "purged" variable will
             * be zero and this counter call won't do anything.
             */
            PINT_perf_count(ncache_pc, PERF_NCACHE_PURGES, purged,
                PINT_PERF_ADD);
        }
    }
    
    PINT_perf_count(ncache_pc, PERF_NCACHE_NUM_ENTRIES,
        ncache->num_entries, PINT_PERF_SET);

    gen_mutex_unlock(&ncache_mutex);
  
    /* cleanup if we did not succeed for some reason */
    if(ret < 0)
    {
        ncache_free_payload(tmp_payload);
    }
  
    gossip_debug(GOSSIP_NCACHE_DEBUG, "ncache: update(): return=%d\n", ret);
    return(ret);
}
コード例 #6
0
ファイル: ncache.c プロジェクト: snsl/pvfs2-osd
/** 
 * Retrieves a _copy_ of a cached object reference, and reports the
 * status to indicate if they are valid or  not
 * @return 0 on success, -PVFS_error on failure
 */
int PINT_ncache_get_cached_entry(
    const char* entry,                 /**< path of obect to look up*/
    PVFS_object_ref* entry_ref,        /**< PVFS2 object looked up */
    const PVFS_object_ref* parent_ref) /**< Parent of PVFS2 object */
{
    int ret = -1;
    struct PINT_tcache_entry* tmp_entry;
    struct ncache_payload* tmp_payload;
    struct ncache_key entry_key;
    int status;

    gossip_debug(GOSSIP_NCACHE_DEBUG, 
                 "ncache: get_cached_entry(): [%s]\n",entry);
  
    entry_key.entry_name = entry;
    entry_key.parent_ref.handle = parent_ref->handle;
    entry_key.parent_ref.fs_id = parent_ref->fs_id;

    gen_mutex_lock(&ncache_mutex);

    /* lookup entry */
    ret = PINT_tcache_lookup(ncache, (void *) &entry_key, &tmp_entry, &status);
    if(ret < 0 || status != 0)
    {
        gossip_debug(GOSSIP_NCACHE_DEBUG, 
            "ncache: miss: name=[%s]\n", entry_key.entry_name);
        PINT_perf_count(ncache_pc, PERF_NCACHE_MISSES, 1, PINT_PERF_ADD);
        gen_mutex_unlock(&ncache_mutex);
        /* Return -PVFS_ENOENT if the entry has expired */
        if(status != 0)
        {   
            return(-PVFS_ENOENT);
        }
        return(ret);
    }
    tmp_payload = tmp_entry->payload;
  
    gossip_debug(GOSSIP_NCACHE_DEBUG, "ncache: status=%d, entry_status=%d\n",
                 status, tmp_payload->entry_status);

    /* copy out entry ref if valid */
    if(tmp_payload->entry_status == 0 && 
       tmp_payload->parent_ref.handle == parent_ref->handle)
    {
        gossip_debug(GOSSIP_NCACHE_DEBUG, "ncache: copying out ref.\n");
        *entry_ref = tmp_payload->entry_ref;
    }
  
    if(tmp_payload->entry_status == 0) 
    {
        /* return success if we got _anything_ out of the cache */
        PINT_perf_count(ncache_pc, PERF_NCACHE_HITS, 1, PINT_PERF_ADD);
        gen_mutex_unlock(&ncache_mutex);
        return(0);
    }

    gen_mutex_unlock(&ncache_mutex);
  
    PINT_perf_count(ncache_pc, PERF_NCACHE_MISSES, 1, PINT_PERF_ADD);
    return(-PVFS_ETIME);
}