From: Patrick Mansfield <patmans@us.ibm.com>
To: James Bottomley <James.Bottomley@SteelEye.com>
Cc: hare@suse.de, SCSI Mailing List <linux-scsi@vger.kernel.org>
Subject: Re: [PATCH scsi-misc-2.6] allow REPORT LUN scanning even for LUN 0 PQ of 3
Date: Fri, 23 Sep 2005 15:52:08 -0700 [thread overview]
Message-ID: <20050923225208.GA21452@us.ibm.com> (raw)
In-Reply-To: <1127439208.4818.94.camel@mulgrave>
On Thu, Sep 22, 2005 at 08:33:28PM -0500, James Bottomley wrote:
> On Wed, 2005-09-21 at 17:10 -0700, Patrick Mansfield wrote:
> > I removed the bad "!" on !scsi_device_get(), and the "insmod ./scsi_debug.ko
> > max_luns=3' found 2 sd's as expected.
>
> Fixed it.
>
> > But, scsi_debug module count is still at 1. Removing (via delete attr) the
> > 2 scsi_debug devices, and module count is still at 1. So probably still a
> > missing scsi_device_put(). I'm trying to debug a bit more.
>
> Found it and fixed that too ... missing a put after the find_device.
OK, works fine now ...
> +static inline void scsi_destroy_sdev(struct scsi_device *sdev)
> +{
> + if (sdev->host->hostt->slave_destroy)
> + sdev->host->hostt->slave_destroy(sdev);
> + transport_destroy_device(&sdev->sdev_gendev);
> + put_device(&sdev->sdev_gendev);
One nit ... get rid of the inline, as the code path is not performance
critical.
Also, note that most devices won't behave as scsi_debug configured as
previosly patched: it had PQ !=0 for LUN 0, but then put LUN 0 in REPORT
LUN output.
So, we hit the already existing sdev case in James' patch.
But it was a good test case :)
For the record, here's a scsi_debug patch to not have LUN 0 show up, and
not have it in REPORT LUNS output.
--- linux-2.6.14-rc2-git1/drivers/scsi/scsi_debug.c 2005-08-28 17:51:48.000000000 -0700
+++ jamesb-lun0-replun/drivers/scsi/scsi_debug.c 2005-09-23 15:33:51.000000000 -0700
@@ -619,7 +619,10 @@ static int resp_inquiry(struct scsi_cmnd
alloc_len = (cmd[3] << 8) + cmd[4];
memset(arr, 0, SDEBUG_MAX_INQ_ARR_SZ);
- pq_pdt = (scsi_debug_ptype & 0x1f);
+ if (devip->lun == 0)
+ pq_pdt = 0x7f; /* XXX hack no LUN 0 */
+ else
+ pq_pdt = (scsi_debug_ptype & 0x1f);
arr[0] = pq_pdt;
if (0x2 & cmd[1]) { /* CMDDT bit set */
mk_sense_buffer(devip, ILLEGAL_REQUEST, INVALID_FIELD_IN_CDB,
@@ -946,7 +949,7 @@ static int resp_report_luns(struct scsi_
struct sdebug_dev_info * devip)
{
unsigned int alloc_len;
- int lun_cnt, i, upper;
+ int lun_cnt, i, upper, lun;
unsigned char *cmd = (unsigned char *)scp->cmnd;
int select_report = (int)cmd[2];
struct scsi_lun *one_lun;
@@ -960,18 +963,18 @@ static int resp_report_luns(struct scsi_
}
/* can produce response with up to 16k luns (lun 0 to lun 16383) */
memset(arr, 0, SDEBUG_RLUN_ARR_SZ);
- lun_cnt = scsi_debug_max_luns;
+ lun_cnt = scsi_debug_max_luns - 1;
arr[2] = ((sizeof(struct scsi_lun) * lun_cnt) >> 8) & 0xff;
arr[3] = (sizeof(struct scsi_lun) * lun_cnt) & 0xff;
lun_cnt = min((int)((SDEBUG_RLUN_ARR_SZ - 8) /
sizeof(struct scsi_lun)), lun_cnt);
one_lun = (struct scsi_lun *) &arr[8];
- for (i = 0; i < lun_cnt; i++) {
- upper = (i >> 8) & 0x3f;
+ for (i = 0, lun = 1; i < lun_cnt; i++, lun++) {
+ upper = (lun >> 8) & 0x3f;
if (upper)
one_lun[i].scsi_lun[0] =
(upper | (SAM2_LUN_ADDRESS_METHOD << 6));
- one_lun[i].scsi_lun[1] = i & 0xff;
+ one_lun[i].scsi_lun[1] = lun & 0xff;
}
return fill_from_dev_buffer(scp, arr,
min((int)alloc_len, SDEBUG_RLUN_ARR_SZ));
-- Patrick Mansfield
prev parent reply other threads:[~2005-09-23 22:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-30 22:43 [PATCH scsi-misc-2.6] allow REPORT LUN scanning even for LUN 0 PQ of 3 Patrick Mansfield
2005-08-30 22:45 ` [PATCH scsi-misc-2.6] scsi_debug testing patch, return LUN 0 with PQ 3 Patrick Mansfield
2005-09-08 6:26 ` [PATCH scsi-misc-2.6] allow REPORT LUN scanning even for LUN 0 PQ of 3 Hannes Reinecke
2005-09-21 3:11 ` James Bottomley
2005-09-21 22:15 ` Patrick Mansfield
2005-09-22 0:10 ` Patrick Mansfield
2005-09-23 1:33 ` James Bottomley
2005-09-23 22:52 ` Patrick Mansfield [this message]
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=20050923225208.GA21452@us.ibm.com \
--to=patmans@us.ibm.com \
--cc=James.Bottomley@SteelEye.com \
--cc=hare@suse.de \
--cc=linux-scsi@vger.kernel.org \
/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