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,
rel_fdc();
return -EBUSY;
}
fsync_dev(inode->i_rdev);
fsync_bdev(inode->i_bdev);
if (fd_motor_on(drive) == 0) {
rel_fdc();
return -ENODEV;
......
......@@ -161,7 +161,7 @@ static void go_sync(struct super_block *sb, int remount_flag)
}
file_list_unlock();
DQUOT_OFF(sb);
fsync_dev(sb->s_dev);
fsync_bdev(sb->s_bdev);
flags = MS_RDONLY;
if (sb->s_op && sb->s_op->remount_fs) {
ret = sb->s_op->remount_fs(sb, &flags, NULL);
......@@ -174,7 +174,7 @@ static void go_sync(struct super_block *sb, int remount_flag)
} else
printk("nothing to do\n");
} else { /* Sync only */
fsync_dev(sb->s_dev);
fsync_bdev(sb->s_bdev);
printk("OK\n");
}
console_loglevel = orig_loglevel;
......
......@@ -1434,7 +1434,7 @@ int __openfirmware powerbook_sleep_G3(void)
* BenH: Moved to _after_ sleep request and changed video
* drivers to vmalloc() during sleep request. This way, all
* 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 */
ret = broadcast_sleep(PBOOK_SLEEP_NOW, PBOOK_WAKE);
......@@ -1589,7 +1589,7 @@ int __openfirmware powerbook_sleep_Core99(void)
* BenH: Moved to _after_ sleep request and changed video
* drivers to vmalloc() during sleep request. This way, all
* 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 */
ret = broadcast_sleep(PBOOK_SLEEP_NOW, PBOOK_WAKE);
......@@ -1764,7 +1764,7 @@ int __openfirmware powerbook_sleep_3400(void)
* BenH: Moved to _after_ sleep request and changed video
* drivers to vmalloc() during sleep request. This way, all
* 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 */
ret = broadcast_sleep(PBOOK_SLEEP_NOW, PBOOK_WAKE);
......
......@@ -916,7 +916,7 @@ int __openfirmware powerbook_sleep(void)
/* Sync the disks. */
/* XXX It would be nice to have some way to ensure that
* nobody is dirtying any new buffers while we wait. */
fsync_dev(0);
sys_sync();
/* Turn off the display backlight */
save_backlight = backlight_enabled;
......
......@@ -878,7 +878,7 @@ static int lvm_blk_ioctl(struct inode *inode, struct file *file,
P_IOCTL("BLKFLSBUF\n");
fsync_dev(inode->i_rdev);
fsync_bdev(inode->i_bdev);
invalidate_buffers(inode->i_rdev);
break;
......
......@@ -890,7 +890,8 @@ static mdk_rdev_t * find_rdev_all(kdev_t dev)
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;
unsigned offs;
int error;
......@@ -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);
fsync_dev(dev);
fsync_bdev(bdev);
page = grab_cache_page(mapping, sb_offset/(PAGE_CACHE_SIZE/BLOCK_SIZE));
offs = sb_offset % (PAGE_CACHE_SIZE/BLOCK_SIZE);
if (!page)
......@@ -946,7 +947,7 @@ static int write_disk_sb(mdk_rdev_t * rdev)
UnlockPage(page);
wait_on_page(page);
page_cache_release(page);
fsync_dev(dev);
fsync_bdev(bdev);
skip:
return 0;
unlock:
......
......@@ -1137,9 +1137,6 @@ static int i2ob_release(struct inode *inode, struct file *file)
if(!dev->i2odev)
return 0;
/* Sync the device so we don't get errors */
fsync_dev(inode->i_rdev);
if (dev->refcnt <= 0)
printk(KERN_ALERT "i2ob_release: refcount(%d) <= 0\n", dev->refcnt);
dev->refcnt--;
......
......@@ -540,7 +540,7 @@ static int mtdblock_ioctl(struct inode * inode, struct file * file,
if(!capable(CAP_SYS_ADMIN))
return -EACCES;
#endif
fsync_dev(inode->i_rdev);
fsync_bdev(inode->i_bdev);
invalidate_buffers(inode->i_rdev);
down(&mtdblk->cache_sem);
write_cached_data(mtdblk);
......
......@@ -221,7 +221,7 @@ static int mtdblock_ioctl(struct inode * inode, struct file * file,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
if(!capable(CAP_SYS_ADMIN)) return -EACCES;
#endif
fsync_dev(inode->i_rdev);
fsync_bdev(inode->i_bdev);
invalidate_buffers(inode->i_rdev);
if (mtd->sync)
mtd->sync(mtd);
......
......@@ -795,7 +795,7 @@ static int nftl_ioctl(struct inode * inode, struct file * file, unsigned int cmd
}
case BLKFLSBUF:
if (!capable(CAP_SYS_ADMIN)) return -EACCES;
fsync_dev(inode->i_rdev);
fsync_bdev(inode->i_bdev);
invalidate_buffers(inode->i_rdev);
if (nftl->mtd->sync)
nftl->mtd->sync(nftl->mtd);
......
......@@ -654,7 +654,7 @@ int xpram_ioctl (struct inode *inode, struct file *filp,
(u64 *) arg);
case BLKFLSBUF: /* flush, 0x1261 */
fsync_dev(inode->i_rdev);
fsync_bdev(inode->i_bdev);
if ( capable(CAP_SYS_ADMIN) )invalidate_buffers(inode->i_rdev);
return 0;
......@@ -1191,10 +1191,7 @@ void cleanup_module(void)
{
int i;
/* first of all, flush it all and reset all the data structures */
for (i=0; i<xpram_devs; i++)
fsync_dev(MKDEV(xpram_major, i)); /* flush the devices */
/* first of all, reset all the data structures */
#if (XPRAM_VERSION == 22)
blk_dev[major].request_fn = NULL;
......
......@@ -343,36 +343,37 @@ int fsync_no_super(struct block_device *bdev)
int fsync_dev(kdev_t dev)
{
sync_buffers(dev, 0);
lock_kernel();
sync_inodes(dev);
if (!kdev_none(dev)) {
struct super_block *sb = get_super(dev);
if (sb) {
DQUOT_SYNC(sb);
drop_super(sb);
struct block_device *bdev = bdget(kdev_t_to_nr(dev));
if (bdev) {
int res = fsync_bdev(bdev);
bdput(bdev);
return res;
}
} else
DQUOT_SYNC(NULL);
sync_supers(dev);
unlock_kernel();
return sync_buffers(dev, 1);
return 0;
}
/*
* There's no real reason to pretend we should
* ever do anything differently
*/
void sync_dev(kdev_t dev)
int fsync_bdev(struct block_device *bdev)
{
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)
{
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;
}
......
......@@ -1216,8 +1216,8 @@ extern void sync_inodes(kdev_t);
extern void sync_unlocked_inodes(void);
extern void write_inode_now(struct inode *, int);
extern int sync_buffers(kdev_t, int);
extern void sync_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_no_super(struct block_device *);
extern void sync_inodes_sb(struct super_block *);
......
......@@ -181,6 +181,7 @@ EXPORT_SYMBOL(invalidate_device);
EXPORT_SYMBOL(invalidate_inode_pages);
EXPORT_SYMBOL(truncate_inode_pages);
EXPORT_SYMBOL(fsync_dev);
EXPORT_SYMBOL(fsync_bdev);
EXPORT_SYMBOL(fsync_no_super);
EXPORT_SYMBOL(permission);
EXPORT_SYMBOL(vfs_permission);
......@@ -311,7 +312,6 @@ EXPORT_SYMBOL(blk_dev);
EXPORT_SYMBOL(is_read_only);
EXPORT_SYMBOL(set_device_ro);
EXPORT_SYMBOL(bmap);
EXPORT_SYMBOL(sync_dev);
EXPORT_SYMBOL(devfs_register_partitions);
EXPORT_SYMBOL(blkdev_open);
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