cb8e9e
From 3a1bcd22e39c26b247ef01da374cceb3d07255d1 Mon Sep 17 00:00:00 2001
cb8e9e
From: vmallika <vmallika@redhat.com>
cb8e9e
Date: Thu, 18 Jun 2015 12:02:50 +0530
cb8e9e
Subject: [PATCH 126/129] quota: allow writes when with ENOENT/ESTALE on active fd
cb8e9e
cb8e9e
This is a backport of http://review.gluster.org/#/c/11307/
cb8e9e
cb8e9e
> We may get ENOENT/ESTALE in case of below scenario
cb8e9e
>         fd = open file.txt
cb8e9e
>         unlink file.txt
cb8e9e
>         write on fd
cb8e9e
> Here build_ancestry can fail as the file is removed.
cb8e9e
> For now ignore ENOENT/ESTALE on active fd with
cb8e9e
> writev and fallocate.
cb8e9e
> We need to re-visit this code once we understand
cb8e9e
> how other file-system behave in this scenario
cb8e9e
>
cb8e9e
> Below patch fixes the issue in DHT:
cb8e9e
> http://review.gluster.org/#/c/11097
cb8e9e
>
cb8e9e
> Change-Id: I7be683583b808c280e3ea2ddd036c1558a6d53e5
cb8e9e
> BUG: 1188242
cb8e9e
> Signed-off-by: vmallika <vmallika@redhat.com>
cb8e9e
cb8e9e
Change-Id: Idf4696ef7c02e426b076f18a4e65d7ef6b9560ea
cb8e9e
BUG: 1224115
cb8e9e
Signed-off-by: vmallika <vmallika@redhat.com>
cb8e9e
Reviewed-on: https://code.engineering.redhat.com/gerrit/51224
cb8e9e
Reviewed-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
cb8e9e
Tested-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
cb8e9e
---
cb8e9e
 xlators/features/quota/src/quota.c |   32 +++++++++++++++++++++++++++++++-
cb8e9e
 1 files changed, 31 insertions(+), 1 deletions(-)
cb8e9e
cb8e9e
diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c
cb8e9e
index 569b3c0..ef094f8 100644
cb8e9e
--- a/xlators/features/quota/src/quota.c
cb8e9e
+++ b/xlators/features/quota/src/quota.c
cb8e9e
@@ -1578,6 +1578,20 @@ quota_writev_helper (call_frame_t *frame, xlator_t *this, fd_t *fd,
cb8e9e
 
cb8e9e
                         vector = new_vector;
cb8e9e
                         count = new_count;
cb8e9e
+                } else if (op_errno == ENOENT || op_errno == ESTALE) {
cb8e9e
+                        /* We may get ENOENT/ESTALE in case of below scenario
cb8e9e
+                         *     fd = open file.txt
cb8e9e
+                         *     unlink file.txt
cb8e9e
+                         *     write on fd
cb8e9e
+                         * Here build_ancestry can fail as the file is removed.
cb8e9e
+                         * For now ignore ENOENT/ESTALE with writes on active fd
cb8e9e
+                         * We need to re-visit this code once we understand
cb8e9e
+                         * how other file-system behave in this scenario
cb8e9e
+                         */
cb8e9e
+                        gf_msg_debug (this->name, 0, "quota enforcer failed "
cb8e9e
+                                      "with ENOENT/ESTALE on %s, cannot check "
cb8e9e
+                                      "quota limits and allowing writes",
cb8e9e
+                                      uuid_utoa (fd->inode->gfid));
cb8e9e
                 } else {
cb8e9e
                         goto unwind;
cb8e9e
                 }
cb8e9e
@@ -4600,7 +4614,23 @@ quota_fallocate_helper (call_frame_t *frame, xlator_t *this, fd_t *fd,
cb8e9e
 
cb8e9e
         if (local->op_ret == -1) {
cb8e9e
                 op_errno = local->op_errno;
cb8e9e
-                goto unwind;
cb8e9e
+                if (op_errno == ENOENT || op_errno == ESTALE) {
cb8e9e
+                        /* We may get ENOENT/ESTALE in case of below scenario
cb8e9e
+                         *     fd = open file.txt
cb8e9e
+                         *     unlink file.txt
cb8e9e
+                         *     fallocate on fd
cb8e9e
+                         * Here build_ancestry can fail as the file is removed.
cb8e9e
+                         * For now ignore ENOENT/ESTALE on active fd
cb8e9e
+                         * We need to re-visit this code once we understand
cb8e9e
+                         * how other file-system behave in this scenario
cb8e9e
+                         */
cb8e9e
+                        gf_msg_debug (this->name, 0, "quota enforcer failed "
cb8e9e
+                                      "with ENOENT/ESTALE on %s, cannot check "
cb8e9e
+                                      "quota limits and allowing fallocate",
cb8e9e
+                                      uuid_utoa (fd->inode->gfid));
cb8e9e
+                } else {
cb8e9e
+                        goto unwind;
cb8e9e
+                }
cb8e9e
         }
cb8e9e
 
cb8e9e
         STACK_WIND (frame, quota_fallocate_cbk,
cb8e9e
-- 
cb8e9e
1.7.1
cb8e9e