Skip to content

Commit d4430d6

Browse files
author
Al Viro
committed
[PATCH] beginning of methods conversion
To keep the size of changesets sane we split the switch by drivers; to keep the damn thing bisectable we do the following: 1) rename the affected methods, add ones with correct prototypes, make (few) callers handle both. That's this changeset. 2) for each driver convert to new methods. *ALL* drivers are converted in this series. 3) kill the old (renamed) methods. Note that it _is_ a flagday; all in-tree drivers are converted and by the end of this series no trace of old methods remain. The only reason why we do that this way is to keep the damn thing bisectable and allow per-driver debugging if anything goes wrong. New methods: open(bdev, mode) release(disk, mode) ioctl(bdev, mode, cmd, arg) /* Called without BKL */ compat_ioctl(bdev, mode, cmd, arg) locked_ioctl(bdev, mode, cmd, arg) /* Called with BKL, legacy */ Signed-off-by: Al Viro <[email protected]>
1 parent badf808 commit d4430d6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+167
-131
lines changed

arch/um/drivers/ubd_kern.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ static int ubd_getgeo(struct block_device *bdev, struct hd_geometry *geo);
108108

109109
static struct block_device_operations ubd_blops = {
110110
.owner = THIS_MODULE,
111-
.open = ubd_open,
112-
.release = ubd_release,
113-
.ioctl = ubd_ioctl,
111+
.__open = ubd_open,
112+
.__release = ubd_release,
113+
.__ioctl = ubd_ioctl,
114114
.getgeo = ubd_getgeo,
115115
};
116116

block/compat_ioctl.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -708,17 +708,17 @@ static int compat_blkdev_driver_ioctl(struct inode *inode, struct file *file,
708708
return -ENOIOCTLCMD;
709709
}
710710

711-
if (disk->fops->unlocked_ioctl)
712-
return disk->fops->unlocked_ioctl(file, cmd, arg);
711+
if (disk->fops->__unlocked_ioctl)
712+
return disk->fops->__unlocked_ioctl(file, cmd, arg);
713713

714-
if (disk->fops->ioctl) {
714+
if (disk->fops->__ioctl) {
715715
lock_kernel();
716-
ret = disk->fops->ioctl(inode, file, cmd, arg);
716+
ret = disk->fops->__ioctl(inode, file, cmd, arg);
717717
unlock_kernel();
718718
return ret;
719719
}
720720

721-
return -ENOTTY;
721+
return __blkdev_driver_ioctl(inode->i_bdev, file->f_mode, cmd, arg);
722722
}
723723

724724
static int compat_blkdev_locked_ioctl(struct inode *inode, struct file *file,
@@ -805,10 +805,11 @@ long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg)
805805

806806
lock_kernel();
807807
ret = compat_blkdev_locked_ioctl(inode, file, bdev, cmd, arg);
808-
/* FIXME: why do we assume -> compat_ioctl needs the BKL? */
809-
if (ret == -ENOIOCTLCMD && disk->fops->compat_ioctl)
810-
ret = disk->fops->compat_ioctl(file, cmd, arg);
808+
if (ret == -ENOIOCTLCMD && disk->fops->__compat_ioctl)
809+
ret = disk->fops->__compat_ioctl(file, cmd, arg);
811810
unlock_kernel();
811+
if (ret == -ENOIOCTLCMD && disk->fops->compat_ioctl)
812+
ret = disk->fops->compat_ioctl(bdev, file->f_mode, cmd, arg);
812813

813814
if (ret != -ENOIOCTLCMD)
814815
return ret;

