Skip to content

Commit 2657a41

Browse files
authored
Merge pull request #353 from igaw/introduce-connection-error-mapping
fabrics: Introduce connection connect error mapping
2 parents 126beac + 2242d07 commit 2657a41

3 files changed

Lines changed: 35 additions & 1 deletion

File tree

src/nvme/fabrics.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,26 @@ static int __nvmf_add_ctrl(nvme_root_t r, const char *argstr)
526526
if (ret != len) {
527527
nvme_msg(r, LOG_NOTICE, "Failed to write to %s: %s\n",
528528
nvmf_dev, strerror(errno));
529-
ret = -ENVME_CONNECT_WRITE;
529+
switch (errno) {
530+
case EALREADY:
531+
ret = -ENVME_CONNECT_ALREADY;
532+
break;
533+
case EINVAL:
534+
ret = -ENVME_CONNECT_INVAL;
535+
break;
536+
case EADDRINUSE:
537+
ret = -ENVME_CONNECT_ADDRINUSE;
538+
break;
539+
case ENODEV:
540+
ret = -ENVME_CONNECT_NODEV;
541+
break;
542+
case EOPNOTSUPP:
543+
ret = -ENVME_CONNECT_OPNOTSUPP;
544+
break;
545+
default:
546+
ret = -ENVME_CONNECT_WRITE;
547+
break;
548+
}
530549
goto out_close;
531550
}
532551

src/nvme/util.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,11 @@ static const char * const libnvme_status[] = {
536536
[ENVME_CONNECT_INVAL_TR] = "invalid transport type",
537537
[ENVME_CONNECT_LOOKUP_SUBSYS_NAME] = "failed to lookup subsystem name",
538538
[ENVME_CONNECT_LOOKUP_SUBSYS] = "failed to lookup subsystem",
539+
[ENVME_CONNECT_ALREADY] = "already connnected",
540+
[ENVME_CONNECT_INVAL] = "invalid arguments/configuration",
541+
[ENVME_CONNECT_ADDRINUSE] = "hostnqn already in use",
542+
[ENVME_CONNECT_NODEV] = "invalid interface",
543+
[ENVME_CONNECT_OPNOTSUPP] ="not supported",
539544
};
540545

541546
const char *nvme_errno_to_string(int status)

src/nvme/util.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131
* @ENVME_CONNECT_INVAL_TR: invalid transport type
3232
* @ENVME_CONNECT_LOOKUP_SUBSYS_NAME: failed to lookup subsystem name
3333
* @ENVME_CONNECT_LOOKUP_SUBSYS: failed to lookup subsystem
34+
* @ENVME_CONNECT_ALREADY: the connect attempt failed, already connected
35+
* @ENVME_CONNECT_INVAL: invalid arguments/configuration
36+
* @ENVME_CONNECT_ADDRINUSE: hostnqn already in use
37+
* @ENVME_CONNECT_NODEV: invalid interface
38+
* @ENVME_CONNECT_OPNOTSUPP: not supported
3439
*/
3540
enum nvme_connect_err {
3641
ENVME_CONNECT_RESOLVE = 1000,
@@ -45,6 +50,11 @@ enum nvme_connect_err {
4550
ENVME_CONNECT_INVAL_TR,
4651
ENVME_CONNECT_LOOKUP_SUBSYS_NAME,
4752
ENVME_CONNECT_LOOKUP_SUBSYS,
53+
ENVME_CONNECT_ALREADY,
54+
ENVME_CONNECT_INVAL,
55+
ENVME_CONNECT_ADDRINUSE,
56+
ENVME_CONNECT_NODEV,
57+
ENVME_CONNECT_OPNOTSUPP,
4858
};
4959

5060
/**

0 commit comments

Comments
 (0)