Project

General

Profile

Actions

Bug #5305

open

libsmp doesn't return correct errno when expander device is gone

Added by Tao Xu almost 9 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
lib - userland libraries
Start date:
2014-11-10
Due date:
% Done:

0%

Estimated time:
Difficulty:
Bite-size
Tags:
needs-triage
Gerrit CR:
External Bug:

Description

If the result of SMP passthru request is MPI2_IOCSTATUS_SCSI_DEVICE_NOT_THERE, mpt_sas will return ENODEV to the SCSA framework. And SMP target driver will pass the errno to caller (e.g. libsmp).

https://github.com/illumos/illumos-gate/blob/master/usr/src/uts/common/io/scsi/adapters/mpt_sas/mptsas.c#L15884

    /* do passthrough success, check the smp status */
    if (LE_16(rep.IOCStatus) != MPI2_IOCSTATUS_SUCCESS) {
        switch (LE_16(rep.IOCStatus)) {
        case MPI2_IOCSTATUS_SCSI_DEVICE_NOT_THERE:
            smp_pkt->smp_pkt_reason = ENODEV;
            break;

https://github.com/illumos/illumos-gate/blob/master/usr/src/uts/common/io/scsi/targets/smp.c#L524

        default:
            smp_log(smp_state, CE_NOTE,
                "!smp_transport failed, smp_pkt_reason %d",
                smp_pkt->smp_pkt_reason);
            rval = smp_pkt->smp_pkt_reason;
            goto copyout;

libsmp doesn't check or pass ENODEV, so userland application won't know the reason of failed SMP request.

https://github.com/illumos/illumos-gate/blob/master/usr/src/lib/scsi/plugins/smp/usmp/common/usmp.c#L183

    if (ioctl(dp->ud_fd, USMPFUNC, &cmd) < 0) {
        ASSERT(errno != EFAULT);
        switch (errno) {
        case EINVAL:
            return (smp_error(ESMP_BADFUNC, "internal usmp error"));
        case EPERM:
            return (smp_error(ESMP_PERM,
                "insufficient privileges"));
        case EIO:
            return (smp_error(ESMP_IO, "I/O error"));
        default:
            return (smp_error(ESMP_SYS, "usmp ioctl failed: %s",
                strerror(errno)));
        }
    }

Typically this issue can happen when expander device is removed but fail to offline in devinfo tree. Removed device fails to offline when there's kernel LDI or userland contract constraints.

No data to display

Actions

Also available in: Atom PDF