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
};

drivers/block/floppy.c

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

39033903
static struct block_device_operations floppy_fops = {
39043904
.owner = THIS_MODULE,
3905-
.open = floppy_open,
3906-
.release = floppy_release,
3907-
.ioctl = fd_ioctl,
3905+
.__open = floppy_open,
3906+
.__release = floppy_release,
3907+
.__ioctl = fd_ioctl,
39083908
.getgeo = fd_getgeo,
39093909
.media_changed = check_floppy_change,
39103910
.revalidate_disk = floppy_revalidate,

drivers/block/loop.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,11 +1355,11 @@ static int lo_release(struct inode *inode, struct file *file)
13551355

13561356
static struct block_device_operations lo_fops = {
13571357
.owner = THIS_MODULE,
1358-
.open = lo_open,
1359-
.release = lo_release,
1360-
.ioctl = lo_ioctl,
1358+
.__open = lo_open,
1359+
.__release = lo_release,
1360+
.__ioctl = lo_ioctl,
13611361
#ifdef CONFIG_COMPAT
1362-
.compat_ioctl = lo_compat_ioctl,
1362+
.__compat_ioctl = lo_compat_ioctl,
13631363
#endif
13641364
};
13651365

drivers/block/nbd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
691691
static struct block_device_operations nbd_fops =
692692
{
693693
.owner = THIS_MODULE,
694-
.ioctl = nbd_ioctl,
694+
.__ioctl = nbd_ioctl,
695695
};
696696

697697
/*

drivers/block/paride/pcd.c

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

253253
static struct block_device_operations pcd_bdops = {
254254
.owner = THIS_MODULE,
255-
.open = pcd_block_open,
256-
.release = pcd_block_release,
257-
.ioctl = pcd_block_ioctl,
255+
.__open = pcd_block_open,
256+
.__release = pcd_block_release,
257+
.__ioctl = pcd_block_ioctl,
258258
.media_changed = pcd_block_media_changed,
259259
};
260260

drivers/block/paride/pd.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -807,9 +807,9 @@ static int pd_revalidate(struct gendisk *p)
807807

808808
static struct block_device_operations pd_fops = {
809809
.owner = THIS_MODULE,
810-
.open = pd_open,
811-
.release = pd_release,
812-
.ioctl = pd_ioctl,
810+
.__open = pd_open,
811+
.__release = pd_release,
812+
.__ioctl = pd_ioctl,
813813
.getgeo = pd_getgeo,
814814
.media_changed = pd_check_media,
815815
.revalidate_disk= pd_revalidate

drivers/block/paride/pf.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,9 @@ static char *pf_buf; /* buffer for request in progress */
264264

265265
static struct block_device_operations pf_fops = {
266266
.owner = THIS_MODULE,
267-
.open = pf_open,
268-
.release = pf_release,
269-
.ioctl = pf_ioctl,
267+
.__open = pf_open,
268+
.__release = pf_release,
269+
.__ioctl = pf_ioctl,
270270
.getgeo = pf_getgeo,
271271
.media_changed = pf_check_media,
272272
};

drivers/block/pktcdvd.c

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

28482848
static struct block_device_operations pktcdvd_ops = {
28492849
.owner = THIS_MODULE,
2850-
.open = pkt_open,
2851-
.release = pkt_close,
2852-
.ioctl = pkt_ioctl,
2850+
.__open = pkt_open,
2851+
.__release = pkt_close,
2852+
.__ioctl = pkt_ioctl,
28532853
.media_changed = pkt_media_changed,
28542854
};
28552855

drivers/block/swim3.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -998,9 +998,9 @@ static int floppy_revalidate(struct gendisk *disk)
998998
}
999999

10001000
static struct block_device_operations floppy_fops = {
1001-
.open = floppy_open,
1002-
.release = floppy_release,
1003-
.ioctl = floppy_ioctl,
1001+
.__open = floppy_open,
1002+
.__release = floppy_release,
1003+
.__ioctl = floppy_ioctl,
10041004
.media_changed = floppy_check_change,
10051005
.revalidate_disk= floppy_revalidate,
10061006
};

drivers/block/ub.c

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

