cb8e9e
From 296d280c75299a5271ab8e88bf99f731986fd0e5 Mon Sep 17 00:00:00 2001
cb8e9e
From: vmallika <vmallika@redhat.com>
cb8e9e
Date: Thu, 30 Apr 2015 12:35:40 +0530
cb8e9e
Subject: [PATCH 04/18] features/quota: prevent statfs frame loss when an error
cb8e9e
 happens during ancestry building
cb8e9e
cb8e9e
This is a backport of http://review.gluster.org/#/c/9380/
cb8e9e
cb8e9e
> We do quota_build_ancestry in function 'quota_get_limit_dir',
cb8e9e
> suppose if quota_build_ancestry fails, then we don't have a
cb8e9e
> frame saved to continue the statfs FOP and client can hang.
cb8e9e
>
cb8e9e
> Change-Id: I92e25c1510d09444b9d4810afdb6b2a69dcd92c0
cb8e9e
> BUG: 1178619
cb8e9e
> Signed-off-by: Raghavendra G <rgowdapp@redhat.com>
cb8e9e
> Signed-off-by: vmallika <vmallika@redhat.com>
cb8e9e
> Reviewed-on: http://review.gluster.org/9380
cb8e9e
> Tested-by: Gluster Build System <jenkins@build.gluster.com>
cb8e9e
cb8e9e
Change-Id: I998f417d62d6ea4f57f237f547243d44c2da438c
cb8e9e
BUG: 1226162
cb8e9e
Signed-off-by: vmallika <vmallika@redhat.com>
cb8e9e
Reviewed-on: http://review.gluster.org/11025
cb8e9e
Tested-by: Gluster Build System <jenkins@build.gluster.com>
cb8e9e
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
cb8e9e
Tested-by: Raghavendra G <rgowdapp@redhat.com>
cb8e9e
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
cb8e9e
Signed-off-by: Sachin Pandit <spandit@redhat.com>
cb8e9e
Reviewed-on: https://code.engineering.redhat.com/gerrit/49896
cb8e9e
Reviewed-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
cb8e9e
Tested-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
cb8e9e
---
cb8e9e
 xlators/features/quota/src/quota.c | 29 ++++++++++++++---------------
cb8e9e
 1 file changed, 14 insertions(+), 15 deletions(-)
cb8e9e
cb8e9e
diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c
cb8e9e
index a649df8..621e849 100644
cb8e9e
--- a/xlators/features/quota/src/quota.c
cb8e9e
+++ b/xlators/features/quota/src/quota.c
cb8e9e
@@ -4272,16 +4272,9 @@ quota_statfs_continue (call_frame_t *frame, xlator_t *this, inode_t *inode)
cb8e9e
         quota_local_t   *local          = frame->local;
cb8e9e
         int              ret            = -1;
cb8e9e
 
cb8e9e
-        stub = fop_statfs_stub (frame, quota_statfs_helper,
cb8e9e
-                                &local->loc, local->xdata);
cb8e9e
-        if (!stub)
cb8e9e
-                goto err;
cb8e9e
-
cb8e9e
         LOCK (&local->lock);
cb8e9e
         {
cb8e9e
                 local->inode = inode_ref (inode);
cb8e9e
-                local->link_count = 1;
cb8e9e
-                local->stub = stub;
cb8e9e
         }
cb8e9e
         UNLOCK (&local->lock);
cb8e9e
 
cb8e9e
@@ -4289,12 +4282,6 @@ quota_statfs_continue (call_frame_t *frame, xlator_t *this, inode_t *inode)
cb8e9e
                               quota_statfs_validate_cbk);
cb8e9e
         if (0 > ret)
cb8e9e
                 quota_handle_validate_error (local, -1, -ret);
cb8e9e
-        return;
cb8e9e
-
cb8e9e
-err:
cb8e9e
-        QUOTA_STACK_UNWIND (statfs, frame, -1, ENOMEM, NULL, NULL);
cb8e9e
-
cb8e9e
-        return;
cb8e9e
 }
cb8e9e
 
cb8e9e
 void
cb8e9e
@@ -4361,6 +4348,7 @@ quota_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
cb8e9e
         int8_t           ignore_deem_statfs  = 0;
cb8e9e
         quota_priv_t    *priv                = NULL;
cb8e9e
         quota_local_t   *local               = NULL;
cb8e9e
+        call_stub_t     *stub                = NULL;
cb8e9e
 
cb8e9e
         priv = this->private;
cb8e9e
         GF_ASSERT (loc);
cb8e9e
@@ -4380,6 +4368,7 @@ quota_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
cb8e9e
                         op_errno = ENOMEM;
cb8e9e
                         goto err;
cb8e9e
                 }
cb8e9e
+                frame->local = local;
cb8e9e
 
cb8e9e
                 ret = loc_copy (&local->loc, loc);
cb8e9e
                 if (-1 == ret) {
cb8e9e
@@ -4390,9 +4379,19 @@ quota_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
cb8e9e
                 if (xdata)
cb8e9e
                         local->xdata = dict_ref (xdata);
cb8e9e
 
cb8e9e
-                local->link_count = 1;
cb8e9e
+                stub = fop_statfs_stub (frame, quota_statfs_helper,
cb8e9e
+                                        &local->loc, local->xdata);
cb8e9e
+                if (!stub) {
cb8e9e
+                        op_errno = ENOMEM;
cb8e9e
+                        goto err;
cb8e9e
+                }
cb8e9e
 
cb8e9e
-                frame->local = local;
cb8e9e
+                LOCK (&local->lock);
cb8e9e
+                {
cb8e9e
+                        local->link_count = 1;
cb8e9e
+                        local->stub = stub;
cb8e9e
+                }
cb8e9e
+                UNLOCK (&local->lock);
cb8e9e
 
cb8e9e
                 quota_get_limit_dir (frame, loc->inode, this);
cb8e9e
 
cb8e9e
-- 
cb8e9e
1.9.3
cb8e9e