linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Bart Van Assche <bvanassche@acm.org>,
	"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>,
	James Bottomley <james.bottomley@hansenpartnership.com>,
	linux-scsi@vger.kernel.org
Subject: Re: [PATCH 3/4] aacraid: use blk_mq_rq_busy_iter() for traversing outstanding commands
Date: Fri, 1 Nov 2019 17:30:43 +0100	[thread overview]
Message-ID: <49cab747-c1d6-a97a-6adb-8e547e8a2e0a@suse.de> (raw)
In-Reply-To: <6c70be12-cc58-1c69-beed-f9cd8ef65269@acm.org>

On 11/1/19 4:34 PM, Bart Van Assche wrote:
> On 11/1/19 4:18 AM, Hannes Reinecke wrote:
>> +static bool synchronize_busy_iter(struct request *req, void *data, 
>> bool reserved)
>> +{
>> +    struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req);
>> +    struct synchronize_busy_data *busy_data = data;
>> +
>> +    if (busy_data->sdev == cmd->device &&
>> +        cmd->SCp.phase == AAC_OWNER_FIRMWARE) {
>> +        u64 cmnd_lba;
>> +        u32 cmnd_count;
>> +
>> +        if (cmd->cmnd[0] == WRITE_6) {
>> +            cmnd_lba = ((cmd->cmnd[1] & 0x1F) << 16) |
>> +                (cmd->cmnd[2] << 8) |
>> +                cmd->cmnd[3];
>> +            cmnd_count = cmd->cmnd[4];
>> +            if (cmnd_count == 0)
>> +                cmnd_count = 256;
>> +        } else if (cmd->cmnd[0] == WRITE_16) {
>> +            cmnd_lba = ((u64)cmd->cmnd[2] << 56) |
>> +                ((u64)cmd->cmnd[3] << 48) |
>> +                ((u64)cmd->cmnd[4] << 40) |
>> +                ((u64)cmd->cmnd[5] << 32) |
>> +                ((u64)cmd->cmnd[6] << 24) |
>> +                (cmd->cmnd[7] << 16) |
>> +                (cmd->cmnd[8] << 8) |
>> +                cmd->cmnd[9];
>> +            cmnd_count = (cmd->cmnd[10] << 24) |
>> +                (cmd->cmnd[11] << 16) |
>> +                (cmd->cmnd[12] << 8) |
>> +                cmd->cmnd[13];
>> +        } else if (cmd->cmnd[0] == WRITE_12) {
>> +            cmnd_lba = ((u64)cmd->cmnd[2] << 24) |
>> +                (cmd->cmnd[3] << 16) |
>> +                (cmd->cmnd[4] << 8) |
>> +                cmd->cmnd[5];
>> +            cmnd_count = (cmd->cmnd[6] << 24) |
>> +                (cmd->cmnd[7] << 16) |
>> +                (cmd->cmnd[8] << 8) |
>> +                cmd->cmnd[9];
>> +        } else if (cmd->cmnd[0] == WRITE_10) {
>> +            cmnd_lba = ((u64)cmd->cmnd[2] << 24) |
>> +                (cmd->cmnd[3] << 16) |
>> +                (cmd->cmnd[4] << 8) |
>> +                cmd->cmnd[5];
>> +            cmnd_count = (cmd->cmnd[7] << 8) |
>> +                cmd->cmnd[8];
>> +        } else
>> +            return true;
> 
> The above code looks very similar to the code in scsi_trace.c. Although 
> SCSI LLDs shouldn't parse CDBs, there are a few SCSI LLDs that do this. 
> Would it be worth it to introduce a function in the SCSI core that 
> extracts the most important fields from a CDB (LBA, data buffer size, ...)?
> 
Possibly.
I'll see what I can come up with.

But in either case I'd rather do this as a separate patchset.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke            Teamlead Storage & Networking
hare@suse.de                              +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah
HRB 21284 (AG Nürnberg)

  reply	other threads:[~2019-11-01 16:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-01 11:18 [PATCH 0/4] scsi: remove legacy cmd_list implementation Hannes Reinecke
2019-11-01 11:18 ` [PATCH 1/4] dpt_i2o: use midlayer tcq implementation Hannes Reinecke
2019-11-01 11:18 ` [PATCH 2/4] dpt_i2o: make adpt_i2o_to_scsi() a void function Hannes Reinecke
2019-11-01 11:18 ` [PATCH 3/4] aacraid: use blk_mq_rq_busy_iter() for traversing outstanding commands Hannes Reinecke
2019-11-01 15:34   ` Bart Van Assche
2019-11-01 16:30     ` Hannes Reinecke [this message]
2019-11-02 16:20   ` kbuild test robot
2019-11-02 16:20   ` [PATCH] aacraid: fix semicolon.cocci warnings kbuild test robot
2019-11-01 11:18 ` [PATCH 4/4] scsi: Remove cmd_list functionality Hannes Reinecke
2019-11-01 15:28   ` Bart Van Assche
2019-11-15  8:05 [PATCHv2 0/4] scsi: remove legacy cmd_list implementation Hannes Reinecke
2019-11-15  8:05 ` [PATCH 3/4] aacraid: use blk_mq_rq_busy_iter() for traversing outstanding commands Hannes Reinecke
2019-11-15  9:06   ` Christoph Hellwig

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=49cab747-c1d6-a97a-6adb-8e547e8a2e0a@suse.de \
    --to=hare@suse.de \
    --cc=bvanassche@acm.org \
    --cc=hch@lst.de \
    --cc=james.bottomley@hansenpartnership.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.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;
as well as URLs for NNTP newsgroup(s).