17921792
static struct block_device_operations ub_bd_fops = {
17931793
.owner = THIS_MODULE,
1794-
.open = ub_bd_open,
1795-
.release = ub_bd_release,
1796-
.ioctl = ub_bd_ioctl,
1794+
.__open = ub_bd_open,
1795+
.__release = ub_bd_release,
1796+
.__ioctl = ub_bd_ioctl,
17971797
.media_changed = ub_bd_media_changed,
17981798
.revalidate_disk = ub_bd_revalidate,
17991799
};

drivers/block/viodasd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@ static int viodasd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
221221
*/
222222
static struct block_device_operations viodasd_fops = {
223223
.owner = THIS_MODULE,
224-
.open = viodasd_open,
225-
.release = viodasd_release,
224+
.__open = viodasd_open,
225+
.__release = viodasd_release,
226226
.getgeo = viodasd_getgeo,
227227
};
228228

drivers/block/virtio_blk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ static int virtblk_getgeo(struct block_device *bd, struct hd_geometry *geo)
180180
}
181181

182182
static struct block_device_operations virtblk_fops = {
183-
.ioctl = virtblk_ioctl,
183+
.__ioctl = virtblk_ioctl,
184184
.owner = THIS_MODULE,
185185
.getgeo = virtblk_getgeo,
186186
};

drivers/block/xd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static int xd_getgeo(struct block_device *bdev, struct hd_geometry *geo);
132132

133133
static struct block_device_operations xd_fops = {
134134
.owner = THIS_MODULE,
135-
.ioctl = xd_ioctl,
135+
.__ioctl = xd_ioctl,
136136
.getgeo = xd_getgeo,
137137
};
138138
static DECLARE_WAIT_QUEUE_HEAD(xd_wait_int);

drivers/block/xen-blkfront.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,8 +1041,8 @@ static int blkif_release(struct inode *inode, struct file *filep)
10411041
static struct block_device_operations xlvbd_block_fops =
10421042
{
10431043
.owner = THIS_MODULE,
1044-
.open = blkif_open,
1045-
.release = blkif_release,
1044+
.__open = blkif_open,
1045+
.__release = blkif_release,
10461046
.getgeo = blkif_getgeo,
10471047
.ioctl = blkif_ioctl,
10481048
};

drivers/block/xsysace.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,8 +919,8 @@ static int ace_getgeo(struct block_device *bdev, struct hd_geometry *geo)
919919

920920
static struct block_device_operations ace_fops = {
921921
.owner = THIS_MODULE,
922-
.open = ace_open,
923-
.release = ace_release,
922+
.__open = ace_open,
923+
.__release = ace_release,
924924
.media_changed = ace_media_changed,
925925
.revalidate_disk = ace_revalidate_disk,
926926
.getgeo = ace_getgeo,

drivers/block/z2ram.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,8 @@ z2_release( struct inode *inode, struct file *filp )
314314
static struct block_device_operations z2_fops =
315315
{
316316
.owner = THIS_MODULE,
317-
.open = z2_open,
318-
.release = z2_release,
317+
.__open = z2_open,
318+
.__release = z2_release,
319319
};
320320

321321
static struct kobject *z2_find(dev_t dev, int *part, void *data)

drivers/cdrom/gdrom.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -514,10 +514,10 @@ static int gdrom_bdops_ioctl(struct inode *inode, struct file *file,
514514

515515
static struct block_device_operations gdrom_bdops = {
516516
.owner = THIS_MODULE,
517-
.open = gdrom_bdops_open,
518-
.release = gdrom_bdops_release,
517+
.__open = gdrom_bdops_open,
518+
.__release = gdrom_bdops_release,
519519
.media_changed = gdrom_bdops_mediachanged,
520-
.ioctl = gdrom_bdops_ioctl,
520+
.__ioctl = gdrom_bdops_ioctl,
521521
};
522522

523523
static irqreturn_t gdrom_command_interrupt(int irq, void *dev_id)

drivers/cdrom/viocd.c

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

181181
struct block_device_operations viocd_fops = {
182182
.owner = THIS_MODULE,
183-
.open = viocd_blk_open,
184-
.release = viocd_blk_release,
185-
.ioctl = viocd_blk_ioctl,
183+
.__open = viocd_blk_open,
184+
.__release = viocd_blk_release,
185+
.__ioctl = viocd_blk_ioctl,
186186
.media_changed = viocd_blk_media_changed,
187187
};
188188

0 commit comments

Comments
 (0)