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