Commit 7155112c authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] (1/7) kdev_t removals

* new function - fsync_bdev() (analog of fsync_dev(), but takes
  struct block_device * instead of kdev_t.  Callers of fsync_dev()
  that have struct block_device in question are using fsync_bdev()
  now.
* old code for fsync_dev(NODEV) had been moved to sys_sync().
  Other callers of fsync_dev(NODEV) are calling sys_sync() now.
* fsync_dev() became a wrapper fro fsync_bdev().
* sync_dev() (not used anywhere in the tree) is gone.
* i2oblock.c had fsync_dev() called in ->release().  Removed.
* s390/block/xparm.c was doing fsync_dev() on its devices in
  cleanup_module().  Removed.
parent 8a0acc94
...@@ -1514,7 +1514,7 @@ static int fd_ioctl(struct inode *inode, struct file *filp, ...@@ -1514,7 +1514,7 @@ static int fd_ioctl(struct inode *inode, struct file *filp,
rel_fdc(); rel_fdc();
return -EBUSY; return -EBUSY;
} }
fsync_dev(inode->i_rdev); fsync_bdev(inode->i_bdev);
if (fd_motor_on(drive) == 0) { if (fd_motor_on(drive) == 0) {
rel_fdc(); rel_fdc();
return -ENODEV; return -ENODEV;
......
...@@ -161,7 +161,7 @@ static void go_sync(struct super_block *sb, int remount_flag) ...@@ -161,7 +161,7 @@ static void go_sync(struct super_block *sb, int remount_flag)
} }
file_list_unlock(); file_list_unlock();
DQUOT_OFF(sb); DQUOT_OFF(sb);
fsync_dev(sb->s_dev); fsync_bdev(sb->s_bdev);
flags = MS_RDONLY; flags = MS_RDONLY;
if (sb->s_op && sb->s_op->remount_fs) { if (sb->s_op && sb->s_op->remount_fs) {
ret = sb->s_op->remount_fs(sb, &flags, NULL); ret = sb->s_op->remount_fs(sb, &flags, NULL);
...@@ -174,7 +174,7 @@ static void go_sync(struct super_block *sb, int remount_flag) ...@@ -174,7 +174,7 @@ static void go_sync(struct super_block *sb, int remount_flag)
} else } else
printk("nothing to do\n"); printk("nothing to do\n");
} else { /* Sync only */ } else { /* Sync only */
fsync_dev(sb->s_dev); fsync_bdev(sb->s_bdev);
printk("OK\n"); printk("OK\n");
} }
console_loglevel = orig_loglevel; console_loglevel = orig_loglevel;
......
...@@ -1434,7 +1434,7 @@ int __openfirmware powerbook_sleep_G3(void) ...@@ -1434,7 +1434,7 @@ int __openfirmware powerbook_sleep_G3(void)
* BenH: Moved to _after_ sleep request and changed video * BenH: Moved to _after_ sleep request and changed video
* drivers to vmalloc() during sleep request. This way, all * drivers to vmalloc() during sleep request. This way, all
* vmalloc's are done before actual sleep of block drivers */ * vmalloc's are done before actual sleep of block drivers */
fsync_dev(0); sys_sync();
/* Sleep can fail now. May not be very robust but useful for debugging */ /* Sleep can fail now. May not be very robust but useful for debugging */
ret = broadcast_sleep(PBOOK_SLEEP_NOW, PBOOK_WAKE); ret = broadcast_sleep(PBOOK_SLEEP_NOW, PBOOK_WAKE);
...@@ -1589,7 +1589,7 @@ int __openfirmware powerbook_sleep_Core99(void) ...@@ -1589,7 +1589,7 @@ int __openfirmware powerbook_sleep_Core99(void)
* BenH: Moved to _after_ sleep request and changed video * BenH: Moved to _after_ sleep request and changed video
* drivers to vmalloc() during sleep request. This way, all * drivers to vmalloc() during sleep request. This way, all
* vmalloc's are done before actual sleep of block drivers */ * vmalloc's are done before actual sleep of block drivers */
fsync_dev(0); sys_sync();
/* Sleep can fail now. May not be very robust but useful for debugging */ /* Sleep can fail now. May not be very robust but useful for debugging */
ret = broadcast_sleep(PBOOK_SLEEP_NOW, PBOOK_WAKE); ret = broadcast_sleep(PBOOK_SLEEP_NOW, PBOOK_WAKE);
...@@ -1764,7 +1764,7 @@ int __openfirmware powerbook_sleep_3400(void) ...@@ -1764,7 +1764,7 @@ int __openfirmware powerbook_sleep_3400(void)
* BenH: Moved to _after_ sleep request and changed video * BenH: Moved to _after_ sleep request and changed video
* drivers to vmalloc() during sleep request. This way, all * drivers to vmalloc() during sleep request. This way, all
* vmalloc's are done before actual sleep of block drivers */ * vmalloc's are done before actual sleep of block drivers */
fsync_dev(0); sys_sync();
/* Sleep can fail now. May not be very robust but useful for debugging */ /* Sleep can fail now. May not be very robust but useful for debugging */
ret = broadcast_sleep(PBOOK_SLEEP_NOW, PBOOK_WAKE); ret = broadcast_sleep(PBOOK_SLEEP_NOW, PBOOK_WAKE);
......
...@@ -916,7 +916,7 @@ int __openfirmware powerbook_sleep(void) ...@@ -916,7 +916,7 @@ int __openfirmware powerbook_sleep(void)
/* Sync the disks. */ /* Sync the disks. */
/* XXX It would be nice to have some way to ensure that /* XXX It would be nice to have some way to ensure that
* nobody is dirtying any new buffers while we wait. */ * nobody is dirtying any new buffers while we wait. */
fsync_dev(0); sys_sync();
/* Turn off the display backlight */ /* Turn off the display backlight */
save_backlight = backlight_enabled; save_backlight = backlight_enabled;
......
...@@ -878,7 +878,7 @@ static int lvm_blk_ioctl(struct inode *inode, struct file *file, ...@@ -878,7 +878,7 @@ static int lvm_blk_ioctl(struct inode *inode, struct file *file,
P_IOCTL("BLKFLSBUF\n"); P_IOCTL("BLKFLSBUF\n");
fsync_dev(inode->i_rdev); fsync_bdev(inode->i_bdev);
invalidate_buffers(inode->i_rdev); invalidate_buffers(inode->i_rdev);
break; break;
......
...@@ -890,7 +890,8 @@ static mdk_rdev_t * find_rdev_all(kdev_t dev) ...@@ -890,7 +890,8 @@ static mdk_rdev_t * find_rdev_all(kdev_t dev)
static int write_disk_sb(mdk_rdev_t * rdev) static int write_disk_sb(mdk_rdev_t * rdev)
{ {
struct address_space *mapping = rdev->bdev->bd_inode->i_mapping; struct block_device *bdev = rdev->bdev;
struct address_space *mapping = bdev->bd_inode->i_mapping;
struct page *page; struct page *page;
unsigned offs; unsigned offs;
int error; int error;
...@@ -929,7 +930,7 @@ static int write_disk_sb(mdk_rdev_t * rdev) ...@@ -929,7 +930,7 @@ static int write_disk_sb(mdk_rdev_t * rdev)
} }
printk(KERN_INFO "(write) %s's sb offset: %ld\n", partition_name(dev), sb_offset); printk(KERN_INFO "(write) %s's sb offset: %ld\n", partition_name(dev), sb_offset);
fsync_dev(dev); fsync_bdev(bdev);
page = grab_cache_page(mapping, sb_offset/(PAGE_CACHE_SIZE/BLOCK_SIZE)); page = grab_cache_page(mapping, sb_offset/(PAGE_CACHE_SIZE/BLOCK_SIZE));
offs = sb_offset % (PAGE_CACHE_SIZE/BLOCK_SIZE); offs = sb_offset % (PAGE_CACHE_SIZE/BLOCK_SIZE);
if (!page) if (!page)
...@@ -946,7 +947,7 @@ static int write_disk_sb(mdk_rdev_t * rdev) ...@@ -946,7 +947,7 @@ static int write_disk_sb(mdk_rdev_t * rdev)
UnlockPage(page); UnlockPage(page);
wait_on_page(page); wait_on_page(page);
page_cache_release(page); page_cache_release(page);
fsync_dev(dev); fsync_bdev(bdev);
skip: skip:
return 0; return 0;
unlock: unlock:
......
...@@ -1137,9 +1137,6 @@ static int i2ob_release(struct inode *inode, struct file *file) ...@@ -1137,9 +1137,6 @@ static int i2ob_release(struct inode *inode, struct file *file)
if(!dev->i2odev) if(!dev->i2odev)
return 0; return 0;
/* Sync the device so we don't get errors */
fsync_dev(inode->i_rdev);
if (dev->refcnt <= 0) if (dev->refcnt <= 0)
printk(KERN_ALERT "i2ob_release: refcount(%d) <= 0\n", dev->refcnt); printk(KERN_ALERT "i2ob_release: refcount(%d) <= 0\n", dev->refcnt);
dev->refcnt--; dev->refcnt--;
......
...@@ -540,7 +540,7 @@ static int mtdblock_ioctl(struct inode * inode, struct file * file, ...@@ -540,7 +540,7 @@ static int mtdblock_ioctl(struct inode * inode, struct file * file,
if(!capable(CAP_SYS_ADMIN)) if(!capable(CAP_SYS_ADMIN))
return -EACCES; return -EACCES;
#endif #endif
fsync_dev(inode->i_rdev); fsync_bdev(inode->i_bdev);
invalidate_buffers(inode->i_rdev); invalidate_buffers(inode->i_rdev);
down(&mtdblk->cache_sem); down(&mtdblk->cache_sem);
write_cached_data(mtdblk); write_cached_data(mtdblk);
......
...@@ -221,7 +221,7 @@ static int mtdblock_ioctl(struct inode * inode, struct file * file, ...@@ -221,7 +221,7 @@ static int mtdblock_ioctl(struct inode * inode, struct file * file,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0) #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
if(!capable(CAP_SYS_ADMIN)) return -EACCES; if(!capable(CAP_SYS_ADMIN)) return -EACCES;
#endif #endif
fsync_dev(inode->i_rdev); fsync_bdev(inode->i_bdev);
invalidate_buffers(inode->i_rdev); invalidate_buffers(inode->i_rdev);
if (mtd->sync) if (mtd->sync)
mtd->sync(mtd); mtd->sync(mtd);
......
...@@ -795,7 +795,7 @@ static int nftl_ioctl(struct inode * inode, struct file * file, unsigned int cmd ...@@ -795,7 +795,7 @@ static int nftl_ioctl(struct inode * inode, struct file * file, unsigned int cmd
} }
case BLKFLSBUF: case BLKFLSBUF:
if (!capable(CAP_SYS_ADMIN)) return -EACCES; if (!capable(CAP_SYS_ADMIN)) return -EACCES;
fsync_dev(inode->i_rdev); fsync_bdev(inode->i_bdev);
invalidate_buffers(inode->i_rdev); invalidate_buffers(inode->i_rdev);
if (nftl->mtd->sync) if (nftl->mtd->sync)
nftl->mtd->sync(nftl->mtd); nftl->mtd->sync(nftl->mtd);
......
...@@ -654,7 +654,7 @@ int xpram_ioctl (struct inode *inode, struct file *filp, ...@@ -654,7 +654,7 @@ int xpram_ioctl (struct inode *inode, struct file *filp,
(u64 *) arg); (u64 *) arg);
case BLKFLSBUF: /* flush, 0x1261 */ case BLKFLSBUF: /* flush, 0x1261 */
fsync_dev(inode->i_rdev); fsync_bdev(inode->i_bdev);
if ( capable(CAP_SYS_ADMIN) )invalidate_buffers(inode->i_rdev); if ( capable(CAP_SYS_ADMIN) )invalidate_buffers(inode->i_rdev);
return 0; return 0;
...@@ -1191,10 +1191,7 @@ void cleanup_module(void) ...@@ -1191,10 +1191,7 @@ void cleanup_module(void)
{ {
int i; int i;
/* first of all, flush it all and reset all the data structures */ /* first of all, reset all the data structures */
for (i=0; i<xpram_devs; i++)
fsync_dev(MKDEV(xpram_major, i)); /* flush the devices */
#if (XPRAM_VERSION == 22) #if (XPRAM_VERSION == 22)
blk_dev[major].request_fn = NULL; blk_dev[major].request_fn = NULL;
......
...@@ -343,36 +343,37 @@ int fsync_no_super(struct block_device *bdev) ...@@ -343,36 +343,37 @@ int fsync_no_super(struct block_device *bdev)
int fsync_dev(kdev_t dev) int fsync_dev(kdev_t dev)
{ {
sync_buffers(dev, 0); struct block_device *bdev = bdget(kdev_t_to_nr(dev));
if (bdev) {
lock_kernel(); int res = fsync_bdev(bdev);
sync_inodes(dev); bdput(bdev);
if (!kdev_none(dev)) { return res;
struct super_block *sb = get_super(dev); }
if (sb) { return 0;
DQUOT_SYNC(sb);
drop_super(sb);
}
} else
DQUOT_SYNC(NULL);
sync_supers(dev);
unlock_kernel();
return sync_buffers(dev, 1);
} }
/* int fsync_bdev(struct block_device *bdev)
* There's no real reason to pretend we should
* ever do anything differently
*/
void sync_dev(kdev_t dev)
{ {
fsync_dev(dev); struct super_block *sb = get_super(to_kdev_t(bdev->bd_dev));
if (sb) {
int res = fsync_super(sb);
drop_super(sb);
return res;
}
return fsync_no_super(bdev);
} }
asmlinkage long sys_sync(void) asmlinkage long sys_sync(void)
{ {
fsync_dev(NODEV); sync_buffers(NODEV, 0);
lock_kernel();
sync_inodes(NODEV);
DQUOT_SYNC(NULL);
sync_supers(NODEV);
unlock_kernel();
sync_buffers(NODEV, 1);
return 0; return 0;
} }
......
...@@ -1216,8 +1216,8 @@ extern void sync_inodes(kdev_t); ...@@ -1216,8 +1216,8 @@ extern void sync_inodes(kdev_t);
extern void sync_unlocked_inodes(void); extern void sync_unlocked_inodes(void);
extern void write_inode_now(struct inode *, int); extern void write_inode_now(struct inode *, int);
extern int sync_buffers(kdev_t, int); extern int sync_buffers(kdev_t, int);
extern void sync_dev(kdev_t);
extern int fsync_dev(kdev_t); extern int fsync_dev(kdev_t);
extern int fsync_bdev(struct block_device *);
extern int fsync_super(struct super_block *); extern int fsync_super(struct super_block *);
extern int fsync_no_super(struct block_device *); extern int fsync_no_super(struct block_device *);
extern void sync_inodes_sb(struct super_block *); extern void sync_inodes_sb(struct super_block *);
......
...@@ -181,6 +181,7 @@ EXPORT_SYMBOL(invalidate_device); ...@@ -181,6 +181,7 @@ EXPORT_SYMBOL(invalidate_device);
EXPORT_SYMBOL(invalidate_inode_pages); EXPORT_SYMBOL(invalidate_inode_pages);
EXPORT_SYMBOL(truncate_inode_pages); EXPORT_SYMBOL(truncate_inode_pages);
EXPORT_SYMBOL(fsync_dev); EXPORT_SYMBOL(fsync_dev);
EXPORT_SYMBOL(fsync_bdev);
EXPORT_SYMBOL(fsync_no_super); EXPORT_SYMBOL(fsync_no_super);
EXPORT_SYMBOL(permission); EXPORT_SYMBOL(permission);
EXPORT_SYMBOL(vfs_permission); EXPORT_SYMBOL(vfs_permission);
...@@ -311,7 +312,6 @@ EXPORT_SYMBOL(blk_dev); ...@@ -311,7 +312,6 @@ EXPORT_SYMBOL(blk_dev);
EXPORT_SYMBOL(is_read_only); EXPORT_SYMBOL(is_read_only);
EXPORT_SYMBOL(set_device_ro); EXPORT_SYMBOL(set_device_ro);
EXPORT_SYMBOL(bmap); EXPORT_SYMBOL(bmap);
EXPORT_SYMBOL(sync_dev);
EXPORT_SYMBOL(devfs_register_partitions); EXPORT_SYMBOL(devfs_register_partitions);
EXPORT_SYMBOL(blkdev_open); EXPORT_SYMBOL(blkdev_open);
EXPORT_SYMBOL(blkdev_get); EXPORT_SYMBOL(blkdev_get);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment