From 4cbb14cf6fc3f1b52ff0062a9fee88e2170ad454 Mon Sep 17 00:00:00 2001 From: Anand Avati Date: Tue, 29 Jan 2013 10:05:29 -0800 Subject: quick-read: various fixes - initialize xdata in qr_lookup even if it was NULL from top. This allows qr to do its job even if lookup originated from fuse-resolve.c - extend test cases to include 1 second delay and retry - fix bug while checking condition for cached unwind qr_readv_cached() unwinds if op_ret > 0. Therefore qr_readv() must wind to subvol only if !(op_ret > 0) (i.e, op_ret <= 0). - qr_readv_cached() is using uninitialized @conf pointer. Thanks to Raghavendra Bhat for catching this! Change-Id: Ifaf2ea2685e452210ef9ba3c2d1f2ab51900650c BUG: 846240 Signed-off-by: Anand Avati Reviewed-on: http://review.gluster.org/4452 Reviewed-by: Raghavendra Bhat Tested-by: Gluster Build System --- tests/performance/quick-read.t | 12 +++++++++++- xlators/performance/quick-read/src/quick-read.c | 13 ++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/tests/performance/quick-read.t b/tests/performance/quick-read.t index 84bb7e66..082998e4 100644 --- a/tests/performance/quick-read.t +++ b/tests/performance/quick-read.t @@ -31,6 +31,16 @@ function write_to() TEST write_to "$M0/$F0" "$D0"; EXPECT "$D0" cat $M1/$F0; +EXPECT "$D0" cat $M0/$F0; +EXPECT "$D0" cat $M1/$F0; +EXPECT "$D0" cat $M0/$F0; + +sleep 1; + +EXPECT "$D0" cat $M1/$F0; +EXPECT "$D0" cat $M0/$F0; +EXPECT "$D0" cat $M1/$F0; +EXPECT "$D0" cat $M0/$F0; TEST $CLI volume set $V0 performance.quick-read off; @@ -38,7 +48,7 @@ D1="hello-this-is-a-test-message1"; F1="test-file1"; TEST write_to "$M0/$F1" "$D1"; -EXPECT "$D1" cat $M1/$F1; +EXPECT "$D1" cat $M0/$F1; EXPECT "$D0" cat $M1/$F0; diff --git a/xlators/performance/quick-read/src/quick-read.c b/xlators/performance/quick-read/src/quick-read.c index 34e27138..1a0f8675 100644 --- a/xlators/performance/quick-read/src/quick-read.c +++ b/xlators/performance/quick-read/src/quick-read.c @@ -372,9 +372,13 @@ gf_boolean_t __qr_cache_is_fresh (xlator_t *this, qr_inode_t *qr_inode) { qr_conf_t *conf = NULL; + qr_private_t *priv = NULL; struct timeval now; struct timeval diff; + priv = this->private; + conf = &priv->conf; + gettimeofday (&now, NULL); timersub (&now, &qr_inode->last_refresh, &diff); @@ -444,6 +448,7 @@ qr_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) qr_conf_t *conf = NULL; qr_inode_t *qr_inode = NULL; int ret = -1; + dict_t *new_xdata = NULL; priv = this->private; conf = &priv->conf; @@ -453,6 +458,9 @@ qr_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) /* cached. only validate in qr_lookup_cbk */ goto wind; + if (!xdata) + xdata = new_xdata = dict_new (); + if (!xdata) goto wind; @@ -470,6 +478,9 @@ wind: STACK_WIND (frame, qr_lookup_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->lookup, loc, xdata); + if (new_xdata) + dict_unref (new_xdata); + return 0; } @@ -598,7 +609,7 @@ qr_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, if (!qr_inode) goto wind; - if (qr_readv_cached (frame, qr_inode, size, offset, flags, xdata) != 0) + if (qr_readv_cached (frame, qr_inode, size, offset, flags, xdata) <= 0) goto wind; return 0; -- cgit