mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: WangYuli <wangyuli@uniontech.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
	usb-storage@lists.one-eyed-alien.net,
	linux-kernel@vger.kernel.org, zhanjun@uniontech.com,
	guanwentao@uniontech.com, chenlinxuan@uniontech.com,
	Xinwei Zhou <zhouxinwei@uniontech.com>,
	Xu Rao <raoxu@uniontech.com>,
	Yujing Ming <mingyujing@uniontech.com>
Subject: Re: [PATCH] usb-storage: Bypass certain SCSI commands on disks with "use_192_bytes_for_3f" attribute
Date: Fri, 7 Feb 2025 17:15:12 +0800	[thread overview]
Message-ID: <137902FEE03CCB3B+6130227f-9ddc-4043-9945-da465c28d9d1@uniontech.com> (raw)
In-Reply-To: <80ef917b-3680-4f85-93ba-c92d2b69ebaa@rowland.harvard.edu>


[-- Attachment #1.1.1.1: Type: text/plain, Size: 1582 bytes --]


On 2025/2/6 22:58, Alan Stern wrote:
> Is usb-storage really the right place to put this test?  Wouldn't it
> be better to put it in the SCSI layer where the ioctl is converted to
> a SCSI command?  That way it would affect all SCSI devices with the
> use_192_bytes_for_3f flag, not just USB devices.
Yes, yes... 
This problem may occur not only in USB devices. It is more appropriate to modify it at the SCSI layer. I'll 
send the patch v2 soon.
>
> Also, instead of making the command fail completely, wouldn't it be
> better to change the transfer length to 192 if the original value was
> larger?

But I personally think that it is not appropriate to modify it directly 
to 192. After all, it is called by the user through ioctl, and the 
kernel itself will not construct such a data frame. As shown in the 
following code:

sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer)
      {
             int res;
             struct scsi_device *sdp = sdkp->device;
             struct scsi_mode_data data;
             int old_wp = sdkp->write_prot;

             set_disk_ro(sdkp->disk, 0);
             if (sdp->skip_ms_page_3f) {
sd_first_printk(KERN_NOTICE, sdkp, "Assuming Write Enabled\n");
                     return;
             }

             if (sdp->use_192_bytes_for_3f) {
res = sd_do_mode_sense(sdp, 0, 0x3F, buffer, 192, &data, NULL);

>
-- 
WangYuli

[-- Attachment #1.1.1.2: Type: text/html, Size: 2845 bytes --]

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 645 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

      reply	other threads:[~2025-02-07  9:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-06  5:41 WangYuli
2025-02-06  5:50 ` Greg KH
2025-02-06 14:58 ` Alan Stern
2025-02-07  9:15   ` WangYuli [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=137902FEE03CCB3B+6130227f-9ddc-4043-9945-da465c28d9d1@uniontech.com \
    --to=wangyuli@uniontech.com \
    --cc=chenlinxuan@uniontech.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=guanwentao@uniontech.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mingyujing@uniontech.com \
    --cc=raoxu@uniontech.com \
    --cc=stern@rowland.harvard.edu \
    --cc=usb-storage@lists.one-eyed-alien.net \
    --cc=zhanjun@uniontech.com \
    --cc=zhouxinwei@uniontech.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®