SCSI: convert struct class_device to struct device
[safe/jmp/linux-2.6] / block / ioctl.c
index 35fdb7d..52d6385 100644 (file)
@@ -5,6 +5,7 @@
 #include <linux/backing-dev.h>
 #include <linux/buffer_head.h>
 #include <linux/smp_lock.h>
+#include <linux/blktrace_api.h>
 #include <asm/uaccess.h>
 
 static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user *arg)
@@ -60,7 +61,7 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
                                }
                        }
                        /* all seems OK */
-                       add_partition(disk, part, start, length);
+                       add_partition(disk, part, start, length, ADDPART_FLAG_NONE);
                        mutex_unlock(&bdev->bd_mutex);
                        return 0;
                case BLKPG_DEL_PARTITION:
@@ -79,9 +80,9 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
                        }
                        /* all seems OK */
                        fsync_bdev(bdevp);
-                       invalidate_bdev(bdevp, 0);
+                       invalidate_bdev(bdevp);
 
-                       mutex_lock(&bdev->bd_mutex);
+                       mutex_lock_nested(&bdev->bd_mutex, 1);
                        delete_partition(disk, part);
                        mutex_unlock(&bdev->bd_mutex);
                        mutex_unlock(&bdevp->bd_mutex);
@@ -189,12 +190,17 @@ static int blkdev_locked_ioctl(struct file *file, struct block_device *bdev,
                return put_ulong(arg, bdev->bd_inode->i_size >> 9);
        case BLKGETSIZE64:
                return put_u64(arg, bdev->bd_inode->i_size);
+       case BLKTRACESTART:
+       case BLKTRACESTOP:
+       case BLKTRACESETUP:
+       case BLKTRACETEARDOWN:
+               return blk_trace_ioctl(bdev, cmd, (char __user *) arg);
        }
        return -ENOIOCTLCMD;
 }
 
-static int blkdev_driver_ioctl(struct inode *inode, struct file *file,
-               struct gendisk *disk, unsigned cmd, unsigned long arg)
+int blkdev_driver_ioctl(struct inode *inode, struct file *file,
+                       struct gendisk *disk, unsigned cmd, unsigned long arg)
 {
        int ret;
        if (disk->fops->unlocked_ioctl)
@@ -209,7 +215,12 @@ static int blkdev_driver_ioctl(struct inode *inode, struct file *file,
 
        return -ENOTTY;
 }
+EXPORT_SYMBOL_GPL(blkdev_driver_ioctl);
 
+/*
+ * always keep this in sync with compat_blkdev_ioctl() and
+ * compat_blkdev_locked_ioctl()
+ */
 int blkdev_ioctl(struct inode *inode, struct file *file, unsigned cmd,
                        unsigned long arg)
 {
@@ -229,7 +240,7 @@ int blkdev_ioctl(struct inode *inode, struct file *file, unsigned cmd,
 
                lock_kernel();
                fsync_bdev(bdev);
-               invalidate_bdev(bdev, 0);
+               invalidate_bdev(bdev);
                unlock_kernel();
                return 0;
 
@@ -277,21 +288,4 @@ int blkdev_ioctl(struct inode *inode, struct file *file, unsigned cmd,
 
        return blkdev_driver_ioctl(inode, file, disk, cmd, arg);
 }
-
-/* Most of the generic ioctls are handled in the normal fallback path.
-   This assumes the blkdev's low level compat_ioctl always returns
-   ENOIOCTLCMD for unknown ioctls. */
-long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg)
-{
-       struct block_device *bdev = file->f_dentry->d_inode->i_bdev;
-       struct gendisk *disk = bdev->bd_disk;
-       int ret = -ENOIOCTLCMD;
-       if (disk->fops->compat_ioctl) {
-               lock_kernel();
-               ret = disk->fops->compat_ioctl(file, cmd, arg);
-               unlock_kernel();
-       }
-       return ret;
-}
-
 EXPORT_SYMBOL_GPL(blkdev_ioctl);