Page MenuHomeFreeBSD

nvme: fix resv commands with nda device
ClosedPublic

Authored by yuri_aetern.org on Dec 14 2022, 7:16 AM.
Tags
None
Referenced Files
F104148595: D37696.diff
Wed, Dec 4, 2:32 AM
Unknown Object (File)
Mon, Nov 18, 2:42 PM
Unknown Object (File)
Sat, Nov 9, 5:59 PM
Unknown Object (File)
Wed, Nov 6, 3:26 PM
Unknown Object (File)
Wed, Nov 6, 3:26 PM
Unknown Object (File)
Wed, Nov 6, 3:26 PM
Unknown Object (File)
Wed, Nov 6, 3:26 PM
Unknown Object (File)
Tue, Nov 5, 3:09 AM
Subscribers

Details

Summary
  • passing I/O commands through nda requires nsid field to be set (it was unused when going through nvme_ns_ioctl())
  • ccb's status can be OR'ed with the flags, use CAM_STATUS_MASK
Test Plan

pre:

# nvmecontrol resv report nda24
nvmecontrol: report request failed: Input/output error

nvme24: RESERVATION REPORT sqid:3 cid:127 nsid:0
nvme24: INVALID NAMESPACE OR FORMAT (00/0b) crd:0 m:0 dnr:1 sqid:3 cid:127 cdw0:0

post:

# nvmecontrol resv report nda24
Generation:                       2152
Reservation Type:                 3
Number of Registered Controllers: 1
Persist Through Power Loss State: 0
Controller ID:                    0x0023
  Reservation Status:             1
  Host Identifier:                0x2818887a
  Reservation Key:                0xea35a678b846fea2

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

With one exception, these changes look good to my eye.
But I've not chased things all the way through the protocol stack to make sure that the nsid isn't getting overridden in the passthrough cases (I don't see any, btw, but I didn't chase all possible paths down)

sys/cam/nvme/nvme_da.c
444–445

This is wrong. CAM_REQ_CMP is not a bitmask.

But it should be CAM_REQ_CMP always at this point in the code. What is it? None of the xtra bits should be set on a passthrough CCB, so this confuses me.

The proper thing to test for, though, is likely (ccb->ccb_h.status & CAM_STATUS_MASK) to account for those extra bits, all of which appear to be only in the error / recovery path, or for queueing commands which the passthrough interface doesn't do today.

sys/cam/nvme/nvme_da.c
444–445

"should be CAM_REQ_CMP on success" I should have said. It can be any of the other errors too...

sys/cam/nvme/nvme_da.c
444–445

May be I'm phrasing it wrong, what I meant is that it got OR'ed in the following commit:

commit abea0c6b0ddc969d1f3b9cab1fd90df00de1f2e4
Author: Warner Losh <imp@FreeBSD.org>
Date:   Sat Jul 17 16:10:46 2021 -0600

    cam: Mark the qos data is valid in xpd_done_direct() too.

    Sponsored by:           Netflix

diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c
index b76d6f5adde..6b5a04b174e 100644
--- a/sys/cam/cam_xpt.c
+++ b/sys/cam/cam_xpt.c
@@ -4642,6 +4642,7 @@ xpt_done_direct(union ccb *done_ccb)

        /* Store the time the ccb was in the sim */
        done_ccb->ccb_h.qos.periph_data = cam_iosched_delta_t(done_ccb->ccb_h.qos.periph_data);
+       done_ccb->ccb_h.status |= CAM_QOS_VALID;
        xpt_done_process(&done_ccb->ccb_h);
 }
yuri_aetern.org edited the summary of this revision. (Show Details)

use CAM_STATUS_MASK, status is not really a bitmap

This looks good to me now.... I must not have been doing passthrough commands that set QOS_VALID on completion somehow...

This revision is now accepted and ready to land.Dec 14 2022, 4:45 PM

Can I get a Signed-off-by: line or an email address with your full name so I can commit?

In D37696#857437, @imp wrote:

Can I get a Signed-off-by: line or an email address with your full name so I can commit?

Let's go with yuripv@.

This revision was automatically updated to reflect the committed changes.