block/ioctl.c

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -269,17 +269,24 @@ int blkdev_driver_ioctl(struct inode *inode, struct file *file,
269269
struct gendisk *disk, unsigned cmd, unsigned long arg)
270270
{
271271
int ret;
272-
if (disk->fops->unlocked_ioctl)
273-
return disk->fops->unlocked_ioctl(file, cmd, arg);
272+
fmode_t mode = 0;
273+
if (file) {
274+
mode = file->f_mode;
275+
if (file->f_flags & O_NDELAY)
276+
mode |= FMODE_NDELAY_NOW;
277+
}
278+
279+
if (disk->fops->__unlocked_ioctl)
280+
return disk->fops->__unlocked_ioctl(file, cmd, arg);
274281

275-
if (disk->fops->ioctl) {
282+
if (disk->fops->__ioctl) {
276283
lock_kernel();
277-
ret = disk->fops->ioctl(inode, file, cmd, arg);
284+
ret = disk->fops->__ioctl(inode, file, cmd, arg);
278285
unlock_kernel();
279286
return ret;
280287
}
281288

282-
return -ENOTTY;
289+
return __blkdev_driver_ioctl(inode->i_bdev, mode, cmd, arg);
283290
}
284291
EXPORT_SYMBOL_GPL(blkdev_driver_ioctl);
285292

@@ -295,12 +302,22 @@ int __blkdev_driver_ioctl(struct block_device *bdev, fmode_t mode,
295302
fake_file.f_path.dentry = &fake_dentry;
296303
fake_dentry.d_inode = bdev->bd_inode;
297304

298-
if (disk->fops->unlocked_ioctl)
299-
return disk->fops->unlocked_ioctl(&fake_file, cmd, arg);
305+
if (disk->fops->__unlocked_ioctl)
306+
return disk->fops->__unlocked_ioctl(&fake_file, cmd, arg);
307+
308+
if (disk->fops->__ioctl) {
309+
lock_kernel();
310+
ret = disk->fops->__ioctl(bdev->bd_inode, &fake_file, cmd, arg);
311+
unlock_kernel();
312+
return ret;
313+
}
314+
315+
if (disk->fops->ioctl)
316+
return disk->fops->ioctl(bdev, mode, cmd, arg);
300317

301-
if (disk->fops->ioctl) {
318+
if (disk->fops->locked_ioctl) {
302319
lock_kernel();
303-
ret = disk->fops->ioctl(bdev->bd_inode, &fake_file, cmd, arg);
320+
ret = disk->fops->locked_ioctl(bdev, mode, cmd, arg);
304321
unlock_kernel();
305322
return ret;
306323
}

drivers/block/DAC960.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static int DAC960_revalidate_disk(struct gendisk *disk)
153153

154154
static struct block_device_operations DAC960_BlockDeviceOperations = {
155155
.owner = THIS_MODULE,
156-
.open = DAC960_open,
156+
.__open = DAC960_open,
157157
.getgeo = DAC960_getgeo,
158158
.media_changed = DAC960_media_changed,
159159
.revalidate_disk = DAC960_revalidate_disk,

drivers/block/amiflop.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,9 +1648,9 @@ static int amiga_floppy_change(struct gendisk *disk)
16481648

16491649
static struct block_device_operations floppy_fops = {
16501650
.owner = THIS_MODULE,
1651-
.open = floppy_open,
1652-
.release = floppy_release,
1653-
.ioctl = fd_ioctl,
1651+
.__open = floppy_open,
1652+
.__release = floppy_release,
1653+
.__ioctl = fd_ioctl,
16541654
.getgeo = fd_getgeo,
16551655
.media_changed = amiga_floppy_change,
16561656
};

drivers/block/aoe/aoeblk.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ aoeblk_getgeo(struct block_device *bdev, struct hd_geometry *geo)
239239
}
240240

241241
static struct block_device_operations aoe_bdops = {
242-
.open = aoeblk_open,
243-
.release = aoeblk_release,
242+
.__open = aoeblk_open,
243+
.__release = aoeblk_release,
244244
.getgeo = aoeblk_getgeo,
245245
.owner = THIS_MODULE,
246246
};

drivers/block/ataflop.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,9 +1857,9 @@ static int floppy_release( struct inode * inode, struct file * filp )
18571857

18581858
static struct block_device_operations floppy_fops = {
18591859
.owner = THIS_MODULE,
1860-
.open = floppy_open,
1861-
.release = floppy_release,
1862-
.ioctl = fd_ioctl,
1860+
.__open = floppy_open,
1861+
.__release = floppy_release,
1862+
.__ioctl = fd_ioctl,
18631863
.media_changed = check_floppy_change,
18641864
.revalidate_disk= floppy_revalidate,
18651865
};

drivers/block/brd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ static int brd_ioctl(struct inode *inode, struct file *file,
376376

377377
static struct block_device_operations brd_fops = {
378378
.owner = THIS_MODULE,
379-
.ioctl = brd_ioctl,
379+
.__ioctl = brd_ioctl,
380380
#ifdef CONFIG_BLK_DEV_XIP
381381
.direct_access = brd_direct_access,
382382
#endif

drivers/block/cciss.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,12 @@ static long cciss_compat_ioctl(struct file *f, unsigned cmd, unsigned long arg);
197197

198198
static struct block_device_operations cciss_fops = {
199199
.owner = THIS_MODULE,
200-
.open = cciss_open,
201-
.release = cciss_release,
202-
.ioctl = cciss_ioctl,
200+
.__open = cciss_open,
201+
.__release = cciss_release,
202+
.__ioctl = cciss_ioctl,
203203
.getgeo = cciss_getgeo,
204204
#ifdef CONFIG_COMPAT
205-
.compat_ioctl = cciss_compat_ioctl,
205+
.__compat_ioctl = cciss_compat_ioctl,
206206
#endif
207207
.revalidate_disk = cciss_revalidate,
208208
};

drivers/block/cpqarray.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ static inline ctlr_info_t *get_host(struct gendisk *disk)
195195

196196
static struct block_device_operations ida_fops = {
197197
.owner = THIS_MODULE,
198-
.open = ida_open,
199-
.release = ida_release,
200-
.ioctl = ida_ioctl,
198+
.__open = ida_open,
199+
.__release = ida_release,
200+
.__ioctl = ida_ioctl,
201201
.getgeo = ida_getgeo,
202202
.revalidate_disk= ida_revalidate,
203203
};

0 commit comments

Comments
 (0)