From: Christoph Hellwig <hch@lst.de>
To: Shaun Tancheff <shaun@tancheff.com>
Cc: linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org,
Christoph Hellwig <hch@lst.de>,
"Martin K . Petersen" <martin.petersen@oracle.com>,
Tejun Heo <tj@kernel.org>,
Josh Bingaman <josh.bingaman@seagate.com>,
Shaun Tancheff <shaun.tancheff@seagate.com>
Subject: Re: [PATCH v4] Add support for SCT Write Same
Date: Mon, 1 Aug 2016 11:40:47 +0200 [thread overview]
Message-ID: <20160801094047.GA14677@lst.de> (raw)
In-Reply-To: <1469815276-18423-1-git-send-email-shaun@tancheff.com>
> + u8 unmap = cdb[1] & 0x8;
> + bool use_sct = unmap ? false : true;
I think this would be a bit easier to understand if the use_sct flag
goes away, and we instead just key off "if (unmap)" below.
> - /* for now we only support WRITE SAME with the unmap bit set */
> - if (unlikely(!(cdb[1] & 0x8))) {
> + /*
> + * If UNMAP is not set and SCT write same is not available then fail.
> + */
> + if (use_sct && !ata_id_sct_write_same(dev->id)) {
> fp = 1;
> bp = 3;
> goto invalid_fld;
I don't think the comment adds much value. But now that we implement
WRITE SAME for both the unmap and non-unmap case we'll also need a similar
check here to reject a WRITE SAME with the unmap flag if TRIM isn't
supported, don't we?
> @@ -3304,26 +3315,56 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc)
> if (!scsi_sg_count(scmd))
> goto invalid_param_len;
>
> - buf = page_address(sg_page(scsi_sglist(scmd)));
> - size = ata_set_lba_range_entries(buf, 512, block, n_block);
> + sg = scsi_sglist(scmd);
> + buf = page_address(sg_page(sg)) + sg->offset;
I still think that this is broken for arbitrary user space pass through
command (and probably was broken before you touched the code). We really
need something that does a kmap here. I think the safest think to do
is to rewrite ata_set_lba_range_entries to use sg_copy_from_buffer (
and move it out of the header while we're at it). That should be
a prep patch to the SCT support.
> + /*
> + * if we only have SCT then ignore the state of unmap request
> + * a zero the blocks.
> + */
> + if (use_sct) {
The comment doesn't match what the code does. It only uses SCT
if use_sct, aka !unmap is true.
> /**
> + * ata_scsiop_maint_in - Simulate a subset of MAINTENANCE_IN
> + * @args: device MAINTENANCE_IN data / SCSI command of interest.
> + * @rbuf: Response buffer, to which simulated SCSI cmd output is sent.
> + *
> + * Yields a subset to satisfy scsi_report_opcode()
> + *
> + * LOCKING:
> + * spin_lock_irqsave(host lock)
> + switch (cdb[3]) {
> + case INQUIRY:
> + case FORMAT_UNIT:
> + case MODE_SENSE:
> + case MODE_SENSE_10:
> + case READ_CAPACITY:
> + case SERVICE_ACTION_IN_16:
> + case REPORT_LUNS:
> + case REQUEST_SENSE:
> + case SYNCHRONIZE_CACHE:
> + case REZERO_UNIT:
> + case SEEK_6:
> + case SEEK_10:
> + case TEST_UNIT_READY:
> + case SEND_DIAGNOSTIC:
> + supported = 3;
> + break;
> + case MAINTENANCE_IN:
> + supported = 3;
> + break;
> + case READ_6:
> + case READ_10:
> + case READ_16:
> + case WRITE_6:
> + case WRITE_10:
> + case WRITE_16:
> + supported = 3;
> + break;
Please handle all the supported commands in a single fallthrough
statement.
Also please make supported a bool and do the conversion to the magic
SCSI format in a single place at the end of the function.
> + case ZBC_IN:
> + case ZBC_OUT:
> + supported = 3;
> + break;
Should we report this for non-ZBC devices?
prev parent reply other threads:[~2016-08-01 9:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-29 18:01 [PATCH v4] Add support for SCT Write Same Shaun Tancheff
2016-08-01 9:40 ` Christoph Hellwig [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=20160801094047.GA14677@lst.de \
--to=hch@lst.de \
--cc=josh.bingaman@seagate.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=shaun.tancheff@seagate.com \
--cc=shaun@tancheff.com \
--cc=tj@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.