From 91b58109a339748d992cb767e145c19722756653 Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Thu, 24 Apr 2003 08:39:06 -0700 Subject: [PATCH] [PATCH] invalidate_device()/check_disk_change() fixes * bogus calls of invalidate_buffers() gone from floppy_open() * invalidate_buffers() killed. * new helper - __invalidate_device(bdev, do_sync). invalidate_device() is calling it. * fixed races between floppy_open()/floppy_open and floppy_open()/set_geometry(): a) floppy_open()/floppy_release() is done under a semaphore. That closes the races between simultaneous open() on /dev/fd0foo and /dev/fd0bar. b) pointer to struct block_device is kept as long as floppy is opened (per-drive, non-NULL when number of openers is non-zero, does not contribute to block_device refcount). c) set_geometry() grabs the same semaphore and invalidates the devices directly instead of messing with setting fake "it had changed" and calling __check_disk_change(). * __check_disk_change() killed - no remaining callers * full_check_disk_change() killed - ditto. --- drivers/acorn/block/fd1772.c | 3 - drivers/block/amiflop.c | 5 +- drivers/block/ataflop.c | 11 +--- drivers/block/floppy.c | 106 +++++++++++++++++----------------- drivers/block/floppy98.c | 107 ++++++++++++++++++----------------- drivers/block/paride/pt.c | 2 - fs/block_dev.c | 33 +---------- fs/buffer.c | 9 --- fs/inode.c | 15 +++-- include/linux/buffer_head.h | 4 -- include/linux/fs.h | 3 +- kernel/ksyms.c | 3 +- 12 files changed, 124 insertions(+), 177 deletions(-) diff --git a/drivers/acorn/block/fd1772.c b/drivers/acorn/block/fd1772.c index 6104ea2e254c1..0d2a8cba9fa38 100644 --- a/drivers/acorn/block/fd1772.c +++ b/drivers/acorn/block/fd1772.c @@ -1474,9 +1474,6 @@ static int floppy_open(struct inode *inode, struct file *filp) fd_device[drive] = type; - if (old_dev && old_dev != type) - invalidate_buffers(mk_kdev(MAJOR_NR, drive + (old_dev<<2))); - if (filp->f_flags & O_NDELAY) return 0; diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c index a1b73f1a12c59..2e470c6b91956 100644 --- a/drivers/block/amiflop.c +++ b/drivers/block/amiflop.c @@ -1496,7 +1496,7 @@ static int fd_ioctl(struct inode *inode, struct file *filp, break; case FDFMTEND: floppy_off(drive); - invalidate_device(inode->i_rdev, 0); + invalidate_bdev(inode->i_bdev, 0); break; case FDGETPRM: memset((void *)&getprm, 0, sizeof (getprm)); @@ -1604,9 +1604,6 @@ static int floppy_open(struct inode *inode, struct file *filp) #endif local_irq_restore(flags); - if (old_dev != system) - invalidate_buffers(mk_kdev(FLOPPY_MAJOR, drive + (system << 2))); - unit[drive].dtype=&data_types[system]; unit[drive].blocks=unit[drive].type->heads*unit[drive].type->tracks* data_types[system].sects*unit[drive].type->sect_mult; diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c index 23249c0c11619..30a47a7aff2d7 100644 --- a/drivers/block/ataflop.c +++ b/drivers/block/ataflop.c @@ -364,7 +364,7 @@ static __inline__ void set_head_settle_flag( void ); static __inline__ int get_head_settle_flag( void ); static void floppy_irq (int irq, void *dummy, struct pt_regs *fp); static void fd_error( void ); -static int do_format(kdev_t drive, struct atari_format_descr *desc); +static int do_format(int drive, int type, struct atari_format_descr *desc); static void do_fd_action( int drive ); static void fd_calibrate( void ); static void fd_calibrate_done( int status ); @@ -656,12 +656,11 @@ static void fd_error( void ) p += n; \ } while(0) -static int do_format(kdev_t device, struct atari_format_descr *desc) +static int do_format(int drive, int type, struct atari_format_descr *desc) { unsigned char *p; int sect, nsect; unsigned long flags; - int type, drive = minor(device) & 3; DPRINT(("do_format( dr=%d tr=%d he=%d offs=%d )\n", drive, desc->track, desc->head, desc->sect_offset )); @@ -673,7 +672,6 @@ static int do_format(kdev_t device, struct atari_format_descr *desc) atari_turnon_irq( IRQ_MFP_FDC ); /* should be already, just to be sure */ local_irq_restore(flags); - type = minor(device) >> 2; if (type) { if (--type >= NUM_DISK_MINORS || minor2disktype[type].drive_types > DriveType) { @@ -1690,7 +1688,7 @@ static int fd_ioctl(struct inode *inode, struct file *filp, return -EBUSY; if (copy_from_user(&fmt_desc, (void *) param, sizeof(fmt_desc))) return -EFAULT; - return do_format(device, &fmt_desc); + return do_format(drive, type, &fmt_desc); case FDCLRPRM: UDT = NULL; /* MSch: invalidate default_params */ @@ -1864,9 +1862,6 @@ static int floppy_open( struct inode *inode, struct file *filp ) fd_device[drive] = type; - if (old_dev && old_dev != type) - invalidate_buffers(mk_kdev(FLOPPY_MAJOR, drive + (type<<2))); - if (filp->f_flags & O_NDELAY) return 0; diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index b49ffd409364a..e85256befeec8 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -283,12 +283,6 @@ static inline void fallback_on_nodma_alloc(char **addr, size_t l) static unsigned long fake_change; static int initialising=1; -static inline int TYPE(kdev_t x) { - return (minor(x)>>2) & 0x1f; -} -static inline int DRIVE(kdev_t x) { - return (minor(x)&0x03) | ((minor(x)&0x80) >> 5); -} #define ITYPE(x) (((x)>>2) & 0x1f) #define TOMINOR(x) ((x & 3) | ((x & 4) << 5)) #define UNIT(x) ((x) & 0x03) /* drive on fdc */ @@ -415,6 +409,8 @@ static struct floppy_drive_struct drive_state[N_DRIVE]; static struct floppy_write_errors write_errors[N_DRIVE]; static struct timer_list motor_off_timer[N_DRIVE]; static struct gendisk *disks[N_DRIVE]; +static struct block_device *opened_bdev[N_DRIVE]; +static DECLARE_MUTEX(open_lock); static struct floppy_raw_cmd *raw_cmd, default_raw_cmd; /* @@ -3332,25 +3328,21 @@ static inline int set_geometry(unsigned int cmd, struct floppy_struct *g, if (type){ if (!capable(CAP_SYS_ADMIN)) return -EPERM; + down(&open_lock); LOCK_FDC(drive,1); - for (cnt = 0; cnt < N_DRIVE; cnt++){ - if (ITYPE(drive_state[cnt].fd_device) == type && - drive_state[cnt].fd_ref) - set_bit(drive, &fake_change); - } floppy_type[type] = *g; floppy_type[type].name="user format"; for (cnt = type << 2; cnt < (type << 2) + 4; cnt++) floppy_sizes[cnt]= floppy_sizes[cnt+0x80]= floppy_type[type].size+1; process_fd_request(); - for (cnt = 0; cnt < N_DRIVE; cnt++){ - if (ITYPE(drive_state[cnt].fd_device) == type && - drive_state[cnt].fd_ref) - __check_disk_change( - MKDEV(FLOPPY_MAJOR, - drive_state[cnt].fd_device)); + for (cnt = 0; cnt < N_DRIVE; cnt++) { + struct block_device *bdev = opened_bdev[cnt]; + if (!bdev || ITYPE(drive_state[cnt].fd_device) != type) + continue; + __invalidate_device(bdev, 0); } + up(&open_lock); } else { LOCK_FDC(drive,1); if (cmd != FDDEFPRM) @@ -3448,8 +3440,8 @@ static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, #define OUT(c,x) case c: outparam = (const char *) (x); break #define IN(c,x,tag) case c: *(x) = inparam. tag ; return 0 - int i,drive,type; - kdev_t device; + int drive = (long)inode->i_bdev->bd_disk->private_data; + int i, type = ITYPE(UDRS->fd_device); int ret; int size; union inparam { @@ -3460,9 +3452,6 @@ static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, } inparam; /* parameters coming from user space */ const char *outparam; /* parameters passed back to user space */ - device = inode->i_rdev; - type = TYPE(device); - drive = DRIVE(device); /* convert compatibility eject ioctls into floppy eject ioctl. * We do this in order to provide a means to eject floppy disks before @@ -3675,15 +3664,19 @@ static void __init config_types(void) static int floppy_release(struct inode * inode, struct file * filp) { - int drive = DRIVE(inode->i_rdev); + int drive = (long)inode->i_bdev->bd_disk->private_data; + down(&open_lock); if (UDRS->fd_ref < 0) UDRS->fd_ref=0; else if (!UDRS->fd_ref--) { DPRINT("floppy_release with fd_ref == 0"); UDRS->fd_ref = 0; } + if (!UDRS->fd_ref) + opened_bdev[drive] = NULL; floppy_release_irq_and_dma(); + up(&open_lock); return 0; } @@ -3692,28 +3685,19 @@ 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. */ -#define RETERR(x) do{floppy_release(inode,filp); return -(x);}while(0) - static int floppy_open(struct inode * inode, struct file * filp) { - int drive; + int drive = (long)inode->i_bdev->bd_disk->private_data; int old_dev; int try; + int res = -EBUSY; char *tmp; filp->private_data = (void*) 0; - - drive = DRIVE(inode->i_rdev); - if (drive >= N_DRIVE || - !(allowed_drive_mask & (1 << drive)) || - fdc_state[FDC(drive)].version == FDC_NONE) - return -ENXIO; - - if (TYPE(inode->i_rdev) >= NUMBER(floppy_type)) - return -ENXIO; + down(&open_lock); old_dev = UDRS->fd_device; - if (UDRS->fd_ref && old_dev != minor(inode->i_rdev)) - return -EBUSY; + if (opened_bdev[drive] && opened_bdev[drive] != inode->i_bdev) + goto out2; if (!UDRS->fd_ref && (UDP->flags & FD_BROKEN_DCL)){ USETF(FD_DISK_CHANGED); @@ -3722,16 +3706,20 @@ static int floppy_open(struct inode * inode, struct file * filp) if (UDRS->fd_ref == -1 || (UDRS->fd_ref && (filp->f_flags & O_EXCL))) - return -EBUSY; + goto out2; if (floppy_grab_irq_and_dma()) - return -EBUSY; + goto out2; if (filp->f_flags & O_EXCL) UDRS->fd_ref = -1; else UDRS->fd_ref++; + opened_bdev[drive] = inode->i_bdev; + + res = -ENXIO; + if (!floppy_track_buffer){ /* if opening an ED drive, reserve a big buffer, * else reserve a small one */ @@ -3751,7 +3739,7 @@ static int floppy_open(struct inode * inode, struct file * filp) } if (!tmp && !floppy_track_buffer) { DPRINT("Unable to allocate DMA memory\n"); - RETERR(ENXIO); + goto out; } if (floppy_track_buffer) { if (tmp) @@ -3768,8 +3756,6 @@ static int floppy_open(struct inode * inode, struct file * filp) if (old_dev != -1 && old_dev != minor(inode->i_rdev)) { if (buffer_drive == drive) buffer_track = -1; - /* umm, invalidate_buffers() in ->open?? --hch */ - invalidate_buffers(mk_kdev(FLOPPY_MAJOR,old_dev)); } /* Allow ioctls if we have write-permissions even if read-only open. @@ -3782,18 +3768,30 @@ static int floppy_open(struct inode * inode, struct file * filp) if (UFDCS->rawcmd == 1) UFDCS->rawcmd = 2; - if (filp->f_flags & O_NDELAY) - return 0; - if (filp->f_mode & 3) { - UDRS->last_checked = 0; - check_disk_change(inode->i_bdev); - if (UTESTF(FD_DISK_CHANGED)) - RETERR(ENXIO); - } - if ((filp->f_mode & 2) && !(UTESTF(FD_DISK_WRITABLE))) - RETERR(EROFS); + if (!filp->f_flags & O_NDELAY) { + if (filp->f_mode & 3) { + UDRS->last_checked = 0; + check_disk_change(inode->i_bdev); + if (UTESTF(FD_DISK_CHANGED)) + goto out; + } + res = -EROFS; + if ((filp->f_mode & 2) && !(UTESTF(FD_DISK_WRITABLE))) + goto out; + } + up(&open_lock); return 0; -#undef RETERR +out: + if (UDRS->fd_ref < 0) + UDRS->fd_ref=0; + else + UDRS->fd_ref--; + if (!UDRS->fd_ref) + opened_bdev[drive] = NULL; + floppy_release_irq_and_dma(); +out2: + up(&open_lock); + return res; } /* @@ -4216,6 +4214,8 @@ static struct gendisk *floppy_find(dev_t dev, int *part, void *data) !(allowed_drive_mask & (1 << drive)) || fdc_state[FDC(drive)].version == FDC_NONE) return NULL; + if (((*part >> 2) & 0x1f) >= NUMBER(floppy_type)) + return NULL; *part = 0; return get_disk(disks[drive]); } diff --git a/drivers/block/floppy98.c b/drivers/block/floppy98.c index 8dc1de8b46d93..a01a515f06182 100644 --- a/drivers/block/floppy98.c +++ b/drivers/block/floppy98.c @@ -318,12 +318,6 @@ static inline void fallback_on_nodma_alloc(char **addr, size_t l) static unsigned long fake_change; static int initialising=1; -static inline int TYPE(kdev_t x) { - return (minor(x)>>2) & 0x1f; -} -static inline int DRIVE(kdev_t x) { - return (minor(x)&0x03) | ((minor(x)&0x80) >> 5); -} #define ITYPE(x) (((x)>>2) & 0x1f) #define TOMINOR(x) ((x & 3) | ((x & 4) << 5)) #define UNIT(x) ((x) & 0x03) /* drive on fdc */ @@ -450,6 +444,8 @@ static struct floppy_drive_struct drive_state[N_DRIVE]; static struct floppy_write_errors write_errors[N_DRIVE]; static struct timer_list motor_off_timer[N_DRIVE]; static struct gendisk *disks[N_DRIVE]; +static struct block_device *opened_bdev[N_DRIVE]; +static DECLARE_MUTEX(open_lock); static struct floppy_raw_cmd *raw_cmd, default_raw_cmd; /* @@ -3384,25 +3380,21 @@ static inline int set_geometry(unsigned int cmd, struct floppy_struct *g, if (type){ if (!capable(CAP_SYS_ADMIN)) return -EPERM; + down(&open_lock); LOCK_FDC(drive,1); - for (cnt = 0; cnt < N_DRIVE; cnt++){ - if (ITYPE(drive_state[cnt].fd_device) == type && - drive_state[cnt].fd_ref) - set_bit(drive, &fake_change); - } floppy_type[type] = *g; floppy_type[type].name="user format"; for (cnt = type << 2; cnt < (type << 2) + 4; cnt++) floppy_sizes[cnt]= floppy_sizes[cnt+0x80]= floppy_type[type].size+1; process_fd_request(); - for (cnt = 0; cnt < N_DRIVE; cnt++){ - if (ITYPE(drive_state[cnt].fd_device) == type && - drive_state[cnt].fd_ref) - __check_disk_change( - MKDEV(FLOPPY_MAJOR, - drive_state[cnt].fd_device)); + for (cnt = 0; cnt < N_DRIVE; cnt++) { + struct block_device *bdev = opened_bdev[cnt]; + if (!bdev || ITYPE(drive_state[cnt].fd_device) != type) + continue; + __invalidate_device(bdev, 0); } + up(&open_lock); } else { LOCK_FDC(drive,1); if (cmd != FDDEFPRM) @@ -3500,8 +3492,8 @@ static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, #define OUT(c,x) case c: outparam = (const char *) (x); break #define IN(c,x,tag) case c: *(x) = inparam. tag ; return 0 - int i,drive,type; - kdev_t device; + int drive = (long)inode->i_bdev->bd_disk->private_data; + int i, type = ITYPE(UDRS->fd_device); int ret; int size; union inparam { @@ -3512,10 +3504,6 @@ static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, } inparam; /* parameters coming from user space */ const char *outparam; /* parameters passed back to user space */ - device = inode->i_rdev; - type = TYPE(device); - drive = DRIVE(device); - /* convert compatibility eject ioctls into floppy eject ioctl. * We do this in order to provide a means to eject floppy disks before * installing the new fdutils package */ @@ -3750,15 +3738,19 @@ static void __init config_types(void) static int floppy_release(struct inode * inode, struct file * filp) { - int drive = DRIVE(inode->i_rdev); + int drive = (long)inode->i_bdev->bd_disk->private_data; + down(&open_lock); if (UDRS->fd_ref < 0) UDRS->fd_ref=0; else if (!UDRS->fd_ref--) { DPRINT("floppy_release with fd_ref == 0"); UDRS->fd_ref = 0; } + if (!UDRS->fd_ref) + opened_bdev[drive] = NULL; floppy_release_irq_and_dma(); + up(&open_lock); return 0; } @@ -3771,9 +3763,10 @@ static int floppy_release(struct inode * inode, struct file * filp) static int floppy_open(struct inode * inode, struct file * filp) { - int drive; + int drive = (long)inode->i_bdev->bd_disk->private_data; int old_dev; int try; + int res = -EBUSY; char *tmp; #ifdef PC9800_DEBUG_FLOPPY @@ -3781,7 +3774,6 @@ static int floppy_open(struct inode * inode, struct file * filp) #endif filp->private_data = (void*) 0; - drive = DRIVE(inode->i_rdev); #ifdef PC9800_DEBUG_FLOPPY printk("floppy open: drive=%d, current_drive=%d, UDP->cmos=%d\n" "floppy open: FDCS={spec1=%d, spec2=%d, dtr=%d, version=%d, dor=%d, address=%lu}\n", @@ -3796,16 +3788,10 @@ static int floppy_open(struct inode * inode, struct file * filp) } #endif /* PC9800_DEBUG_FLOPPY */ - if (drive >= N_DRIVE || - !(allowed_drive_mask & (1 << drive)) || - fdc_state[FDC(drive)].version == FDC_NONE) - return -ENXIO; - - if (TYPE(inode->i_rdev) >= NUMBER(floppy_type)) - return -ENXIO; + down(&open_lock); old_dev = UDRS->fd_device; - if (UDRS->fd_ref && old_dev != minor(inode->i_rdev)) - return -EBUSY; + if (opened_bdev[drive] && opened_bdev[drive] != inode->i_bdev) + goto out2; if (!UDRS->fd_ref && (UDP->flags & FD_BROKEN_DCL)){ USETF(FD_DISK_CHANGED); @@ -3814,16 +3800,20 @@ static int floppy_open(struct inode * inode, struct file * filp) if (UDRS->fd_ref == -1 || (UDRS->fd_ref && (filp->f_flags & O_EXCL))) - return -EBUSY; + goto out2; if (floppy_grab_irq_and_dma()) - return -EBUSY; + goto out2; if (filp->f_flags & O_EXCL) UDRS->fd_ref = -1; else UDRS->fd_ref++; + opened_bdev[drive] = inode->i_bdev; + + res = -ENXIO; + if (!floppy_track_buffer){ /* if opening an ED drive, reserve a big buffer, * else reserve a small one */ @@ -3843,7 +3833,7 @@ static int floppy_open(struct inode * inode, struct file * filp) } if (!tmp && !floppy_track_buffer) { DPRINT("Unable to allocate DMA memory\n"); - RETERR(ENXIO); + goto out; } if (floppy_track_buffer) { if (tmp) @@ -3860,8 +3850,6 @@ static int floppy_open(struct inode * inode, struct file * filp) if (old_dev != -1 && old_dev != minor(inode->i_rdev)) { if (buffer_drive == drive) buffer_track = -1; - /* umm, invalidate_buffers() in ->open?? --hch */ - invalidate_buffers(mk_kdev(FLOPPY_MAJOR,old_dev)); } #ifdef PC9800_DEBUG_FLOPPY @@ -3883,22 +3871,33 @@ static int floppy_open(struct inode * inode, struct file * filp) printk("floppy open: floppy.c:%d passed\n", __LINE__); #endif - if (filp->f_flags & O_NDELAY) - return 0; - if (filp->f_mode & 3) { - UDRS->last_checked = 0; - check_disk_change(inode->i_bdev); - if (UTESTF(FD_DISK_CHANGED)) - RETERR(ENXIO); - } - if ((filp->f_mode & 2) && !(UTESTF(FD_DISK_WRITABLE))) - RETERR(EROFS); + if (!(filp->f_flags & O_NDELAY)) { + if (filp->f_mode & 3) { + UDRS->last_checked = 0; + check_disk_change(inode->i_bdev); + if (UTESTF(FD_DISK_CHANGED)) + goto out; + } + res = -EROFS; + if ((filp->f_mode & 2) && !(UTESTF(FD_DISK_WRITABLE))) + goto out; #ifdef PC9800_DEBUG_FLOPPY - printk("floppy open: end normally\n"); + printk("floppy open: end normally\n"); #endif - + } + up(&open_lock); return 0; -#undef RETERR +out: + if (UDRS->fd_ref < 0) + UDRS->fd_ref=0; + else + UDRS->fd_ref--; + if (!UDRS->fd_ref) + opened_bdev[drive] = NULL; + floppy_release_irq_and_dma(); +out2: + up(&open_lock); + return res; } /* @@ -4254,6 +4253,8 @@ static struct gendisk *floppy_find(dev_t dev, int *part, void *data) !(allowed_drive_mask & (1 << drive)) || fdc_state[FDC(drive)].version == FDC_NONE) return NULL; + if (((*part>>2) & 0x1f) >= NUMBER(floppy_type)) + return NULL; return get_disk(disks[drive]); } diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c index 3bded7393de26..fca579eb6ad02 100644 --- a/drivers/block/paride/pt.c +++ b/drivers/block/paride/pt.c @@ -661,8 +661,6 @@ static int pt_ioctl(struct inode *inode,struct file *file, int unit; struct mtop mtop; - if (!inode || kdev_none(inode->i_rdev)) - return -EINVAL; unit = DEVICE_NR(inode->i_rdev); if (unit >= PT_UNITS) return -EINVAL; diff --git a/fs/block_dev.c b/fs/block_dev.c index 9a974170a10b0..595d89d64e7ed 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -449,14 +449,13 @@ int check_disk_change(struct block_device *bdev) { struct gendisk *disk = bdev->bd_disk; struct block_device_operations * bdops = disk->fops; - kdev_t dev = to_kdev_t(bdev->bd_dev); if (!bdops->media_changed) return 0; if (!bdops->media_changed(bdev->bd_disk)) return 0; - if (invalidate_device(dev, 0)) + if (__invalidate_device(bdev, 0)) printk("VFS: busy inodes on changed media.\n"); if (bdops->revalidate_disk) @@ -466,36 +465,6 @@ int check_disk_change(struct block_device *bdev) return 1; } -int full_check_disk_change(struct block_device *bdev) -{ - int res = 0; - if (bdev->bd_contains != bdev) - BUG(); - down(&bdev->bd_sem); - if (check_disk_change(bdev) && bdev->bd_invalidated) { - rescan_partitions(bdev->bd_disk, bdev); - res = 1; - } - up(&bdev->bd_sem); - return res; -} - -/* - * Will die as soon as two remaining callers get converted. - */ -int __check_disk_change(dev_t dev) -{ - struct block_device *bdev = bdget(dev); - int res; - if (!bdev) - return 0; - if (blkdev_get(bdev, FMODE_READ, 0, BDEV_RAW) < 0) - return 0; - res = full_check_disk_change(bdev); - blkdev_put(bdev, BDEV_RAW); - return res; -} - static void bd_set_size(struct block_device *bdev, loff_t size) { unsigned bsize = bdev_hardsect_size(bdev); diff --git a/fs/buffer.c b/fs/buffer.c index 47e2cf01f30cc..f57274d6b9c9f 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -447,15 +447,6 @@ void invalidate_bdev(struct block_device *bdev, int destroy_dirty_buffers) invalidate_inode_pages(bdev->bd_inode->i_mapping); } -void __invalidate_buffers(kdev_t dev, int destroy_dirty_buffers) -{ - struct block_device *bdev = bdget(kdev_t_to_nr(dev)); - if (bdev) { - invalidate_bdev(bdev, destroy_dirty_buffers); - bdput(bdev); - } -} - /* * Kick pdflush then try to free up some ZONE_NORMAL memory. */ diff --git a/fs/inode.c b/fs/inode.c index 364901cdf9018..6e9b869fe9d22 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -340,15 +340,11 @@ int invalidate_inodes(struct super_block * sb) return busy; } -int invalidate_device(kdev_t dev, int do_sync) +int __invalidate_device(struct block_device *bdev, int do_sync) { struct super_block *sb; - struct block_device *bdev = bdget(kdev_t_to_nr(dev)); int res; - if (!bdev) - return 0; - if (do_sync) fsync_bdev(bdev); @@ -366,6 +362,15 @@ int invalidate_device(kdev_t dev, int do_sync) drop_super(sb); } invalidate_bdev(bdev, 0); + return res; +} + +int invalidate_device(kdev_t dev, int do_sync) +{ + int res = 0; + struct block_device *bdev = bdget(kdev_t_to_nr(dev)); + if (bdev) + res = __invalidate_device(bdev, do_sync); bdput(bdev); return res; } diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index 26d71a5fb7429..22d3ac8efc6bf 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -128,9 +128,6 @@ BUFFER_FNS(Boundary, boundary) }) #define page_has_buffers(page) PagePrivate(page) -#define invalidate_buffers(dev) __invalidate_buffers((dev), 0) - - /* * Declarations */ @@ -159,7 +156,6 @@ void unmap_underlying_metadata(struct block_device *bdev, sector_t block); void mark_buffer_async_read(struct buffer_head *bh); void mark_buffer_async_write(struct buffer_head *bh); void invalidate_bdev(struct block_device *, int); -void __invalidate_buffers(kdev_t dev, int); int sync_blockdev(struct block_device *bdev); void __wait_on_buffer(struct buffer_head *); wait_queue_head_t *bh_waitq_head(struct buffer_head *bh); diff --git a/include/linux/fs.h b/include/linux/fs.h index df578c422b252..ce89b15c54a15 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1102,9 +1102,8 @@ extern int fs_may_remount_ro(struct super_block *); #define bio_data_dir(bio) ((bio)->bi_rw & 1) extern int check_disk_change(struct block_device *); -extern int full_check_disk_change(struct block_device *); -extern int __check_disk_change(dev_t); extern int invalidate_inodes(struct super_block *); +extern int __invalidate_device(struct block_device *, int); extern int invalidate_device(kdev_t, int); unsigned long invalidate_mapping_pages(struct address_space *mapping, pgoff_t start, pgoff_t end); diff --git a/kernel/ksyms.c b/kernel/ksyms.c index 5d31affa36cee..0902e78133482 100644 --- a/kernel/ksyms.c +++ b/kernel/ksyms.c @@ -186,11 +186,10 @@ EXPORT_SYMBOL(filp_close); EXPORT_SYMBOL(put_filp); EXPORT_SYMBOL(files_lock); EXPORT_SYMBOL(check_disk_change); -EXPORT_SYMBOL(__check_disk_change); -EXPORT_SYMBOL(__invalidate_buffers); EXPORT_SYMBOL(invalidate_bdev); EXPORT_SYMBOL(invalidate_inodes); EXPORT_SYMBOL(invalidate_device); +EXPORT_SYMBOL(__invalidate_device); EXPORT_SYMBOL(invalidate_inode_pages); EXPORT_SYMBOL_GPL(invalidate_inode_pages2); EXPORT_SYMBOL(truncate_inode_pages); -- 2.53.0