From: Sam Ravnborg on
> diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
> index 8a549db..1f70aec 100644
> --- a/drivers/block/pktcdvd.c
> +++ b/drivers/block/pktcdvd.c
> @@ -57,6 +57,7 @@
> #include <linux/seq_file.h>
> #include <linux/miscdevice.h>
> #include <linux/freezer.h>
> +#include <linux/smp_lock.h>
> #include <linux/mutex.h>
> #include <linux/slab.h>
> #include <scsi/scsi_cmnd.h>
> @@ -2762,10 +2763,12 @@ out_mem:
> static int pkt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg)
> {
> struct pktcdvd_device *pd = bdev->bd_disk->private_data;
> + int ret;
>
> VPRINTK("pkt_ioctl: cmd %x, dev %d:%d\n", cmd,
> MAJOR(bdev->bd_dev), MINOR(bdev->bd_dev));
>
> + lock_kernel();
> switch (cmd) {
> case CDROMEJECT:
> /*
> @@ -2783,12 +2786,14 @@ static int pkt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd,
> case CDROM_LAST_WRITTEN:
> case CDROM_SEND_PACKET:
> case SCSI_IOCTL_SEND_COMMAND:
> - return __blkdev_driver_ioctl(pd->bdev, mode, cmd, arg);
> + ret = __blkdev_driver_ioctl(pd->bdev, mode, cmd, arg);
> + break;
>
> default:
> VPRINTK(DRIVER_NAME": Unknown ioctl for %s (%x)\n", pd->name, cmd);
> - return -ENOTTY;
> + ret = -ENOTTY;
> }
> + unlock_kernel();
>
> return 0;
> }
You are loosing the return result here in the two error situations above.
Initialise ret to 0 and return ret seems the easy way to do it.

The rest looked ok - I only looked at the patches.

Sam
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Arnd Bergmann on
On Sunday 04 July 2010 09:30:50 Sam Ravnborg wrote:
> > default:
> > VPRINTK(DRIVER_NAME": Unknown ioctl for %s (%x)\n", pd->name, cmd);
> > - return -ENOTTY;
> > + ret = -ENOTTY;
> > }
> > + unlock_kernel();
> >
> > return 0;
> > }
> You are loosing the return result here in the two error situations above.
> Initialise ret to 0 and return ret seems the easy way to do it.
>
> The rest looked ok - I only looked at the patches.

Good catch, thanks!

I've updated the patch and pushed it out to my git tree.

Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Christoph Hellwig on
Looking at this again I don't like the foo_unlock_ioctl naming you're
adding. Just rename the existing ioctl routines to foo_locked_ioctl
or move the lock_kernel/unlock_kernel calls into the function, which
would be even better.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Arnd Bergmann on
On Wednesday 07 July 2010, Christoph Hellwig wrote:
>
> Looking at this again I don't like the foo_unlock_ioctl naming you're
> adding. Just rename the existing ioctl routines to foo_locked_ioctl
> or move the lock_kernel/unlock_kernel calls into the function, which
> would be even better.

Good point. I followed the naming that I used for the file_operations
conversion, but since the block_device_operations don't use .unlocked_ioctl,
the naming you suggested is better.

I've now changed the sr.c and sd.c to use include the lock_kernel() call
directly in their ioctl functions. For the various floppy drivers, I'd
prefer using separate wrappers because these drivers are mostly legacy
and any subtle bugs introduced could probably go unnoticed for years.

As I mentioned to Sam, I'm more confident with the wrapper than rewriting
a longish function that I can't test.

I also now changed the i2o_block driver ioctl function but split that out
into a separate patch, since I found two more existing issues with
that function that I'm addressing at the same time.

Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Jens Axboe on
On 2010-07-07 16:51, Arnd Bergmann wrote:
> As a preparation for the removal of the big kernel
> lock in the block layer, this removes the BKL
> from the common ioctl handling code, moving it
> into every single driver still using it.
>
> diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c
> index ad3ddef..fc593fb 100644
> --- a/drivers/message/i2o/i2o_block.c
> +++ b/drivers/message/i2o/i2o_block.c
> @@ -941,8 +930,7 @@ static const struct block_device_operations i2o_block_fops = {
> .owner = THIS_MODULE,
> .open = i2o_block_open,
> .release = i2o_block_release,
> - .ioctl = i2o_block_ioctl,
> - .compat_ioctl = i2o_block_ioctl,
> + .locked_ioctl = i2o_block_ioctl,
> .getgeo = i2o_block_getgeo,
> .media_changed = i2o_block_media_changed
> };

Hmm?

--
Jens Axboe

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/