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