Blob Blame History Raw
From afa1b39d6b00fb10e3644b4430cd8f24b001dadc Mon Sep 17 00:00:00 2001
From: N Balachandran <nbalacha@redhat.com>
Date: Tue, 8 Aug 2017 22:33:24 +0530
Subject: [PATCH 598/601] cluster/dht: EBADF handling for fremovexattr and
 fsetxattr

Add EBADF handling for dht_fremovexattr and dht_fsetxattr.

> BUG: 1476665
> Signed-off-by: N Balachandran <nbalacha@redhat.com>
> Reviewed-on: https://review.gluster.org/17999
> Smoke: Gluster Build System <jenkins@build.gluster.org>
> Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>

Change-Id: Ide0d5812dae79655d2565157e5baabcd753b4309
BUG: 1475136
Signed-off-by: N Balachandran <nbalacha@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/114762
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
 xlators/cluster/dht/src/dht-common.c | 16 ++++++++++++++++
 xlators/cluster/dht/src/dht-common.h |  9 +++++++++
 xlators/cluster/dht/src/dht-helper.c | 25 ++++++++++++++++++++++---
 3 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index 55106fa..5ad1ade 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -3811,6 +3811,14 @@ dht_file_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
 
         local->op_errno = op_errno;
 
+        if ((local->fop == GF_FOP_FSETXATTR) &&
+            op_ret == -1 && (op_errno == EBADF) && !(local->fd_checked)) {
+                ret = dht_check_and_open_fd_on_subvol (this, frame);
+                if (ret)
+                        goto out;
+                return 0;
+        }
+
         if ((op_ret == -1) && !dht_inode_missing (op_errno)) {
                 gf_msg_debug (this->name, op_errno,
                               "subvolume %s returned -1.",
@@ -4375,6 +4383,14 @@ dht_file_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
 
         local->op_errno = op_errno;
 
+        if ((local->fop == GF_FOP_FREMOVEXATTR) &&
+            (op_ret == -1) && (op_errno == EBADF) && !(local->fd_checked)) {
+                ret = dht_check_and_open_fd_on_subvol (this, frame);
+                if (ret)
+                        goto out;
+                return 0;
+        }
+
         if ((op_ret == -1) && !dht_inode_missing (op_errno)) {
                 gf_msg_debug (this->name, op_errno,
                               "subvolume %s returned -1",
diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h
index 5f125ee..38f7219 100644
--- a/xlators/cluster/dht/src/dht-common.h
+++ b/xlators/cluster/dht/src/dht-common.h
@@ -1337,4 +1337,13 @@ dht_file_attr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
                    int op_ret, int op_errno, struct iatt *stbuf, dict_t *xdata);
 
 
+int
+dht_file_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+                          int op_ret, int op_errno, dict_t *xdata);
+
+
+int
+dht_file_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+                       int op_ret, int op_errno, dict_t *xdata);
+
 #endif/* _DHT_H */
diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c
index ca9184f..88d39ee 100644
--- a/xlators/cluster/dht/src/dht-helper.c
+++ b/xlators/cluster/dht/src/dht-helper.c
@@ -306,7 +306,6 @@ dht_check_and_open_fd_on_subvol_complete (int ret, call_frame_t *frame,
         switch (fop) {
 
         case GF_FOP_WRITE:
-
                 STACK_WIND_COOKIE (frame, dht_writev_cbk, subvol, subvol,
                                    subvol->fops->writev, fd,
                                    local->rebalance.vector,
@@ -317,13 +316,11 @@ dht_check_and_open_fd_on_subvol_complete (int ret, call_frame_t *frame,
                 break;
 
         case GF_FOP_FLUSH:
-
                 STACK_WIND (frame, dht_flush_cbk, subvol,
                             subvol->fops->flush, fd, local->xattr_req);
                 break;
 
         case GF_FOP_FSETATTR:
-
                 STACK_WIND_COOKIE (frame, dht_file_setattr_cbk, subvol,
                                    subvol, subvol->fops->fsetattr, fd,
                                    &local->rebalance.stbuf,
@@ -381,6 +378,20 @@ dht_check_and_open_fd_on_subvol_complete (int ret, call_frame_t *frame,
                                    local->xattr_req);
                 break;
 
+        case GF_FOP_FSETXATTR:
+                STACK_WIND_COOKIE (frame, dht_file_setxattr_cbk, subvol,
+                                   subvol, subvol->fops->fsetxattr, local->fd,
+                                   local->rebalance.xattr,
+                                   local->rebalance.flags, local->xattr_req);
+                break;
+
+        case GF_FOP_FREMOVEXATTR:
+                STACK_WIND_COOKIE (frame, dht_file_removexattr_cbk, subvol,
+                                   subvol, subvol->fops->fremovexattr,
+                                   local->fd, local->key, local->xattr_req);
+
+                break;
+
         default:
                 gf_msg (this->name, GF_LOG_ERROR, 0,
                         DHT_MSG_UNKNOWN_FOP,
@@ -446,6 +457,14 @@ handle_err:
                 DHT_STACK_UNWIND (fstat, frame, -1, op_errno, NULL, NULL);
                 break;
 
+        case GF_FOP_FSETXATTR:
+                DHT_STACK_UNWIND (fsetxattr, frame, -1, op_errno, NULL);
+                break;
+
+        case GF_FOP_FREMOVEXATTR:
+                DHT_STACK_UNWIND (fremovexattr, frame, -1, op_errno, NULL);
+                break;
+
         default:
                 gf_msg (this->name, GF_LOG_ERROR, 0,
                         DHT_MSG_UNKNOWN_FOP,
-- 
1.8.3.1