Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

vioscsi cmd target id

3 views
Skip to first unread message

Rohan Desai

unread,
Sep 1, 2016, 4:01:43 AM9/1/16
to tech...@netbsd.org
Having an issue with vioscsi in GCE. vioscsi decrements the target id in
commands it sends to virtio. This means that the upper layers notion of the
target id is off by 1. This is especially problematic when presented a lun
on the last target of a bus. It never gets discovered because the scsipi
probe code sends down an xs with the last target number, which vioscsi then
decrements in the command it sends along. The probe code never moves on to
the next target (since it thinks its probed all the targets on the bus) and
the lun is never discovered. I hit this in GCE for local disks because they
create a new bus with a single target for each local disk.

Here's a patch that fixes the issue for me:

@@ -279,12 +279,12 @@ vioscsi_scsipi_request(struct scsipi_channel *chan,
scsipi_adapter_req_t
goto stuffup;
}
req->lun[0] = 1;
- req->lun[1] = periph->periph_target - 1;
+ req->lun[1] = periph->periph_target;
req->lun[2] = 0x40 | (periph->periph_lun >> 8);
req->lun[3] = periph->periph_lun;
memset(req->lun + 4, 0, 4);
DPRINTF(("%s: command for %u:%u at slot %d\n", __func__,
- periph->periph_target - 1, periph->periph_lun, slot));
+ periph->periph_target, periph->periph_lun, slot));

if ((size_t)xs->cmdlen > sizeof(req->cdb)) {
DPRINTF(("%s: bad cmdlen %zu > %zu\n", __func__,

Any reason for decrementing periph_target in the first place?

Christos Zoulas

unread,
Sep 2, 2016, 1:53:01 AM9/2/16
to tech...@netbsd.org
In article <CAAw6btkQ34JoUNjt-Vht0aKVe=hAVpTwy5K7iD...@mail.gmail.com>,
Rohan Desai <desai....@gmail.com> wrote:
>-=-=-=-=-=-
Yes, somehow the first target presented to me was unusable. I tried it with
qemu..
https://wiki.netbsd.org/tutorials/how_to_setup_virtio_scsi_with_qemu/

christos

Christos Zoulas

unread,
Sep 6, 2016, 7:24:13 PM9/6/16
to Rohan Desai, tech...@netbsd.org
On Sep 6, 3:04pm, desai....@gmail.com (Rohan Desai) wrote:
-- Subject: Re: vioscsi cmd target id

| Do you mean target 0? Isn't that the virtual bus target? The probing code
| (see scsi_probe_bus in scsiconf.c) should skip this target since it matches
| the channel id set by vioscsi.

Yes... I did not know it was the virtual bus target... Where is it documented?

christos

Rohan Desai

unread,
Sep 7, 2016, 4:40:33 AM9/7/16
to Christos Zoulas, tech...@netbsd.org
Do you mean target 0? Isn't that the virtual bus target? The probing code
(see scsi_probe_bus in scsiconf.c) should skip this target since it matches
the channel id set by vioscsi.

On Thu, Sep 1, 2016 at 10:52 PM, Christos Zoulas <chri...@astron.com>
wrote:

> In article <CAAw6btkQ34JoUNjt-Vht0aKVe=hAVpTwy5K7iDm5ycb6Pza2Ng@mail.

Rohan Desai

unread,
Sep 7, 2016, 4:40:54 AM9/7/16
to Christos Zoulas, tech...@netbsd.org
I don't find it documented anywhere. The chan_id field of struct
scsipi_channel is documented as "adapter's ID for this channel"
(scsipiconf.h). vioscsi.c sets chan_id to 0.

LYMN

unread,
Sep 8, 2016, 3:01:49 AM9/8/16
to Rohan Desai, Christos Zoulas, tech...@netbsd.org
On Tue, Sep 06, 2016 at 03:04:00PM -0700, Rohan Desai wrote:
> Do you mean target 0? Isn't that the virtual bus target? The probing code
> (see scsi_probe_bus in scsiconf.c) should skip this target since it matches
> the channel id set by vioscsi.
>

On physical scsi controllers the scsi id of the controller is usually 7
because the highest number on the narrow scsi bus wins arbitration (even
for a wide scsi bus this is still the case). Having the controller at 0
is unusual so it has caused some confusion. I guess the smart thing to
do would be to determine the scsi bus controller id somehow and just
skip enumerating that.

--
Brett Lymn
This email has been sent on behalf of one of the following companies within the BAE Systems Australia group of companies:

BAE Systems Australia Limited - Australian Company Number 008 423 005
BAE Systems Australia Defence Pty Limited - Australian Company Number 006 870 846
BAE Systems Australia Logistics Pty Limited - Australian Company Number 086 228 864

Our registered office is Evans Building, Taranaki Road, Edinburgh Parks,
Edinburgh, South Australia, 5111. If the identity of the sending company is
not clear from the content of this email please contact the sender.

This email and any attachments may contain confidential and legally
privileged information. If you are not the intended recipient, do not copy or
disclose its content, but please reply to this email immediately and highlight
the error to the sender and then immediately delete the message.

0 new messages