aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-10-23 13:23:07 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-23 13:23:07 -0400
commit22484856402bfa1ff3defe47f6029ab0418240d9 (patch)
tree140c67bf59674da350a7b51765d6ff7eb101b597 /drivers/block
parent5ed487bc2c44ca4e9668ef9cb54c830e2a9fac47 (diff)
parent56b26add02b4bdea81d5e0ebda60db1fe3311ad4 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/viro/bdev
* git://git.kernel.org/pub/scm/linux/kernel/git/viro/bdev: (66 commits) [PATCH] kill the rest of struct file propagation in block ioctls [PATCH] get rid of struct file use in blkdev_ioctl() BLKBSZSET [PATCH] get rid of blkdev_locked_ioctl() [PATCH] get rid of blkdev_driver_ioctl() [PATCH] sanitize blkdev_get() and friends [PATCH] remember mode of reiserfs journal [PATCH] propagate mode through swsusp_close() [PATCH] propagate mode through open_bdev_excl/close_bdev_excl [PATCH] pass fmode_t to blkdev_put() [PATCH] kill the unused bsize on the send side of /dev/loop [PATCH] trim file propagation in block/compat_ioctl.c [PATCH] end of methods switch: remove the old ones [PATCH] switch sr [PATCH] switch sd [PATCH] switch ide-scsi [PATCH] switch tape_block [PATCH] switch dcssblk [PATCH] switch dasd [PATCH] switch mtd_blkdevs [PATCH] switch mmc ...
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/DAC960.c6
-rw-r--r--drivers/block/amiflop.c46
-rw-r--r--drivers/block/aoe/aoeblk.c12
-rw-r--r--drivers/block/ataflop.c37
-rw-r--r--drivers/block/brd.c5
-rw-r--r--drivers/block/cciss.c71
-rw-r--r--drivers/block/cpqarray.c28
-rw-r--r--drivers/block/floppy.c54
-rw-r--r--drivers/block/loop.c59
-rw-r--r--drivers/block/nbd.c28
-rw-r--r--drivers/block/paride/pcd.c21
-rw-r--r--drivers/block/paride/pd.c14
-rw-r--r--drivers/block/paride/pf.c22
-rw-r--r--drivers/block/paride/pt.c2
-rw-r--r--drivers/block/pktcdvd.c56
-rw-r--r--drivers/block/swim3.c32
-rw-r--r--drivers/block/ub.c22
-rw-r--r--drivers/block/viodasd.c10
-rw-r--r--drivers/block/virtio_blk.c8
-rw-r--r--drivers/block/xd.c4
-rw-r--r--drivers/block/xd.h2
-rw-r--r--drivers/block/xen-blkfront.c15
-rw-r--r--drivers/block/xsysace.c11
-rw-r--r--drivers/block/z2ram.c7
24 files changed, 280 insertions, 292 deletions
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
index a002a381df92..f6a337c34ac4 100644
--- a/drivers/block/DAC960.c
+++ b/drivers/block/DAC960.c
@@ -72,9 +72,9 @@ static long disk_size(DAC960_Controller_T *p, int drive_nr)
72 } 72 }
73} 73}
74 74
75static int DAC960_open(struct inode *inode, struct file *file) 75static int DAC960_open(struct block_device *bdev, fmode_t mode)
76{ 76{
77 struct gendisk *disk = inode->i_bdev->bd_disk; 77 struct gendisk *disk = bdev->bd_disk;
78 DAC960_Controller_T *p = disk->queue->queuedata; 78 DAC960_Controller_T *p = disk->queue->queuedata;
79 int drive_nr = (long)disk->private_data; 79 int drive_nr = (long)disk->private_data;
80 80
@@ -89,7 +89,7 @@ static int DAC960_open(struct inode *inode, struct file *file)
89 return -ENXIO; 89 return -ENXIO;
90 } 90 }
91 91
92 check_disk_change(inode->i_bdev); 92 check_disk_change(bdev);
93 93
94 if (!get_capacity(p->disks[drive_nr])) 94 if (!get_capacity(p->disks[drive_nr]))
95 return -ENXIO; 95 return -ENXIO;
diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c
index 7516baff3bb9..4b1d4ac960f1 100644
--- a/drivers/block/amiflop.c
+++ b/drivers/block/amiflop.c
@@ -1437,10 +1437,11 @@ static int fd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
1437 return 0; 1437 return 0;
1438} 1438}
1439 1439
1440static int fd_ioctl(struct inode *inode, struct file *filp, 1440static int fd_ioctl(struct block_device *bdev, fmode_t mode,
1441 unsigned int cmd, unsigned long param) 1441 unsigned int cmd, unsigned long param)
1442{ 1442{
1443 int drive = iminor(inode) & 3; 1443 struct amiga_floppy_struct *p = bdev->bd_disk->private_data;
1444 int drive = p - unit;
1444 static struct floppy_struct getprm; 1445 static struct floppy_struct getprm;
1445 void __user *argp = (void __user *)param; 1446 void __user *argp = (void __user *)param;
1446 1447
@@ -1451,7 +1452,7 @@ static int fd_ioctl(struct inode *inode, struct file *filp,
1451 rel_fdc(); 1452 rel_fdc();
1452 return -EBUSY; 1453 return -EBUSY;
1453 } 1454 }
1454 fsync_bdev(inode->i_bdev); 1455 fsync_bdev(bdev);
1455 if (fd_motor_on(drive) == 0) { 1456 if (fd_motor_on(drive) == 0) {
1456 rel_fdc(); 1457 rel_fdc();
1457 return -ENODEV; 1458 return -ENODEV;
@@ -1464,12 +1465,12 @@ static int fd_ioctl(struct inode *inode, struct file *filp,
1464 rel_fdc(); 1465 rel_fdc();
1465 break; 1466 break;
1466 case FDFMTTRK: 1467 case FDFMTTRK:
1467 if (param < unit[drive].type->tracks * unit[drive].type->heads) 1468 if (param < p->type->tracks * p->type->heads)
1468 { 1469 {
1469 get_fdc(drive); 1470 get_fdc(drive);
1470 if (fd_seek(drive,param) != 0){ 1471 if (fd_seek(drive,param) != 0){
1471 memset(unit[drive].trackbuf, FD_FILL_BYTE, 1472 memset(p->trackbuf, FD_FILL_BYTE,
1472 unit[drive].dtype->sects * unit[drive].type->sect_mult * 512); 1473 p->dtype->sects * p->type->sect_mult * 512);
1473 non_int_flush_track(drive); 1474 non_int_flush_track(drive);
1474 } 1475 }
1475 floppy_off(drive); 1476 floppy_off(drive);
@@ -1480,14 +1481,14 @@ static int fd_ioctl(struct inode *inode, struct file *filp,
1480 break; 1481 break;
1481 case FDFMTEND: 1482 case FDFMTEND:
1482 floppy_off(drive); 1483 floppy_off(drive);
1483 invalidate_bdev(inode->i_bdev); 1484 invalidate_bdev(bdev);
1484 break; 1485 break;
1485 case FDGETPRM: 1486 case FDGETPRM:
1486 memset((void *)&getprm, 0, sizeof (getprm)); 1487 memset((void *)&getprm, 0, sizeof (getprm));
1487 getprm.track=unit[drive].type->tracks; 1488 getprm.track=p->type->tracks;
1488 getprm.head=unit[drive].type->heads; 1489 getprm.head=p->type->heads;
1489 getprm.sect=unit[drive].dtype->sects * unit[drive].type->sect_mult; 1490 getprm.sect=p->dtype->sects * p->type->sect_mult;
1490 getprm.size=unit[drive].blocks; 1491 getprm.size=p->blocks;
1491 if (copy_to_user(argp, &getprm, sizeof(struct floppy_struct))) 1492 if (copy_to_user(argp, &getprm, sizeof(struct floppy_struct)))
1492 return -EFAULT; 1493 return -EFAULT;
1493 break; 1494 break;
@@ -1500,10 +1501,10 @@ static int fd_ioctl(struct inode *inode, struct file *filp,
1500 break; 1501 break;
1501#ifdef RAW_IOCTL 1502#ifdef RAW_IOCTL
1502 case IOCTL_RAW_TRACK: 1503 case IOCTL_RAW_TRACK:
1503 if (copy_to_user(argp, raw_buf, unit[drive].type->read_size)) 1504 if (copy_to_user(argp, raw_buf, p->type->read_size))
1504 return -EFAULT; 1505 return -EFAULT;
1505 else 1506 else
1506 return unit[drive].type->read_size; 1507 return p->type->read_size;
1507#endif 1508#endif
1508 default: 1509 default:
1509 printk(KERN_DEBUG "fd_ioctl: unknown cmd %d for drive %d.", 1510 printk(KERN_DEBUG "fd_ioctl: unknown cmd %d for drive %d.",
@@ -1548,10 +1549,10 @@ static void fd_probe(int dev)
1548 * /dev/PS0 etc), and disallows simultaneous access to the same 1549 * /dev/PS0 etc), and disallows simultaneous access to the same
1549 * drive with different device numbers. 1550 * drive with different device numbers.
1550 */ 1551 */
1551static int floppy_open(struct inode *inode, struct file *filp) 1552static int floppy_open(struct block_device *bdev, fmode_t mode)
1552{ 1553{
1553 int drive = iminor(inode) & 3; 1554 int drive = MINOR(bdev->bd_dev) & 3;
1554 int system = (iminor(inode) & 4) >> 2; 1555 int system = (MINOR(bdev->bd_dev) & 4) >> 2;
1555 int old_dev; 1556 int old_dev;
1556 unsigned long flags; 1557 unsigned long flags;
1557 1558
@@ -1560,9 +1561,9 @@ static int floppy_open(struct inode *inode, struct file *filp)
1560 if (fd_ref[drive] && old_dev != system) 1561 if (fd_ref[drive] && old_dev != system)
1561 return -EBUSY; 1562 return -EBUSY;
1562 1563
1563 if (filp && filp->f_mode & 3) { 1564 if (mode & (FMODE_READ|FMODE_WRITE)) {
1564 check_disk_change(inode->i_bdev); 1565 check_disk_change(bdev);
1565 if (filp->f_mode & 2 ) { 1566 if (mode & FMODE_WRITE) {
1566 int wrprot; 1567 int wrprot;
1567 1568
1568 get_fdc(drive); 1569 get_fdc(drive);
@@ -1592,9 +1593,10 @@ static int floppy_open(struct inode *inode, struct file *filp)
1592 return 0; 1593 return 0;
1593} 1594}
1594 1595
1595static int floppy_release(struct inode * inode, struct file * filp) 1596static int floppy_release(struct gendisk *disk, fmode_t mode)
1596{ 1597{
1597 int drive = iminor(inode) & 3; 1598 struct amiga_floppy_struct *p = disk->private_data;
1599 int drive = p - unit;
1598 1600
1599 if (unit[drive].dirty == 1) { 1601 if (unit[drive].dirty == 1) {
1600 del_timer (flush_track_timer + drive); 1602 del_timer (flush_track_timer + drive);
@@ -1650,7 +1652,7 @@ static struct block_device_operations floppy_fops = {
1650 .owner = THIS_MODULE, 1652 .owner = THIS_MODULE,
1651 .open = floppy_open, 1653 .open = floppy_open,
1652 .release = floppy_release, 1654 .release = floppy_release,
1653 .ioctl = fd_ioctl, 1655 .locked_ioctl = fd_ioctl,
1654 .getgeo = fd_getgeo, 1656 .getgeo = fd_getgeo,
1655 .media_changed = amiga_floppy_change, 1657 .media_changed = amiga_floppy_change,
1656}; 1658};
diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
index d876ad861237..1747dd272cd4 100644
--- a/drivers/block/aoe/aoeblk.c
+++ b/drivers/block/aoe/aoeblk.c
@@ -118,13 +118,11 @@ aoedisk_rm_sysfs(struct aoedev *d)
118} 118}
119 119
120static int 120static int
121aoeblk_open(struct inode *inode, struct file *filp) 121aoeblk_open(struct block_device *bdev, fmode_t mode)
122{ 122{
123 struct aoedev *d; 123 struct aoedev *d = bdev->bd_disk->private_data;
124 ulong flags; 124 ulong flags;
125 125
126 d = inode->i_bdev->bd_disk->private_data;
127
128 spin_lock_irqsave(&d->lock, flags); 126 spin_lock_irqsave(&d->lock, flags);
129 if (d->flags & DEVFL_UP) { 127 if (d->flags & DEVFL_UP) {
130 d->nopen++; 128 d->nopen++;
@@ -136,13 +134,11 @@ aoeblk_open(struct inode *inode, struct file *filp)
136} 134}
137 135
138static int 136static int
139aoeblk_release(struct inode *inode, struct file *filp) 137aoeblk_release(struct gendisk *disk, fmode_t mode)
140{ 138{
141 struct aoedev *d; 139 struct aoedev *d = disk->private_data;
142 ulong flags; 140 ulong flags;
143 141
144 d = inode->i_bdev->bd_disk->private_data;
145
146 spin_lock_irqsave(&d->lock, flags); 142 spin_lock_irqsave(&d->lock, flags);
147 143
148 if (--d->nopen == 0) { 144 if (--d->nopen == 0) {
diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c
index 432cf4018291..69e1df7dfa14 100644
--- a/drivers/block/ataflop.c
+++ b/drivers/block/ataflop.c
@@ -361,13 +361,13 @@ static void finish_fdc( void );
361static void finish_fdc_done( int dummy ); 361static void finish_fdc_done( int dummy );
362static void setup_req_params( int drive ); 362static void setup_req_params( int drive );
363static void redo_fd_request( void); 363static void redo_fd_request( void);
364static int fd_ioctl( struct inode *inode, struct file *filp, unsigned int 364static int fd_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
365 cmd, unsigned long param); 365 cmd, unsigned long param);
366static void fd_probe( int drive ); 366static void fd_probe( int drive );
367static int fd_test_drive_present( int drive ); 367static int fd_test_drive_present( int drive );
368static void config_types( void ); 368static void config_types( void );
369static int floppy_open( struct inode *inode, struct file *filp ); 369static int floppy_open(struct block_device *bdev, fmode_t mode);
370static int floppy_release( struct inode * inode, struct file * filp ); 370static int floppy_release(struct gendisk *disk, fmode_t mode);
371 371
372/************************* End of Prototypes **************************/ 372/************************* End of Prototypes **************************/
373 373
@@ -1483,10 +1483,10 @@ void do_fd_request(struct request_queue * q)
1483 atari_enable_irq( IRQ_MFP_FDC ); 1483 atari_enable_irq( IRQ_MFP_FDC );
1484} 1484}
1485 1485
1486static int fd_ioctl(struct inode *inode, struct file *filp, 1486static int fd_ioctl(struct block_device *bdev, fmode_t mode,
1487 unsigned int cmd, unsigned long param) 1487 unsigned int cmd, unsigned long param)
1488{ 1488{
1489 struct gendisk *disk = inode->i_bdev->bd_disk; 1489 struct gendisk *disk = bdev->bd_disk;
1490 struct atari_floppy_struct *floppy = disk->private_data; 1490 struct atari_floppy_struct *floppy = disk->private_data;
1491 int drive = floppy - unit; 1491 int drive = floppy - unit;
1492 int type = floppy->type; 1492 int type = floppy->type;
@@ -1661,7 +1661,7 @@ static int fd_ioctl(struct inode *inode, struct file *filp,
1661 /* invalidate the buffer track to force a reread */ 1661 /* invalidate the buffer track to force a reread */
1662 BufferDrive = -1; 1662 BufferDrive = -1;
1663 set_bit(drive, &fake_change); 1663 set_bit(drive, &fake_change);
1664 check_disk_change(inode->i_bdev); 1664 check_disk_change(bdev);
1665 return 0; 1665 return 0;
1666 default: 1666 default:
1667 return -EINVAL; 1667 return -EINVAL;
@@ -1804,37 +1804,36 @@ static void __init config_types( void )
1804 * drive with different device numbers. 1804 * drive with different device numbers.
1805 */ 1805 */
1806 1806
1807static int floppy_open( struct inode *inode, struct file *filp ) 1807static int floppy_open(struct block_device *bdev, fmode_t mode)
1808{ 1808{
1809 struct atari_floppy_struct *p = inode->i_bdev->bd_disk->private_data; 1809 struct atari_floppy_struct *p = bdev->bd_disk->private_data;
1810 int type = iminor(inode) >> 2; 1810 int type = MINOR(bdev->bd_dev) >> 2;
1811 1811
1812 DPRINT(("fd_open: type=%d\n",type)); 1812 DPRINT(("fd_open: type=%d\n",type));
1813 if (p->ref && p->type != type) 1813 if (p->ref && p->type != type)
1814 return -EBUSY; 1814 return -EBUSY;
1815 1815
1816 if (p->ref == -1 || (p->ref && filp->f_flags & O_EXCL)) 1816 if (p->ref == -1 || (p->ref && mode & FMODE_EXCL))
1817 return -EBUSY; 1817 return -EBUSY;
1818 1818
1819 if (filp->f_flags & O_EXCL) 1819 if (mode & FMODE_EXCL)
1820 p->ref = -1; 1820 p->ref = -1;
1821 else 1821 else
1822 p->ref++; 1822 p->ref++;
1823 1823
1824 p->type = type; 1824 p->type = type;
1825 1825
1826 if (filp->f_flags & O_NDELAY) 1826 if (mode & FMODE_NDELAY)
1827 return 0; 1827 return 0;
1828 1828
1829 if (filp->f_mode & 3) { 1829 if (mode & (FMODE_READ|FMODE_WRITE)) {
1830 check_disk_change(inode->i_bdev); 1830 check_disk_change(bdev);
1831 if (filp->f_mode & 2) { 1831 if (mode & FMODE_WRITE) {
1832 if (p->wpstat) { 1832 if (p->wpstat) {
1833 if (p->ref < 0) 1833 if (p->ref < 0)
1834 p->ref = 0; 1834 p->ref = 0;
1835 else 1835 else
1836 p->ref--; 1836 p->ref--;
1837 floppy_release(inode, filp);
1838 return -EROFS; 1837 return -EROFS;
1839 } 1838 }
1840 } 1839 }
@@ -1843,9 +1842,9 @@ static int floppy_open( struct inode *inode, struct file *filp )
1843} 1842}
1844 1843
1845 1844
1846static int floppy_release( struct inode * inode, struct file * filp ) 1845static int floppy_release(struct gendisk *disk, fmode_t mode)
1847{ 1846{
1848 struct atari_floppy_struct *p = inode->i_bdev->bd_disk->private_data; 1847 struct atari_floppy_struct *p = disk->private_data;
1849 if (p->ref < 0) 1848 if (p->ref < 0)
1850 p->ref = 0; 1849 p->ref = 0;
1851 else if (!p->ref--) { 1850 else if (!p->ref--) {
@@ -1859,7 +1858,7 @@ static struct block_device_operations floppy_fops = {
1859 .owner = THIS_MODULE, 1858 .owner = THIS_MODULE,
1860 .open = floppy_open, 1859 .open = floppy_open,
1861 .release = floppy_release, 1860 .release = floppy_release,
1862 .ioctl = fd_ioctl, 1861 .locked_ioctl = fd_ioctl,
1863 .media_changed = check_floppy_change, 1862 .media_changed = check_floppy_change,
1864 .revalidate_disk= floppy_revalidate, 1863 .revalidate_disk= floppy_revalidate,
1865}; 1864};
diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index d070d492e385..bdd4f5f45575 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -340,11 +340,10 @@ static int brd_direct_access (struct block_device *bdev, sector_t sector,
340} 340}
341#endif 341#endif
342 342
343static int brd_ioctl(struct inode *inode, struct file *file, 343static int brd_ioctl(struct block_device *bdev, fmode_t mode,
344 unsigned int cmd, unsigned long arg) 344 unsigned int cmd, unsigned long arg)
345{ 345{
346 int error; 346 int error;
347 struct block_device *bdev = inode->i_bdev;
348 struct brd_device *brd = bdev->bd_disk->private_data; 347 struct brd_device *brd = bdev->bd_disk->private_data;
349 348
350 if (cmd != BLKFLSBUF) 349 if (cmd != BLKFLSBUF)
@@ -376,7 +375,7 @@ static int brd_ioctl(struct inode *inode, struct file *file,
376 375
377static struct block_device_operations brd_fops = { 376static struct block_device_operations brd_fops = {
378 .owner = THIS_MODULE, 377 .owner = THIS_MODULE,
379 .ioctl = brd_ioctl, 378 .locked_ioctl = brd_ioctl,
380#ifdef CONFIG_BLK_DEV_XIP 379#ifdef CONFIG_BLK_DEV_XIP
381 .direct_access = brd_direct_access, 380 .direct_access = brd_direct_access,
382#endif 381#endif
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 1e1f9153000c..4023885353e0 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -152,9 +152,9 @@ static ctlr_info_t *hba[MAX_CTLR];
152 152
153static void do_cciss_request(struct request_queue *q); 153static void do_cciss_request(struct request_queue *q);
154static irqreturn_t do_cciss_intr(int irq, void *dev_id); 154static irqreturn_t do_cciss_intr(int irq, void *dev_id);
155static int cciss_open(struct inode *inode, struct file *filep); 155static int cciss_open(struct block_device *bdev, fmode_t mode);
156static int cciss_release(struct inode *inode, struct file *filep); 156static int cciss_release(struct gendisk *disk, fmode_t mode);
157static int cciss_ioctl(struct inode *inode, struct file *filep, 157static int cciss_ioctl(struct block_device *bdev, fmode_t mode,
158 unsigned int cmd, unsigned long arg); 158 unsigned int cmd, unsigned long arg);
159static int cciss_getgeo(struct block_device *bdev, struct hd_geometry *geo); 159static int cciss_getgeo(struct block_device *bdev, struct hd_geometry *geo);
160 160
@@ -192,14 +192,15 @@ static void cciss_procinit(int i)
192#endif /* CONFIG_PROC_FS */ 192#endif /* CONFIG_PROC_FS */
193 193
194#ifdef CONFIG_COMPAT 194#ifdef CONFIG_COMPAT
195static long cciss_compat_ioctl(struct file *f, unsigned cmd, unsigned long arg); 195static int cciss_compat_ioctl(struct block_device *, fmode_t,
196 unsigned, unsigned long);
196#endif 197#endif
197 198
198static struct block_device_operations cciss_fops = { 199static struct block_device_operations cciss_fops = {
199 .owner = THIS_MODULE, 200 .owner = THIS_MODULE,
200 .open = cciss_open, 201 .open = cciss_open,
201 .release = cciss_release, 202 .release = cciss_release,
202 .ioctl = cciss_ioctl, 203 .locked_ioctl = cciss_ioctl,
203 .getgeo = cciss_getgeo, 204 .getgeo = cciss_getgeo,
204#ifdef CONFIG_COMPAT 205#ifdef CONFIG_COMPAT
205 .compat_ioctl = cciss_compat_ioctl, 206 .compat_ioctl = cciss_compat_ioctl,
@@ -547,13 +548,13 @@ static inline drive_info_struct *get_drv(struct gendisk *disk)
547/* 548/*
548 * Open. Make sure the device is really there. 549 * Open. Make sure the device is really there.
549 */ 550 */
550static int cciss_open(struct inode *inode, struct file *filep) 551static int cciss_open(struct block_device *bdev, fmode_t mode)
551{ 552{
552 ctlr_info_t *host = get_host(inode->i_bdev->bd_disk); 553 ctlr_info_t *host = get_host(bdev->bd_disk);
553 drive_info_struct *drv = get_drv(inode->i_bdev->bd_disk); 554 drive_info_struct *drv = get_drv(bdev->bd_disk);
554 555
555#ifdef CCISS_DEBUG 556#ifdef CCISS_DEBUG
556 printk(KERN_DEBUG "cciss_open %s\n", inode->i_bdev->bd_disk->disk_name); 557 printk(KERN_DEBUG "cciss_open %s\n", bdev->bd_disk->disk_name);
557#endif /* CCISS_DEBUG */ 558#endif /* CCISS_DEBUG */
558 559
559 if (host->busy_initializing || drv->busy_configuring) 560 if (host->busy_initializing || drv->busy_configuring)
@@ -567,9 +568,9 @@ static int cciss_open(struct inode *inode, struct file *filep)
567 * for "raw controller". 568 * for "raw controller".
568 */ 569 */
569 if (drv->heads == 0) { 570 if (drv->heads == 0) {
570 if (iminor(inode) != 0) { /* not node 0? */ 571 if (MINOR(bdev->bd_dev) != 0) { /* not node 0? */
571 /* if not node 0 make sure it is a partition = 0 */ 572 /* if not node 0 make sure it is a partition = 0 */
572 if (iminor(inode) & 0x0f) { 573 if (MINOR(bdev->bd_dev) & 0x0f) {
573 return -ENXIO; 574 return -ENXIO;
574 /* if it is, make sure we have a LUN ID */ 575 /* if it is, make sure we have a LUN ID */
575 } else if (drv->LunID == 0) { 576 } else if (drv->LunID == 0) {
@@ -587,14 +588,13 @@ static int cciss_open(struct inode *inode, struct file *filep)
587/* 588/*
588 * Close. Sync first. 589 * Close. Sync first.
589 */ 590 */
590static int cciss_release(struct inode *inode, struct file *filep) 591static int cciss_release(struct gendisk *disk, fmode_t mode)
591{ 592{
592 ctlr_info_t *host = get_host(inode->i_bdev->bd_disk); 593 ctlr_info_t *host = get_host(disk);
593 drive_info_struct *drv = get_drv(inode->i_bdev->bd_disk); 594 drive_info_struct *drv = get_drv(disk);
594 595
595#ifdef CCISS_DEBUG 596#ifdef CCISS_DEBUG
596 printk(KERN_DEBUG "cciss_release %s\n", 597 printk(KERN_DEBUG "cciss_release %s\n", disk->disk_name);
597 inode->i_bdev->bd_disk->disk_name);
598#endif /* CCISS_DEBUG */ 598#endif /* CCISS_DEBUG */
599 599
600 drv->usage_count--; 600 drv->usage_count--;
@@ -604,21 +604,23 @@ static int cciss_release(struct inode *inode, struct file *filep)
604 604
605#ifdef CONFIG_COMPAT 605#ifdef CONFIG_COMPAT
606 606
607static int do_ioctl(struct file *f, unsigned cmd, unsigned long arg) 607static int do_ioctl(struct block_device *bdev, fmode_t mode,
608 unsigned cmd, unsigned long arg)
608{ 609{
609 int ret; 610 int ret;
610 lock_kernel(); 611 lock_kernel();
611 ret = cciss_ioctl(f->f_path.dentry->d_inode, f, cmd, arg); 612 ret = cciss_ioctl(bdev, mode, cmd, arg);
612 unlock_kernel(); 613 unlock_kernel();
613 return ret; 614 return ret;
614} 615}
615 616
616static int cciss_ioctl32_passthru(struct file *f, unsigned cmd, 617static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
617 unsigned long arg); 618 unsigned cmd, unsigned long arg);
618static int cciss_ioctl32_big_passthru(struct file *f, unsigned cmd, 619static int cciss_ioctl32_big_passthru(struct block_device *bdev, fmode_t mode,
619 unsigned long arg); 620 unsigned cmd, unsigned long arg);
620 621
621static long cciss_compat_ioctl(struct file *f, unsigned cmd, unsigned long arg) 622static int cciss_compat_ioctl(struct block_device *bdev, fmode_t mode,
623 unsigned cmd, unsigned long arg)
622{ 624{
623 switch (cmd) { 625 switch (cmd) {
624 case CCISS_GETPCIINFO: 626 case CCISS_GETPCIINFO:
@@ -636,20 +638,20 @@ static long cciss_compat_ioctl(struct file *f, unsigned cmd, unsigned long arg)
636 case CCISS_REGNEWD: 638 case CCISS_REGNEWD:
637 case CCISS_RESCANDISK: 639 case CCISS_RESCANDISK:
638 case CCISS_GETLUNINFO: 640 case CCISS_GETLUNINFO:
639 return do_ioctl(f, cmd, arg); 641 return do_ioctl(bdev, mode, cmd, arg);
640 642
641 case CCISS_PASSTHRU32: 643 case CCISS_PASSTHRU32:
642 return cciss_ioctl32_passthru(f, cmd, arg); 644 return cciss_ioctl32_passthru(bdev, mode, cmd, arg);
643 case CCISS_BIG_PASSTHRU32: 645 case CCISS_BIG_PASSTHRU32:
644 return cciss_ioctl32_big_passthru(f, cmd, arg); 646 return cciss_ioctl32_big_passthru(bdev, mode, cmd, arg);
645 647
646 default: 648 default:
647 return -ENOIOCTLCMD; 649 return -ENOIOCTLCMD;
648 } 650 }
649} 651}
650 652
651static int cciss_ioctl32_passthru(struct file *f, unsigned cmd, 653static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
652 unsigned long arg) 654 unsigned cmd, unsigned long arg)
653{ 655{
654 IOCTL32_Command_struct __user *arg32 = 656 IOCTL32_Command_struct __user *arg32 =
655 (IOCTL32_Command_struct __user *) arg; 657 (IOCTL32_Command_struct __user *) arg;
@@ -676,7 +678,7 @@ static int cciss_ioctl32_passthru(struct file *f, unsigned cmd,
676 if (err) 678 if (err)
677 return -EFAULT; 679 return -EFAULT;
678 680
679 err = do_ioctl(f, CCISS_PASSTHRU, (unsigned long)p); 681 err = do_ioctl(bdev, mode, CCISS_PASSTHRU, (unsigned long)p);
680 if (err) 682 if (err)
681 return err; 683 return err;
682 err |= 684 err |=
@@ -687,8 +689,8 @@ static int cciss_ioctl32_passthru(struct file *f, unsigned cmd,
687 return err; 689 return err;
688} 690}
689 691
690static int cciss_ioctl32_big_passthru(struct file *file, unsigned cmd, 692static int cciss_ioctl32_big_passthru(struct block_device *bdev, fmode_t mode,
691 unsigned long arg) 693 unsigned cmd, unsigned long arg)
692{ 694{
693 BIG_IOCTL32_Command_struct __user *arg32 = 695 BIG_IOCTL32_Command_struct __user *arg32 =
694 (BIG_IOCTL32_Command_struct __user *) arg; 696 (BIG_IOCTL32_Command_struct __user *) arg;
@@ -717,7 +719,7 @@ static int cciss_ioctl32_big_passthru(struct file *file, unsigned cmd,
717 if (err) 719 if (err)
718 return -EFAULT; 720 return -EFAULT;
719 721
720 err = do_ioctl(file, CCISS_BIG_PASSTHRU, (unsigned long)p); 722 err = do_ioctl(bdev, mode, CCISS_BIG_PASSTHRU, (unsigned long)p);
721 if (err) 723 if (err)
722 return err; 724 return err;
723 err |= 725 err |=
@@ -745,10 +747,9 @@ static int cciss_getgeo(struct block_device *bdev, struct hd_geometry *geo)
745/* 747/*
746 * ioctl 748 * ioctl
747 */ 749 */
748static int cciss_ioctl(struct inode *inode, struct file *filep, 750static int cciss_ioctl(struct block_device *bdev, fmode_t mode,
749 unsigned int cmd, unsigned long arg) 751 unsigned int cmd, unsigned long arg)
750{ 752{
751 struct block_device *bdev = inode->i_bdev;
752 struct gendisk *disk = bdev->bd_disk; 753 struct gendisk *disk = bdev->bd_disk;
753 ctlr_info_t *host = get_host(disk); 754 ctlr_info_t *host = get_host(disk);
754 drive_info_struct *drv = get_drv(disk); 755 drive_info_struct *drv = get_drv(disk);
@@ -1232,7 +1233,7 @@ static int cciss_ioctl(struct inode *inode, struct file *filep,
1232 case SG_EMULATED_HOST: 1233 case SG_EMULATED_HOST:
1233 case SG_IO: 1234 case SG_IO:
1234 case SCSI_IOCTL_SEND_COMMAND: 1235 case SCSI_IOCTL_SEND_COMMAND:
1235 return scsi_cmd_ioctl(filep, disk->queue, disk, cmd, argp); 1236 return scsi_cmd_ioctl(disk->queue, disk, mode, cmd, argp);
1236 1237
1237 /* scsi_cmd_ioctl would normally handle these, below, but */ 1238 /* scsi_cmd_ioctl would normally handle these, below, but */
1238 /* they aren't a good fit for cciss, as CD-ROMs are */ 1239 /* they aren't a good fit for cciss, as CD-ROMs are */
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
index 3d967525e9a9..47d233c6d0b3 100644
--- a/drivers/block/cpqarray.c
+++ b/drivers/block/cpqarray.c
@@ -156,9 +156,9 @@ static int sendcmd(
156 unsigned int blkcnt, 156 unsigned int blkcnt,
157 unsigned int log_unit ); 157 unsigned int log_unit );
158 158
159static int ida_open(struct inode *inode, struct file *filep); 159static int ida_open(struct block_device *bdev, fmode_t mode);
160static int ida_release(struct inode *inode, struct file *filep); 160static int ida_release(struct gendisk *disk, fmode_t mode);
161static int ida_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, unsigned long arg); 161static int ida_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg);
162static int ida_getgeo(struct block_device *bdev, struct hd_geometry *geo); 162static int ida_getgeo(struct block_device *bdev, struct hd_geometry *geo);
163static int ida_ctlr_ioctl(ctlr_info_t *h, int dsk, ida_ioctl_t *io); 163static int ida_ctlr_ioctl(ctlr_info_t *h, int dsk, ida_ioctl_t *io);
164 164
@@ -197,7 +197,7 @@ static struct block_device_operations ida_fops = {
197 .owner = THIS_MODULE, 197 .owner = THIS_MODULE,
198 .open = ida_open, 198 .open = ida_open,
199 .release = ida_release, 199 .release = ida_release,
200 .ioctl = ida_ioctl, 200 .locked_ioctl = ida_ioctl,
201 .getgeo = ida_getgeo, 201 .getgeo = ida_getgeo,
202 .revalidate_disk= ida_revalidate, 202 .revalidate_disk= ida_revalidate,
203}; 203};
@@ -818,12 +818,12 @@ DBGINFO(
818/* 818/*
819 * Open. Make sure the device is really there. 819 * Open. Make sure the device is really there.
820 */ 820 */
821static int ida_open(struct inode *inode, struct file *filep) 821static int ida_open(struct block_device *bdev, fmode_t mode)
822{ 822{
823 drv_info_t *drv = get_drv(inode->i_bdev->bd_disk); 823 drv_info_t *drv = get_drv(bdev->bd_disk);
824 ctlr_info_t *host = get_host(inode->i_bdev->bd_disk); 824 ctlr_info_t *host = get_host(bdev->bd_disk);
825 825
826 DBGINFO(printk("ida_open %s\n", inode->i_bdev->bd_disk->disk_name)); 826 DBGINFO(printk("ida_open %s\n", bdev->bd_disk->disk_name));
827 /* 827 /*
828 * Root is allowed to open raw volume zero even if it's not configured 828 * Root is allowed to open raw volume zero even if it's not configured
829 * so array config can still work. I don't think I really like this, 829 * so array config can still work. I don't think I really like this,
@@ -843,9 +843,9 @@ static int ida_open(struct inode *inode, struct file *filep)
843/* 843/*
844 * Close. Sync first. 844 * Close. Sync first.
845 */ 845 */
846static int ida_release(struct inode *inode, struct file *filep) 846static int ida_release(struct gendisk *disk, fmode_t mode)
847{ 847{
848 ctlr_info_t *host = get_host(inode->i_bdev->bd_disk); 848 ctlr_info_t *host = get_host(disk);
849 host->usage_count--; 849 host->usage_count--;
850 return 0; 850 return 0;
851} 851}
@@ -1128,10 +1128,10 @@ static int ida_getgeo(struct block_device *bdev, struct hd_geometry *geo)
1128 * ida_ioctl does some miscellaneous stuff like reporting drive geometry, 1128 * ida_ioctl does some miscellaneous stuff like reporting drive geometry,
1129 * setting readahead and submitting commands from userspace to the controller. 1129 * setting readahead and submitting commands from userspace to the controller.
1130 */ 1130 */
1131static int ida_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, unsigned long arg) 1131static int ida_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg)
1132{ 1132{
1133 drv_info_t *drv = get_drv(inode->i_bdev->bd_disk); 1133 drv_info_t *drv = get_drv(bdev->bd_disk);
1134 ctlr_info_t *host = get_host(inode->i_bdev->bd_disk); 1134 ctlr_info_t *host = get_host(bdev->bd_disk);
1135 int error; 1135 int error;
1136 ida_ioctl_t __user *io = (ida_ioctl_t __user *)arg; 1136 ida_ioctl_t __user *io = (ida_ioctl_t __user *)arg;
1137 ida_ioctl_t *my_io; 1137 ida_ioctl_t *my_io;
@@ -1165,7 +1165,7 @@ out_passthru:
1165 put_user(host->ctlr_sig, (int __user *)arg); 1165 put_user(host->ctlr_sig, (int __user *)arg);
1166 return 0; 1166 return 0;
1167 case IDAREVALIDATEVOLS: 1167 case IDAREVALIDATEVOLS:
1168 if (iminor(inode) != 0) 1168 if (MINOR(bdev->bd_dev) != 0)
1169 return -ENXIO; 1169 return -ENXIO;
1170 return revalidate_allvol(host); 1170 return revalidate_allvol(host);
1171 case IDADRIVERVERSION: 1171 case IDADRIVERVERSION:
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 2cea27aba9a0..14db747a636e 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -3450,14 +3450,14 @@ static int fd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
3450 return 0; 3450 return 0;
3451} 3451}
3452 3452
3453static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, 3453static int fd_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd,
3454 unsigned long param) 3454 unsigned long param)
3455{ 3455{
3456#define FD_IOCTL_ALLOWED ((filp) && (filp)->private_data) 3456#define FD_IOCTL_ALLOWED (mode & (FMODE_WRITE|FMODE_WRITE_IOCTL))
3457#define OUT(c,x) case c: outparam = (const char *) (x); break 3457#define OUT(c,x) case c: outparam = (const char *) (x); break
3458#define IN(c,x,tag) case c: *(x) = inparam. tag ; return 0 3458#define IN(c,x,tag) case c: *(x) = inparam. tag ; return 0
3459 3459
3460 int drive = (long)inode->i_bdev->bd_disk->private_data; 3460 int drive = (long)bdev->bd_disk->private_data;
3461 int type = ITYPE(UDRS->fd_device); 3461 int type = ITYPE(UDRS->fd_device);
3462 int i; 3462 int i;
3463 int ret; 3463 int ret;
@@ -3516,11 +3516,11 @@ static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
3516 current_type[drive] = NULL; 3516 current_type[drive] = NULL;
3517 floppy_sizes[drive] = MAX_DISK_SIZE << 1; 3517 floppy_sizes[drive] = MAX_DISK_SIZE << 1;
3518 UDRS->keep_data = 0; 3518 UDRS->keep_data = 0;
3519 return invalidate_drive(inode->i_bdev); 3519 return invalidate_drive(bdev);
3520 case FDSETPRM: 3520 case FDSETPRM:
3521 case FDDEFPRM: 3521 case FDDEFPRM:
3522 return set_geometry(cmd, &inparam.g, 3522 return set_geometry(cmd, &inparam.g,
3523 drive, type, inode->i_bdev); 3523 drive, type, bdev);
3524 case FDGETPRM: 3524 case FDGETPRM:
3525 ECALL(get_floppy_geometry(drive, type, 3525 ECALL(get_floppy_geometry(drive, type,
3526 (struct floppy_struct **) 3526 (struct floppy_struct **)
@@ -3551,7 +3551,7 @@ static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
3551 case FDFMTEND: 3551 case FDFMTEND:
3552 case FDFLUSH: 3552 case FDFLUSH:
3553 LOCK_FDC(drive, 1); 3553 LOCK_FDC(drive, 1);
3554 return invalidate_drive(inode->i_bdev); 3554 return invalidate_drive(bdev);
3555 3555
3556 case FDSETEMSGTRESH: 3556 case FDSETEMSGTRESH:
3557 UDP->max_errors.reporting = 3557 UDP->max_errors.reporting =
@@ -3659,9 +3659,9 @@ static void __init config_types(void)
3659 printk("\n"); 3659 printk("\n");
3660} 3660}
3661 3661
3662static int floppy_release(struct inode *inode, struct file *filp) 3662static int floppy_release(struct gendisk *disk, fmode_t mode)
3663{ 3663{
3664 int drive = (long)inode->i_bdev->bd_disk->private_data; 3664 int drive = (long)disk->private_data;
3665 3665
3666 mutex_lock(&open_lock); 3666 mutex_lock(&open_lock);
3667 if (UDRS->fd_ref < 0) 3667 if (UDRS->fd_ref < 0)
@@ -3682,18 +3682,17 @@ static int floppy_release(struct inode *inode, struct file *filp)
3682 * /dev/PS0 etc), and disallows simultaneous access to the same 3682 * /dev/PS0 etc), and disallows simultaneous access to the same
3683 * drive with different device numbers. 3683 * drive with different device numbers.
3684 */ 3684 */
3685static int floppy_open(struct inode *inode, struct file *filp) 3685static int floppy_open(struct block_device *bdev, fmode_t mode)
3686{ 3686{
3687 int drive = (long)inode->i_bdev->bd_disk->private_data; 3687 int drive = (long)bdev->bd_disk->private_data;
3688 int old_dev; 3688 int old_dev, new_dev;
3689 int try; 3689 int try;
3690 int res = -EBUSY; 3690 int res = -EBUSY;
3691 char *tmp; 3691 char *tmp;
3692 3692
3693 filp->private_data = (void *)0;
3694 mutex_lock(&open_lock); 3693 mutex_lock(&open_lock);
3695 old_dev = UDRS->fd_device; 3694 old_dev = UDRS->fd_device;
3696 if (opened_bdev[drive] && opened_bdev[drive] != inode->i_bdev) 3695 if (opened_bdev[drive] && opened_bdev[drive] != bdev)
3697 goto out2; 3696 goto out2;
3698 3697
3699 if (!UDRS->fd_ref && (UDP->flags & FD_BROKEN_DCL)) { 3698 if (!UDRS->fd_ref && (UDP->flags & FD_BROKEN_DCL)) {
@@ -3701,15 +3700,15 @@ static int floppy_open(struct inode *inode, struct file *filp)
3701 USETF(FD_VERIFY); 3700 USETF(FD_VERIFY);
3702 } 3701 }
3703 3702
3704 if (UDRS->fd_ref == -1 || (UDRS->fd_ref && (filp->f_flags & O_EXCL))) 3703 if (UDRS->fd_ref == -1 || (UDRS->fd_ref && (mode & FMODE_EXCL)))
3705 goto out2; 3704 goto out2;
3706 3705
3707 if (filp->f_flags & O_EXCL) 3706 if (mode & FMODE_EXCL)
3708 UDRS->fd_ref = -1; 3707 UDRS->fd_ref = -1;
3709 else 3708 else
3710 UDRS->fd_ref++; 3709 UDRS->fd_ref++;
3711 3710
3712 opened_bdev[drive] = inode->i_bdev; 3711 opened_bdev[drive] = bdev;
3713 3712
3714 res = -ENXIO; 3713 res = -ENXIO;
3715 3714
@@ -3744,31 +3743,26 @@ static int floppy_open(struct inode *inode, struct file *filp)
3744 } 3743 }
3745 } 3744 }
3746 3745
3747 UDRS->fd_device = iminor(inode); 3746 new_dev = MINOR(bdev->bd_dev);
3748 set_capacity(disks[drive], floppy_sizes[iminor(inode)]); 3747 UDRS->fd_device = new_dev;
3749 if (old_dev != -1 && old_dev != iminor(inode)) { 3748 set_capacity(disks[drive], floppy_sizes[new_dev]);
3749 if (old_dev != -1 && old_dev != new_dev) {
3750 if (buffer_drive == drive) 3750 if (buffer_drive == drive)
3751 buffer_track = -1; 3751 buffer_track = -1;
3752 } 3752 }
3753 3753
3754 /* Allow ioctls if we have write-permissions even if read-only open.
3755 * Needed so that programs such as fdrawcmd still can work on write
3756 * protected disks */
3757 if ((filp->f_mode & FMODE_WRITE) || !file_permission(filp, MAY_WRITE))
3758 filp->private_data = (void *)8;
3759
3760 if (UFDCS->rawcmd == 1) 3754 if (UFDCS->rawcmd == 1)
3761 UFDCS->rawcmd = 2; 3755 UFDCS->rawcmd = 2;
3762 3756
3763 if (!(filp->f_flags & O_NDELAY)) { 3757 if (!(mode & FMODE_NDELAY)) {
3764 if (filp->f_mode & 3) { 3758 if (mode & (FMODE_READ|FMODE_WRITE)) {
3765 UDRS->last_checked = 0; 3759 UDRS->last_checked = 0;
3766 check_disk_change(inode->i_bdev); 3760 check_disk_change(bdev);
3767 if (UTESTF(FD_DISK_CHANGED)) 3761 if (UTESTF(FD_DISK_CHANGED))
3768 goto out; 3762 goto out;
3769 } 3763 }
3770 res = -EROFS; 3764 res = -EROFS;
3771 if ((filp->f_mode & 2) && !(UTESTF(FD_DISK_WRITABLE))) 3765 if ((mode & FMODE_WRITE) && !(UTESTF(FD_DISK_WRITABLE)))
3772 goto out; 3766 goto out;
3773 } 3767 }
3774 mutex_unlock(&open_lock); 3768 mutex_unlock(&open_lock);
@@ -3911,7 +3905,7 @@ static struct block_device_operations floppy_fops = {
3911 .owner = THIS_MODULE, 3905 .owner = THIS_MODULE,
3912 .open = floppy_open, 3906 .open = floppy_open,
3913 .release = floppy_release, 3907 .release = floppy_release,
3914 .ioctl = fd_ioctl, 3908 .locked_ioctl = fd_ioctl,
3915 .getgeo = fd_getgeo, 3909 .getgeo = fd_getgeo,
3916 .media_changed = check_floppy_change, 3910 .media_changed = check_floppy_change,
3917 .revalidate_disk = floppy_revalidate, 3911 .revalidate_disk = floppy_revalidate,
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index d3a25b027ff9..3f09cd8bcc38 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -210,7 +210,7 @@ lo_do_transfer(struct loop_device *lo, int cmd,
210 * space operations write_begin and write_end. 210 * space operations write_begin and write_end.
211 */ 211 */
212static int do_lo_send_aops(struct loop_device *lo, struct bio_vec *bvec, 212static int do_lo_send_aops(struct loop_device *lo, struct bio_vec *bvec,
213 int bsize, loff_t pos, struct page *unused) 213 loff_t pos, struct page *unused)
214{ 214{
215 struct file *file = lo->lo_backing_file; /* kudos to NFsckingS */ 215 struct file *file = lo->lo_backing_file; /* kudos to NFsckingS */
216 struct address_space *mapping = file->f_mapping; 216 struct address_space *mapping = file->f_mapping;
@@ -302,7 +302,7 @@ static int __do_lo_send_write(struct file *file,
302 * filesystems. 302 * filesystems.
303 */ 303 */
304static int do_lo_send_direct_write(struct loop_device *lo, 304static int do_lo_send_direct_write(struct loop_device *lo,
305 struct bio_vec *bvec, int bsize, loff_t pos, struct page *page) 305 struct bio_vec *bvec, loff_t pos, struct page *page)
306{ 306{
307 ssize_t bw = __do_lo_send_write(lo->lo_backing_file, 307 ssize_t bw = __do_lo_send_write(lo->lo_backing_file,
308 kmap(bvec->bv_page) + bvec->bv_offset, 308 kmap(bvec->bv_page) + bvec->bv_offset,
@@ -326,7 +326,7 @@ static int do_lo_send_direct_write(struct loop_device *lo,
326 * destination pages of the backing file. 326 * destination pages of the backing file.
327 */ 327 */
328static int do_lo_send_write(struct loop_device *lo, struct bio_vec *bvec, 328static int do_lo_send_write(struct loop_device *lo, struct bio_vec *bvec,
329 int bsize, loff_t pos, struct page *page) 329 loff_t pos, struct page *page)
330{ 330{
331 int ret = lo_do_transfer(lo, WRITE, page, 0, bvec->bv_page, 331 int ret = lo_do_transfer(lo, WRITE, page, 0, bvec->bv_page,
332 bvec->bv_offset, bvec->bv_len, pos >> 9); 332 bvec->bv_offset, bvec->bv_len, pos >> 9);
@@ -341,10 +341,9 @@ static int do_lo_send_write(struct loop_device *lo, struct bio_vec *bvec,
341 return ret; 341 return ret;
342} 342}
343 343
344static int lo_send(struct loop_device *lo, struct bio *bio, int bsize, 344static int lo_send(struct loop_device *lo, struct bio *bio, loff_t pos)
345 loff_t pos)
346{ 345{
347 int (*do_lo_send)(struct loop_device *, struct bio_vec *, int, loff_t, 346 int (*do_lo_send)(struct loop_device *, struct bio_vec *, loff_t,
348 struct page *page); 347 struct page *page);
349 struct bio_vec *bvec; 348 struct bio_vec *bvec;
350 struct page *page = NULL; 349 struct page *page = NULL;
@@ -362,7 +361,7 @@ static int lo_send(struct loop_device *lo, struct bio *bio, int bsize,
362 } 361 }
363 } 362 }
364 bio_for_each_segment(bvec, bio, i) { 363 bio_for_each_segment(bvec, bio, i) {
365 ret = do_lo_send(lo, bvec, bsize, pos, page); 364 ret = do_lo_send(lo, bvec, pos, page);
366 if (ret < 0) 365 if (ret < 0)
367 break; 366 break;
368 pos += bvec->bv_len; 367 pos += bvec->bv_len;
@@ -478,7 +477,7 @@ static int do_bio_filebacked(struct loop_device *lo, struct bio *bio)
478 477
479 pos = ((loff_t) bio->bi_sector << 9) + lo->lo_offset; 478 pos = ((loff_t) bio->bi_sector << 9) + lo->lo_offset;
480 if (bio_rw(bio) == WRITE) 479 if (bio_rw(bio) == WRITE)
481 ret = lo_send(lo, bio, lo->lo_blocksize, pos); 480 ret = lo_send(lo, bio, pos);
482 else 481 else
483 ret = lo_receive(lo, bio, lo->lo_blocksize, pos); 482 ret = lo_receive(lo, bio, lo->lo_blocksize, pos);
484 return ret; 483 return ret;
@@ -652,8 +651,8 @@ static void do_loop_switch(struct loop_device *lo, struct switch_request *p)
652 * This can only work if the loop device is used read-only, and if the 651 * This can only work if the loop device is used read-only, and if the
653 * new backing store is the same size and type as the old backing store. 652 * new backing store is the same size and type as the old backing store.
654 */ 653 */
655static int loop_change_fd(struct loop_device *lo, struct file *lo_file, 654static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
656 struct block_device *bdev, unsigned int arg) 655 unsigned int arg)
657{ 656{
658 struct file *file, *old_file; 657 struct file *file, *old_file;
659 struct inode *inode; 658 struct inode *inode;
@@ -712,7 +711,7 @@ static inline int is_loop_device(struct file *file)
712 return i && S_ISBLK(i->i_mode) && MAJOR(i->i_rdev) == LOOP_MAJOR; 711 return i && S_ISBLK(i->i_mode) && MAJOR(i->i_rdev) == LOOP_MAJOR;
713} 712}
714 713
715static int loop_set_fd(struct loop_device *lo, struct file *lo_file, 714static int loop_set_fd(struct loop_device *lo, fmode_t mode,
716 struct block_device *bdev, unsigned int arg) 715 struct block_device *bdev, unsigned int arg)
717{ 716{
718 struct file *file, *f; 717 struct file *file, *f;
@@ -740,7 +739,7 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
740 while (is_loop_device(f)) { 739 while (is_loop_device(f)) {
741 struct loop_device *l; 740 struct loop_device *l;
742 741
743 if (f->f_mapping->host->i_rdev == lo_file->f_mapping->host->i_rdev) 742 if (f->f_mapping->host->i_bdev == bdev)
744 goto out_putf; 743 goto out_putf;
745 744
746 l = f->f_mapping->host->i_bdev->bd_disk->private_data; 745 l = f->f_mapping->host->i_bdev->bd_disk->private_data;
@@ -786,7 +785,7 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
786 goto out_putf; 785 goto out_putf;
787 } 786 }
788 787
789 if (!(lo_file->f_mode & FMODE_WRITE)) 788 if (!(mode & FMODE_WRITE))
790 lo_flags |= LO_FLAGS_READ_ONLY; 789 lo_flags |= LO_FLAGS_READ_ONLY;
791 790
792 set_device_ro(bdev, (lo_flags & LO_FLAGS_READ_ONLY) != 0); 791 set_device_ro(bdev, (lo_flags & LO_FLAGS_READ_ONLY) != 0);
@@ -918,9 +917,11 @@ static int loop_clr_fd(struct loop_device *lo, struct block_device *bdev)
918 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE); 917 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
919 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE); 918 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
920 memset(lo->lo_file_name, 0, LO_NAME_SIZE); 919 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
921 invalidate_bdev(bdev); 920 if (bdev)
921 invalidate_bdev(bdev);
922 set_capacity(lo->lo_disk, 0); 922 set_capacity(lo->lo_disk, 0);
923 bd_set_size(bdev, 0); 923 if (bdev)
924 bd_set_size(bdev, 0);
924 mapping_set_gfp_mask(filp->f_mapping, gfp); 925 mapping_set_gfp_mask(filp->f_mapping, gfp);
925 lo->lo_state = Lo_unbound; 926 lo->lo_state = Lo_unbound;
926 fput(filp); 927 fput(filp);
@@ -1137,22 +1138,22 @@ loop_get_status64(struct loop_device *lo, struct loop_info64 __user *arg) {
1137 return err; 1138 return err;
1138} 1139}
1139 1140
1140static int lo_ioctl(struct inode * inode, struct file * file, 1141static int lo_ioctl(struct block_device *bdev, fmode_t mode,
1141 unsigned int cmd, unsigned long arg) 1142 unsigned int cmd, unsigned long arg)
1142{ 1143{
1143 struct loop_device *lo = inode->i_bdev->bd_disk->private_data; 1144 struct loop_device *lo = bdev->bd_disk->private_data;
1144 int err; 1145 int err;
1145 1146
1146 mutex_lock(&lo->lo_ctl_mutex); 1147 mutex_lock(&lo->lo_ctl_mutex);
1147 switch (cmd) { 1148 switch (cmd) {
1148 case LOOP_SET_FD: 1149 case LOOP_SET_FD:
1149 err = loop_set_fd(lo, file, inode->i_bdev, arg); 1150 err = loop_set_fd(lo, mode, bdev, arg);
1150 break; 1151 break;
1151 case LOOP_CHANGE_FD: 1152 case LOOP_CHANGE_FD:
1152 err = loop_change_fd(lo, file, inode->i_bdev, arg); 1153 err = loop_change_fd(lo, bdev, arg);
1153 break; 1154 break;
1154 case LOOP_CLR_FD: 1155 case LOOP_CLR_FD:
1155 err = loop_clr_fd(lo, inode->i_bdev); 1156 err = loop_clr_fd(lo, bdev);
1156 break; 1157 break;
1157 case LOOP_SET_STATUS: 1158 case LOOP_SET_STATUS:
1158 err = loop_set_status_old(lo, (struct loop_info __user *) arg); 1159 err = loop_set_status_old(lo, (struct loop_info __user *) arg);
@@ -1292,10 +1293,10 @@ loop_get_status_compat(struct loop_device *lo,
1292 return err; 1293 return err;
1293} 1294}
1294 1295
1295static long lo_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 1296static int lo_compat_ioctl(struct block_device *bdev, fmode_t mode,
1297 unsigned int cmd, unsigned long arg)
1296{ 1298{
1297 struct inode *inode = file->f_path.dentry->d_inode; 1299 struct loop_device *lo = bdev->bd_disk->private_data;
1298 struct loop_device *lo = inode->i_bdev->bd_disk->private_data;
1299 int err; 1300 int err;
1300 1301
1301 switch(cmd) { 1302 switch(cmd) {
@@ -1317,7 +1318,7 @@ static long lo_compat_ioctl(struct file *file, unsigned int cmd, unsigned long a
1317 arg = (unsigned long) compat_ptr(arg); 1318 arg = (unsigned long) compat_ptr(arg);
1318 case LOOP_SET_FD: 1319 case LOOP_SET_FD:
1319 case LOOP_CHANGE_FD: 1320 case LOOP_CHANGE_FD:
1320 err = lo_ioctl(inode, file, cmd, arg); 1321 err = lo_ioctl(bdev, mode, cmd, arg);
1321 break; 1322 break;
1322 default: 1323 default:
1323 err = -ENOIOCTLCMD; 1324 err = -ENOIOCTLCMD;
@@ -1327,9 +1328,9 @@ static long lo_compat_ioctl(struct file *file, unsigned int cmd, unsigned long a
1327} 1328}
1328#endif 1329#endif
1329 1330
1330static int lo_open(struct inode *inode, struct file *file) 1331static int lo_open(struct block_device *bdev, fmode_t mode)
1331{ 1332{
1332 struct loop_device *lo = inode->i_bdev->bd_disk->private_data; 1333 struct loop_device *lo = bdev->bd_disk->private_data;
1333 1334
1334 mutex_lock(&lo->lo_ctl_mutex); 1335 mutex_lock(&lo->lo_ctl_mutex);
1335 lo->lo_refcnt++; 1336 lo->lo_refcnt++;
@@ -1338,15 +1339,15 @@ static int lo_open(struct inode *inode, struct file *file)
1338 return 0; 1339 return 0;
1339} 1340}
1340 1341
1341static int lo_release(struct inode *inode, struct file *file) 1342static int lo_release(struct gendisk *disk, fmode_t mode)
1342{ 1343{
1343 struct loop_device *lo = inode->i_bdev->bd_disk->private_data; 1344 struct loop_device *lo = disk->private_data;
1344 1345
1345 mutex_lock(&lo->lo_ctl_mutex); 1346 mutex_lock(&lo->lo_ctl_mutex);
1346 --lo->lo_refcnt; 1347 --lo->lo_refcnt;
1347 1348
1348 if ((lo->lo_flags & LO_FLAGS_AUTOCLEAR) && !lo->lo_refcnt) 1349 if ((lo->lo_flags & LO_FLAGS_AUTOCLEAR) && !lo->lo_refcnt)
1349 loop_clr_fd(lo, inode->i_bdev); 1350 loop_clr_fd(lo, NULL);
1350 1351
1351 mutex_unlock(&lo->lo_ctl_mutex); 1352 mutex_unlock(&lo->lo_ctl_mutex);
1352 1353
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 9034ca585afd..d3a91cacee8c 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -557,10 +557,11 @@ static void do_nbd_request(struct request_queue * q)
557 } 557 }
558} 558}
559 559
560static int nbd_ioctl(struct inode *inode, struct file *file, 560static int nbd_ioctl(struct block_device *bdev, fmode_t mode,
561 unsigned int cmd, unsigned long arg) 561 unsigned int cmd, unsigned long arg)
562{ 562{
563 struct nbd_device *lo = inode->i_bdev->bd_disk->private_data; 563 struct nbd_device *lo = bdev->bd_disk->private_data;
564 struct file *file;
564 int error; 565 int error;
565 struct request sreq ; 566 struct request sreq ;
566 struct task_struct *thread; 567 struct task_struct *thread;
@@ -612,8 +613,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
612 error = -EINVAL; 613 error = -EINVAL;
613 file = fget(arg); 614 file = fget(arg);
614 if (file) { 615 if (file) {
615 struct block_device *bdev = inode->i_bdev; 616 struct inode *inode = file->f_path.dentry->d_inode;
616 inode = file->f_path.dentry->d_inode;
617 if (S_ISSOCK(inode->i_mode)) { 617 if (S_ISSOCK(inode->i_mode)) {
618 lo->file = file; 618 lo->file = file;
619 lo->sock = SOCKET_I(inode); 619 lo->sock = SOCKET_I(inode);
@@ -628,14 +628,14 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
628 case NBD_SET_BLKSIZE: 628 case NBD_SET_BLKSIZE:
629 lo->blksize = arg; 629 lo->blksize = arg;
630 lo->bytesize &= ~(lo->blksize-1); 630 lo->bytesize &= ~(lo->blksize-1);
631 inode->i_bdev->bd_inode->i_size = lo->bytesize; 631 bdev->bd_inode->i_size = lo->bytesize;
632 set_blocksize(inode->i_bdev, lo->blksize); 632 set_blocksize(bdev, lo->blksize);
633 set_capacity(lo->disk, lo->bytesize >> 9); 633 set_capacity(lo->disk, lo->bytesize >> 9);
634 return 0; 634 return 0;
635 case NBD_SET_SIZE: 635 case NBD_SET_SIZE:
636 lo->bytesize = arg & ~(lo->blksize-1); 636 lo->bytesize = arg & ~(lo->blksize-1);
637 inode->i_bdev->bd_inode->i_size = lo->bytesize; 637 bdev->bd_inode->i_size = lo->bytesize;
638 set_blocksize(inode->i_bdev, lo->blksize); 638 set_blocksize(bdev, lo->blksize);
639 set_capacity(lo->disk, lo->bytesize >> 9); 639 set_capacity(lo->disk, lo->bytesize >> 9);
640 return 0; 640 return 0;
641 case NBD_SET_TIMEOUT: 641 case NBD_SET_TIMEOUT:
@@ -643,8 +643,8 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
643 return 0; 643 return 0;
644 case NBD_SET_SIZE_BLOCKS: 644 case NBD_SET_SIZE_BLOCKS:
645 lo->bytesize = ((u64) arg) * lo->blksize; 645 lo->bytesize = ((u64) arg) * lo->blksize;
646 inode->i_bdev->bd_inode->i_size = lo->bytesize; 646 bdev->bd_inode->i_size = lo->bytesize;
647 set_blocksize(inode->i_bdev, lo->blksize); 647 set_blocksize(bdev, lo->blksize);
648 set_capacity(lo->disk, lo->bytesize >> 9); 648 set_capacity(lo->disk, lo->bytesize >> 9);
649 return 0; 649 return 0;
650 case NBD_DO_IT: 650 case NBD_DO_IT:
@@ -666,10 +666,10 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
666 if (file) 666 if (file)
667 fput(file); 667 fput(file);
668 lo->bytesize = 0; 668 lo->bytesize = 0;
669 inode->i_bdev->bd_inode->i_size = 0; 669 bdev->bd_inode->i_size = 0;
670 set_capacity(lo->disk, 0); 670 set_capacity(lo->disk, 0);
671 if (max_part > 0) 671 if (max_part > 0)
672 ioctl_by_bdev(inode->i_bdev, BLKRRPART, 0); 672 ioctl_by_bdev(bdev, BLKRRPART, 0);
673 return lo->harderror; 673 return lo->harderror;
674 case NBD_CLEAR_QUE: 674 case NBD_CLEAR_QUE:
675 /* 675 /*
@@ -680,7 +680,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
680 return 0; 680 return 0;
681 case NBD_PRINT_DEBUG: 681 case NBD_PRINT_DEBUG:
682 printk(KERN_INFO "%s: next = %p, prev = %p, head = %p\n", 682 printk(KERN_INFO "%s: next = %p, prev = %p, head = %p\n",
683 inode->i_bdev->bd_disk->disk_name, 683 bdev->bd_disk->disk_name,
684 lo->queue_head.next, lo->queue_head.prev, 684 lo->queue_head.next, lo->queue_head.prev,
685 &lo->queue_head); 685 &lo->queue_head);
686 return 0; 686 return 0;
@@ -691,7 +691,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
691static struct block_device_operations nbd_fops = 691static struct block_device_operations nbd_fops =
692{ 692{
693 .owner = THIS_MODULE, 693 .owner = THIS_MODULE,
694 .ioctl = nbd_ioctl, 694 .locked_ioctl = nbd_ioctl,
695}; 695};
696 696
697/* 697/*
diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c
index b8a994a2b013..e91d4b4b014f 100644
--- a/drivers/block/paride/pcd.c
+++ b/drivers/block/paride/pcd.c
@@ -223,23 +223,24 @@ static int pcd_warned; /* Have we logged a phase warning ? */
223 223
224/* kernel glue structures */ 224/* kernel glue structures */
225 225
226static int pcd_block_open(struct inode *inode, struct file *file) 226static int pcd_block_open(struct block_device *bdev, fmode_t mode)
227{ 227{
228 struct pcd_unit *cd = inode->i_bdev->bd_disk->private_data; 228 struct pcd_unit *cd = bdev->bd_disk->private_data;
229 return cdrom_open(&cd->info, inode, file); 229 return cdrom_open(&cd->info, bdev, mode);
230} 230}
231 231
232static int pcd_block_release(struct inode *inode, struct file *file) 232static int pcd_block_release(struct gendisk *disk, fmode_t mode)
233{ 233{
234 struct pcd_unit *cd = inode->i_bdev->bd_disk->private_data; 234 struct pcd_unit *cd = disk->private_data;
235 return cdrom_release(&cd->info, file); 235 cdrom_release(&cd->info, mode);
236 return 0;
236} 237}
237 238
238static int pcd_block_ioctl(struct inode *inode, struct file *file, 239static int pcd_block_ioctl(struct block_device *bdev, fmode_t mode,
239 unsigned cmd, unsigned long arg) 240 unsigned cmd, unsigned long arg)
240{ 241{
241 struct pcd_unit *cd = inode->i_bdev->bd_disk->private_data; 242 struct pcd_unit *cd = bdev->bd_disk->private_data;
242 return cdrom_ioctl(file, &cd->info, inode, cmd, arg); 243 return cdrom_ioctl(&cd->info, bdev, mode, cmd, arg);
243} 244}
244 245
245static int pcd_block_media_changed(struct gendisk *disk) 246static int pcd_block_media_changed(struct gendisk *disk)
@@ -252,7 +253,7 @@ static struct block_device_operations pcd_bdops = {
252 .owner = THIS_MODULE, 253 .owner = THIS_MODULE,
253 .open = pcd_block_open, 254 .open = pcd_block_open,
254 .release = pcd_block_release, 255 .release = pcd_block_release,
255 .ioctl = pcd_block_ioctl, 256 .locked_ioctl = pcd_block_ioctl,
256 .media_changed = pcd_block_media_changed, 257 .media_changed = pcd_block_media_changed,
257}; 258};
258 259
diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c
index 5fdfa7c888ce..9299455b0af6 100644
--- a/drivers/block/paride/pd.c
+++ b/drivers/block/paride/pd.c
@@ -728,9 +728,9 @@ static int pd_special_command(struct pd_unit *disk,
728 728
729/* kernel glue structures */ 729/* kernel glue structures */
730 730
731static int pd_open(struct inode *inode, struct file *file) 731static int pd_open(struct block_device *bdev, fmode_t mode)
732{ 732{
733 struct pd_unit *disk = inode->i_bdev->bd_disk->private_data; 733 struct pd_unit *disk = bdev->bd_disk->private_data;
734 734
735 disk->access++; 735 disk->access++;
736 736
@@ -758,10 +758,10 @@ static int pd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
758 return 0; 758 return 0;
759} 759}
760 760
761static int pd_ioctl(struct inode *inode, struct file *file, 761static int pd_ioctl(struct block_device *bdev, fmode_t mode,
762 unsigned int cmd, unsigned long arg) 762 unsigned int cmd, unsigned long arg)
763{ 763{
764 struct pd_unit *disk = inode->i_bdev->bd_disk->private_data; 764 struct pd_unit *disk = bdev->bd_disk->private_data;
765 765
766 switch (cmd) { 766 switch (cmd) {
767 case CDROMEJECT: 767 case CDROMEJECT:
@@ -773,9 +773,9 @@ static int pd_ioctl(struct inode *inode, struct file *file,
773 } 773 }
774} 774}
775 775
776static int pd_release(struct inode *inode, struct file *file) 776static int pd_release(struct gendisk *p, fmode_t mode)
777{ 777{
778 struct pd_unit *disk = inode->i_bdev->bd_disk->private_data; 778 struct pd_unit *disk = p->private_data;
779 779
780 if (!--disk->access && disk->removable) 780 if (!--disk->access && disk->removable)
781 pd_special_command(disk, pd_door_unlock); 781 pd_special_command(disk, pd_door_unlock);
@@ -809,7 +809,7 @@ static struct block_device_operations pd_fops = {
809 .owner = THIS_MODULE, 809 .owner = THIS_MODULE,
810 .open = pd_open, 810 .open = pd_open,
811 .release = pd_release, 811 .release = pd_release,
812 .ioctl = pd_ioctl, 812 .locked_ioctl = pd_ioctl,
813 .getgeo = pd_getgeo, 813 .getgeo = pd_getgeo,
814 .media_changed = pd_check_media, 814 .media_changed = pd_check_media,
815 .revalidate_disk= pd_revalidate 815 .revalidate_disk= pd_revalidate
diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c
index e7fe6ca97dd8..bef3b997ba3e 100644
--- a/drivers/block/paride/pf.c
+++ b/drivers/block/paride/pf.c
@@ -201,13 +201,13 @@ module_param_array(drive3, int, NULL, 0);
201#define ATAPI_READ_10 0x28 201#define ATAPI_READ_10 0x28
202#define ATAPI_WRITE_10 0x2a 202#define ATAPI_WRITE_10 0x2a
203 203
204static int pf_open(struct inode *inode, struct file *file); 204static int pf_open(struct block_device *bdev, fmode_t mode);
205static void do_pf_request(struct request_queue * q); 205static void do_pf_request(struct request_queue * q);
206static int pf_ioctl(struct inode *inode, struct file *file, 206static int pf_ioctl(struct block_device *bdev, fmode_t mode,
207 unsigned int cmd, unsigned long arg); 207 unsigned int cmd, unsigned long arg);
208static int pf_getgeo(struct block_device *bdev, struct hd_geometry *geo); 208static int pf_getgeo(struct block_device *bdev, struct hd_geometry *geo);
209 209
210static int pf_release(struct inode *inode, struct file *file); 210static int pf_release(struct gendisk *disk, fmode_t mode);
211 211
212static int pf_detect(void); 212static int pf_detect(void);
213static void do_pf_read(void); 213static void do_pf_read(void);
@@ -266,7 +266,7 @@ static struct block_device_operations pf_fops = {
266 .owner = THIS_MODULE, 266 .owner = THIS_MODULE,
267 .open = pf_open, 267 .open = pf_open,
268 .release = pf_release, 268 .release = pf_release,
269 .ioctl = pf_ioctl, 269 .locked_ioctl = pf_ioctl,
270 .getgeo = pf_getgeo, 270 .getgeo = pf_getgeo,
271 .media_changed = pf_check_media, 271 .media_changed = pf_check_media,
272}; 272};
@@ -296,16 +296,16 @@ static void __init pf_init_units(void)
296 } 296 }
297} 297}
298 298
299static int pf_open(struct inode *inode, struct file *file) 299static int pf_open(struct block_device *bdev, fmode_t mode)
300{ 300{
301 struct pf_unit *pf = inode->i_bdev->bd_disk->private_data; 301 struct pf_unit *pf = bdev->bd_disk->private_data;
302 302
303 pf_identify(pf); 303 pf_identify(pf);
304 304
305 if (pf->media_status == PF_NM) 305 if (pf->media_status == PF_NM)
306 return -ENODEV; 306 return -ENODEV;
307 307
308 if ((pf->media_status == PF_RO) && (file->f_mode & 2)) 308 if ((pf->media_status == PF_RO) && (mode & FMODE_WRITE))
309 return -EROFS; 309 return -EROFS;
310 310
311 pf->access++; 311 pf->access++;
@@ -333,9 +333,9 @@ static int pf_getgeo(struct block_device *bdev, struct hd_geometry *geo)
333 return 0; 333 return 0;
334} 334}
335 335
336static int pf_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) 336static int pf_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg)
337{ 337{
338 struct pf_unit *pf = inode->i_bdev->bd_disk->private_data; 338 struct pf_unit *pf = bdev->bd_disk->private_data;
339 339
340 if (cmd != CDROMEJECT) 340 if (cmd != CDROMEJECT)
341 return -EINVAL; 341 return -EINVAL;
@@ -346,9 +346,9 @@ static int pf_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
346 return 0; 346 return 0;
347} 347}
348 348
349static int pf_release(struct inode *inode, struct file *file) 349static int pf_release(struct gendisk *disk, fmode_t mode)
350{ 350{
351 struct pf_unit *pf = inode->i_bdev->bd_disk->private_data; 351 struct pf_unit *pf = disk->private_data;
352 352
353 if (pf->access <= 0) 353 if (pf->access <= 0)
354 return -EINVAL; 354 return -EINVAL;
diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c
index 5ae229656eaa..1e4006e18f03 100644
--- a/drivers/block/paride/pt.c
+++ b/drivers/block/paride/pt.c
@@ -667,7 +667,7 @@ static int pt_open(struct inode *inode, struct file *file)
667 goto out; 667 goto out;
668 668
669 err = -EROFS; 669 err = -EROFS;
670 if ((!(tape->flags & PT_WRITE_OK)) && (file->f_mode & 2)) 670 if ((!(tape->flags & PT_WRITE_OK)) && (file->f_mode & FMODE_WRITE))
671 goto out; 671 goto out;
672 672
673 if (!(iminor(inode) & 128)) 673 if (!(iminor(inode) & 128))
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 195ca7c720f5..f20bf359b84f 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -2320,7 +2320,7 @@ static int pkt_open_write(struct pktcdvd_device *pd)
2320/* 2320/*
2321 * called at open time. 2321 * called at open time.
2322 */ 2322 */
2323static int pkt_open_dev(struct pktcdvd_device *pd, int write) 2323static int pkt_open_dev(struct pktcdvd_device *pd, fmode_t write)
2324{ 2324{
2325 int ret; 2325 int ret;
2326 long lba; 2326 long lba;
@@ -2332,7 +2332,7 @@ static int pkt_open_dev(struct pktcdvd_device *pd, int write)
2332 * so bdget() can't fail. 2332 * so bdget() can't fail.
2333 */ 2333 */
2334 bdget(pd->bdev->bd_dev); 2334 bdget(pd->bdev->bd_dev);
2335 if ((ret = blkdev_get(pd->bdev, FMODE_READ, O_RDONLY))) 2335 if ((ret = blkdev_get(pd->bdev, FMODE_READ)))
2336 goto out; 2336 goto out;
2337 2337
2338 if ((ret = bd_claim(pd->bdev, pd))) 2338 if ((ret = bd_claim(pd->bdev, pd)))
@@ -2381,7 +2381,7 @@ static int pkt_open_dev(struct pktcdvd_device *pd, int write)
2381out_unclaim: 2381out_unclaim:
2382 bd_release(pd->bdev); 2382 bd_release(pd->bdev);
2383out_putdev: 2383out_putdev:
2384 blkdev_put(pd->bdev); 2384 blkdev_put(pd->bdev, FMODE_READ);
2385out: 2385out:
2386 return ret; 2386 return ret;
2387} 2387}
@@ -2399,7 +2399,7 @@ static void pkt_release_dev(struct pktcdvd_device *pd, int flush)
2399 2399
2400 pkt_set_speed(pd, MAX_SPEED, MAX_SPEED); 2400 pkt_set_speed(pd, MAX_SPEED, MAX_SPEED);
2401 bd_release(pd->bdev); 2401 bd_release(pd->bdev);
2402 blkdev_put(pd->bdev); 2402 blkdev_put(pd->bdev, FMODE_READ);
2403 2403
2404 pkt_shrink_pktlist(pd); 2404 pkt_shrink_pktlist(pd);
2405} 2405}
@@ -2411,7 +2411,7 @@ static struct pktcdvd_device *pkt_find_dev_from_minor(int dev_minor)
2411 return pkt_devs[dev_minor]; 2411 return pkt_devs[dev_minor];
2412} 2412}
2413 2413
2414static int pkt_open(struct inode *inode, struct file *file) 2414static int pkt_open(struct block_device *bdev, fmode_t mode)
2415{ 2415{
2416 struct pktcdvd_device *pd = NULL; 2416 struct pktcdvd_device *pd = NULL;
2417 int ret; 2417 int ret;
@@ -2419,7 +2419,7 @@ static int pkt_open(struct inode *inode, struct file *file)
2419 VPRINTK(DRIVER_NAME": entering open\n"); 2419 VPRINTK(DRIVER_NAME": entering open\n");
2420 2420
2421 mutex_lock(&ctl_mutex); 2421 mutex_lock(&ctl_mutex);
2422 pd = pkt_find_dev_from_minor(iminor(inode)); 2422 pd = pkt_find_dev_from_minor(MINOR(bdev->bd_dev));
2423 if (!pd) { 2423 if (!pd) {
2424 ret = -ENODEV; 2424 ret = -ENODEV;
2425 goto out; 2425 goto out;
@@ -2428,20 +2428,20 @@ static int pkt_open(struct inode *inode, struct file *file)
2428 2428
2429 pd->refcnt++; 2429 pd->refcnt++;
2430 if (pd->refcnt > 1) { 2430 if (pd->refcnt > 1) {
2431 if ((file->f_mode & FMODE_WRITE) && 2431 if ((mode & FMODE_WRITE) &&
2432 !test_bit(PACKET_WRITABLE, &pd->flags)) { 2432 !test_bit(PACKET_WRITABLE, &pd->flags)) {
2433 ret = -EBUSY; 2433 ret = -EBUSY;
2434 goto out_dec; 2434 goto out_dec;
2435 } 2435 }
2436 } else { 2436 } else {
2437 ret = pkt_open_dev(pd, file->f_mode & FMODE_WRITE); 2437 ret = pkt_open_dev(pd, mode & FMODE_WRITE);
2438 if (ret) 2438 if (ret)
2439 goto out_dec; 2439 goto out_dec;
2440 /* 2440 /*
2441 * needed here as well, since ext2 (among others) may change 2441 * needed here as well, since ext2 (among others) may change
2442 * the blocksize at mount time 2442 * the blocksize at mount time
2443 */ 2443 */
2444 set_blocksize(inode->i_bdev, CD_FRAMESIZE); 2444 set_blocksize(bdev, CD_FRAMESIZE);
2445 } 2445 }
2446 2446
2447 mutex_unlock(&ctl_mutex); 2447 mutex_unlock(&ctl_mutex);
@@ -2455,9 +2455,9 @@ out:
2455 return ret; 2455 return ret;
2456} 2456}
2457 2457
2458static int pkt_close(struct inode *inode, struct file *file) 2458static int pkt_close(struct gendisk *disk, fmode_t mode)
2459{ 2459{
2460 struct pktcdvd_device *pd = inode->i_bdev->bd_disk->private_data; 2460 struct pktcdvd_device *pd = disk->private_data;
2461 int ret = 0; 2461 int ret = 0;
2462 2462
2463 mutex_lock(&ctl_mutex); 2463 mutex_lock(&ctl_mutex);
@@ -2765,7 +2765,7 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
2765 bdev = bdget(dev); 2765 bdev = bdget(dev);
2766 if (!bdev) 2766 if (!bdev)
2767 return -ENOMEM; 2767 return -ENOMEM;
2768 ret = blkdev_get(bdev, FMODE_READ, O_RDONLY | O_NONBLOCK); 2768 ret = blkdev_get(bdev, FMODE_READ | FMODE_NDELAY);
2769 if (ret) 2769 if (ret)
2770 return ret; 2770 return ret;
2771 2771
@@ -2790,19 +2790,28 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
2790 return 0; 2790 return 0;
2791 2791
2792out_mem: 2792out_mem:
2793 blkdev_put(bdev); 2793 blkdev_put(bdev, FMODE_READ|FMODE_WRITE);
2794 /* This is safe: open() is still holding a reference. */ 2794 /* This is safe: open() is still holding a reference. */
2795 module_put(THIS_MODULE); 2795 module_put(THIS_MODULE);
2796 return ret; 2796 return ret;
2797} 2797}
2798 2798
2799static int pkt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) 2799static int pkt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg)
2800{ 2800{
2801 struct pktcdvd_device *pd = inode->i_bdev->bd_disk->private_data; 2801 struct pktcdvd_device *pd = bdev->bd_disk->private_data;
2802 2802
2803 VPRINTK("pkt_ioctl: cmd %x, dev %d:%d\n", cmd, imajor(inode), iminor(inode)); 2803 VPRINTK("pkt_ioctl: cmd %x, dev %d:%d\n", cmd,
2804 MAJOR(bdev->bd_dev), MINOR(bdev->bd_dev));
2804 2805
2805 switch (cmd) { 2806 switch (cmd) {
2807 case CDROMEJECT:
2808 /*
2809 * The door gets locked when the device is opened, so we
2810 * have to unlock it or else the eject command fails.
2811 */
2812 if (pd->refcnt == 1)
2813 pkt_lock_door(pd, 0);
2814 /* fallthru */
2806 /* 2815 /*
2807 * forward selected CDROM ioctls to CD-ROM, for UDF 2816 * forward selected CDROM ioctls to CD-ROM, for UDF
2808 */ 2817 */
@@ -2811,16 +2820,7 @@ static int pkt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u
2811 case CDROM_LAST_WRITTEN: 2820 case CDROM_LAST_WRITTEN:
2812 case CDROM_SEND_PACKET: 2821 case CDROM_SEND_PACKET:
2813 case SCSI_IOCTL_SEND_COMMAND: 2822 case SCSI_IOCTL_SEND_COMMAND:
2814 return blkdev_ioctl(pd->bdev->bd_inode, file, cmd, arg); 2823 return __blkdev_driver_ioctl(pd->bdev, mode, cmd, arg);
2815
2816 case CDROMEJECT:
2817 /*
2818 * The door gets locked when the device is opened, so we
2819 * have to unlock it or else the eject command fails.
2820 */
2821 if (pd->refcnt == 1)
2822 pkt_lock_door(pd, 0);
2823 return blkdev_ioctl(pd->bdev->bd_inode, file, cmd, arg);
2824 2824
2825 default: 2825 default:
2826 VPRINTK(DRIVER_NAME": Unknown ioctl for %s (%x)\n", pd->name, cmd); 2826 VPRINTK(DRIVER_NAME": Unknown ioctl for %s (%x)\n", pd->name, cmd);
@@ -2849,7 +2849,7 @@ static struct block_device_operations pktcdvd_ops = {
2849 .owner = THIS_MODULE, 2849 .owner = THIS_MODULE,
2850 .open = pkt_open, 2850 .open = pkt_open,
2851 .release = pkt_close, 2851 .release = pkt_close,
2852 .ioctl = pkt_ioctl, 2852 .locked_ioctl = pkt_ioctl,
2853 .media_changed = pkt_media_changed, 2853 .media_changed = pkt_media_changed,
2854}; 2854};
2855 2855
@@ -2975,7 +2975,7 @@ static int pkt_remove_dev(dev_t pkt_dev)
2975 pkt_debugfs_dev_remove(pd); 2975 pkt_debugfs_dev_remove(pd);
2976 pkt_sysfs_dev_remove(pd); 2976 pkt_sysfs_dev_remove(pd);
2977 2977
2978 blkdev_put(pd->bdev); 2978 blkdev_put(pd->bdev, FMODE_READ|FMODE_WRITE);
2979 2979
2980 remove_proc_entry(pd->name, pkt_proc); 2980 remove_proc_entry(pd->name, pkt_proc);
2981 DPRINTK(DRIVER_NAME": writer %s unmapped\n", pd->name); 2981 DPRINTK(DRIVER_NAME": writer %s unmapped\n", pd->name);
diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c
index 730ccea78e45..612965307ba0 100644
--- a/drivers/block/swim3.c
+++ b/drivers/block/swim3.c
@@ -244,10 +244,10 @@ static int grab_drive(struct floppy_state *fs, enum swim_state state,
244 int interruptible); 244 int interruptible);
245static void release_drive(struct floppy_state *fs); 245static void release_drive(struct floppy_state *fs);
246static int fd_eject(struct floppy_state *fs); 246static int fd_eject(struct floppy_state *fs);
247static int floppy_ioctl(struct inode *inode, struct file *filp, 247static int floppy_ioctl(struct block_device *bdev, fmode_t mode,
248 unsigned int cmd, unsigned long param); 248 unsigned int cmd, unsigned long param);
249static int floppy_open(struct inode *inode, struct file *filp); 249static int floppy_open(struct block_device *bdev, fmode_t mode);
250static int floppy_release(struct inode *inode, struct file *filp); 250static int floppy_release(struct gendisk *disk, fmode_t mode);
251static int floppy_check_change(struct gendisk *disk); 251static int floppy_check_change(struct gendisk *disk);
252static int floppy_revalidate(struct gendisk *disk); 252static int floppy_revalidate(struct gendisk *disk);
253 253
@@ -839,10 +839,10 @@ static int fd_eject(struct floppy_state *fs)
839static struct floppy_struct floppy_type = 839static struct floppy_struct floppy_type =
840 { 2880,18,2,80,0,0x1B,0x00,0xCF,0x6C,NULL }; /* 7 1.44MB 3.5" */ 840 { 2880,18,2,80,0,0x1B,0x00,0xCF,0x6C,NULL }; /* 7 1.44MB 3.5" */
841 841
842static int floppy_ioctl(struct inode *inode, struct file *filp, 842static int floppy_ioctl(struct block_device *bdev, fmode_t mode,
843 unsigned int cmd, unsigned long param) 843 unsigned int cmd, unsigned long param)
844{ 844{
845 struct floppy_state *fs = inode->i_bdev->bd_disk->private_data; 845 struct floppy_state *fs = bdev->bd_disk->private_data;
846 int err; 846 int err;
847 847
848 if ((cmd & 0x80) && !capable(CAP_SYS_ADMIN)) 848 if ((cmd & 0x80) && !capable(CAP_SYS_ADMIN))
@@ -868,9 +868,9 @@ static int floppy_ioctl(struct inode *inode, struct file *filp,
868 return -ENOTTY; 868 return -ENOTTY;
869} 869}
870 870
871static int floppy_open(struct inode *inode, struct file *filp) 871static int floppy_open(struct block_device *bdev, fmode_t mode)
872{ 872{
873 struct floppy_state *fs = inode->i_bdev->bd_disk->private_data; 873 struct floppy_state *fs = bdev->bd_disk->private_data;
874 struct swim3 __iomem *sw = fs->swim3; 874 struct swim3 __iomem *sw = fs->swim3;
875 int n, err = 0; 875 int n, err = 0;
876 876
@@ -904,17 +904,17 @@ static int floppy_open(struct inode *inode, struct file *filp)
904 swim3_action(fs, SETMFM); 904 swim3_action(fs, SETMFM);
905 swim3_select(fs, RELAX); 905 swim3_select(fs, RELAX);
906 906
907 } else if (fs->ref_count == -1 || filp->f_flags & O_EXCL) 907 } else if (fs->ref_count == -1 || mode & FMODE_EXCL)
908 return -EBUSY; 908 return -EBUSY;
909 909
910 if (err == 0 && (filp->f_flags & O_NDELAY) == 0 910 if (err == 0 && (mode & FMODE_NDELAY) == 0
911 && (filp->f_mode & 3)) { 911 && (mode & (FMODE_READ|FMODE_WRITE))) {
912 check_disk_change(inode->i_bdev); 912 check_disk_change(bdev);
913 if (fs->ejected) 913 if (fs->ejected)
914 err = -ENXIO; 914 err = -ENXIO;
915 } 915 }
916 916
917 if (err == 0 && (filp->f_mode & 2)) { 917 if (err == 0 && (mode & FMODE_WRITE)) {
918 if (fs->write_prot < 0) 918 if (fs->write_prot < 0)
919 fs->write_prot = swim3_readbit(fs, WRITE_PROT); 919 fs->write_prot = swim3_readbit(fs, WRITE_PROT);
920 if (fs->write_prot) 920 if (fs->write_prot)
@@ -930,7 +930,7 @@ static int floppy_open(struct inode *inode, struct file *filp)
930 return err; 930 return err;
931 } 931 }
932 932
933 if (filp->f_flags & O_EXCL) 933 if (mode & FMODE_EXCL)
934 fs->ref_count = -1; 934 fs->ref_count = -1;
935 else 935 else
936 ++fs->ref_count; 936 ++fs->ref_count;
@@ -938,9 +938,9 @@ static int floppy_open(struct inode *inode, struct file *filp)
938 return 0; 938 return 0;
939} 939}
940 940
941static int floppy_release(struct inode *inode, struct file *filp) 941static int floppy_release(struct gendisk *disk, fmode_t mode)
942{ 942{
943 struct floppy_state *fs = inode->i_bdev->bd_disk->private_data; 943 struct floppy_state *fs = disk->private_data;
944 struct swim3 __iomem *sw = fs->swim3; 944 struct swim3 __iomem *sw = fs->swim3;
945 if (fs->ref_count > 0 && --fs->ref_count == 0) { 945 if (fs->ref_count > 0 && --fs->ref_count == 0) {
946 swim3_action(fs, MOTOR_OFF); 946 swim3_action(fs, MOTOR_OFF);
@@ -1000,7 +1000,7 @@ static int floppy_revalidate(struct gendisk *disk)
1000static struct block_device_operations floppy_fops = { 1000static struct block_device_operations floppy_fops = {
1001 .open = floppy_open, 1001 .open = floppy_open,
1002 .release = floppy_release, 1002 .release = floppy_release,
1003 .ioctl = floppy_ioctl, 1003 .locked_ioctl = floppy_ioctl,
1004 .media_changed = floppy_check_change, 1004 .media_changed = floppy_check_change,
1005 .revalidate_disk= floppy_revalidate, 1005 .revalidate_disk= floppy_revalidate,
1006}; 1006};
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index f60e41833f69..fccac18d3111 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -1667,10 +1667,9 @@ static void ub_revalidate(struct ub_dev *sc, struct ub_lun *lun)
1667 * This is mostly needed to keep refcounting, but also to support 1667 * This is mostly needed to keep refcounting, but also to support
1668 * media checks on removable media drives. 1668 * media checks on removable media drives.
1669 */ 1669 */
1670static int ub_bd_open(struct inode *inode, struct file *filp) 1670static int ub_bd_open(struct block_device *bdev, fmode_t mode)
1671{ 1671{
1672 struct gendisk *disk = inode->i_bdev->bd_disk; 1672 struct ub_lun *lun = bdev->bd_disk->private_data;
1673 struct ub_lun *lun = disk->private_data;
1674 struct ub_dev *sc = lun->udev; 1673 struct ub_dev *sc = lun->udev;
1675 unsigned long flags; 1674 unsigned long flags;
1676 int rc; 1675 int rc;
@@ -1684,19 +1683,19 @@ static int ub_bd_open(struct inode *inode, struct file *filp)
1684 spin_unlock_irqrestore(&ub_lock, flags); 1683 spin_unlock_irqrestore(&ub_lock, flags);
1685 1684
1686 if (lun->removable || lun->readonly) 1685 if (lun->removable || lun->readonly)
1687 check_disk_change(inode->i_bdev); 1686 check_disk_change(bdev);
1688 1687
1689 /* 1688 /*
1690 * The sd.c considers ->media_present and ->changed not equivalent, 1689 * The sd.c considers ->media_present and ->changed not equivalent,
1691 * under some pretty murky conditions (a failure of READ CAPACITY). 1690 * under some pretty murky conditions (a failure of READ CAPACITY).
1692 * We may need it one day. 1691 * We may need it one day.
1693 */ 1692 */
1694 if (lun->removable && lun->changed && !(filp->f_flags & O_NDELAY)) { 1693 if (lun->removable && lun->changed && !(mode & FMODE_NDELAY)) {
1695 rc = -ENOMEDIUM; 1694 rc = -ENOMEDIUM;
1696 goto err_open; 1695 goto err_open;
1697 } 1696 }
1698 1697
1699 if (lun->readonly && (filp->f_mode & FMODE_WRITE)) { 1698 if (lun->readonly && (mode & FMODE_WRITE)) {
1700 rc = -EROFS; 1699 rc = -EROFS;
1701 goto err_open; 1700 goto err_open;
1702 } 1701 }
@@ -1710,9 +1709,8 @@ err_open:
1710 1709
1711/* 1710/*
1712 */ 1711 */
1713static int ub_bd_release(struct inode *inode, struct file *filp) 1712static int ub_bd_release(struct gendisk *disk, fmode_t mode)
1714{ 1713{
1715 struct gendisk *disk = inode->i_bdev->bd_disk;
1716 struct ub_lun *lun = disk->private_data; 1714 struct ub_lun *lun = disk->private_data;
1717 struct ub_dev *sc = lun->udev; 1715 struct ub_dev *sc = lun->udev;
1718 1716
@@ -1723,13 +1721,13 @@ static int ub_bd_release(struct inode *inode, struct file *filp)
1723/* 1721/*
1724 * The ioctl interface. 1722 * The ioctl interface.
1725 */ 1723 */
1726static int ub_bd_ioctl(struct inode *inode, struct file *filp, 1724static int ub_bd_ioctl(struct block_device *bdev, fmode_t mode,
1727 unsigned int cmd, unsigned long arg) 1725 unsigned int cmd, unsigned long arg)
1728{ 1726{
1729 struct gendisk *disk = inode->i_bdev->bd_disk; 1727 struct gendisk *disk = bdev->bd_disk;
1730 void __user *usermem = (void __user *) arg; 1728 void __user *usermem = (void __user *) arg;
1731 1729
1732 return scsi_cmd_ioctl(filp, disk->queue, disk, cmd, usermem); 1730 return scsi_cmd_ioctl(disk->queue, disk, mode, cmd, usermem);
1733} 1731}
1734 1732
1735/* 1733/*
@@ -1793,7 +1791,7 @@ static struct block_device_operations ub_bd_fops = {
1793 .owner = THIS_MODULE, 1791 .owner = THIS_MODULE,
1794 .open = ub_bd_open, 1792 .open = ub_bd_open,
1795 .release = ub_bd_release, 1793 .release = ub_bd_release,
1796 .ioctl = ub_bd_ioctl, 1794 .locked_ioctl = ub_bd_ioctl,
1797 .media_changed = ub_bd_media_changed, 1795 .media_changed = ub_bd_media_changed,
1798 .revalidate_disk = ub_bd_revalidate, 1796 .revalidate_disk = ub_bd_revalidate,
1799}; 1797};
diff --git a/drivers/block/viodasd.c b/drivers/block/viodasd.c
index 1730d29e6044..ecccf65dce2f 100644
--- a/drivers/block/viodasd.c
+++ b/drivers/block/viodasd.c
@@ -130,15 +130,15 @@ struct viodasd_device {
130/* 130/*
131 * External open entry point. 131 * External open entry point.
132 */ 132 */
133static int viodasd_open(struct inode *ino, struct file *fil) 133static int viodasd_open(struct block_device *bdev, fmode_t mode)
134{ 134{
135 struct viodasd_device *d = ino->i_bdev->bd_disk->private_data; 135 struct viodasd_device *d = bdev->bd_disk->private_data;
136 HvLpEvent_Rc hvrc; 136 HvLpEvent_Rc hvrc;
137 struct viodasd_waitevent we; 137 struct viodasd_waitevent we;
138 u16 flags = 0; 138 u16 flags = 0;
139 139
140 if (d->read_only) { 140 if (d->read_only) {
141 if ((fil != NULL) && (fil->f_mode & FMODE_WRITE)) 141 if (mode & FMODE_WRITE)
142 return -EROFS; 142 return -EROFS;
143 flags = vioblockflags_ro; 143 flags = vioblockflags_ro;
144 } 144 }
@@ -179,9 +179,9 @@ static int viodasd_open(struct inode *ino, struct file *fil)
179/* 179/*
180 * External release entry point. 180 * External release entry point.
181 */ 181 */
182static int viodasd_release(struct inode *ino, struct file *fil) 182static int viodasd_release(struct gendisk *disk, fmode_t mode)
183{ 183{
184 struct viodasd_device *d = ino->i_bdev->bd_disk->private_data; 184 struct viodasd_device *d = disk->private_data;
185 HvLpEvent_Rc hvrc; 185 HvLpEvent_Rc hvrc;
186 186
187 /* Send the event to OS/400. We DON'T expect a response */ 187 /* Send the event to OS/400. We DON'T expect a response */
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 6ec5fc052786..85d79a02d487 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -146,11 +146,11 @@ static void do_virtblk_request(struct request_queue *q)
146 vblk->vq->vq_ops->kick(vblk->vq); 146 vblk->vq->vq_ops->kick(vblk->vq);
147} 147}
148 148
149static int virtblk_ioctl(struct inode *inode, struct file *filp, 149static int virtblk_ioctl(struct block_device *bdev, fmode_t mode,
150 unsigned cmd, unsigned long data) 150 unsigned cmd, unsigned long data)
151{ 151{
152 return scsi_cmd_ioctl(filp, inode->i_bdev->bd_disk->queue, 152 return scsi_cmd_ioctl(bdev->bd_disk->queue,
153 inode->i_bdev->bd_disk, cmd, 153 bdev->bd_disk, mode, cmd,
154 (void __user *)data); 154 (void __user *)data);
155} 155}
156 156
@@ -180,7 +180,7 @@ static int virtblk_getgeo(struct block_device *bd, struct hd_geometry *geo)
180} 180}
181 181
182static struct block_device_operations virtblk_fops = { 182static struct block_device_operations virtblk_fops = {
183 .ioctl = virtblk_ioctl, 183 .locked_ioctl = virtblk_ioctl,
184 .owner = THIS_MODULE, 184 .owner = THIS_MODULE,
185 .getgeo = virtblk_getgeo, 185 .getgeo = virtblk_getgeo,
186}; 186};
diff --git a/drivers/block/xd.c b/drivers/block/xd.c
index 624d30f7da3f..64b496fce98b 100644
--- a/drivers/block/xd.c
+++ b/drivers/block/xd.c
@@ -132,7 +132,7 @@ static int xd_getgeo(struct block_device *bdev, struct hd_geometry *geo);
132 132
133static struct block_device_operations xd_fops = { 133static struct block_device_operations xd_fops = {
134 .owner = THIS_MODULE, 134 .owner = THIS_MODULE,
135 .ioctl = xd_ioctl, 135 .locked_ioctl = xd_ioctl,
136 .getgeo = xd_getgeo, 136 .getgeo = xd_getgeo,
137}; 137};
138static DECLARE_WAIT_QUEUE_HEAD(xd_wait_int); 138static DECLARE_WAIT_QUEUE_HEAD(xd_wait_int);
@@ -343,7 +343,7 @@ static int xd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
343} 343}
344 344
345/* xd_ioctl: handle device ioctl's */ 345/* xd_ioctl: handle device ioctl's */
346static int xd_ioctl (struct inode *inode,struct file *file,u_int cmd,u_long arg) 346static int xd_ioctl(struct block_device *bdev, fmode_t mode, u_int cmd, u_long arg)
347{ 347{
348 switch (cmd) { 348 switch (cmd) {
349 case HDIO_SET_DMA: 349 case HDIO_SET_DMA:
diff --git a/drivers/block/xd.h b/drivers/block/xd.h
index cffd44a20383..37cacef16e93 100644
--- a/drivers/block/xd.h
+++ b/drivers/block/xd.h
@@ -105,7 +105,7 @@ static u_char xd_detect (u_char *controller, unsigned int *address);
105static u_char xd_initdrives (void (*init_drive)(u_char drive)); 105static u_char xd_initdrives (void (*init_drive)(u_char drive));
106 106
107static void do_xd_request (struct request_queue * q); 107static void do_xd_request (struct request_queue * q);
108static int xd_ioctl (struct inode *inode,struct file *file,unsigned int cmd,unsigned long arg); 108static int xd_ioctl (struct block_device *bdev,fmode_t mode,unsigned int cmd,unsigned long arg);
109static int xd_readwrite (u_char operation,XD_INFO *disk,char *buffer,u_int block,u_int count); 109static int xd_readwrite (u_char operation,XD_INFO *disk,char *buffer,u_int block,u_int count);
110static void xd_recalibrate (u_char drive); 110static void xd_recalibrate (u_char drive);
111 111
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 1a50ae70f716..b220c686089d 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -156,11 +156,10 @@ static int blkif_getgeo(struct block_device *bd, struct hd_geometry *hg)
156 return 0; 156 return 0;
157} 157}
158 158
159static int blkif_ioctl(struct inode *inode, struct file *filep, 159static int blkif_ioctl(struct block_device *bdev, fmode_t mode,
160 unsigned command, unsigned long argument) 160 unsigned command, unsigned long argument)
161{ 161{
162 struct blkfront_info *info = 162 struct blkfront_info *info = bdev->bd_disk->private_data;
163 inode->i_bdev->bd_disk->private_data;
164 int i; 163 int i;
165 164
166 dev_dbg(&info->xbdev->dev, "command: 0x%x, argument: 0x%lx\n", 165 dev_dbg(&info->xbdev->dev, "command: 0x%x, argument: 0x%lx\n",
@@ -1014,16 +1013,16 @@ static int blkfront_is_ready(struct xenbus_device *dev)
1014 return info->is_ready; 1013 return info->is_ready;
1015} 1014}
1016 1015
1017static int blkif_open(struct inode *inode, struct file *filep) 1016static int blkif_open(struct block_device *bdev, fmode_t mode)
1018{ 1017{
1019 struct blkfront_info *info = inode->i_bdev->bd_disk->private_data; 1018 struct blkfront_info *info = bdev->bd_disk->private_data;
1020 info->users++; 1019 info->users++;
1021 return 0; 1020 return 0;
1022} 1021}
1023 1022
1024static int blkif_release(struct inode *inode, struct file *filep) 1023static int blkif_release(struct gendisk *disk, fmode_t mode)
1025{ 1024{
1026 struct blkfront_info *info = inode->i_bdev->bd_disk->private_data; 1025 struct blkfront_info *info = disk->private_data;
1027 info->users--; 1026 info->users--;
1028 if (info->users == 0) { 1027 if (info->users == 0) {
1029 /* Check whether we have been instructed to close. We will 1028 /* Check whether we have been instructed to close. We will
@@ -1044,7 +1043,7 @@ static struct block_device_operations xlvbd_block_fops =
1044 .open = blkif_open, 1043 .open = blkif_open,
1045 .release = blkif_release, 1044 .release = blkif_release,
1046 .getgeo = blkif_getgeo, 1045 .getgeo = blkif_getgeo,
1047 .ioctl = blkif_ioctl, 1046 .locked_ioctl = blkif_ioctl,
1048}; 1047};
1049 1048
1050 1049
diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c
index 4a7a059ebaf7..ecab9e67d47a 100644
--- a/drivers/block/xsysace.c
+++ b/drivers/block/xsysace.c
@@ -870,25 +870,24 @@ static int ace_revalidate_disk(struct gendisk *gd)
870 return ace->id_result; 870 return ace->id_result;
871} 871}
872 872
873static int ace_open(struct inode *inode, struct file *filp) 873static int ace_open(struct block_device *bdev, fmode_t mode)
874{ 874{
875 struct ace_device *ace = inode->i_bdev->bd_disk->private_data; 875 struct ace_device *ace = bdev->bd_disk->private_data;
876 unsigned long flags; 876 unsigned long flags;
877 877
878 dev_dbg(ace->dev, "ace_open() users=%i\n", ace->users + 1); 878 dev_dbg(ace->dev, "ace_open() users=%i\n", ace->users + 1);
879 879
880 filp->private_data = ace;
881 spin_lock_irqsave(&ace->lock, flags); 880 spin_lock_irqsave(&ace->lock, flags);
882 ace->users++; 881 ace->users++;
883 spin_unlock_irqrestore(&ace->lock, flags); 882 spin_unlock_irqrestore(&ace->lock, flags);
884 883
885 check_disk_change(inode->i_bdev); 884 check_disk_change(bdev);
886 return 0; 885 return 0;
887} 886}
888 887
889static int ace_release(struct inode *inode, struct file *filp) 888static int ace_release(struct gendisk *disk, fmode_t mode)
890{ 889{
891 struct ace_device *ace = inode->i_bdev->bd_disk->private_data; 890 struct ace_device *ace = disk->private_data;
892 unsigned long flags; 891 unsigned long flags;
893 u16 val; 892 u16 val;
894 893
diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c
index be20a67f1fa8..80754cdd3119 100644
--- a/drivers/block/z2ram.c
+++ b/drivers/block/z2ram.c
@@ -137,8 +137,7 @@ get_chipram( void )
137 return; 137 return;
138} 138}
139 139
140static int 140static int z2_open(struct block_device *bdev, fmode_t mode)
141z2_open( struct inode *inode, struct file *filp )
142{ 141{
143 int device; 142 int device;
144 int max_z2_map = ( Z2RAM_SIZE / Z2RAM_CHUNKSIZE ) * 143 int max_z2_map = ( Z2RAM_SIZE / Z2RAM_CHUNKSIZE ) *
@@ -147,7 +146,7 @@ z2_open( struct inode *inode, struct file *filp )
147 sizeof( z2ram_map[0] ); 146 sizeof( z2ram_map[0] );
148 int rc = -ENOMEM; 147 int rc = -ENOMEM;
149 148
150 device = iminor(inode); 149 device = MINOR(bdev->bd_dev);
151 150
152 if ( current_device != -1 && current_device != device ) 151 if ( current_device != -1 && current_device != device )
153 { 152 {
@@ -299,7 +298,7 @@ err_out:
299} 298}
300 299
301static int 300static int
302z2_release( struct inode *inode, struct file *filp ) 301z2_release(struct gendisk *disk, fmode_t mode)
303{ 302{
304 if ( current_device == -1 ) 303 if ( current_device == -1 )
305 return 0; 304 return 0;