From 781e390dcf0d2e4af8d8882131292a544fbb2288 Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Tue, 23 Feb 2010 01:22:14 +0000 Subject: performance/io-cache: use loc_copy and loc_wipe in ioc_lookup. Signed-off-by: Raghavendra G Signed-off-by: Anand V. Avati BUG: 570 (Cache only those files whose sizes falls under a configured window size) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=570 --- xlators/performance/io-cache/src/io-cache.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'xlators') diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c index 3a440ca77..f16bc393f 100644 --- a/xlators/performance/io-cache/src/io-cache.c +++ b/xlators/performance/io-cache/src/io-cache.c @@ -188,9 +188,6 @@ ioc_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, uint32_t weight = 0xffffffff; const char *path = NULL; ioc_local_t *local = NULL; - - if (op_ret != 0) - goto out; local = frame->local; if (local == NULL) { @@ -199,6 +196,9 @@ ioc_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto out; } + if (op_ret != 0) + goto out; + path = local->file_loc.path; LOCK (&inode->lock); @@ -243,6 +243,10 @@ ioc_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, ioc_table_unlock (ioc_inode->table); out: + if (local != NULL) { + loc_wipe (&local->file_loc); + } + STACK_UNWIND (frame, op_ret, op_errno, inode, stbuf, dict); return 0; } @@ -252,7 +256,7 @@ ioc_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xattr_req) { ioc_local_t *local = NULL; - int32_t op_errno = -1; + int32_t op_errno = -1, ret = -1; local = CALLOC (1, sizeof (ioc_local_t)); if (local == NULL) { @@ -261,10 +265,14 @@ ioc_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, goto unwind; } - local->file_loc.path = loc->path; - local->file_loc.inode = loc->inode; - frame->local = local; + ret = loc_copy (&local->file_loc, loc); + if (ret != 0) { + gf_log (this->name, GF_LOG_ERROR, "out of memory"); + op_errno = ENOMEM; + goto unwind; + } + STACK_WIND (frame, ioc_lookup_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->lookup, loc, xattr_req); @@ -272,6 +280,10 @@ ioc_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, return 0; unwind: + if (local != NULL) { + loc_wipe (&local->file_loc); + } + STACK_UNWIND (frame, -1, op_errno, NULL, NULL, NULL); return 0; } -- cgit