Blob Blame History Raw
From 296d280c75299a5271ab8e88bf99f731986fd0e5 Mon Sep 17 00:00:00 2001
From: vmallika <vmallika@redhat.com>
Date: Thu, 30 Apr 2015 12:35:40 +0530
Subject: [PATCH 04/18] features/quota: prevent statfs frame loss when an error
 happens during ancestry building

This is a backport of http://review.gluster.org/#/c/9380/

> We do quota_build_ancestry in function 'quota_get_limit_dir',
> suppose if quota_build_ancestry fails, then we don't have a
> frame saved to continue the statfs FOP and client can hang.
>
> Change-Id: I92e25c1510d09444b9d4810afdb6b2a69dcd92c0
> BUG: 1178619
> Signed-off-by: Raghavendra G <rgowdapp@redhat.com>
> Signed-off-by: vmallika <vmallika@redhat.com>
> Reviewed-on: http://review.gluster.org/9380
> Tested-by: Gluster Build System <jenkins@build.gluster.com>

Change-Id: I998f417d62d6ea4f57f237f547243d44c2da438c
BUG: 1226162
Signed-off-by: vmallika <vmallika@redhat.com>
Reviewed-on: http://review.gluster.org/11025
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Tested-by: Raghavendra G <rgowdapp@redhat.com>
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Signed-off-by: Sachin Pandit <spandit@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/49896
Reviewed-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
Tested-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
---
 xlators/features/quota/src/quota.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c
index a649df8..621e849 100644
--- a/xlators/features/quota/src/quota.c
+++ b/xlators/features/quota/src/quota.c
@@ -4272,16 +4272,9 @@ quota_statfs_continue (call_frame_t *frame, xlator_t *this, inode_t *inode)
         quota_local_t   *local          = frame->local;
         int              ret            = -1;
 
-        stub = fop_statfs_stub (frame, quota_statfs_helper,
-                                &local->loc, local->xdata);
-        if (!stub)
-                goto err;
-
         LOCK (&local->lock);
         {
                 local->inode = inode_ref (inode);
-                local->link_count = 1;
-                local->stub = stub;
         }
         UNLOCK (&local->lock);
 
@@ -4289,12 +4282,6 @@ quota_statfs_continue (call_frame_t *frame, xlator_t *this, inode_t *inode)
                               quota_statfs_validate_cbk);
         if (0 > ret)
                 quota_handle_validate_error (local, -1, -ret);
-        return;
-
-err:
-        QUOTA_STACK_UNWIND (statfs, frame, -1, ENOMEM, NULL, NULL);
-
-        return;
 }
 
 void
@@ -4361,6 +4348,7 @@ quota_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
         int8_t           ignore_deem_statfs  = 0;
         quota_priv_t    *priv                = NULL;
         quota_local_t   *local               = NULL;
+        call_stub_t     *stub                = NULL;
 
         priv = this->private;
         GF_ASSERT (loc);
@@ -4380,6 +4368,7 @@ quota_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
                         op_errno = ENOMEM;
                         goto err;
                 }
+                frame->local = local;
 
                 ret = loc_copy (&local->loc, loc);
                 if (-1 == ret) {
@@ -4390,9 +4379,19 @@ quota_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
                 if (xdata)
                         local->xdata = dict_ref (xdata);
 
-                local->link_count = 1;
+                stub = fop_statfs_stub (frame, quota_statfs_helper,
+                                        &local->loc, local->xdata);
+                if (!stub) {
+                        op_errno = ENOMEM;
+                        goto err;
+                }
 
-                frame->local = local;
+                LOCK (&local->lock);
+                {
+                        local->link_count = 1;
+                        local->stub = stub;
+                }
+                UNLOCK (&local->lock);
 
                 quota_get_limit_dir (frame, loc->inode, this);
 
-- 
1.9.3