diff options
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/DAC960.c | 6 | ||||
-rw-r--r-- | drivers/block/amiflop.c | 46 | ||||
-rw-r--r-- | drivers/block/aoe/aoeblk.c | 14 | ||||
-rw-r--r-- | drivers/block/ataflop.c | 37 | ||||
-rw-r--r-- | drivers/block/brd.c | 5 | ||||
-rw-r--r-- | drivers/block/cciss.c | 71 | ||||
-rw-r--r-- | drivers/block/cpqarray.c | 28 | ||||
-rw-r--r-- | drivers/block/floppy.c | 54 | ||||
-rw-r--r-- | drivers/block/loop.c | 59 | ||||
-rw-r--r-- | drivers/block/nbd.c | 30 | ||||
-rw-r--r-- | drivers/block/paride/pcd.c | 21 | ||||
-rw-r--r-- | drivers/block/paride/pd.c | 14 | ||||
-rw-r--r-- | drivers/block/paride/pf.c | 22 | ||||
-rw-r--r-- | drivers/block/paride/pt.c | 2 | ||||
-rw-r--r-- | drivers/block/pktcdvd.c | 56 | ||||
-rw-r--r-- | drivers/block/swim3.c | 32 | ||||
-rw-r--r-- | drivers/block/ub.c | 22 | ||||
-rw-r--r-- | drivers/block/viodasd.c | 10 | ||||
-rw-r--r-- | drivers/block/virtio_blk.c | 8 | ||||
-rw-r--r-- | drivers/block/xd.c | 4 | ||||
-rw-r--r-- | drivers/block/xd.h | 2 | ||||
-rw-r--r-- | drivers/block/xen-blkfront.c | 15 | ||||
-rw-r--r-- | drivers/block/xsysace.c | 11 | ||||
-rw-r--r-- | drivers/block/z2ram.c | 7 |
24 files changed, 282 insertions, 294 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) } } -static int DAC960_open(struct inode *inode, struct file *file) +static int DAC960_open(struct block_device *bdev, fmode_t mode) { - struct gendisk *disk = inode->i_bdev->bd_disk; + struct gendisk *disk = bdev->bd_disk; DAC960_Controller_T *p = disk->queue->queuedata; int drive_nr = (long)disk->private_data; @@ -89,7 +89,7 @@ static int DAC960_open(struct inode *inode, struct file *file) return -ENXIO; } - check_disk_change(inode->i_bdev); + check_disk_change(bdev); if (!get_capacity(p->disks[drive_nr])) 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) return 0; } -static int fd_ioctl(struct inode *inode, struct file *filp, +static int fd_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long param) { - int drive = iminor(inode) & 3; + struct amiga_floppy_struct *p = bdev->bd_disk->private_data; + int drive = p - unit; static struct floppy_struct getprm; void __user *argp = (void __user *)param; @@ -1451,7 +1452,7 @@ static int fd_ioctl(struct inode *inode, struct file *filp, rel_fdc(); return -EBUSY; } - fsync_bdev(inode->i_bdev); + fsync_bdev(bdev); if (fd_motor_on(drive) == 0) { rel_fdc(); return -ENODEV; @@ -1464,12 +1465,12 @@ static int fd_ioctl(struct inode *inode, struct file *filp, rel_fdc(); break; case FDFMTTRK: - if (param < unit[drive].type->tracks * unit[drive].type->heads) + if (param < p->type->tracks * p->type->heads) { get_fdc(drive); if (fd_seek(drive,param) != 0){ - memset(unit[drive].trackbuf, FD_FILL_BYTE, - unit[drive].dtype->sects * unit[drive].type->sect_mult * 512); + memset(p->trackbuf, FD_FILL_BYTE, + p->dtype->sects * p->type->sect_mult * 512); non_int_flush_track(drive); } floppy_off(drive); @@ -1480,14 +1481,14 @@ static int fd_ioctl(struct inode *inode, struct file *filp, break; case FDFMTEND: floppy_off(drive); - invalidate_bdev(inode->i_bdev); + invalidate_bdev(bdev); break; case FDGETPRM: memset((void *)&getprm, 0, sizeof (getprm)); - getprm.track=unit[drive].type->tracks; - getprm.head=unit[drive].type->heads; - getprm.sect=unit[drive].dtype->sects * unit[drive].type->sect_mult; - getprm.size=unit[drive].blocks; + getprm.track=p->type->tracks; + getprm.head=p->type->heads; + getprm.sect=p->dtype->sects * p->type->sect_mult; + getprm.size=p->blocks; if (copy_to_user(argp, &getprm, sizeof(struct floppy_struct))) return -EFAULT; break; @@ -1500,10 +1501,10 @@ static int fd_ioctl(struct inode *inode, struct file *filp, break; #ifdef RAW_IOCTL case IOCTL_RAW_TRACK: - if (copy_to_user(argp, raw_buf, unit[drive].type->read_size)) + if (copy_to_user(argp, raw_buf, p->type->read_size)) return -EFAULT; else - return unit[drive].type->read_size; + return p->type->read_size; #endif default: printk(KERN_DEBUG "fd_ioctl: unknown cmd %d for drive %d.", @@ -1548,10 +1549,10 @@ static void fd_probe(int dev) * /dev/PS0 etc), and disallows simultaneous access to the same * drive with different device numbers. */ -static int floppy_open(struct inode *inode, struct file *filp) +static int floppy_open(struct block_device *bdev, fmode_t mode) { - int drive = iminor(inode) & 3; - int system = (iminor(inode) & 4) >> 2; + int drive = MINOR(bdev->bd_dev) & 3; + int system = (MINOR(bdev->bd_dev) & 4) >> 2; int old_dev; unsigned long flags; @@ -1560,9 +1561,9 @@ static int floppy_open(struct inode *inode, struct file *filp) if (fd_ref[drive] && old_dev != system) return -EBUSY; - if (filp && filp->f_mode & 3) { - check_disk_change(inode->i_bdev); - if (filp->f_mode & 2 ) { + if (mode & (FMODE_READ|FMODE_WRITE)) { + check_disk_change(bdev); + if (mode & FMODE_WRITE) { int wrprot; get_fdc(drive); @@ -1592,9 +1593,10 @@ static int floppy_open(struct inode *inode, struct file *filp) return 0; } -static int floppy_release(struct inode * inode, struct file * filp) +static int floppy_release(struct gendisk *disk, fmode_t mode) { - int drive = iminor(inode) & 3; + struct amiga_floppy_struct *p = disk->private_data; + int drive = p - unit; if (unit[drive].dirty == 1) { del_timer (flush_track_timer + drive); @@ -1650,7 +1652,7 @@ static struct block_device_operations floppy_fops = { .owner = THIS_MODULE, .open = floppy_open, .release = floppy_release, - .ioctl = fd_ioctl, + .locked_ioctl = fd_ioctl, .getgeo = fd_getgeo, .media_changed = amiga_floppy_change, }; diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c index b82654e883a7..1747dd272cd4 100644 --- a/drivers/block/aoe/aoeblk.c +++ b/drivers/block/aoe/aoeblk.c @@ -90,7 +90,7 @@ static DEVICE_ATTR(state, S_IRUGO, aoedisk_show_state, NULL); static DEVICE_ATTR(mac, S_IRUGO, aoedisk_show_mac, NULL); static DEVICE_ATTR(netif, S_IRUGO, aoedisk_show_netif, NULL); static struct device_attribute dev_attr_firmware_version = { - .attr = { .name = "firmware-version", .mode = S_IRUGO, .owner = THIS_MODULE }, + .attr = { .name = "firmware-version", .mode = S_IRUGO }, .show = aoedisk_show_fwver, }; @@ -118,13 +118,11 @@ aoedisk_rm_sysfs(struct aoedev *d) } static int -aoeblk_open(struct inode *inode, struct file *filp) +aoeblk_open(struct block_device *bdev, fmode_t mode) { - struct aoedev *d; + struct aoedev *d = bdev->bd_disk->private_data; ulong flags; - d = inode->i_bdev->bd_disk->private_data; - spin_lock_irqsave(&d->lock, flags); if (d->flags & DEVFL_UP) { d->nopen++; @@ -136,13 +134,11 @@ aoeblk_open(struct inode *inode, struct file *filp) } static int -aoeblk_release(struct inode *inode, struct file *filp) +aoeblk_release(struct gendisk *disk, fmode_t mode) { - struct aoedev *d; + struct aoedev *d = disk->private_data; ulong flags; - d = inode->i_bdev->bd_disk->private_data; - spin_lock_irqsave(&d->lock, flags); 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 ); static void finish_fdc_done( int dummy ); static void setup_req_params( int drive ); static void redo_fd_request( void); -static int fd_ioctl( struct inode *inode, struct file *filp, unsigned int +static int fd_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long param); static void fd_probe( int drive ); static int fd_test_drive_present( int drive ); static void config_types( void ); -static int floppy_open( struct inode *inode, struct file *filp ); -static int floppy_release( struct inode * inode, struct file * filp ); +static int floppy_open(struct block_device *bdev, fmode_t mode); +static int floppy_release(struct gendisk *disk, fmode_t mode); /************************* End of Prototypes **************************/ @@ -1483,10 +1483,10 @@ void do_fd_request(struct request_queue * q) atari_enable_irq( IRQ_MFP_FDC ); } -static int fd_ioctl(struct inode *inode, struct file *filp, +static int fd_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long param) { - struct gendisk *disk = inode->i_bdev->bd_disk; + struct gendisk *disk = bdev->bd_disk; struct atari_floppy_struct *floppy = disk->private_data; int drive = floppy - unit; int type = floppy->type; @@ -1661,7 +1661,7 @@ static int fd_ioctl(struct inode *inode, struct file *filp, /* invalidate the buffer track to force a reread */ BufferDrive = -1; set_bit(drive, &fake_change); - check_disk_change(inode->i_bdev); + check_disk_change(bdev); return 0; default: return -EINVAL; @@ -1804,37 +1804,36 @@ static void __init config_types( void ) * drive with different device numbers. */ -static int floppy_open( struct inode *inode, struct file *filp ) +static int floppy_open(struct block_device *bdev, fmode_t mode) { - struct atari_floppy_struct *p = inode->i_bdev->bd_disk->private_data; - int type = iminor(inode) >> 2; + struct atari_floppy_struct *p = bdev->bd_disk->private_data; + int type = MINOR(bdev->bd_dev) >> 2; DPRINT(("fd_open: type=%d\n",type)); if (p->ref && p->type != type) return -EBUSY; - if (p->ref == -1 || (p->ref && filp->f_flags & O_EXCL)) + if (p->ref == -1 || (p->ref && mode & FMODE_EXCL)) return -EBUSY; - if (filp->f_flags & O_EXCL) + if (mode & FMODE_EXCL) p->ref = -1; else p->ref++; p->type = type; - if (filp->f_flags & O_NDELAY) + if (mode & FMODE_NDELAY) return 0; - if (filp->f_mode & 3) { - check_disk_change(inode->i_bdev); - if (filp->f_mode & 2) { + if (mode & (FMODE_READ|FMODE_WRITE)) { + check_disk_change(bdev); + if (mode & FMODE_WRITE) { if (p->wpstat) { if (p->ref < 0) p->ref = 0; else p->ref--; - floppy_release(inode, filp); return -EROFS; } } @@ -1843,9 +1842,9 @@ static int floppy_open( struct inode *inode, struct file *filp ) } -static int floppy_release( struct inode * inode, struct file * filp ) +static int floppy_release(struct gendisk *disk, fmode_t mode) { - struct atari_floppy_struct *p = inode->i_bdev->bd_disk->private_data; + struct atari_floppy_struct *p = disk->private_data; if (p->ref < 0) p->ref = 0; else if (!p->ref--) { @@ -1859,7 +1858,7 @@ static struct block_device_operations floppy_fops = { .owner = THIS_MODULE, .open = floppy_open, .release = floppy_release, - .ioctl = fd_ioctl, + .locked_ioctl = fd_ioctl, .media_changed = check_floppy_change, .revalidate_disk= floppy_revalidate, }; 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, } #endif -static int brd_ioctl(struct inode *inode, struct file *file, +static int brd_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) { int error; - struct block_device *bdev = inode->i_bdev; struct brd_device *brd = bdev->bd_disk->private_data; if (cmd != BLKFLSBUF) @@ -376,7 +375,7 @@ static int brd_ioctl(struct inode *inode, struct file *file, static struct block_device_operations brd_fops = { .owner = THIS_MODULE, - .ioctl = brd_ioctl, + .locked_ioctl = brd_ioctl, #ifdef CONFIG_BLK_DEV_XIP .direct_access = brd_direct_access, #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]; static void do_cciss_request(struct request_queue *q); static irqreturn_t do_cciss_intr(int irq, void *dev_id); -static int cciss_open(struct inode *inode, struct file *filep); -static int cciss_release(struct inode *inode, struct file *filep); -static int cciss_ioctl(struct inode *inode, struct file *filep, +static int cciss_open(struct block_device *bdev, fmode_t mode); +static int cciss_release(struct gendisk *disk, fmode_t mode); +static int cciss_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg); static int cciss_getgeo(struct block_device *bdev, struct hd_geometry *geo); @@ -192,14 +192,15 @@ static void cciss_procinit(int i) #endif /* CONFIG_PROC_FS */ #ifdef CONFIG_COMPAT -static long cciss_compat_ioctl(struct file *f, unsigned cmd, unsigned long arg); +static int cciss_compat_ioctl(struct block_device *, fmode_t, + unsigned, unsigned long); #endif static struct block_device_operations cciss_fops = { .owner = THIS_MODULE, .open = cciss_open, .release = cciss_release, - .ioctl = cciss_ioctl, + .locked_ioctl = cciss_ioctl, .getgeo = cciss_getgeo, #ifdef CONFIG_COMPAT .compat_ioctl = cciss_compat_ioctl, @@ -547,13 +548,13 @@ static inline drive_info_struct *get_drv(struct gendisk *disk) /* * Open. Make sure the device is really there. */ -static int cciss_open(struct inode *inode, struct file *filep) +static int cciss_open(struct block_device *bdev, fmode_t mode) { - ctlr_info_t *host = get_host(inode->i_bdev->bd_disk); - drive_info_struct *drv = get_drv(inode->i_bdev->bd_disk); + ctlr_info_t *host = get_host(bdev->bd_disk); + drive_info_struct *drv = get_drv(bdev->bd_disk); #ifdef CCISS_DEBUG - printk(KERN_DEBUG "cciss_open %s\n", inode->i_bdev->bd_disk->disk_name); + printk(KERN_DEBUG "cciss_open %s\n", bdev->bd_disk->disk_name); #endif /* CCISS_DEBUG */ if (host->busy_initializing || drv->busy_configuring) @@ -567,9 +568,9 @@ static int cciss_open(struct inode *inode, struct file *filep) * for "raw controller". */ if (drv->heads == 0) { - if (iminor(inode) != 0) { /* not node 0? */ + if (MINOR(bdev->bd_dev) != 0) { /* not node 0? */ /* if not node 0 make sure it is a partition = 0 */ - if (iminor(inode) & 0x0f) { + if (MINOR(bdev->bd_dev) & 0x0f) { return -ENXIO; /* if it is, make sure we have a LUN ID */ } else if (drv->LunID == 0) { @@ -587,14 +588,13 @@ static int cciss_open(struct inode *inode, struct file *filep) /* * Close. Sync first. */ -static int cciss_release(struct inode *inode, struct file *filep) +static int cciss_release(struct gendisk *disk, fmode_t mode) { - ctlr_info_t *host = get_host(inode->i_bdev->bd_disk); - drive_info_struct *drv = get_drv(inode->i_bdev->bd_disk); + ctlr_info_t *host = get_host(disk); + drive_info_struct *drv = get_drv(disk); #ifdef CCISS_DEBUG - printk(KERN_DEBUG "cciss_release %s\n", - inode->i_bdev->bd_disk->disk_name); + printk(KERN_DEBUG "cciss_release %s\n", disk->disk_name); #endif /* CCISS_DEBUG */ drv->usage_count--; @@ -604,21 +604,23 @@ static int cciss_release(struct inode *inode, struct file *filep) #ifdef CONFIG_COMPAT -static int do_ioctl(struct file *f, unsigned cmd, unsigned long arg) +static int do_ioctl(struct block_device *bdev, fmode_t mode, + unsigned cmd, unsigned long arg) { int ret; lock_kernel(); - ret = cciss_ioctl(f->f_path.dentry->d_inode, f, cmd, arg); + ret = cciss_ioctl(bdev, mode, cmd, arg); unlock_kernel(); return ret; } -static int cciss_ioctl32_passthru(struct file *f, unsigned cmd, - unsigned long arg); -static int cciss_ioctl32_big_passthru(struct file *f, unsigned cmd, - unsigned long arg); +static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode, + unsigned cmd, unsigned long arg); +static int cciss_ioctl32_big_passthru(struct block_device *bdev, fmode_t mode, + unsigned cmd, unsigned long arg); -static long cciss_compat_ioctl(struct file *f, unsigned cmd, unsigned long arg) +static int cciss_compat_ioctl(struct block_device *bdev, fmode_t mode, + unsigned cmd, unsigned long arg) { switch (cmd) { case CCISS_GETPCIINFO: @@ -636,20 +638,20 @@ static long cciss_compat_ioctl(struct file *f, unsigned cmd, unsigned long arg) case CCISS_REGNEWD: case CCISS_RESCANDISK: case CCISS_GETLUNINFO: - return do_ioctl(f, cmd, arg); + return do_ioctl(bdev, mode, cmd, arg); case CCISS_PASSTHRU32: - return cciss_ioctl32_passthru(f, cmd, arg); + return cciss_ioctl32_passthru(bdev, mode, cmd, arg); case CCISS_BIG_PASSTHRU32: - return cciss_ioctl32_big_passthru(f, cmd, arg); + return cciss_ioctl32_big_passthru(bdev, mode, cmd, arg); default: return -ENOIOCTLCMD; } } -static int cciss_ioctl32_passthru(struct file *f, unsigned cmd, - unsigned long arg) +static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode, + unsigned cmd, unsigned long arg) { IOCTL32_Command_struct __user *arg32 = (IOCTL32_Command_struct __user *) arg; @@ -676,7 +678,7 @@ static int cciss_ioctl32_passthru(struct file *f, unsigned cmd, if (err) return -EFAULT; - err = do_ioctl(f, CCISS_PASSTHRU, (unsigned long)p); + err = do_ioctl(bdev, mode, CCISS_PASSTHRU, (unsigned long)p); if (err) return err; err |= @@ -687,8 +689,8 @@ static int cciss_ioctl32_passthru(struct file *f, unsigned cmd, return err; } -static int cciss_ioctl32_big_passthru(struct file *file, unsigned cmd, - unsigned long arg) +static int cciss_ioctl32_big_passthru(struct block_device *bdev, fmode_t mode, + unsigned cmd, unsigned long arg) { BIG_IOCTL32_Command_struct __user *arg32 = (BIG_IOCTL32_Command_struct __user *) arg; @@ -717,7 +719,7 @@ static int cciss_ioctl32_big_passthru(struct file *file, unsigned cmd, if (err) return -EFAULT; - err = do_ioctl(file, CCISS_BIG_PASSTHRU, (unsigned long)p); + err = do_ioctl(bdev, mode, CCISS_BIG_PASSTHRU, (unsigned long)p); if (err) return err; err |= @@ -745,10 +747,9 @@ static int cciss_getgeo(struct block_device *bdev, struct hd_geometry *geo) /* * ioctl */ -static int cciss_ioctl(struct inode *inode, struct file *filep, +static int cciss_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) { - struct block_device *bdev = inode->i_bdev; struct gendisk *disk = bdev->bd_disk; ctlr_info_t *host = get_host(disk); drive_info_struct *drv = get_drv(disk); @@ -1232,7 +1233,7 @@ static int cciss_ioctl(struct inode *inode, struct file *filep, case SG_EMULATED_HOST: case SG_IO: case SCSI_IOCTL_SEND_COMMAND: - return scsi_cmd_ioctl(filep, disk->queue, disk, cmd, argp); + return scsi_cmd_ioctl(disk->queue, disk, mode, cmd, argp); /* scsi_cmd_ioctl would normally handle these, below, but */ /* 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( unsigned int blkcnt, unsigned int log_unit ); -static int ida_open(struct inode *inode, struct file *filep); -static int ida_release(struct inode *inode, struct file *filep); -static int ida_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, unsigned long arg); +static int ida_open(struct block_device *bdev, fmode_t mode); +static int ida_release(struct gendisk *disk, fmode_t mode); +static int ida_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg); static int ida_getgeo(struct block_device *bdev, struct hd_geometry *geo); static int ida_ctlr_ioctl(ctlr_info_t *h, int dsk, ida_ioctl_t *io); @@ -197,7 +197,7 @@ static struct block_device_operations ida_fops = { .owner = THIS_MODULE, .open = ida_open, .release = ida_release, - .ioctl = ida_ioctl, + .locked_ioctl = ida_ioctl, .getgeo = ida_getgeo, .revalidate_disk= ida_revalidate, }; @@ -818,12 +818,12 @@ DBGINFO( /* * Open. Make sure the device is really there. */ -static int ida_open(struct inode *inode, struct file *filep) +static int ida_open(struct block_device *bdev, fmode_t mode) { - drv_info_t *drv = get_drv(inode->i_bdev->bd_disk); - ctlr_info_t *host = get_host(inode->i_bdev->bd_disk); + drv_info_t *drv = get_drv(bdev->bd_disk); + ctlr_info_t *host = get_host(bdev->bd_disk); - DBGINFO(printk("ida_open %s\n", inode->i_bdev->bd_disk->disk_name)); + DBGINFO(printk("ida_open %s\n", bdev->bd_disk->disk_name)); /* * Root is allowed to open raw volume zero even if it's not configured * 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) /* * Close. Sync first. */ -static int ida_release(struct inode *inode, struct file *filep) +static int ida_release(struct gendisk *disk, fmode_t mode) { - ctlr_info_t *host = get_host(inode->i_bdev->bd_disk); + ctlr_info_t *host = get_host(disk); host->usage_count--; return 0; } @@ -1128,10 +1128,10 @@ static int ida_getgeo(struct block_device *bdev, struct hd_geometry *geo) * ida_ioctl does some miscellaneous stuff like reporting drive geometry, * setting readahead and submitting commands from userspace to the controller. */ -static int ida_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, unsigned long arg) +static int ida_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) { - drv_info_t *drv = get_drv(inode->i_bdev->bd_disk); - ctlr_info_t *host = get_host(inode->i_bdev->bd_disk); + drv_info_t *drv = get_drv(bdev->bd_disk); + ctlr_info_t *host = get_host(bdev->bd_disk); int error; ida_ioctl_t __user *io = (ida_ioctl_t __user *)arg; ida_ioctl_t *my_io; @@ -1165,7 +1165,7 @@ out_passthru: put_user(host->ctlr_sig, (int __user *)arg); return 0; case IDAREVALIDATEVOLS: - if (iminor(inode) != 0) + if (MINOR(bdev->bd_dev) != 0) return -ENXIO; return revalidate_allvol(host); 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) return 0; } -static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, +static int fd_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long param) { -#define FD_IOCTL_ALLOWED ((filp) && (filp)->private_data) +#define FD_IOCTL_ALLOWED (mode & (FMODE_WRITE|FMODE_WRITE_IOCTL)) #define OUT(c,x) case c: outparam = (const char *) (x); break #define IN(c,x,tag) case c: *(x) = inparam. tag ; return 0 - int drive = (long)inode->i_bdev->bd_disk->private_data; + int drive = (long)bdev->bd_disk->private_data; int type = ITYPE(UDRS->fd_device); int i; int ret; @@ -3516,11 +3516,11 @@ static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, current_type[drive] = NULL; floppy_sizes[drive] = MAX_DISK_SIZE << 1; UDRS->keep_data = 0; - return invalidate_drive(inode->i_bdev); + return invalidate_drive(bdev); case FDSETPRM: case FDDEFPRM: return set_geometry(cmd, &inparam.g, - drive, type, inode->i_bdev); + drive, type, bdev); case FDGETPRM: ECALL(get_floppy_geometry(drive, type, (struct floppy_struct **) @@ -3551,7 +3551,7 @@ static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, case FDFMTEND: case FDFLUSH: LOCK_FDC(drive, 1); - return invalidate_drive(inode->i_bdev); + return invalidate_drive(bdev); case FDSETEMSGTRESH: UDP->max_errors.reporting = @@ -3659,9 +3659,9 @@ static void __init config_types(void) printk("\n"); } -static int floppy_release(struct inode *inode, struct file *filp) +static int floppy_release(struct gendisk *disk, fmode_t mode) { - int drive = (long)inode->i_bdev->bd_disk->private_data; + int drive = (long)disk->private_data; mutex_lock(&open_lock); if (UDRS->fd_ref < 0) @@ -3682,18 +3682,17 @@ static int floppy_release(struct inode *inode, struct file *filp) * /dev/PS0 etc), and disallows simultaneous access to the same * drive with different device numbers. */ -static int floppy_open(struct inode *inode, struct file *filp) +static int floppy_open(struct block_device *bdev, fmode_t mode) { - int drive = (long)inode->i_bdev->bd_disk->private_data; - int old_dev; + int drive = (long)bdev->bd_disk->private_data; + int old_dev, new_dev; int try; int res = -EBUSY; char *tmp; - filp->private_data = (void *)0; mutex_lock(&open_lock); old_dev = UDRS->fd_device; - if (opened_bdev[drive] && opened_bdev[drive] != inode->i_bdev) + if (opened_bdev[drive] && opened_bdev[drive] != bdev) goto out2; if (!UDRS->fd_ref && (UDP->flags & FD_BROKEN_DCL)) { @@ -3701,15 +3700,15 @@ static int floppy_open(struct inode *inode, struct file *filp) USETF(FD_VERIFY); } - if (UDRS->fd_ref == -1 || (UDRS->fd_ref && (filp->f_flags & O_EXCL))) + if (UDRS->fd_ref == -1 || (UDRS->fd_ref && (mode & FMODE_EXCL))) goto out2; - if (filp->f_flags & O_EXCL) + if (mode & FMODE_EXCL) UDRS->fd_ref = -1; else UDRS->fd_ref++; - opened_bdev[drive] = inode->i_bdev; + opened_bdev[drive] = bdev; res = -ENXIO; @@ -3744,31 +3743,26 @@ static int floppy_open(struct inode *inode, struct file *filp) } } - UDRS->fd_device = iminor(inode); - set_capacity(disks[drive], floppy_sizes[iminor(inode)]); - if (old_dev != -1 && old_dev != iminor(inode)) { + new_dev = MINOR(bdev->bd_dev); + UDRS->fd_device = new_dev; + set_capacity(disks[drive], floppy_sizes[new_dev]); + if (old_dev != -1 && old_dev != new_dev) { if (buffer_drive == drive) buffer_track = -1; } - /* Allow ioctls if we have write-permissions even if read-only open. - * Needed so that programs such as fdrawcmd still can work on write - * protected disks */ - if ((filp->f_mode & FMODE_WRITE) || !file_permission(filp, MAY_WRITE)) - filp->private_data = (void *)8; - if (UFDCS->rawcmd == 1) UFDCS->rawcmd = 2; - if (!(filp->f_flags & O_NDELAY)) { - if (filp->f_mode & 3) { + if (!(mode & FMODE_NDELAY)) { + if (mode & (FMODE_READ|FMODE_WRITE)) { UDRS->last_checked = 0; - check_disk_change(inode->i_bdev); + check_disk_change(bdev); if (UTESTF(FD_DISK_CHANGED)) goto out; } res = -EROFS; - if ((filp->f_mode & 2) && !(UTESTF(FD_DISK_WRITABLE))) + if ((mode & FMODE_WRITE) && !(UTESTF(FD_DISK_WRITABLE))) goto out; } mutex_unlock(&open_lock); @@ -3911,7 +3905,7 @@ static struct block_device_operations floppy_fops = { .owner = THIS_MODULE, .open = floppy_open, .release = floppy_release, - .ioctl = fd_ioctl, + .locked_ioctl = fd_ioctl, .getgeo = fd_getgeo, .media_changed = check_floppy_change, .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, * space operations write_begin and write_end. */ static int do_lo_send_aops(struct loop_device *lo, struct bio_vec *bvec, - int bsize, loff_t pos, struct page *unused) + loff_t pos, struct page *unused) { struct file *file = lo->lo_backing_file; /* kudos to NFsckingS */ struct address_space *mapping = file->f_mapping; @@ -302,7 +302,7 @@ static int __do_lo_send_write(struct file *file, * filesystems. */ static int do_lo_send_direct_write(struct loop_device *lo, - struct bio_vec *bvec, int bsize, loff_t pos, struct page *page) + struct bio_vec *bvec, loff_t pos, struct page *page) { ssize_t bw = __do_lo_send_write(lo->lo_backing_file, kmap(bvec->bv_page) + bvec->bv_offset, @@ -326,7 +326,7 @@ static int do_lo_send_direct_write(struct loop_device *lo, * destination pages of the backing file. */ static int do_lo_send_write(struct loop_device *lo, struct bio_vec *bvec, - int bsize, loff_t pos, struct page *page) + loff_t pos, struct page *page) { int ret = lo_do_transfer(lo, WRITE, page, 0, bvec->bv_page, 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, return ret; } -static int lo_send(struct loop_device *lo, struct bio *bio, int bsize, - loff_t pos) +static int lo_send(struct loop_device *lo, struct bio *bio, loff_t pos) { - int (*do_lo_send)(struct loop_device *, struct bio_vec *, int, loff_t, + int (*do_lo_send)(struct loop_device *, struct bio_vec *, loff_t, struct page *page); struct bio_vec *bvec; struct page *page = NULL; @@ -362,7 +361,7 @@ static int lo_send(struct loop_device *lo, struct bio *bio, int bsize, } } bio_for_each_segment(bvec, bio, i) { - ret = do_lo_send(lo, bvec, bsize, pos, page); + ret = do_lo_send(lo, bvec, pos, page); if (ret < 0) break; pos += bvec->bv_len; @@ -478,7 +477,7 @@ static int do_bio_filebacked(struct loop_device *lo, struct bio *bio) pos = ((loff_t) bio->bi_sector << 9) + lo->lo_offset; if (bio_rw(bio) == WRITE) - ret = lo_send(lo, bio, lo->lo_blocksize, pos); + ret = lo_send(lo, bio, pos); else ret = lo_receive(lo, bio, lo->lo_blocksize, pos); return ret; @@ -652,8 +651,8 @@ static void do_loop_switch(struct loop_device *lo, struct switch_request *p) * This can only work if the loop device is used read-only, and if the * new backing store is the same size and type as the old backing store. */ -static int loop_change_fd(struct loop_device *lo, struct file *lo_file, - struct block_device *bdev, unsigned int arg) +static int loop_change_fd(struct loop_device *lo, struct block_device *bdev, + unsigned int arg) { struct file *file, *old_file; struct inode *inode; @@ -712,7 +711,7 @@ static inline int is_loop_device(struct file *file) return i && S_ISBLK(i->i_mode) && MAJOR(i->i_rdev) == LOOP_MAJOR; } -static int loop_set_fd(struct loop_device *lo, struct file *lo_file, +static int loop_set_fd(struct loop_device *lo, fmode_t mode, struct block_device *bdev, unsigned int arg) { struct file *file, *f; @@ -740,7 +739,7 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file, while (is_loop_device(f)) { struct loop_device *l; - if (f->f_mapping->host->i_rdev == lo_file->f_mapping->host->i_rdev) + if (f->f_mapping->host->i_bdev == bdev) goto out_putf; 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, goto out_putf; } - if (!(lo_file->f_mode & FMODE_WRITE)) + if (!(mode & FMODE_WRITE)) lo_flags |= LO_FLAGS_READ_ONLY; 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) memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE); memset(lo->lo_crypt_name, 0, LO_NAME_SIZE); memset(lo->lo_file_name, 0, LO_NAME_SIZE); - invalidate_bdev(bdev); + if (bdev) + invalidate_bdev(bdev); set_capacity(lo->lo_disk, 0); - bd_set_size(bdev, 0); + if (bdev) + bd_set_size(bdev, 0); mapping_set_gfp_mask(filp->f_mapping, gfp); lo->lo_state = Lo_unbound; fput(filp); @@ -1137,22 +1138,22 @@ loop_get_status64(struct loop_device *lo, struct loop_info64 __user *arg) { return err; } -static int lo_ioctl(struct inode * inode, struct file * file, +static int lo_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) { - struct loop_device *lo = inode->i_bdev->bd_disk->private_data; + struct loop_device *lo = bdev->bd_disk->private_data; int err; mutex_lock(&lo->lo_ctl_mutex); switch (cmd) { case LOOP_SET_FD: - err = loop_set_fd(lo, file, inode->i_bdev, arg); + err = loop_set_fd(lo, mode, bdev, arg); break; case LOOP_CHANGE_FD: - err = loop_change_fd(lo, file, inode->i_bdev, arg); + err = loop_change_fd(lo, bdev, arg); break; case LOOP_CLR_FD: - err = loop_clr_fd(lo, inode->i_bdev); + err = loop_clr_fd(lo, bdev); break; case LOOP_SET_STATUS: err = loop_set_status_old(lo, (struct loop_info __user *) arg); @@ -1292,10 +1293,10 @@ loop_get_status_compat(struct loop_device *lo, return err; } -static long lo_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +static int lo_compat_ioctl(struct block_device *bdev, fmode_t mode, + unsigned int cmd, unsigned long arg) { - struct inode *inode = file->f_path.dentry->d_inode; - struct loop_device *lo = inode->i_bdev->bd_disk->private_data; + struct loop_device *lo = bdev->bd_disk->private_data; int err; switch(cmd) { @@ -1317,7 +1318,7 @@ static long lo_compat_ioctl(struct file *file, unsigned int cmd, unsigned long a arg = (unsigned long) compat_ptr(arg); case LOOP_SET_FD: case LOOP_CHANGE_FD: - err = lo_ioctl(inode, file, cmd, arg); + err = lo_ioctl(bdev, mode, cmd, arg); break; default: err = -ENOIOCTLCMD; @@ -1327,9 +1328,9 @@ static long lo_compat_ioctl(struct file *file, unsigned int cmd, unsigned long a } #endif -static int lo_open(struct inode *inode, struct file *file) +static int lo_open(struct block_device *bdev, fmode_t mode) { - struct loop_device *lo = inode->i_bdev->bd_disk->private_data; + struct loop_device *lo = bdev->bd_disk->private_data; mutex_lock(&lo->lo_ctl_mutex); lo->lo_refcnt++; @@ -1338,15 +1339,15 @@ static int lo_open(struct inode *inode, struct file *file) return 0; } -static int lo_release(struct inode *inode, struct file *file) +static int lo_release(struct gendisk *disk, fmode_t mode) { - struct loop_device *lo = inode->i_bdev->bd_disk->private_data; + struct loop_device *lo = disk->private_data; mutex_lock(&lo->lo_ctl_mutex); --lo->lo_refcnt; if ((lo->lo_flags & LO_FLAGS_AUTOCLEAR) && !lo->lo_refcnt) - loop_clr_fd(lo, inode->i_bdev); + loop_clr_fd(lo, NULL); mutex_unlock(&lo->lo_ctl_mutex); diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 7b3351260d56..d3a91cacee8c 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -391,7 +391,7 @@ static ssize_t pid_show(struct device *dev, } static struct device_attribute pid_attr = { - .attr = { .name = "pid", .mode = S_IRUGO, .owner = THIS_MODULE }, + .attr = { .name = "pid", .mode = S_IRUGO}, .show = pid_show, }; @@ -557,10 +557,11 @@ static void do_nbd_request(struct request_queue * q) } } -static int nbd_ioctl(struct inode *inode, struct file *file, +static int nbd_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) { - struct nbd_device *lo = inode->i_bdev->bd_disk->private_data; + struct nbd_device *lo = bdev->bd_disk->private_data; + struct file *file; int error; struct request sreq ; struct task_struct *thread; @@ -612,8 +613,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file, error = -EINVAL; file = fget(arg); if (file) { - struct block_device *bdev = inode->i_bdev; - inode = file->f_path.dentry->d_inode; + struct inode *inode = file->f_path.dentry->d_inode; if (S_ISSOCK(inode->i_mode)) { lo->file = file; lo->sock = SOCKET_I(inode); @@ -628,14 +628,14 @@ static int nbd_ioctl(struct inode *inode, struct file *file, case NBD_SET_BLKSIZE: lo->blksize = arg; lo->bytesize &= ~(lo->blksize-1); - inode->i_bdev->bd_inode->i_size = lo->bytesize; - set_blocksize(inode->i_bdev, lo->blksize); + bdev->bd_inode->i_size = lo->bytesize; + set_blocksize(bdev, lo->blksize); set_capacity(lo->disk, lo->bytesize >> 9); return 0; case NBD_SET_SIZE: lo->bytesize = arg & ~(lo->blksize-1); - inode->i_bdev->bd_inode->i_size = lo->bytesize; - set_blocksize(inode->i_bdev, lo->blksize); + bdev->bd_inode->i_size = lo->bytesize; + set_blocksize(bdev, lo->blksize); set_capacity(lo->disk, lo->bytesize >> 9); return 0; case NBD_SET_TIMEOUT: @@ -643,8 +643,8 @@ static int nbd_ioctl(struct inode *inode, struct file *file, return 0; case NBD_SET_SIZE_BLOCKS: lo->bytesize = ((u64) arg) * lo->blksize; - inode->i_bdev->bd_inode->i_size = lo->bytesize; - set_blocksize(inode->i_bdev, lo->blksize); + bdev->bd_inode->i_size = lo->bytesize; + set_blocksize(bdev, lo->blksize); set_capacity(lo->disk, lo->bytesize >> 9); return 0; case NBD_DO_IT: @@ -666,10 +666,10 @@ static int nbd_ioctl(struct inode *inode, struct file *file, if (file) fput(file); lo->bytesize = 0; - inode->i_bdev->bd_inode->i_size = 0; + bdev->bd_inode->i_size = 0; set_capacity(lo->disk, 0); if (max_part > 0) - ioctl_by_bdev(inode->i_bdev, BLKRRPART, 0); + ioctl_by_bdev(bdev, BLKRRPART, 0); return lo->harderror; case NBD_CLEAR_QUE: /* @@ -680,7 +680,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file, return 0; case NBD_PRINT_DEBUG: printk(KERN_INFO "%s: next = %p, prev = %p, head = %p\n", - inode->i_bdev->bd_disk->disk_name, + bdev->bd_disk->disk_name, lo->queue_head.next, lo->queue_head.prev, &lo->queue_head); return 0; @@ -691,7 +691,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file, static struct block_device_operations nbd_fops = { .owner = THIS_MODULE, - .ioctl = nbd_ioctl, + .locked_ioctl = nbd_ioctl, }; /* 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 ? */ /* kernel glue structures */ -static int pcd_block_open(struct inode *inode, struct file *file) +static int pcd_block_open(struct block_device *bdev, fmode_t mode) { - struct pcd_unit *cd = inode->i_bdev->bd_disk->private_data; - return cdrom_open(&cd->info, inode, file); + struct pcd_unit *cd = bdev->bd_disk->private_data; + return cdrom_open(&cd->info, bdev, mode); } -static int pcd_block_release(struct inode *inode, struct file *file) +static int pcd_block_release(struct gendisk *disk, fmode_t mode) { - struct pcd_unit *cd = inode->i_bdev->bd_disk->private_data; - return cdrom_release(&cd->info, file); + struct pcd_unit *cd = disk->private_data; + cdrom_release(&cd->info, mode); + return 0; } -static int pcd_block_ioctl(struct inode *inode, struct file *file, +static int pcd_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, unsigned long arg) { - struct pcd_unit *cd = inode->i_bdev->bd_disk->private_data; - return cdrom_ioctl(file, &cd->info, inode, cmd, arg); + struct pcd_unit *cd = bdev->bd_disk->private_data; + return cdrom_ioctl(&cd->info, bdev, mode, cmd, arg); } static int pcd_block_media_changed(struct gendisk *disk) @@ -252,7 +253,7 @@ static struct block_device_operations pcd_bdops = { .owner = THIS_MODULE, .open = pcd_block_open, .release = pcd_block_release, - .ioctl = pcd_block_ioctl, + .locked_ioctl = pcd_block_ioctl, .media_changed = pcd_block_media_changed, }; 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, /* kernel glue structures */ -static int pd_open(struct inode *inode, struct file *file) +static int pd_open(struct block_device *bdev, fmode_t mode) { - struct pd_unit *disk = inode->i_bdev->bd_disk->private_data; + struct pd_unit *disk = bdev->bd_disk->private_data; disk->access++; @@ -758,10 +758,10 @@ static int pd_getgeo(struct block_device *bdev, struct hd_geometry *geo) return 0; } -static int pd_ioctl(struct inode *inode, struct file *file, +static int pd_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) { - struct pd_unit *disk = inode->i_bdev->bd_disk->private_data; + struct pd_unit *disk = bdev->bd_disk->private_data; switch (cmd) { case CDROMEJECT: @@ -773,9 +773,9 @@ static int pd_ioctl(struct inode *inode, struct file *file, } } -static int pd_release(struct inode *inode, struct file *file) +static int pd_release(struct gendisk *p, fmode_t mode) { - struct pd_unit *disk = inode->i_bdev->bd_disk->private_data; + struct pd_unit *disk = p->private_data; if (!--disk->access && disk->removable) pd_special_command(disk, pd_door_unlock); @@ -809,7 +809,7 @@ static struct block_device_operations pd_fops = { .owner = THIS_MODULE, .open = pd_open, .release = pd_release, - .ioctl = pd_ioctl, + .locked_ioctl = pd_ioctl, .getgeo = pd_getgeo, .media_changed = pd_check_media, .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); #define ATAPI_READ_10 0x28 #define ATAPI_WRITE_10 0x2a -static int pf_open(struct inode *inode, struct file *file); +static int pf_open(struct block_device *bdev, fmode_t mode); static void do_pf_request(struct request_queue * q); -static int pf_ioctl(struct inode *inode, struct file *file, +static int pf_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg); static int pf_getgeo(struct block_device *bdev, struct hd_geometry *geo); -static int pf_release(struct inode *inode, struct file *file); +static int pf_release(struct gendisk *disk, fmode_t mode); static int pf_detect(void); static void do_pf_read(void); @@ -266,7 +266,7 @@ static struct block_device_operations pf_fops = { .owner = THIS_MODULE, .open = pf_open, .release = pf_release, - .ioctl = pf_ioctl, + .locked_ioctl = pf_ioctl, .getgeo = pf_getgeo, .media_changed = pf_check_media, }; @@ -296,16 +296,16 @@ static void __init pf_init_units(void) } } -static int pf_open(struct inode *inode, struct file *file) +static int pf_open(struct block_device *bdev, fmode_t mode) { - struct pf_unit *pf = inode->i_bdev->bd_disk->private_data; + struct pf_unit *pf = bdev->bd_disk->private_data; pf_identify(pf); if (pf->media_status == PF_NM) return -ENODEV; - if ((pf->media_status == PF_RO) && (file->f_mode & 2)) + if ((pf->media_status == PF_RO) && (mode & FMODE_WRITE)) return -EROFS; pf->access++; @@ -333,9 +333,9 @@ static int pf_getgeo(struct block_device *bdev, struct hd_geometry *geo) return 0; } -static int pf_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) +static int pf_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) { - struct pf_unit *pf = inode->i_bdev->bd_disk->private_data; + struct pf_unit *pf = bdev->bd_disk->private_data; if (cmd != CDROMEJECT) return -EINVAL; @@ -346,9 +346,9 @@ static int pf_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un return 0; } -static int pf_release(struct inode *inode, struct file *file) +static int pf_release(struct gendisk *disk, fmode_t mode) { - struct pf_unit *pf = inode->i_bdev->bd_disk->private_data; + struct pf_unit *pf = disk->private_data; if (pf->access <= 0) 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) goto out; err = -EROFS; - if ((!(tape->flags & PT_WRITE_OK)) && (file->f_mode & 2)) + if ((!(tape->flags & PT_WRITE_OK)) && (file->f_mode & FMODE_WRITE)) goto out; 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) /* * called at open time. */ -static int pkt_open_dev(struct pktcdvd_device *pd, int write) +static int pkt_open_dev(struct pktcdvd_device *pd, fmode_t write) { int ret; long lba; @@ -2332,7 +2332,7 @@ static int pkt_open_dev(struct pktcdvd_device *pd, int write) * so bdget() can't fail. */ bdget(pd->bdev->bd_dev); - if ((ret = blkdev_get(pd->bdev, FMODE_READ, O_RDONLY))) + if ((ret = blkdev_get(pd->bdev, FMODE_READ))) goto out; if ((ret = bd_claim(pd->bdev, pd))) @@ -2381,7 +2381,7 @@ static int pkt_open_dev(struct pktcdvd_device *pd, int write) out_unclaim: bd_release(pd->bdev); out_putdev: - blkdev_put(pd->bdev); + blkdev_put(pd->bdev, FMODE_READ); out: return ret; } @@ -2399,7 +2399,7 @@ static void pkt_release_dev(struct pktcdvd_device *pd, int flush) pkt_set_speed(pd, MAX_SPEED, MAX_SPEED); bd_release(pd->bdev); - blkdev_put(pd->bdev); + blkdev_put(pd->bdev, FMODE_READ); pkt_shrink_pktlist(pd); } @@ -2411,7 +2411,7 @@ static struct pktcdvd_device *pkt_find_dev_from_minor(int dev_minor) return pkt_devs[dev_minor]; } -static int pkt_open(struct inode *inode, struct file *file) +static int pkt_open(struct block_device *bdev, fmode_t mode) { struct pktcdvd_device *pd = NULL; int ret; @@ -2419,7 +2419,7 @@ static int pkt_open(struct inode *inode, struct file *file) VPRINTK(DRIVER_NAME": entering open\n"); mutex_lock(&ctl_mutex); - pd = pkt_find_dev_from_minor(iminor(inode)); + pd = pkt_find_dev_from_minor(MINOR(bdev->bd_dev)); if (!pd) { ret = -ENODEV; goto out; @@ -2428,20 +2428,20 @@ static int pkt_open(struct inode *inode, struct file *file) pd->refcnt++; if (pd->refcnt > 1) { - if ((file->f_mode & FMODE_WRITE) && + if ((mode & FMODE_WRITE) && !test_bit(PACKET_WRITABLE, &pd->flags)) { ret = -EBUSY; goto out_dec; } } else { - ret = pkt_open_dev(pd, file->f_mode & FMODE_WRITE); + ret = pkt_open_dev(pd, mode & FMODE_WRITE); if (ret) goto out_dec; /* * needed here as well, since ext2 (among others) may change * the blocksize at mount time */ - set_blocksize(inode->i_bdev, CD_FRAMESIZE); + set_blocksize(bdev, CD_FRAMESIZE); } mutex_unlock(&ctl_mutex); @@ -2455,9 +2455,9 @@ out: return ret; } -static int pkt_close(struct inode *inode, struct file *file) +static int pkt_close(struct gendisk *disk, fmode_t mode) { - struct pktcdvd_device *pd = inode->i_bdev->bd_disk->private_data; + struct pktcdvd_device *pd = disk->private_data; int ret = 0; mutex_lock(&ctl_mutex); @@ -2765,7 +2765,7 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev) bdev = bdget(dev); if (!bdev) return -ENOMEM; - ret = blkdev_get(bdev, FMODE_READ, O_RDONLY | O_NONBLOCK); + ret = blkdev_get(bdev, FMODE_READ | FMODE_NDELAY); if (ret) return ret; @@ -2790,19 +2790,28 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev) return 0; out_mem: - blkdev_put(bdev); + blkdev_put(bdev, FMODE_READ|FMODE_WRITE); /* This is safe: open() is still holding a reference. */ module_put(THIS_MODULE); return ret; } -static int pkt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) +static int pkt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) { - struct pktcdvd_device *pd = inode->i_bdev->bd_disk->private_data; + struct pktcdvd_device *pd = bdev->bd_disk->private_data; - VPRINTK("pkt_ioctl: cmd %x, dev %d:%d\n", cmd, imajor(inode), iminor(inode)); + VPRINTK("pkt_ioctl: cmd %x, dev %d:%d\n", cmd, + MAJOR(bdev->bd_dev), MINOR(bdev->bd_dev)); switch (cmd) { + case CDROMEJECT: + /* + * The door gets locked when the device is opened, so we + * have to unlock it or else the eject command fails. + */ + if (pd->refcnt == 1) + pkt_lock_door(pd, 0); + /* fallthru */ /* * forward selected CDROM ioctls to CD-ROM, for UDF */ @@ -2811,16 +2820,7 @@ static int pkt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, u case CDROM_LAST_WRITTEN: case CDROM_SEND_PACKET: case SCSI_IOCTL_SEND_COMMAND: - return blkdev_ioctl(pd->bdev->bd_inode, file, cmd, arg); - - case CDROMEJECT: - /* - * The door gets locked when the device is opened, so we - * have to unlock it or else the eject command fails. - */ - if (pd->refcnt == 1) - pkt_lock_door(pd, 0); - return blkdev_ioctl(pd->bdev->bd_inode, file, cmd, arg); + return __blkdev_driver_ioctl(pd->bdev, mode, cmd, arg); default: VPRINTK(DRIVER_NAME": Unknown ioctl for %s (%x)\n", pd->name, cmd); @@ -2849,7 +2849,7 @@ static struct block_device_operations pktcdvd_ops = { .owner = THIS_MODULE, .open = pkt_open, .release = pkt_close, - .ioctl = pkt_ioctl, + .locked_ioctl = pkt_ioctl, .media_changed = pkt_media_changed, }; @@ -2975,7 +2975,7 @@ static int pkt_remove_dev(dev_t pkt_dev) pkt_debugfs_dev_remove(pd); pkt_sysfs_dev_remove(pd); - blkdev_put(pd->bdev); + blkdev_put(pd->bdev, FMODE_READ|FMODE_WRITE); remove_proc_entry(pd->name, pkt_proc); 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, int interruptible); static void release_drive(struct floppy_state *fs); static int fd_eject(struct floppy_state *fs); -static int floppy_ioctl(struct inode *inode, struct file *filp, +static int floppy_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long param); -static int floppy_open(struct inode *inode, struct file *filp); -static int floppy_release(struct inode *inode, struct file *filp); +static int floppy_open(struct block_device *bdev, fmode_t mode); +static int floppy_release(struct gendisk *disk, fmode_t mode); static int floppy_check_change(struct gendisk *disk); static int floppy_revalidate(struct gendisk *disk); @@ -839,10 +839,10 @@ static int fd_eject(struct floppy_state *fs) static struct floppy_struct floppy_type = { 2880,18,2,80,0,0x1B,0x00,0xCF,0x6C,NULL }; /* 7 1.44MB 3.5" */ -static int floppy_ioctl(struct inode *inode, struct file *filp, +static int floppy_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long param) { - struct floppy_state *fs = inode->i_bdev->bd_disk->private_data; + struct floppy_state *fs = bdev->bd_disk->private_data; int err; if ((cmd & 0x80) && !capable(CAP_SYS_ADMIN)) @@ -868,9 +868,9 @@ static int floppy_ioctl(struct inode *inode, struct file *filp, return -ENOTTY; } -static int floppy_open(struct inode *inode, struct file *filp) +static int floppy_open(struct block_device *bdev, fmode_t mode) { - struct floppy_state *fs = inode->i_bdev->bd_disk->private_data; + struct floppy_state *fs = bdev->bd_disk->private_data; struct swim3 __iomem *sw = fs->swim3; int n, err = 0; @@ -904,17 +904,17 @@ static int floppy_open(struct inode *inode, struct file *filp) swim3_action(fs, SETMFM); swim3_select(fs, RELAX); - } else if (fs->ref_count == -1 || filp->f_flags & O_EXCL) + } else if (fs->ref_count == -1 || mode & FMODE_EXCL) return -EBUSY; - if (err == 0 && (filp->f_flags & O_NDELAY) == 0 - && (filp->f_mode & 3)) { - check_disk_change(inode->i_bdev); + if (err == 0 && (mode & FMODE_NDELAY) == 0 + && (mode & (FMODE_READ|FMODE_WRITE))) { + check_disk_change(bdev); if (fs->ejected) err = -ENXIO; } - if (err == 0 && (filp->f_mode & 2)) { + if (err == 0 && (mode & FMODE_WRITE)) { if (fs->write_prot < 0) fs->write_prot = swim3_readbit(fs, WRITE_PROT); if (fs->write_prot) @@ -930,7 +930,7 @@ static int floppy_open(struct inode *inode, struct file *filp) return err; } - if (filp->f_flags & O_EXCL) + if (mode & FMODE_EXCL) fs->ref_count = -1; else ++fs->ref_count; @@ -938,9 +938,9 @@ static int floppy_open(struct inode *inode, struct file *filp) return 0; } -static int floppy_release(struct inode *inode, struct file *filp) +static int floppy_release(struct gendisk *disk, fmode_t mode) { - struct floppy_state *fs = inode->i_bdev->bd_disk->private_data; + struct floppy_state *fs = disk->private_data; struct swim3 __iomem *sw = fs->swim3; if (fs->ref_count > 0 && --fs->ref_count == 0) { swim3_action(fs, MOTOR_OFF); @@ -1000,7 +1000,7 @@ static int floppy_revalidate(struct gendisk *disk) static struct block_device_operations floppy_fops = { .open = floppy_open, .release = floppy_release, - .ioctl = floppy_ioctl, + .locked_ioctl = floppy_ioctl, .media_changed = floppy_check_change, .revalidate_disk= floppy_revalidate, }; 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) * This is mostly needed to keep refcounting, but also to support * media checks on removable media drives. */ -static int ub_bd_open(struct inode *inode, struct file *filp) +static int ub_bd_open(struct block_device *bdev, fmode_t mode) { - struct gendisk *disk = inode->i_bdev->bd_disk; - struct ub_lun *lun = disk->private_data; + struct ub_lun *lun = bdev->bd_disk->private_data; struct ub_dev *sc = lun->udev; unsigned long flags; int rc; @@ -1684,19 +1683,19 @@ static int ub_bd_open(struct inode *inode, struct file *filp) spin_unlock_irqrestore(&ub_lock, flags); if (lun->removable || lun->readonly) - check_disk_change(inode->i_bdev); + check_disk_change(bdev); /* * The sd.c considers ->media_present and ->changed not equivalent, * under some pretty murky conditions (a failure of READ CAPACITY). * We may need it one day. */ - if (lun->removable && lun->changed && !(filp->f_flags & O_NDELAY)) { + if (lun->removable && lun->changed && !(mode & FMODE_NDELAY)) { rc = -ENOMEDIUM; goto err_open; } - if (lun->readonly && (filp->f_mode & FMODE_WRITE)) { + if (lun->readonly && (mode & FMODE_WRITE)) { rc = -EROFS; goto err_open; } @@ -1710,9 +1709,8 @@ err_open: /* */ -static int ub_bd_release(struct inode *inode, struct file *filp) +static int ub_bd_release(struct gendisk *disk, fmode_t mode) { - struct gendisk *disk = inode->i_bdev->bd_disk; struct ub_lun *lun = disk->private_data; struct ub_dev *sc = lun->udev; @@ -1723,13 +1721,13 @@ static int ub_bd_release(struct inode *inode, struct file *filp) /* * The ioctl interface. */ -static int ub_bd_ioctl(struct inode *inode, struct file *filp, +static int ub_bd_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) { - struct gendisk *disk = inode->i_bdev->bd_disk; + struct gendisk *disk = bdev->bd_disk; void __user *usermem = (void __user *) arg; - return scsi_cmd_ioctl(filp, disk->queue, disk, cmd, usermem); + return scsi_cmd_ioctl(disk->queue, disk, mode, cmd, usermem); } /* @@ -1793,7 +1791,7 @@ static struct block_device_operations ub_bd_fops = { .owner = THIS_MODULE, .open = ub_bd_open, .release = ub_bd_release, - .ioctl = ub_bd_ioctl, + .locked_ioctl = ub_bd_ioctl, .media_changed = ub_bd_media_changed, .revalidate_disk = ub_bd_revalidate, }; 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 { /* * External open entry point. */ -static int viodasd_open(struct inode *ino, struct file *fil) +static int viodasd_open(struct block_device *bdev, fmode_t mode) { - struct viodasd_device *d = ino->i_bdev->bd_disk->private_data; + struct viodasd_device *d = bdev->bd_disk->private_data; HvLpEvent_Rc hvrc; struct viodasd_waitevent we; u16 flags = 0; if (d->read_only) { - if ((fil != NULL) && (fil->f_mode & FMODE_WRITE)) + if (mode & FMODE_WRITE) return -EROFS; flags = vioblockflags_ro; } @@ -179,9 +179,9 @@ static int viodasd_open(struct inode *ino, struct file *fil) /* * External release entry point. */ -static int viodasd_release(struct inode *ino, struct file *fil) +static int viodasd_release(struct gendisk *disk, fmode_t mode) { - struct viodasd_device *d = ino->i_bdev->bd_disk->private_data; + struct viodasd_device *d = disk->private_data; HvLpEvent_Rc hvrc; /* 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) vblk->vq->vq_ops->kick(vblk->vq); } -static int virtblk_ioctl(struct inode *inode, struct file *filp, +static int virtblk_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, unsigned long data) { - return scsi_cmd_ioctl(filp, inode->i_bdev->bd_disk->queue, - inode->i_bdev->bd_disk, cmd, + return scsi_cmd_ioctl(bdev->bd_disk->queue, + bdev->bd_disk, mode, cmd, (void __user *)data); } @@ -180,7 +180,7 @@ static int virtblk_getgeo(struct block_device *bd, struct hd_geometry *geo) } static struct block_device_operations virtblk_fops = { - .ioctl = virtblk_ioctl, + .locked_ioctl = virtblk_ioctl, .owner = THIS_MODULE, .getgeo = virtblk_getgeo, }; 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); static struct block_device_operations xd_fops = { .owner = THIS_MODULE, - .ioctl = xd_ioctl, + .locked_ioctl = xd_ioctl, .getgeo = xd_getgeo, }; static DECLARE_WAIT_QUEUE_HEAD(xd_wait_int); @@ -343,7 +343,7 @@ static int xd_getgeo(struct block_device *bdev, struct hd_geometry *geo) } /* xd_ioctl: handle device ioctl's */ -static int xd_ioctl (struct inode *inode,struct file *file,u_int cmd,u_long arg) +static int xd_ioctl(struct block_device *bdev, fmode_t mode, u_int cmd, u_long arg) { switch (cmd) { 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); static u_char xd_initdrives (void (*init_drive)(u_char drive)); static void do_xd_request (struct request_queue * q); -static int xd_ioctl (struct inode *inode,struct file *file,unsigned int cmd,unsigned long arg); +static int xd_ioctl (struct block_device *bdev,fmode_t mode,unsigned int cmd,unsigned long arg); static int xd_readwrite (u_char operation,XD_INFO *disk,char *buffer,u_int block,u_int count); static void xd_recalibrate (u_char drive); 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) return 0; } -static int blkif_ioctl(struct inode *inode, struct file *filep, +static int blkif_ioctl(struct block_device *bdev, fmode_t mode, unsigned command, unsigned long argument) { - struct blkfront_info *info = - inode->i_bdev->bd_disk->private_data; + struct blkfront_info *info = bdev->bd_disk->private_data; int i; 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) return info->is_ready; } -static int blkif_open(struct inode *inode, struct file *filep) +static int blkif_open(struct block_device *bdev, fmode_t mode) { - struct blkfront_info *info = inode->i_bdev->bd_disk->private_data; + struct blkfront_info *info = bdev->bd_disk->private_data; info->users++; return 0; } -static int blkif_release(struct inode *inode, struct file *filep) +static int blkif_release(struct gendisk *disk, fmode_t mode) { - struct blkfront_info *info = inode->i_bdev->bd_disk->private_data; + struct blkfront_info *info = disk->private_data; info->users--; if (info->users == 0) { /* Check whether we have been instructed to close. We will @@ -1044,7 +1043,7 @@ static struct block_device_operations xlvbd_block_fops = .open = blkif_open, .release = blkif_release, .getgeo = blkif_getgeo, - .ioctl = blkif_ioctl, + .locked_ioctl = blkif_ioctl, }; 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) return ace->id_result; } -static int ace_open(struct inode *inode, struct file *filp) +static int ace_open(struct block_device *bdev, fmode_t mode) { - struct ace_device *ace = inode->i_bdev->bd_disk->private_data; + struct ace_device *ace = bdev->bd_disk->private_data; unsigned long flags; dev_dbg(ace->dev, "ace_open() users=%i\n", ace->users + 1); - filp->private_data = ace; spin_lock_irqsave(&ace->lock, flags); ace->users++; spin_unlock_irqrestore(&ace->lock, flags); - check_disk_change(inode->i_bdev); + check_disk_change(bdev); return 0; } -static int ace_release(struct inode *inode, struct file *filp) +static int ace_release(struct gendisk *disk, fmode_t mode) { - struct ace_device *ace = inode->i_bdev->bd_disk->private_data; + struct ace_device *ace = disk->private_data; unsigned long flags; u16 val; 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 ) return; } -static int -z2_open( struct inode *inode, struct file *filp ) +static int z2_open(struct block_device *bdev, fmode_t mode) { int device; int max_z2_map = ( Z2RAM_SIZE / Z2RAM_CHUNKSIZE ) * @@ -147,7 +146,7 @@ z2_open( struct inode *inode, struct file *filp ) sizeof( z2ram_map[0] ); int rc = -ENOMEM; - device = iminor(inode); + device = MINOR(bdev->bd_dev); if ( current_device != -1 && current_device != device ) { @@ -299,7 +298,7 @@ err_out: } static int -z2_release( struct inode *inode, struct file *filp ) +z2_release(struct gendisk *disk, fmode_t mode) { if ( current_device == -1 ) return 0; |