From 3438475cfda277fac0de6758ea9f85e3587596b5 Mon Sep 17 00:00:00 2001 From: Raghavendra Bhat Date: Tue, 19 Feb 2013 12:37:04 +0530 Subject: performance/open-behind: use anonymous fd for doing fstat and readv Change-Id: I61a3c221e0a15736ab6315e2538c03dac27480a5 BUG: 846240 Signed-off-by: Raghavendra Bhat Reviewed-on: http://review.gluster.org/4483 Tested-by: Gluster Build System Reviewed-by: Anand Avati Reviewed-on: http://review.gluster.org/5807 Reviewed-by: Kaleb KEITHLEY --- tests/performance/open-behind.t | 18 ++++++++++++++++++ xlators/mgmt/glusterd/src/glusterd-volume-set.c | 5 +++++ xlators/performance/open-behind/src/open-behind.c | 4 ++-- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/tests/performance/open-behind.t b/tests/performance/open-behind.t index 2524ce9e2..032154a20 100755 --- a/tests/performance/open-behind.t +++ b/tests/performance/open-behind.t @@ -32,6 +32,21 @@ function write_to() TEST write_to "$M0/$F0" "$D0"; EXPECT "$D0" cat $M1/$F0; +# open-behind delays open and uses anonymous fds for fops like +# fstat and readv. So after creating the file, if volume is restarted +# then later when the file is read, because of the use of anonymous fds +# volume top open will show number of files opened as 0. +TEST $CLI volume stop $V0; +sleep 1; +TEST $CLI volume start $V0; + +sleep 2; +cat $M1/$F0 >/dev/null; + +string=$(gluster volume top $V0 open | grep -w "$F0"); + +EXPECT "" echo $string; + TEST $CLI volume set $V0 performance.open-behind off; D1="hello-this-is-a-test-message1"; @@ -42,4 +57,7 @@ EXPECT "$D1" cat $M1/$F1; EXPECT "$D0" cat $M1/$F0; +gluster volume top $V0 open | grep -w "$F0" >/dev/null 2>&1 +TEST [ $? -eq 0 ]; + cleanup; diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c index df3aa9639..e5333cc31 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c @@ -669,6 +669,11 @@ struct volopt_map_entry glusterd_volopt_map[] = { .op_version = 2, .flags = OPT_FLAG_CLIENT_OPT }, + { .key = "performance.lazy-open", + .voltype = "performance/open-behind", + .option = "lazy-open", + .op_version = 2 + }, /* Client xlator options */ { .key = "network.frame-timeout", diff --git a/xlators/performance/open-behind/src/open-behind.c b/xlators/performance/open-behind/src/open-behind.c index e67919734..ec5f62580 100644 --- a/xlators/performance/open-behind/src/open-behind.c +++ b/xlators/performance/open-behind/src/open-behind.c @@ -361,7 +361,7 @@ ob_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, if (!stub) goto err; - open_and_resume (this, fd, stub); + open_and_resume (this, wind_fd, stub); return 0; err: @@ -408,7 +408,7 @@ ob_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata) if (!stub) goto err; - open_and_resume (this, fd, stub); + open_and_resume (this, wind_fd, stub); return 0; err: -- cgit