From: Wu Bo <wubo40@huawei.com>
To: <axboe@kernel.dk>, <linux-ide@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Cc: <linfeilong@huawei.com>, <yanaijie@huawei.com>, <wubo40@huawei.com>
Subject: [RFC PATCH] ata: add lun validity check on ata_sas_queuecmd
Date: Thu, 18 Mar 2021 20:53:53 +0800 [thread overview]
Message-ID: <1616072033-287811-1-git-send-email-wubo40@huawei.com> (raw)
Hi all,
After executing rescan-scsi-bus.sh -r -m, the system adds 255 more disks.
The reason is as follows:
1. Execute the rescan-scsi-bus.sh script to scan all targets.
2. The REPORT_LUNS failed due to some errors on the device of sdb(LUN0).
3. Do a sequential scan on the target which sdb belongs to.
4. Have already scanned LUN 0, so start at LUN 1. and keep scanning until
reach the max.
5. For SATA device, the driver of ata does not check the validity of
LUN ID before dispatch commands to ATA device.
Result in LUN 1~MAX successfully added to the system.
trace:
__scsi_scan_target()
-> scsi_report_lun_scan()
-> scsi_sequential_lun_scan()
Steps to reproduce as follow:
step1: lsscsi
[1:0:0:0] disk ATA /dev/sda
[1:0:1:0] disk ATA /dev/sdb
[1:0:2:0] disk ATA /dev/sdc
[1:0:3:0] disk ATA /dev/sdd
[1:0:4:0] disk ATA /dev/sde
step2: echo "offline" > /sys/block/sdb/device/state
step3: rescan-scsi-bus.sh -r -m
step4: lsscsi
[1:0:0:0] disk ATA /dev/sda
[1:0:1:1] disk ATA /dev/sdr
[1:0:1:2] disk ATA /dev/sds
[1:0:1:3] disk ATA /dev/sdt
[1:0:1:4] disk ATA /dev/sdu
......
[1:0:1:251] disk ATA /dev/sdjh
[1:0:1:252] disk ATA /dev/sdji
[1:0:1:253] disk ATA /dev/sdjj
[1:0:1:254] disk ATA /dev/sdjk
[1:0:1:255] disk ATA /dev/sdjl
[1:0:2:0] disk ATA /dev/sdc
[1:0:3:0] disk ATA /dev/sdd
[1:0:4:0] disk ATA /dev/sde
Signed-off-by: Wu Bo <wubo40@huawei.com>
---
drivers/ata/libata-sata.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/ata/libata-sata.c b/drivers/ata/libata-sata.c
index c16423e..e30a412 100644
--- a/drivers/ata/libata-sata.c
+++ b/drivers/ata/libata-sata.c
@@ -1242,7 +1242,8 @@ int ata_sas_queuecmd(struct scsi_cmnd *cmd, struct ata_port *ap)
ata_scsi_dump_cdb(ap, cmd);
- if (likely(ata_dev_enabled(ap->link.device)))
+ if (likely(ata_dev_enabled(ap->link.device)) &&
+ (cmd->device->lun == 0))
rc = __ata_scsi_queuecmd(cmd, ap->link.device);
else {
cmd->result = (DID_BAD_TARGET << 16);
--
1.8.3.1
reply other threads:[~2021-03-18 12:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1616072033-287811-1-git-send-email-wubo40@huawei.com \
--to=wubo40@huawei.com \
--cc=axboe@kernel.dk \
--cc=linfeilong@huawei.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=yanaijie@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®