14f8ab
From f30fa3938f980f03d08479776037090e7fc11f42 Mon Sep 17 00:00:00 2001
14f8ab
From: Ashish Pandey <aspandey@redhat.com>
14f8ab
Date: Tue, 5 May 2020 18:17:49 +0530
14f8ab
Subject: [PATCH 369/375] cluster/ec: Return correct error code and log message
14f8ab
14f8ab
In case of readdir was send with an FD on which opendir
14f8ab
was failed, this FD will be useless and we return it with error.
14f8ab
For now, we are returning it with EINVAL without logging any
14f8ab
message in log file.
14f8ab
14f8ab
Return a correct error code and also log the message to improve thing to debug.
14f8ab
14f8ab
>fixes: #1220
14f8ab
>Change-Id: Iaf035254b9c5aa52fa43ace72d328be622b06169
14f8ab
>Signed-off-by: Ashish Pandey <aspandey@redhat.com>
14f8ab
(Backport of https://review.gluster.org/#/c/glusterfs/+/24407/)
14f8ab
14f8ab
BUG: 1831403
14f8ab
Change-Id: Ib5bf30c47b7491abd0ad5ca0ce52ec77945b2e53
14f8ab
Signed-off-by: Ashish Pandey <aspandey@redhat.com>
14f8ab
Reviewed-on: https://code.engineering.redhat.com/gerrit/200209
14f8ab
Tested-by: RHGS Build Bot <nigelb@redhat.com>
14f8ab
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
14f8ab
---
14f8ab
 xlators/cluster/ec/src/ec-dir-read.c | 11 +++++++++--
14f8ab
 1 file changed, 9 insertions(+), 2 deletions(-)
14f8ab
14f8ab
diff --git a/xlators/cluster/ec/src/ec-dir-read.c b/xlators/cluster/ec/src/ec-dir-read.c
14f8ab
index 8310d4a..9924425 100644
14f8ab
--- a/xlators/cluster/ec/src/ec-dir-read.c
14f8ab
+++ b/xlators/cluster/ec/src/ec-dir-read.c
14f8ab
@@ -388,9 +388,16 @@ ec_manager_readdir(ec_fop_data_t *fop, int32_t state)
14f8ab
             /* Return error if opendir has not been successfully called on
14f8ab
              * any subvolume. */
14f8ab
             ctx = ec_fd_get(fop->fd, fop->xl);
14f8ab
-            if ((ctx == NULL) || (ctx->open == 0)) {
14f8ab
-                fop->error = EINVAL;
14f8ab
+            if (ctx == NULL) {
14f8ab
+                fop->error = ENOMEM;
14f8ab
+            } else if (ctx->open == 0) {
14f8ab
+                fop->error = EBADFD;
14f8ab
+            }
14f8ab
 
14f8ab
+            if (fop->error) {
14f8ab
+                gf_msg(fop->xl->name, GF_LOG_ERROR, fop->error,
14f8ab
+                       EC_MSG_INVALID_REQUEST, "EC is not winding readdir: %s",
14f8ab
+                       ec_msg_str(fop));
14f8ab
                 return EC_STATE_REPORT;
14f8ab
             }
14f8ab
 
14f8ab
-- 
14f8ab
1.8.3.1
14f8ab