summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@zresearch.com>2009-07-09 00:27:46 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-07-16 00:37:46 -0700
commit206e1af66adea885fcaf5ad02a510ac0deb36870 (patch)
treee5a66e5e4f3080fdc8612be0b86fda7bff509c35
parentcd945c716fdbd430d575f43732801163b076b258 (diff)
quick-read: implement qr_flush.
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
-rw-r--r--xlators/performance/quick-read/src/quick-read.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/xlators/performance/quick-read/src/quick-read.c b/xlators/performance/quick-read/src/quick-read.c
index 41662ed3cce..4b2e58ea014 100644
--- a/xlators/performance/quick-read/src/quick-read.c
+++ b/xlators/performance/quick-read/src/quick-read.c
@@ -1474,6 +1474,79 @@ out:
}
+int32_t
+qr_flush_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno)
+{
+ STACK_UNWIND (frame, op_ret, op_errno);
+ return 0;
+}
+
+
+int32_t
+qr_flush_helper (call_frame_t *frame, xlator_t *this, fd_t *fd)
+{
+ STACK_WIND (frame, qr_flush_cbk, FIRST_CHILD (this),
+ FIRST_CHILD (this)->fops->flush, fd);
+ return 0;
+}
+
+
+int32_t
+qr_flush (call_frame_t *frame, xlator_t *this, fd_t *fd)
+{
+ uint64_t value = 0;
+ call_stub_t *stub = NULL;
+ qr_fd_ctx_t *qr_fd_ctx = NULL;
+ int32_t ret = -1, op_ret = -1, op_errno = -1;
+ char can_wind = 0, need_unwind = 0;
+
+ ret = fd_ctx_get (fd, this, &value);
+ if (ret == 0) {
+ qr_fd_ctx = (qr_fd_ctx_t *)(long)value;
+ }
+
+ if (qr_fd_ctx) {
+ LOCK (&qr_fd_ctx->lock);
+ {
+ if (qr_fd_ctx->opened) {
+ can_wind = 1;
+ } else if (qr_fd_ctx->open_in_transit) {
+ stub = fop_flush_stub (frame, qr_flush_helper,
+ fd);
+ if (stub == NULL) {
+ op_ret = -1;
+ op_errno = ENOMEM;
+ need_unwind = 1;
+ qr_fd_ctx->open_in_transit = 0;
+ goto unlock;
+ }
+
+ list_add_tail (&stub->list,
+ &qr_fd_ctx->waiting_ops);
+ } else {
+ op_ret = 0;
+ need_unwind = 1;
+ }
+ }
+ unlock:
+ UNLOCK (&qr_fd_ctx->lock);
+ } else {
+ op_ret = 0;
+ need_unwind = 1;
+ }
+
+ if (need_unwind) {
+ STACK_UNWIND (frame, op_ret, op_errno);
+ } else if (can_wind) {
+ STACK_WIND (frame, qr_flush_cbk, FIRST_CHILD (this),
+ FIRST_CHILD (this)->fops->flush, fd);
+ }
+
+ return 0;
+}
+
+
int32_t
init (xlator_t *this)
{
@@ -1555,6 +1628,7 @@ struct xlator_fops fops = {
.fchmod = qr_fchmod,
.fsetxattr = qr_fsetxattr,
.fgetxattr = qr_fgetxattr,
+ .flush = qr_flush,
};