]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
fabrics: return error when discovery retry exhausted
authorMinwoo Im <minwoo.im.dev@gmail.com>
Tue, 18 Jun 2019 12:53:38 +0000 (21:53 +0900)
committerMinwoo Im <minwoo.im.dev@gmail.com>
Thu, 20 Jun 2019 14:23:17 +0000 (23:23 +0900)
If the discovery page is not updated to the latest one over the 10
times, it's currently returning DISC_OK if the numrec has no problem.
If so, the caller might think that the discovery has been successfully
done without any errors even there is.

This patch makes it return an error -EAGAIN if retry(10 times) has been
exhausted.

Cc: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Chaitanya Kulkarni <chaianya.kulkarni@wdc.com>
fabrics.c

index adedca0620662a24efedfc06f1f7053e556f26c9..8470d974b2d5d2ec0f23b2bf3bf25771cf015550 100644 (file)
--- a/fabrics.c
+++ b/fabrics.c
@@ -291,6 +291,7 @@ enum {
        DISC_NO_LOG,
        DISC_GET_NUMRECS,
        DISC_GET_LOG,
+       DISC_RETRY_EXHAUSTED,
        DISC_NOT_EQUAL,
 };
 
@@ -385,6 +386,16 @@ static int nvmf_get_log_page_discovery(const char *dev_path,
        } while (genctr != le64_to_cpu(log->genctr) &&
                 ++retries < max_retries);
 
+       /*
+        * If genctr is still different with the one in the log entry, it
+        * means the retires have been exhausted to max_retries.  Then it
+        * should be retried by the caller or the user.
+        */
+       if (genctr != le64_to_cpu(log->genctr)) {
+               error = DISC_RETRY_EXHAUSTED;
+               goto out_free_log;
+       }
+
        if (*numrec != le32_to_cpu(log->numrec)) {
                error = DISC_NOT_EQUAL;
                goto out_free_log;
@@ -882,6 +893,10 @@ static int do_discover(char *argstr, bool connect)
                fprintf(stdout, "No discovery log entries to fetch.\n");
                ret = DISC_OK;
                break;
+       case DISC_RETRY_EXHAUSTED:
+               fprintf(stdout, "Discovery retries exhausted.\n");
+               ret = -EAGAIN;
+               break;
        case DISC_NOT_EQUAL:
                fprintf(stderr,
                "Numrec values of last two get discovery log page not equal\n");