All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <jens.axboe@oracle.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: James Bottomley <James.Bottomley@SteelEye.com>,
	SCSI development list <linux-scsi@vger.kernel.org>
Subject: Re: [Bug 7026] CD/DVD burning with USB writer doesn't work
Date: Mon, 8 Jan 2007 20:24:40 +0100	[thread overview]
Message-ID: <20070108192440.GB11203@kernel.dk> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0701081112590.4249-100000@iolanthe.rowland.org>

On Mon, Jan 08 2007, Alan Stern wrote:
> On Wed, 6 Dec 2006, James Bottomley wrote:
> 
> > On Wed, 2006-12-06 at 13:58 -0500, Alan Stern wrote:
> > > I'd love to do that -- but blkdev_ioctl() wants inode->i_bdev to be set, 
> > > and blkdev_locked_ioctl() uses it as the argument to bdev_get_queue().  So 
> > > it won't work with sg, which uses character device nodes.
> > 
> > Well, even sg has the queue ... and what we're looking for are the queue
> > parameters.  In block/ioctl.c the bdev is just used for getting the
> > queue parameters (mainly via bdev->bd_disk->queue), so I could see if
> > Jens might be amenable to refactoring the queue ioctls so we can get at
> > them simply with a struct request_queue parameter.
> > 
> > > How about adding BLKSECTGET to the list of commands accepted by 
> > > sg_ioctl()?
> > 
> > That's certainly a possible hack ... although I'd prefer to see the full
> > queue ioctls exposed.
> 
> James:
> 
> Back in December you wrote a patch to expose the queue ioctls, and sent it
> (off-list) to Jens Axboe and to me.  Jens spproved it, but then it
> disappeared and was never applied.  Unfortunately I have lost my copy of
> it.
> 
> If you still have the patch, could you please apply it?  If you don't, I 
> could try to re-create it.  Or maybe Jens still has it in his email 
> records.  Either way, please let me know.

This one?

diff --git a/block/ioctl.c b/block/ioctl.c
index 58aab63..8444d0c 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -135,6 +135,31 @@ static int put_u64(unsigned long arg, u6
 	return put_user(val, (u64 __user *)arg);
 }
 
