summaryrefslogtreecommitdiffstats
path: root/xlators/performance/stat-prefetch
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2009-11-25 13:53:11 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-11-26 09:26:56 -0800
commitd01ba463de631fb38f96b2aa02907f0ac40db4eb (patch)
tree99e3ca26f438290cb4a9892948d8b8bf27f20f3b /xlators/performance/stat-prefetch
parent71eae4bd2f5384bd79c4e0bb6ac679841a8dc042 (diff)
performance/stat-prefetch: remove lock member in sp_fd_ctx_t.
- since the lifetime of fd context can be no longer than the fd, we can use lock in fd. Signed-off-by: Raghavendra G <raghavendra@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 405 (Segmentation fault in stat-prefetch.) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=405
Diffstat (limited to 'xlators/performance/stat-prefetch')
-rw-r--r--xlators/performance/stat-prefetch/src/stat-prefetch.c40
-rw-r--r--xlators/performance/stat-prefetch/src/stat-prefetch.h18
2 files changed, 22 insertions, 36 deletions
diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch.c b/xlators/performance/stat-prefetch/src/stat-prefetch.c
index 75a74b531..73fac4c7c 100644
--- a/xlators/performance/stat-prefetch/src/stat-prefetch.c
+++ b/xlators/performance/stat-prefetch/src/stat-prefetch.c
@@ -250,11 +250,7 @@ __sp_get_cache_fd (xlator_t *this, fd_t *fd)
fd_ctx = (void *)(long) value;
- LOCK (&fd_ctx->lock);
- {
- cache = fd_ctx->cache;
- }
- UNLOCK (&fd_ctx->lock);
+ cache = fd_ctx->cache;
out:
return cache;
@@ -314,9 +310,6 @@ sp_fd_ctx_init (void)
sp_fd_ctx_t *fd_ctx = NULL;
fd_ctx = CALLOC (1, sizeof (*fd_ctx));
- if (fd_ctx) {
- LOCK_INIT (&fd_ctx->lock);
- }
return fd_ctx;
}
@@ -364,19 +357,16 @@ sp_del_cache_fd (xlator_t *this, fd_t *fd)
goto out;
}
- ret = fd_ctx_get (fd, this, &value);
- if (ret == -1) {
- goto out;
- }
-
- fd_ctx = (void *)(long) value;
-
- LOCK (&fd_ctx->lock);
+ LOCK (&fd->lock);
{
- cache = fd_ctx->cache;
- fd_ctx->cache = NULL;
+ ret = __fd_ctx_get (fd, this, &value);
+ if (ret == 0) {
+ fd_ctx = (void *)(long) value;
+ cache = fd_ctx->cache;
+ fd_ctx->cache = NULL;
+ }
}
- UNLOCK (&fd_ctx->lock);
+ UNLOCK (&fd->lock);
out:
return cache;
@@ -431,15 +421,11 @@ __sp_put_cache (xlator_t *this, fd_t *fd, sp_cache_t *cache)
}
}
- LOCK (&fd_ctx->lock);
- {
- if (fd_ctx->cache) {
- sp_cache_free (fd_ctx->cache);
- }
-
- fd_ctx->cache = cache;
+ if (fd_ctx->cache) {
+ sp_cache_free (fd_ctx->cache);
}
- UNLOCK (&fd_ctx->lock);
+
+ fd_ctx->cache = cache;
out:
return ret;
diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch.h b/xlators/performance/stat-prefetch/src/stat-prefetch.h
index 3ea163b2c..0e9353303 100644
--- a/xlators/performance/stat-prefetch/src/stat-prefetch.h
+++ b/xlators/performance/stat-prefetch/src/stat-prefetch.h
@@ -37,25 +37,25 @@
struct sp_cache {
rbthash_table_t *table;
- uint64_t expected_offset; /* Offset where the next read will
- * happen.
- */
- gf_lock_t lock;
- unsigned long miss;
- unsigned long hits;
+ uint64_t expected_offset; /* Offset where the next read will
+ * happen.
+ */
+ gf_lock_t lock;
+ unsigned long miss;
+ unsigned long hits;
+ uint32_t ref;
};
typedef struct sp_cache sp_cache_t;
struct sp_fd_ctx {
sp_cache_t *cache;
- inode_t *parent_inode; /*
+ inode_t *parent_inode; /*
* inode corresponding to dirname (path)
*/
char *name; /*
- * basename of path on which this fd is
+ * basename of path on which this fd is
* opened
*/
- gf_lock_t lock;
};
typedef struct sp_fd_ctx sp_fd_ctx_t;