[PVFS2-CVS] commit by neill in pvfs2/src/client/sysint: acache.c
CVS commit program
cvs at parl.clemson.edu
Mon Oct 4 16:23:17 EDT 2004
Update of /projects/cvsroot/pvfs2/src/client/sysint
In directory parlweb:/tmp/cvs-serv6092/src/client/sysint
Modified Files:
acache.c
Log Message:
- use mutex-trylocks when locking the pinode object. all cases need
the lock if it's not acquired but it's possible that the object is
already locked; the interface mutex is used for called thread safety
- remove acache duplicated code by re-using the internal status method
- make sure mmap's requesting MAP_SHARED fail (mmap2 returns -EINVAL,
userspace mmap returns standard MMAP_FAILED value)
Index: acache.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/client/sysint/acache.c,v
diff -p -u -r1.17 -r1.18
--- acache.c 4 Oct 2004 18:08:46 -0000 1.17
+++ acache.c 4 Oct 2004 19:23:17 -0000 1.18
@@ -222,9 +222,8 @@ static PINT_pinode *acache_internal_look
NOTE: if a pinode is returned, it is returned with the lock held.
That means no one else can use it before the lock is released (in
- release, or set_valid);
- if status is specified, the pinode status will be filled to avoid
- calling the status method after this call
+ release, or set_valid). if status is specified, the pinode status
+ will be filled to avoid calling the status method after this call
*/
PINT_pinode *PINT_acache_lookup(PVFS_object_ref refn, int *status)
{
@@ -249,7 +248,7 @@ PINT_pinode *PINT_acache_lookup(PVFS_obj
if (pinode)
{
- gen_mutex_lock(pinode->mutex);
+ gen_mutex_trylock(pinode->mutex);
assert(pinode->flag = PINODE_INTERNAL_FLAG_HASHED);
pinode->ref_cnt++;
if (status)
@@ -533,37 +532,14 @@ static void pinode_invalidate(PINT_pinod
static int pinode_status(PINT_pinode *pinode)
{
- struct timeval now;
int ret = PINODE_STATUS_INVALID;
acache_debug("pinode_status entered\n");
- /* if we don't have the lock, get it */
gen_mutex_trylock(pinode->mutex);
- ret = pinode->status;
- if (ret == PINODE_STATUS_VALID)
- {
- ret = PINODE_STATUS_INVALID;
- if (pinode->ref_cnt > 0)
- {
- if (gettimeofday(&now, NULL) == 0)
- {
- ret = (((pinode->time_stamp.tv_sec < now.tv_sec) ||
- ((pinode->time_stamp.tv_sec == now.tv_sec) &&
- (pinode->time_stamp.tv_usec < now.tv_usec))) ?
- PINODE_STATUS_EXPIRED : PINODE_STATUS_VALID);
- }
- }
- }
-
- gossip_debug(GOSSIP_ACACHE_DEBUG, "pinode [%Lu] entry status: %s\n",
- Lu(pinode->refn.handle), get_status_str(ret));
-
- if (ret == PINODE_STATUS_EXPIRED)
- {
- pinode->ref_cnt--;
- }
+ ret = acache_internal_status(pinode);
gen_mutex_unlock(pinode->mutex);
+
acache_debug("pinode_status exited\n");
return ret;
}
More information about the PVFS2-CVS
mailing list