Blob Blame History Raw
From 3a1bcd22e39c26b247ef01da374cceb3d07255d1 Mon Sep 17 00:00:00 2001
From: vmallika <vmallika@redhat.com>
Date: Thu, 18 Jun 2015 12:02:50 +0530
Subject: [PATCH 126/129] quota: allow writes when with ENOENT/ESTALE on active fd

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

> We may get ENOENT/ESTALE in case of below scenario
>         fd = open file.txt
>         unlink file.txt
>         write on fd
> Here build_ancestry can fail as the file is removed.
> For now ignore ENOENT/ESTALE on active fd with
> writev and fallocate.
> We need to re-visit this code once we understand
> how other file-system behave in this scenario
>
> Below patch fixes the issue in DHT:
> http://review.gluster.org/#/c/11097
>
> Change-Id: I7be683583b808c280e3ea2ddd036c1558a6d53e5
> BUG: 1188242
> Signed-off-by: vmallika <vmallika@redhat.com>

Change-Id: Idf4696ef7c02e426b076f18a4e65d7ef6b9560ea
BUG: 1224115
Signed-off-by: vmallika <vmallika@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/51224
Reviewed-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
Tested-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
---
 xlators/features/quota/src/quota.c |   32 +++++++++++++++++++++++++++++++-
 1 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c
index 569b3c0..ef094f8 100644
--- a/xlators/features/quota/src/quota.c
+++ b/xlators/features/quota/src/quota.c
@@ -1578,6 +1578,20 @@ quota_writev_helper (call_frame_t *frame, xlator_t *this, fd_t *fd,
 
                         vector = new_vector;
                         count = new_count;
+                } else if (op_errno == ENOENT || op_errno == ESTALE) {
+                        /* We may get ENOENT/ESTALE in case of below scenario
+                         *     fd = open file.txt
+                         *     unlink file.txt
+                         *     write on fd
+                         * Here build_ancestry can fail as the file is removed.
+                         * For now ignore ENOENT/ESTALE with writes on active fd
+                         * We need to re-visit this code once we understand
+                         * how other file-system behave in this scenario
+                         */
+                        gf_msg_debug (this->name, 0, "quota enforcer failed "
+                                      "with ENOENT/ESTALE on %s, cannot check "
+                                      "quota limits and allowing writes",
+                                      uuid_utoa (fd->inode->gfid));
                 } else {
                         goto unwind;
                 }
@@ -4600,7 +4614,23 @@ quota_fallocate_helper (call_frame_t *frame, xlator_t *this, fd_t *fd,
 
         if (local->op_ret == -1) {
                 op_errno = local->op_errno;
-                goto unwind;
+                if (op_errno == ENOENT || op_errno == ESTALE) {
+                        /* We may get ENOENT/ESTALE in case of below scenario
+                         *     fd = open file.txt
+                         *     unlink file.txt
+                         *     fallocate on fd
+                         * Here build_ancestry can fail as the file is removed.
+                         * For now ignore ENOENT/ESTALE on active fd
+                         * We need to re-visit this code once we understand
+                         * how other file-system behave in this scenario
+                         */
+                        gf_msg_debug (this->name, 0, "quota enforcer failed "
+                                      "with ENOENT/ESTALE on %s, cannot check "
+                                      "quota limits and allowing fallocate",
+                                      uuid_utoa (fd->inode->gfid));
+                } else {
+                        goto unwind;
+                }
         }
 
         STACK_WIND (frame, quota_fallocate_cbk,
-- 
1.7.1