All of lore.kernel.org
 help / color / mirror / Atom feed
From: Douglas Gilbert <dgilbert@interlog.com>
To: Bart Van Assche <bvanassche@acm.org>,
	Tom Yan <tom.ty89@gmail.com>,
	linux-scsi@vger.kernel.org
Cc: stern@rowland.harvard.edu, James.Bottomley@SteelEye.com,
	akinobu.mita@gmail.com, hch@lst.de, jens.axboe@oracle.com
Subject: Re: [PATCH 1/4] scsi: sg: fix BLKSECTGET ioctl
Date: Sat, 5 Sep 2020 16:36:57 -0400	[thread overview]
Message-ID: <868195a0-94f2-f009-bfd4-f206f0da7db8@interlog.com> (raw)
In-Reply-To: <caf0aa91-3e54-f8bd-d818-587f4318716c@acm.org>

On 2020-09-05 3:32 p.m., Bart Van Assche wrote:
> On 2020-09-04 13:05, Tom Yan wrote:
>> It should give out the maximum number of sectors per request
>> instead of maximum number of bytes.
>>
>> Signed-off-by: Tom Yan <tom.ty89@gmail.com>
>> ---
>>   drivers/scsi/sg.c | 6 ++++--
>>   1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
>> index 20472aaaf630..e57831910228 100644
>> --- a/drivers/scsi/sg.c
>> +++ b/drivers/scsi/sg.c
>> @@ -922,6 +922,7 @@ sg_ioctl_common(struct file *filp, Sg_device *sdp, Sg_fd *sfp,
>>   	int result, val, read_only;
>>   	Sg_request *srp;
>>   	unsigned long iflags;
>> +	unsigned int max_sectors;
>>   
>>   	SCSI_LOG_TIMEOUT(3, sg_printk(KERN_INFO, sdp,
>>   				   "sg_ioctl: cmd=0x%x\n", (int) cmd_in));
>> @@ -1114,8 +1115,9 @@ sg_ioctl_common(struct file *filp, Sg_device *sdp, Sg_fd *sfp,
>>   		sdp->sgdebug = (char) val;
>>   		return 0;
>>   	case BLKSECTGET:
>> -		return put_user(max_sectors_bytes(sdp->device->request_queue),
>> -				ip);
>> +		max_sectors = min_t(unsigned int, USHRT_MAX,
>> +				    queue_max_sectors(sdp->device->request_queue));
>> +		return put_user(max_sectors, ip);
>>   	case BLKTRACESETUP:
>>   		return blk_trace_setup(sdp->device->request_queue,
>>   				       sdp->disk->disk_name,
> 
> Is this perhaps a backwards-incompatible change to the kernel ABI, the
> kind of change Linus totally disagrees with?
> 
> Additionally, please Cc linux-api for patches that modify the kernel ABI.
>>From https://www.kernel.org/doc/man-pages/linux-api-ml.html: "The kernel
> source file Documentation/SubmitChecklist notes that all Linux kernel
> patches that change userspace interfaces should be CCed to
> linux-api@vger.kernel.org, so that the various parties who are interested
> in API changes are informed. For further information, see
> https://www.kernel.org/doc/man-pages/linux-api-ml.html"

Hmm,
The BLK* ioctl()s in the sg driver were an undocumented addition by others.
Plus it is not clear to me why a char device such as the sg driver should
be supporting BLK* ioctl(2)s. For example, how should an enclosure react to 
those ioctls or a WLUN?

If they are going to be supported for storage devices and /dev/sdb and
/dev/sg2 are the same device then if:
    blockdev --getmaxsect /dev/sg1

gives a different result to:
    blockdev --getmaxsect /dev/sdb

then I would consider that a bug. So fixing it is making the kernel ABI
more consistent :-)

Doug Gilbert




  reply	other threads:[~2020-09-05 20:37 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-04  4:42 About BLKSECTGET in sg Tom Yan
2020-09-04 16:28 ` Douglas Gilbert
2020-09-04 19:21   ` Tom Yan
2020-09-04 20:05     ` [PATCH 1/4] scsi: sg: fix BLKSECTGET ioctl Tom Yan
2020-09-04 20:05       ` [PATCH 2/4] scsi: sg: implement BLKSSZGET Tom Yan
2020-09-05 18:37         ` Douglas Gilbert
2020-09-04 20:05       ` [PATCH 3/4] scsi: sg: use queue_logical_sector_size() in max_sectors_bytes() Tom Yan
2020-09-05 18:37         ` Douglas Gilbert
2020-09-04 20:05       ` [PATCH 4/4] block/scsi_ioctl.c: " Tom Yan
2020-09-05 18:37         ` Douglas Gilbert
2020-09-05 18:37       ` [PATCH 1/4] scsi: sg: fix BLKSECTGET ioctl Douglas Gilbert
2020-09-05 19:32       ` Bart Van Assche
2020-09-05 20:36         ` Douglas Gilbert [this message]
2020-09-06  1:19           ` Tom Yan
2020-09-06  1:25             ` [PATCH RESEND " Tom Yan
2020-09-06  1:25               ` [PATCH RESEND 2/4] scsi: sg: implement BLKSSZGET Tom Yan
2020-09-06  1:25               ` [PATCH RESEND 3/4] scsi: sg: use queue_logical_sector_size() in max_sectors_bytes() Tom Yan
2020-09-06  1:25               ` [PATCH RESEND 4/4] block/scsi_ioctl.c: " Tom Yan
2020-09-06  1:27             ` [PATCH RESEND 1/4] scsi: sg: fix BLKSECTGET ioctl Tom Yan
2020-09-06  1:27               ` [PATCH RESEND 2/4] scsi: sg: implement BLKSSZGET Tom Yan
2020-09-07  6:09                 ` Christoph Hellwig
2020-09-07  9:01                   ` Tom Yan
2020-09-08  8:42                     ` Christoph Hellwig
2020-09-10  1:59                       ` Tom Yan
2020-09-10  5:28                         ` Christoph Hellwig
2020-09-11  2:52                           ` Tom Yan
2020-09-11  6:48                             ` Christoph Hellwig
2020-09-11 17:52                               ` Douglas Gilbert
2020-09-11 21:33                                 ` Alan Stern
2020-09-16  5:47                               ` Tom Yan
2020-09-06  1:27               ` [PATCH RESEND 3/4] scsi: sg: use queue_logical_sector_size() in max_sectors_bytes() Tom Yan
2020-09-06  6:26                 ` Greg KH
2020-09-06  7:01                   ` Tom Yan
2020-09-06  7:40                     ` [PATCH v2 1/4] scsi: sg: fix BLKSECTGET ioctl Tom Yan
2020-09-06  7:40                       ` [PATCH v2 2/4] scsi: sg: implement BLKSSZGET Tom Yan
2020-09-06  7:40                       ` [PATCH v2 3/4] scsi: sg: use queue_logical_sector_size() in max_sectors_bytes() Tom Yan
2020-09-06  7:40                       ` [PATCH v2 4/4] block/scsi_ioctl.c: " Tom Yan
2020-09-06  7:51                     ` [PATCH v3 1/4] scsi: sg: fix BLKSECTGET ioctl Tom Yan
2020-09-06  7:51                       ` [PATCH v3 2/4] scsi: sg: implement BLKSSZGET Tom Yan
2020-09-06  7:51                       ` [PATCH v3 3/4] scsi: sg: use queue_logical_sector_size() in max_sectors_bytes() Tom Yan
2020-09-06  7:51                       ` [PATCH v3 4/4] block/scsi_ioctl.c: " Tom Yan
2020-09-06  1:27               ` [PATCH RESEND " Tom Yan
2020-09-06  5:09             ` [PATCH 1/4] scsi: sg: fix BLKSECTGET ioctl Douglas Gilbert
2020-09-06  7:16               ` Tom Yan

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=868195a0-94f2-f009-bfd4-f206f0da7db8@interlog.com \
    --to=dgilbert@interlog.com \
    --cc=James.Bottomley@SteelEye.com \
    --cc=akinobu.mita@gmail.com \
    --cc=bvanassche@acm.org \
    --cc=hch@lst.de \
    --cc=jens.axboe@oracle.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=tom.ty89@gmail.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 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.