[PVFS2-CVS]
commit by neill in pvfs2/src/client/sysint: lookup-ncache.sm
ncache.c ncache.h sys-lookup.sm sys-remove.sm
CVS commit program
cvs at parl.clemson.edu
Wed Oct 13 12:04:25 EDT 2004
Update of /projects/cvsroot/pvfs2/src/client/sysint
In directory parlweb:/tmp/cvs-serv31190/src/client/sysint
Modified Files:
lookup-ncache.sm ncache.c ncache.h sys-lookup.sm sys-remove.sm
Log Message:
- add a clientcore_timing debug mask that only logs the operation
timings from the pvfs2-client-core
- clean up the ncache and make it useable by the lookup/remove calls
- increase ncache timeout from 5 seconds to 30 seconds by default
(NOTE: the ncache has almost no effect from the VFS standpoint, as
the kernel's dcache obviates it after the first successful lookup)
Index: lookup-ncache.sm
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/client/sysint/lookup-ncache.sm,v
diff -p -u -r1.7 -r1.8
--- lookup-ncache.sm 28 Jul 2004 14:32:31 -0000 1.7
+++ lookup-ncache.sm 13 Oct 2004 15:04:25 -0000 1.8
@@ -6,15 +6,17 @@
/* pvfs2_client_getattr_pcache_sm
*
- * The purpose of this state machine is to resolve a segment (one component
- * of a path) and a parent handle down to an object handle. This object handle
- * might already be present in a local cache (the ncache) or could be obtained
- * from a remote server.
+ * The purpose of this state machine is to resolve a segment (one
+ * component of a path) and a parent handle down to an object handle.
+ * This object handle might already be present in a local cache (the
+ * ncache) or could be obtained from a remote server.
*
* This state machine uses the msgpair structure in the PINT_client_sm
- * structure in order to perform the message passing. It assumes that this
- * has been previously set up by the state machine above this one. In particular
- * the following fields of the msgpair structure must be filled in:
+ * structure in order to perform the message passing. It assumes that
+ * this has been previously set up by the state machine above this
+ * one. In particular the following fields of the msgpair structure
+ * must be filled in:
+ *
* - req (unencoded lookup request)
* - fs_id
* - handle
@@ -23,15 +25,15 @@
* them in the appropriate place for the state machine jumping to this one
* (e.g. copies object handle out in the remove case)
*
- * This state machine in turns jumps to the pvfs2_msgpairarray_sm
- * to perform messaging, if necessary.
+ * This state machine in turns jumps to the pvfs2_msgpairarray_sm to
+ * perform messaging, if necessary.
*
- * NOTE: the comp_fn can cause a non-zero error_code to be passed back up from
- * the msgpair state machine and through this state machine back to the
- * one that jumped to here. so be aware!
+ * NOTE: the comp_fn can cause a non-zero error_code to be passed back
+ * up from the msgpair state machine and through this state machine
+ * back to the one that jumped to here. so be aware!
*
- * TODO: sometimes we will get new attributes back with the lookup response.
- * we should add these into the pcache as appropriate.
+ * TODO: sometimes we will get new attributes back with the lookup
+ * response. we should add these into the pcache as appropriate.
*/
#include <string.h>
@@ -64,7 +66,6 @@ nested machine pvfs2_client_lookup_ncach
state lookup
{
run lookup_ncache_lookup;
- success => return;
LOOKUP_NCACHE_MISS => xfer_msgpair;
default => return;
}
@@ -84,16 +85,16 @@ static int lookup_ncache_lookup(PINT_cli
int ret = -PVFS_EINVAL;
PVFS_object_ref parent_ref, object_ref;
- gossip_debug(GOSSIP_CLIENT_DEBUG, "lookup_ncache state: lookup\n");
+ gossip_debug(GOSSIP_NCACHE_DEBUG, "lookup_ncache state: lookup\n");
- assert(js_p->error_code == 0); /* sanity check */
+ assert(js_p->error_code == 0);
- parent_ref.fs_id = sm_p->msgpair.fs_id;
+ parent_ref.fs_id = sm_p->msgpair.fs_id;
parent_ref.handle = sm_p->msgpair.handle;
- ret = PINT_ncache_lookup(sm_p->msgpair.req.u.lookup_path.path,
- parent_ref,
- &object_ref);
+ ret = PINT_ncache_lookup(
+ sm_p->msgpair.req.u.lookup_path.path, parent_ref, &object_ref);
+
if (ret == 0)
{
struct PVFS_server_resp fake_resp;
@@ -115,8 +116,10 @@ static int lookup_ncache_lookup(PINT_cli
ret = sm_p->msgpair.comp_fn(sm_p, &fake_resp, 0);
return 1;
}
+
gossip_debug(GOSSIP_NCACHE_DEBUG, "*** ncache clean miss on %s.\n",
sm_p->msgpair.req.u.lookup_path.path);
+
js_p->error_code = LOOKUP_NCACHE_MISS;
return 1;
}
Index: ncache.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/client/sysint/ncache.c,v
diff -p -u -r1.5 -r1.6
--- ncache.c 28 Jul 2004 14:32:32 -0000 1.5
+++ ncache.c 13 Oct 2004 15:04:25 -0000 1.6
@@ -9,31 +9,31 @@
#include <assert.h>
#include "ncache.h"
-struct ncache_entry_s
+typedef struct
{
- PVFS_object_ref parent; /* the pinode of the parent directory */
- char name[PVFS_SEGMENT_MAX]; /* PVFS object name */
- PVFS_object_ref entry; /* the pinode of entry in parent */
- struct timeval tstamp_valid; /* timestamp indicating validity period */
-};
-typedef struct ncache_entry_s ncache_entry;
+ PVFS_object_ref parent; /* parent directory */
+ char name[PVFS_SEGMENT_MAX]; /* segment name */
+ PVFS_object_ref entry; /* entry in parent */
+ struct timeval tstamp_valid; /* timestamp of validity period */
+} ncache_entry;
-struct ncache_t {
+struct ncache_t
+{
ncache_entry dentry;
int prev;
int next;
- int status; /*whether the entry is in use or not*/
+ int status; /*whether the entry is in use or not*/
};
/* Cache Management structure */
-struct ncache_s {
- struct ncache_t element[PINT_NCACHE_MAX_ENTRIES];
- int count;
- int top;
- int bottom;
- gen_mutex_t *mt_lock;
-};
-typedef struct ncache_s ncache;
+typedef struct
+{
+ struct ncache_t element[PINT_NCACHE_MAX_ENTRIES];
+ int count;
+ int top;
+ int bottom;
+ gen_mutex_t *mt_lock;
+} ncache;
#define BAD_LINK -1
#define STATUS_UNUSED 0
@@ -46,21 +46,19 @@ typedef struct ncache_s ncache;
*/
#define ENABLE_NCACHE 1
-/* static internal helper methods */
static void ncache_remove_dentry(int item);
static void ncache_rotate_dentry(int item);
-static int ncache_update_dentry_timestamp(ncache_entry* entry);
static int ncache_get_lru(void);
+static int ncache_update_dentry_timestamp(
+ ncache_entry* entry);
static int ncache_add_dentry(
char *name,
PVFS_object_ref parent,
PVFS_object_ref entry);
-/* static globals required for ncache operation */
static ncache *cache = NULL;
static int s_pint_ncache_timeout_ms = PINT_NCACHE_TIMEOUT_MS;
-
/* compare
*
* compares a ncache entry to the search key
@@ -72,15 +70,19 @@ static inline int compare(
char *name,
PVFS_object_ref refn)
{
- int ret = 0;
+ int ret = 0, len = 0;
if ((element.dentry.parent.handle == refn.handle) &&
(element.dentry.parent.fs_id == refn.fs_id))
{
int len1 = strlen(name);
int len2 = strlen(element.dentry.name);
- int len = ((len1 < len2) ? len1 : len2);
- ret = (strncmp(name,element.dentry.name,len) == 0);
+
+ if (len1 == len2)
+ {
+ len = ((len1 < len2) ? len1 : len2);
+ ret = (strncmp(name, element.dentry.name, len) == 0);
+ }
}
return ret;
}
@@ -89,7 +91,8 @@ static inline int compare(
*
* need to validate the dentry against the timestamp
*
- * returns 0 if dentry timestamp is valid, -1 if dentry is expired
+ * returns 0 if dentry timestamp is valid, -PVFS_errno if dentry is
+ * expired
*/
static inline int check_dentry_expiry(struct timeval time_stamp)
{
@@ -99,9 +102,7 @@ static inline int check_dentry_expiry(st
ret = gettimeofday(&cur_time,NULL);
if (ret == 0)
{
- /* Does the timestamp exceed the current time?
- * If yes, dentry is valid. If no, it is stale.
- */
+ /* does timestamp exceed current time? if so, entry is valid */
ret = (((time_stamp.tv_sec > cur_time.tv_sec) ||
((time_stamp.tv_sec == cur_time.tv_sec) &&
(time_stamp.tv_usec > cur_time.tv_usec))) ? 0 : -1);
@@ -113,7 +114,7 @@ static inline int check_dentry_expiry(st
*
* search PVFS directory cache for specific entry
*
- * returns 0 on success, -pvfs_errno on failure,
+ * returns 0 on success, -PVFS_errno on failure,
* -PVFS_ENOENT if entry is not present.
*/
int PINT_ncache_lookup(
@@ -122,42 +123,49 @@ int PINT_ncache_lookup(
PVFS_object_ref *entry)
{
#if ENABLE_NCACHE
- int i = 0;
- int ret = 0;
+ int ret = -PVFS_EINVAL, i = 0;
+
+ if (!name || !entry)
+ {
+ return ret;
+ }
- assert(name != NULL);
+ gossip_debug(GOSSIP_NCACHE_DEBUG, "PINT_ncache_lookup called on "
+ "segment %s\n\tunder %Lu,%d\n", name, Lu(parent.handle),
+ parent.fs_id);
gen_mutex_lock(cache->mt_lock);
-
- /* No match found */
- entry->handle = PINT_NCACHE_HANDLE_INVALID;
+ entry->handle = PINT_NCACHE_HANDLE_INVALID;
for(i = cache->top; i != BAD_LINK; i = cache->element[i].next)
{
- if (compare(cache->element[i],name,parent))
- {
- /* match found; check to see if it is still valid */
- ret = check_dentry_expiry(cache->element[i].dentry.tstamp_valid);
- if (ret < 0)
- {
- gossip_ldebug(GOSSIP_NCACHE_DEBUG, "ncache entry expired.\n");
- /* Dentry is stale */
- /* Remove the entry from the cache */
- ncache_remove_dentry(i);
-
- /* we never have more than one entry for the same object
- * in the cache, so we can assume we have no up-to-date one
- * at this point.
- */
- gen_mutex_unlock(cache->mt_lock);
- return -PVFS_ENOENT;
- }
-
- /*
- update links so that this dentry is at the top of our list;
- update the time stamp on the ncache entry
+ if (compare(cache->element[i],name,parent))
+ {
+ /* match found; check to see if it is still valid */
+ ret = check_dentry_expiry(
+ cache->element[i].dentry.tstamp_valid);
+
+ if (ret < 0)
+ {
+ /* entry is stale, remove from cache */
+ gossip_debug(GOSSIP_NCACHE_DEBUG,
+ "ncache entry expired.\n");
+ ncache_remove_dentry(i);
+
+ /* we never have more than one entry for the same
+ * object in the cache, so we can assume we have no
+ * up-to-date one at this point.
+ */
+ gen_mutex_unlock(cache->mt_lock);
+ return -PVFS_ENOENT;
+ }
+ gossip_debug(GOSSIP_NCACHE_DEBUG, "ncache entry valid.\n");
+
+ /*
+ update links so that this dentry is at the top of our
+ list; update the time stamp on the ncache entry
*/
- ncache_rotate_dentry(i);
+ ncache_rotate_dentry(i);
ret = ncache_update_dentry_timestamp(
&cache->element[i].dentry);
if (ret < 0)
@@ -165,11 +173,12 @@ int PINT_ncache_lookup(
gen_mutex_unlock(cache->mt_lock);
return -PVFS_ENOENT;
}
- entry->handle = cache->element[i].dentry.entry.handle;
- entry->fs_id = cache->element[i].dentry.entry.fs_id;
- gen_mutex_unlock(cache->mt_lock);
- return 0;
- }
+
+ entry->handle = cache->element[i].dentry.entry.handle;
+ entry->fs_id = cache->element[i].dentry.entry.fs_id;
+ gen_mutex_unlock(cache->mt_lock);
+ return 0;
+ }
}
/* passed through entire cache with no matches */
@@ -190,34 +199,38 @@ int PINT_ncache_lookup(
static void ncache_rotate_dentry(int item)
{
int prev = 0, next = 0, new_bottom;
+
if (cache->top != cache->bottom)
{
- if(cache->top != item)
- {
- /*only move links if there's more than one thing in the list*/
- if (cache->bottom == item)
- {
- new_bottom = cache->element[cache->bottom].prev;
-
- cache->element[new_bottom].next = BAD_LINK;
- cache->bottom = new_bottom;
- }
- else
- {
- /*somewhere in the middle*/
- next = cache->element[item].next;
- prev = cache->element[item].prev;
-
- cache->element[prev].next = next;
- cache->element[next].prev = prev;
- }
-
- cache->element[cache->top].prev = item;
-
- cache->element[item].next = cache->top;
- cache->element[item].prev = BAD_LINK;
- cache->top = item;
- }
+ if (cache->top != item)
+ {
+ /*
+ only move links if there's more than one thing in the
+ list
+ */
+ if (cache->bottom == item)
+ {
+ new_bottom = cache->element[cache->bottom].prev;
+
+ cache->element[new_bottom].next = BAD_LINK;
+ cache->bottom = new_bottom;
+ }
+ else
+ {
+ /*somewhere in the middle*/
+ next = cache->element[item].next;
+ prev = cache->element[item].prev;
+
+ cache->element[prev].next = next;
+ cache->element[next].prev = prev;
+ }
+
+ cache->element[cache->top].prev = item;
+
+ cache->element[item].next = cache->top;
+ cache->element[item].prev = BAD_LINK;
+ cache->top = item;
+ }
}
}
@@ -228,59 +241,56 @@ static void ncache_rotate_dentry(int ite
* returns 0 on success, -1 on failure
*/
int PINT_ncache_insert(
- char *name,
- PVFS_object_ref entry,
- PVFS_object_ref parent)
+ char *name,
+ PVFS_object_ref entry,
+ PVFS_object_ref parent)
{
#if ENABLE_NCACHE
- int i = 0, index = 0, ret = 0;
- unsigned char entry_found = 0;
-
- gen_mutex_lock(cache->mt_lock);
-
- gossip_ldebug(GOSSIP_NCACHE_DEBUG, "NCACHE: Inserting segment %s "
- "(%Lu|%d) under parent (%Lu|%d)\n", name,
- Lu(entry.handle), entry.fs_id, Lu(parent.handle),
- parent.fs_id);
-
- for (i = cache->top; i != BAD_LINK; i = cache->element[i].next)
- {
- if (compare(cache->element[i],name,parent))
- {
- entry_found = 1;
- index = i;
- break;
- }
- }
-
- /* Add/Merge element to the cache */
- if (entry_found == 0)
- {
- /* Element not in cache, add it */
- ncache_add_dentry(name,parent,entry);
- }
- else
- {
- /* We move the dentry to the top of the list, update its
- * timestamp and return
- */
- gossip_ldebug(GOSSIP_NCACHE_DEBUG, "dache inserting entry "
- "already present; timestamp update.\n");
- ncache_rotate_dentry(index);
- ret = ncache_update_dentry_timestamp(
- &cache->element[index].dentry);
- if (ret < 0)
- {
- gen_mutex_unlock(cache->mt_lock);
- return(ret);
- }
- }
- gen_mutex_unlock(cache->mt_lock);
-
- return(0);
-#else
- return(0);
+ int i = 0, index = 0, ret = 0;
+ unsigned char entry_found = 0;
+
+ gen_mutex_lock(cache->mt_lock);
+
+ gossip_debug(
+ GOSSIP_NCACHE_DEBUG, "PINT_ncache_insert: inserting segment "
+ "%s\n\t(%Lu,%d)\n\tunder parent (%Lu,%d)\n", name,
+ Lu(entry.handle), entry.fs_id, Lu(parent.handle),
+ parent.fs_id);
+
+ for (i = cache->top; i != BAD_LINK; i = cache->element[i].next)
+ {
+ if (compare(cache->element[i],name,parent))
+ {
+ entry_found = 1;
+ index = i;
+ break;
+ }
+ }
+
+ /* add/merge element to the cache */
+ if (entry_found == 0)
+ {
+ /* Element not in cache, add it */
+ ncache_add_dentry(name,parent,entry);
+ }
+ else
+ {
+ /* move entry to the top of the list and update its timestamp */
+ gossip_debug(GOSSIP_NCACHE_DEBUG, "dache inserting entry "
+ "already present; timestamp update.\n");
+
+ ncache_rotate_dentry(index);
+ ret = ncache_update_dentry_timestamp(
+ &cache->element[index].dentry);
+ if (ret < 0)
+ {
+ gen_mutex_unlock(cache->mt_lock);
+ return(ret);
+ }
+ }
+ gen_mutex_unlock(cache->mt_lock);
#endif
+ return 0;
}
/* ncache_remove
@@ -290,36 +300,40 @@ int PINT_ncache_insert(
* returns 0 on success, -1 on failure
*/
int PINT_ncache_remove(
- char *name,
- PVFS_object_ref parent,
- int *item_found)
+ char *name,
+ PVFS_object_ref parent,
+ int *item_found)
{
#if ENABLE_NCACHE
- int i = 0;
+ int i = 0;
- if (name == NULL)
- {
- return(-EINVAL);
- }
+ if (!name)
+ {
+ return -PVFS_EINVAL;
+ }
- *item_found = 0;
-
- gen_mutex_lock(cache->mt_lock);
- for(i = cache->top; i != BAD_LINK; i = cache->element[i].next)
- {
- if (compare(cache->element[i],name,parent))
- {
- ncache_remove_dentry(i);
- *item_found = 1;
- break;
- }
- }
- gen_mutex_unlock(cache->mt_lock);
+ if (item_found)
+ {
+ *item_found = 0;
+ }
- return(0);
-#else
- return(0);
+ gen_mutex_lock(cache->mt_lock);
+ for(i = cache->top; i != BAD_LINK; i = cache->element[i].next)
+ {
+ if (compare(cache->element[i],name,parent))
+ {
+ ncache_remove_dentry(i);
+
+ if (item_found)
+ {
+ *item_found = 1;
+ }
+ break;
+ }
+ }
+ gen_mutex_unlock(cache->mt_lock);
#endif
+ return 0;
}
/* ncache_flush
@@ -330,7 +344,7 @@ int PINT_ncache_remove(
*/
int PINT_ncache_flush(void)
{
- return(-ENOSYS);
+ return -PVFS_ENOSYS;
}
/* pint_ncache_initialize
@@ -361,8 +375,11 @@ int PINT_ncache_initialize(void)
cache->element[i].status = STATUS_UNUSED;
}
}
- ret = (cache ? 0 : -ENOMEM);
+ ret = (cache ? 0 : -PVFS_ENOMEM);
}
+
+ gossip_debug(GOSSIP_NCACHE_DEBUG,
+ "PINT_ncache_initialize returning %d\n", ret);
return ret;
#else
return 0;
@@ -381,14 +398,14 @@ int PINT_ncache_finalize(void)
if (cache)
{
- gen_mutex_destroy(cache->mt_lock);
- free(cache);
+ gen_mutex_destroy(cache->mt_lock);
+ free(cache);
cache = NULL;
}
- return 0;
-#else
- return 0;
+
+ gossip_debug(GOSSIP_NCACHE_DEBUG, "PINT_ncache_finalize complete\n");
#endif
+ return 0;
}
int PINT_ncache_get_timeout(void)
@@ -406,48 +423,51 @@ void PINT_ncache_set_timeout(int max_tim
*
* add a dentry to the ncache
*
- * returns 0 on success, -errno on failure
+ * returns 0 on success, -PVFS_errno on failure
*/
static int ncache_add_dentry(
char *name,
PVFS_object_ref parent,
PVFS_object_ref entry)
{
- int new = 0, ret = 0;
- int size = strlen(name) + 1; /* size includes null terminator*/
+ int new = 0, ret = 0;
+ int size = strlen(name) + 1; /* size includes null terminator*/
+
+ new = ncache_get_lru();
- new = ncache_get_lru();
+ /* add element to cache */
+ cache->element[new].status = STATUS_USED;
+ cache->element[new].dentry.parent = parent;
+ cache->element[new].dentry.entry = entry;
+ memcpy(cache->element[new].dentry.name,name,size);
- /* Add the element to the cache */
- cache->element[new].status = STATUS_USED;
- cache->element[new].dentry.parent = parent;
- cache->element[new].dentry.entry = entry;
- memcpy(cache->element[new].dentry.name,name,size);
- /* Set the timestamp */
- ret = ncache_update_dentry_timestamp(
- &cache->element[new].dentry);
- if (ret < 0)
- {
- return(ret);
- }
- cache->element[new].prev = BAD_LINK;
- cache->element[new].next = cache->top;
- /* Make previous element point to new entry */
- if (cache->top != BAD_LINK)
- cache->element[cache->top].prev = new;
+ /* set timestamp */
+ ret = ncache_update_dentry_timestamp(
+ &cache->element[new].dentry);
- cache->top = new;
+ if (ret < 0)
+ {
+ return ret;
+ }
+ cache->element[new].prev = BAD_LINK;
+ cache->element[new].next = cache->top;
- return(0);
+ /* make previous element point to new entry */
+ if (cache->top != BAD_LINK)
+ {
+ cache->element[cache->top].prev = new;
+ }
+ cache->top = new;
+ return 0;
}
/* ncache_get_lru
*
- * this function gets the least recently used cache entry (assuming a full
- * cache) or searches through the cache for the first unused slot (if there
- * are some free slots)
+ * this function gets the least recently used cache entry (assuming a
+ * full cache) or searches through the cache for the first unused slot
+ * (if there are some free slots)
*
- * returns 0 on success, -errno on failure
+ * returns 0 on success, -PVFS_errno on failure
*/
static int ncache_get_lru(void)
{
@@ -455,29 +475,30 @@ static int ncache_get_lru(void)
if (cache->count == PINT_NCACHE_MAX_ENTRIES)
{
- new = cache->bottom;
- cache->bottom = cache->element[new].prev;
- cache->element[cache->bottom].next = BAD_LINK;
- return new;
+ new = cache->bottom;
+ cache->bottom = cache->element[new].prev;
+ cache->element[cache->bottom].next = BAD_LINK;
+ return new;
}
else
{
- for(i = 0; i < PINT_NCACHE_MAX_ENTRIES; i++)
- {
- if (cache->element[i].status == STATUS_UNUSED)
- {
- cache->count++;
- return i;
- }
- }
+ for(i = 0; i < PINT_NCACHE_MAX_ENTRIES; i++)
+ {
+ if (cache->element[i].status == STATUS_UNUSED)
+ {
+ cache->count++;
+ return i;
+ }
+ }
}
- gossip_ldebug(GOSSIP_NCACHE_DEBUG,
+ gossip_debug(GOSSIP_NCACHE_DEBUG,
"error getting least recently used dentry.\n");
- gossip_ldebug(GOSSIP_NCACHE_DEBUG,
+ gossip_debug(GOSSIP_NCACHE_DEBUG,
"cache->count = %d max_entries = %d.\n",
cache->count, PINT_NCACHE_MAX_ENTRIES);
- assert(0);
+
+ return -PVFS_ENOENT;
}
/* ncache_remove_dentry
@@ -497,36 +518,36 @@ static void ncache_remove_dentry(int ite
/* if there's exactly one item in the list, just get rid of it*/
if (cache->top == cache->bottom)
{
- cache->top = 0;
- cache->bottom = 0;
- cache->element[item].prev = BAD_LINK;
- cache->element[item].next = BAD_LINK;
- return;
+ cache->top = 0;
+ cache->bottom = 0;
+ cache->element[item].prev = BAD_LINK;
+ cache->element[item].next = BAD_LINK;
+ return;
}
- /* depending on where the dentry is in the list, we have to do different
- * things if its the first, last, or somewhere in the middle.
+ /* depending on where the dentry is in the list, we have to do
+ * different things if its the first, last, or somewhere in the
+ * middle.
*/
-
if (item == cache->top)
{
- /* Adjust top */
- cache->top = cache->element[item].next;
- cache->element[cache->top].prev = BAD_LINK;
+ /* Adjust top */
+ cache->top = cache->element[item].next;
+ cache->element[cache->top].prev = BAD_LINK;
}
else if (item == cache->bottom)
{
- /* Adjust bottom */
- cache->bottom = cache->element[item].prev;
- cache->element[cache->bottom].next = -1;
+ /* Adjust bottom */
+ cache->bottom = cache->element[item].prev;
+ cache->element[cache->bottom].next = -1;
}
else
{
- /* Item in the middle */
- prev = cache->element[item].prev;
- next = cache->element[item].next;
- cache->element[prev].next = next;
- cache->element[next].prev = prev;
+ /* Item in the middle */
+ prev = cache->element[item].prev;
+ next = cache->element[item].next;
+ cache->element[prev].next = next;
+ cache->element[next].prev = prev;
}
}
@@ -534,7 +555,7 @@ static void ncache_remove_dentry(int ite
*
* updates the timestamp of the ncache entry
*
- * returns 0 on success, -1 on failure
+ * returns 0 on success, -PVFS_errno on failure
*/
static int ncache_update_dentry_timestamp(ncache_entry* entry)
{
Index: ncache.h
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/client/sysint/ncache.h,v
diff -p -u -r1.3 -r1.4
--- ncache.h 8 Jul 2004 16:17:06 -0000 1.3
+++ ncache.h 13 Oct 2004 15:04:25 -0000 1.4
@@ -11,16 +11,14 @@
#include "pint-sysint-utils.h"
/* number of entries allowed in the cache */
-#define PINT_NCACHE_MAX_ENTRIES 512
+#define PINT_NCACHE_MAX_ENTRIES 1024
/* number of milliseconds that cache entries will remain valid */
-#define PINT_NCACHE_TIMEOUT_MS 5000
+#define PINT_NCACHE_TIMEOUT_MS 30000
-/* TODO: replace later with real value from trove */
/* value passed out to indicate lookups that didn't find a match */
#define PINT_NCACHE_HANDLE_INVALID 0
-/* Function Prototypes */
int PINT_ncache_lookup(
char *name,
PVFS_object_ref parent,
@@ -47,3 +45,13 @@ int PINT_ncache_get_timeout(void);
void PINT_ncache_set_timeout(int max_timeout_ms);
#endif
+
+/*
+ * Local variables:
+ * mode: c
+ * c-indent-level: 4
+ * c-basic-offset: 4
+ * End:
+ *
+ * vim: ft=c ts=8 sts=4 sw=4 expandtab
+ */
Index: sys-lookup.sm
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/client/sysint/sys-lookup.sm,v
diff -p -u -r1.48 -r1.49
--- sys-lookup.sm 29 Sep 2004 18:23:54 -0000 1.48
+++ sys-lookup.sm 13 Oct 2004 15:04:25 -0000 1.49
@@ -687,6 +687,16 @@ static int lookup_segment_verify_attr_pr
assert(cur_seg);
/*
+ attempt to insert the resolved segment/object refn into the
+ ncache if it wasn't a cache hit
+ */
+ if (!sm_p->ncache_hit)
+ {
+ PINT_ncache_insert(cur_seg->seg_name, cur_seg->seg_resolved_refn,
+ cur_seg->seg_starting_refn);
+ }
+
+ /*
NOTE: there are two cases here where we need to fetch the attrs.
1) either the attrs are not present at all (i.e. objtype is
Index: sys-remove.sm
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/client/sysint/sys-remove.sm,v
diff -p -u -r1.81 -r1.82
--- sys-remove.sm 4 Oct 2004 16:46:28 -0000 1.81
+++ sys-remove.sm 13 Oct 2004 15:04:25 -0000 1.82
@@ -16,6 +16,7 @@
#include "pint-servreq.h"
#include "pint-cached-config.h"
#include "PINT-reqproto-encode.h"
+#include "ncache.h"
/*
PVFS_{i}sys_remove takes the following steps:
@@ -436,6 +437,12 @@ static int remove_cleanup(PINT_client_sm
PINT_acache_release(sm_p->pinode);
sm_p->acache_hit = 0;
sm_p->pinode = NULL;
+ }
+
+ if (sm_p->ncache_hit)
+ {
+ PINT_ncache_remove(sm_p->u.remove.object_name,
+ sm_p->parent_ref, NULL);
}
if (sm_p->msgarray && (sm_p->msgarray != &sm_p->msgpair))
More information about the PVFS2-CVS
mailing list