From 4db632f5f68adc1c7d7b696d24e5b25058dcedc3 Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Mon, 26 Apr 2010 09:19:47 +0000 Subject: performance/quick-read: don't try to validate again if qr_readv is called just after validation. Signed-off-by: Raghavendra G Signed-off-by: Anand V. Avati BUG: 852 (QR cache-timeout 0 causes high CPU usage and app hangs) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=852 --- xlators/performance/quick-read/src/quick-read.c | 29 +++++++++++++++++-------- xlators/performance/quick-read/src/quick-read.h | 1 + 2 files changed, 21 insertions(+), 9 deletions(-) (limited to 'xlators') diff --git a/xlators/performance/quick-read/src/quick-read.c b/xlators/performance/quick-read/src/quick-read.c index 50b113a3ab3..1470ad50d08 100644 --- a/xlators/performance/quick-read/src/quick-read.c +++ b/xlators/performance/quick-read/src/quick-read.c @@ -553,10 +553,11 @@ static int32_t qr_validate_cache_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct stat *buf) { - qr_file_t *qr_file = NULL; - qr_local_t *local = NULL; - uint64_t value = 0; - int32_t ret = 0; + qr_file_t *qr_file = NULL; + call_stub_t *stub = NULL; + qr_local_t *local = NULL; + uint64_t value = 0; + int32_t ret = 0; local = frame->local; if ((local == NULL) || ((local->fd) == NULL)) { @@ -596,11 +597,11 @@ qr_validate_cache_cbk (call_frame_t *frame, void *cookie, xlator_t *this, } UNLOCK (&qr_file->lock); - frame->local = NULL; - - call_resume (local->stub); + stub = local->stub; + local->stub = NULL; + local->just_validated = 1; + call_resume (stub); - FREE (local); return 0; unwind: @@ -759,6 +760,8 @@ qr_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, off_t offset) { qr_file_t *file = NULL; + qr_local_t *local = NULL; + char just_validated = 0; int32_t ret = -1, op_ret = -1, op_errno = -1; uint64_t value = 0; int count = -1, flags = 0, i = 0; @@ -782,6 +785,13 @@ qr_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, op_ret = 0; conf = this->private; + local = frame->local; + if (local != NULL) { + just_validated = local->just_validated; + FREE (local); + frame->local = NULL; + } + ret = fd_ctx_get (fd, this, &value); if (ret == 0) { qr_fd_ctx = (qr_fd_ctx_t *)(long) value; @@ -801,7 +811,8 @@ qr_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, LOCK (&file->lock); { if (file->xattr){ - if (qr_need_validation (conf,file)) { + if (!just_validated && + qr_need_validation (conf,file)) { need_validation = 1; goto unlock; } diff --git a/xlators/performance/quick-read/src/quick-read.h b/xlators/performance/quick-read/src/quick-read.h index fdecd61ed04..7562f6e65af 100644 --- a/xlators/performance/quick-read/src/quick-read.h +++ b/xlators/performance/quick-read/src/quick-read.h @@ -56,6 +56,7 @@ typedef struct qr_fd_ctx qr_fd_ctx_t; struct qr_local { char is_open; + char just_validated; fd_t *fd; int open_flags; int32_t op_ret; -- cgit