LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: Joerg Schilling <Joerg.Schilling@fokus.fraunhofer.de>
Cc: linux-kernel@vger.kernel.org, <jens.axboe@oracle.com>,
	<James.Bottomley@steeleye.com>, <dougg@torque.net>
Subject: Re: [PATCH] Block layer: separate out queue-oriented ioctls
Date: Mon, 19 Feb 2007 12:06:32 -0500 (EST)	[thread overview]
Message-ID: <Pine.LNX.4.44L0.0702191148421.13197-100000@netrider.rowland.org> (raw)
In-Reply-To: <45d9cb72.je+WdtrFM7WV89m8%Joerg.Schilling@fokus.fraunhofer.de>

On Mon, 19 Feb 2007, Joerg Schilling wrote:

> Alan Stern <stern@rowland.harvard.edu> wrote:
> 
> > Well, if Doug wants to reduce the value returned by SG_GET_RESERVED_SIZE, 
> > it's okay with me.  An advantage of doing this is that older versions of 
> > cdrecord would then work correctly.
> >
> > However you don't seem to realize that people can use programs like
> > cdrecord with devices whose drivers don't support SG_GET_RESERVED_SIZE --
> > because that ioctl works only with sg.  Programs would have to try
> > SG_GET_RESERVED_SIZE and if it faied, then try BLKSECTGET.
> 
> Is there any reason not to have one single ioctl for one basic feature?

Indeed there is not.  That's what I wrote in an earlier email:

  "There should be one single ioctl which can be applied uniformly to all
  CD-type devices (in fact, to all devices using a request_queue) to learn
  max_sectors.  This rules out using SG_GET_RESERVED_SIZE."

> > Remember also, the "reserved size" is _not_ the maximum allowed size of a
> > DMA transfer.  Rather, it is the size of an internal buffer maintained by
> > sg.  It's legal to do an I/O transfer larger than the "reserved size", but 
> > it is not legal to do an I/O transfer larger than max_sectors.
> 
> At the time the call SG_GET_RESERVED_SIZE has been discussed/defined, we did 
> originally agree that the max value should be limited to what the HW allows
> as DMA size. This is why I did originally files a bug against 
> SG_GET_RESERVED_SIZE.

How do you feel about the patch below, either in addition to or instead of 
the previous patch?

Alan Stern



Index: usb-2.6/drivers/scsi/sg.c
===================================================================
--- usb-2.6.orig/drivers/scsi/sg.c
+++ usb-2.6/drivers/scsi/sg.c
@@ -917,6 +917,8 @@ sg_ioctl(struct inode *inode, struct fil
 			return result;
                 if (val < 0)
                         return -EINVAL;
+		if (val > sdp->device->request_queue->max_sectors * 512)
+			return -EOVERFLOW;
 		if (val != sfp->reserve.bufflen) {
 			if (sg_res_in_use(sfp) || sfp->mmap_called)
 				return -EBUSY;
@@ -925,7 +927,8 @@ sg_ioctl(struct inode *inode, struct fil
 		}
 		return 0;
 	case SG_GET_RESERVED_SIZE:
-		val = (int) sfp->reserve.bufflen;
+		val = min_t(int, sfp->reserve.bufflen,
+				sdp->device->request_queue->max_sectors * 512);
 		return put_user(val, ip);
 	case SG_SET_COMMAND_Q:
 		result = get_user(val, ip);


  reply	other threads:[~2007-02-19 17:06 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-16 19:37 Alan Stern
2007-02-17  6:28 ` Jens Axboe
2007-02-17 21:18   ` Joerg Schilling
2007-02-18  3:43   ` Douglas Gilbert
2007-02-18 12:37     ` Joerg Schilling
2007-02-18 16:44     ` Alan Stern
2007-02-18 18:27       ` Joerg Schilling
2007-02-19 16:06         ` Alan Stern
2007-02-19 16:08           ` Joerg Schilling
2007-02-19 17:06             ` Alan Stern [this message]
2007-02-19 22:25               ` Douglas Gilbert
2007-02-20  3:48                 ` Alan Stern
2007-02-20  4:47                   ` Douglas Gilbert
2007-02-20 15:55                     ` Alan Stern
2007-04-26  9:19                 ` Joerg Schilling
2007-04-26 15:04                   ` Alan Stern
2007-04-26 15:08                     ` James Bottomley

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=Pine.LNX.4.44L0.0702191148421.13197-100000@netrider.rowland.org \
    --to=stern@rowland.harvard.edu \
    --cc=James.Bottomley@steeleye.com \
    --cc=Joerg.Schilling@fokus.fraunhofer.de \
    --cc=dougg@torque.net \
    --cc=jens.axboe@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH] Block layer: separate out queue-oriented ioctls' \
    /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

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).