+static int blk_queue_locked_ioctl(struct request_queue *queue,
+				  unsigned cmd, unsigned long arg)
+{
+	switch (cmd) {
+	case BLKSSZGET: /* get block device hardware sector size */
+		return put_int(arg, queue_hardsect_size(queue));
+	case BLKSECTGET:
+		return put_ushort(arg, queue->max_sectors);
+	}
+	return -ENOIOCTLCMD;
+}
+
+int blk_queue_ioctl(struct request_queue *queue, unsigned cmd,
+		    unsigned long arg)
+{
+	int ret;
+
+	lock_kernel();
+	ret = blk_queue_locked_ioctl(queue, cmd, arg);
+	unlock_kernel();
+
+	return ret;
+}
+EXPORT_SYMBOL(blk_queue_ioctl);
+
 static int blkdev_locked_ioctl(struct file *file, struct block_device *bdev,
 				unsigned cmd, unsigned long arg)
 {
@@ -154,10 +179,6 @@ static int blkdev_locked_ioctl(struct fi
 		return put_int(arg, bdev_read_only(bdev) != 0);
 	case BLKBSZGET: /* get the logical block size (cf. BLKSSZGET) */
 		return put_int(arg, block_size(bdev));
-	case BLKSSZGET: /* get block device hardware sector size */
-		return put_int(arg, bdev_hardsect_size(bdev));
-	case BLKSECTGET:
-		return put_ushort(arg, bdev_get_queue(bdev)->max_sectors);
 	case BLKRASET:
 	case BLKFRASET:
 		if(!capable(CAP_SYS_ADMIN))
@@ -278,6 +299,8 @@ int blkdev_ioctl(struct inode *inode, st
 
 	lock_kernel();
 	ret = blkdev_locked_ioctl(file, bdev, cmd, arg);
+	if (ret == -ENOIOCTLCMD)
+		ret = blk_queue_locked_ioctl(bdev_get_queue(bdev), cmd, arg);
 	unlock_kernel();
 	if (ret != -ENOIOCTLCMD)
 		return ret;
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 81e3bc7..d97244b 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -786,6 +786,11 @@ sg_ioctl(struct inode *inode, struct fil
 				   sdp->disk->disk_name, (int) cmd_in));
 	read_only = (O_RDWR != (filp->f_flags & O_ACCMODE));
 
+	/* block ioctls first */
+	result = blk_queue_ioctl(sdp->device->request_queue, cmd_in, arg);
+	if (result != -ENOIOCTLCMD)
+		return result;
+
 	switch (cmd_in) {
 	case SG_IO:
 		{
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index e1c7286..550b04a 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -754,6 +754,8 @@ extern void blk_queue_prep_rq(request_qu
 extern void blk_queue_merge_bvec(request_queue_t *, merge_bvec_fn *);
 extern void blk_queue_dma_alignment(request_queue_t *, int);
 extern void blk_queue_softirq_done(request_queue_t *, softirq_done_fn *);
+extern int blk_queue_ioctl(struct request_queue *queue, unsigned cmd,
+			   unsigned long arg);
 extern struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev);
 extern int blk_queue_ordered(request_queue_t *, unsigned, prepare_flush_fn *);
 extern void blk_queue_issue_flush_fn(request_queue_t *, issue_flush_fn *);



-- 
Jens Axboe


  parent reply	other threads:[~2007-01-08 19:24 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-04 20:11 [Bug 7026] CD/DVD burning with USB writer doesn't work Alan Stern
2006-12-04 21:07 ` James Bottomley
2006-12-05 20:52   ` Alan Stern
2006-12-05 21:50     ` James Bottomley
2006-12-05 22:46       ` Joerg Schilling
2006-12-05 22:58         ` James Bottomley
2006-12-05 23:14           ` Joerg Schilling
2006-12-06 16:12             ` James Bottomley
2006-12-06 16:57               ` Douglas Gilbert
2006-12-06 21:34                 ` Mike Christie
2006-12-06 21:46                   ` Alan Stern
2006-12-07 10:34                     ` Joerg Schilling
2006-12-07 18:27                       ` Alan Stern
2006-12-08 12:45                         ` Joerg Schilling
2006-12-08 15:46                           ` Alan Stern
2006-12-06 22:50                   ` Mike Christie
2006-12-06 23:42                     ` Jeremy Linton
2006-12-06 23:55                       ` Jeremy Linton
2006-12-07  1:22                         ` Mike Christie
2006-12-07  1:40                           ` Mike Christie
2006-12-07  2:05                           ` Mike Christie
2006-12-06 17:42               ` Joerg Schilling
2006-12-06 16:32             ` Alan Stern
2006-12-06 16:47               ` James Bottomley
2006-12-06 17:21                 ` Alan Stern
2006-12-06 17:25                   ` James Bottomley
2006-12-06 18:58                     ` Alan Stern
2006-12-06 19:13                       ` James Bottomley
2006-12-06 20:31                         ` Alan Stern
2007-01-08 16:19                         ` Alan Stern
2007-01-08 16:25                           ` James Bottomley
2007-01-24 20:36                             ` Alan Stern
2007-01-08 19:24                           ` Jens Axboe [this message]
2006-12-06 17:51                   ` Joerg Schilling
2006-12-06 17:49                 ` Joerg Schilling
2006-12-06 17:59                   ` James Bottomley
2006-12-06 18:38                     ` Douglas Gilbert
2006-12-06 18:50                       ` James Bottomley
2006-12-06 20:04                         ` Douglas Gilbert
2006-12-06 18:48                     ` Joerg Schilling
2006-12-06 18:43                 ` Douglas Gilbert
2006-12-05 21:55     ` Douglas Gilbert
2006-12-05 23:08       ` Joerg Schilling
2006-12-05 22:35     ` Joerg Schilling
2006-12-05 23:03     ` Joerg Schilling
  -- strict thread matches above, loose matches on Subject: below --
2007-02-09 10:50 Joerg Schilling
2007-02-09 17:57 ` Alan Stern
2007-02-10  2:02   ` 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=20070108192440.GB11203@kernel.dk \
    --to=jens.axboe@oracle.com \
    --cc=James.Bottomley@SteelEye.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /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.