Commit de6d0d2b authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] (3/7) kdev_t removals

* sync_buffers() split in two functions (sync_buffers() and
  sync_all_buffers()).  Callers of sync_buffers(NODEV) are
  using the latter, those who actually pass a device - the former.
* sync_buffers() switched from kdev_t to struct block_device *.
parent 2d849bd1
...@@ -94,7 +94,7 @@ int set_blocksize(kdev_t dev, int size) ...@@ -94,7 +94,7 @@ int set_blocksize(kdev_t dev, int size)
/* Ok, we're actually changing the blocksize.. */ /* Ok, we're actually changing the blocksize.. */
bdev = bdget(kdev_t_to_nr(dev)); bdev = bdget(kdev_t_to_nr(dev));
sync_buffers(dev, 2); sync_buffers(bdev, 2);
blksize_size[major(dev)][minor(dev)] = size; blksize_size[major(dev)][minor(dev)] = size;
bdev->bd_inode->i_blkbits = blksize_bits(size); bdev->bd_inode->i_blkbits = blksize_bits(size);
kill_bdev(bdev); kill_bdev(bdev);
...@@ -198,7 +198,7 @@ static int __block_fsync(struct inode * inode) ...@@ -198,7 +198,7 @@ static int __block_fsync(struct inode * inode)
int ret, err; int ret, err;
ret = filemap_fdatasync(inode->i_mapping); ret = filemap_fdatasync(inode->i_mapping);
err = sync_buffers(inode->i_rdev, 1); err = sync_buffers(inode->i_bdev, 1);
if (err && !ret) if (err && !ret)
ret = err; ret = err;
err = filemap_fdatawait(inode->i_mapping); err = filemap_fdatawait(inode->i_mapping);
......
...@@ -298,10 +298,15 @@ static int wait_for_locked_buffers(kdev_t dev, int index, int refile) ...@@ -298,10 +298,15 @@ static int wait_for_locked_buffers(kdev_t dev, int index, int refile)
* We will ultimately want to put these in a separate list, but for * We will ultimately want to put these in a separate list, but for
* now we search all of the lists for dirty buffers. * now we search all of the lists for dirty buffers.
*/ */
int sync_buffers(kdev_t dev, int wait) int sync_buffers(struct block_device *bdev, int wait)
{ {
int err = 0; int err = 0;
kdev_t dev;
if (!bdev)
return 0;
dev = to_kdev_t(bdev->bd_dev);
/* One pass for no-wait, three for wait: /* One pass for no-wait, three for wait:
* 0) write out all dirty, unlocked buffers; * 0) write out all dirty, unlocked buffers;
* 1) wait for all dirty locked buffers; * 1) wait for all dirty locked buffers;
...@@ -317,10 +322,28 @@ int sync_buffers(kdev_t dev, int wait) ...@@ -317,10 +322,28 @@ int sync_buffers(kdev_t dev, int wait)
return err; return err;
} }
int sync_all_buffers(int wait)
{
int err = 0;
/* One pass for no-wait, three for wait:
* 0) write out all dirty, unlocked buffers;
* 1) wait for all dirty locked buffers;
* 2) write out all dirty, unlocked buffers;
* 2) wait for completion by waiting for all buffers to unlock.
*/
write_unlocked_buffers(NODEV);
if (wait) {
err = wait_for_locked_buffers(NODEV, BUF_DIRTY, 0);
write_unlocked_buffers(NODEV);
err |= wait_for_locked_buffers(NODEV, BUF_LOCKED, 1);
}
return err;
}
int fsync_super(struct super_block *sb) int fsync_super(struct super_block *sb)
{ {
kdev_t dev = sb->s_dev; sync_buffers(sb->s_bdev, 0);
sync_buffers(dev, 0);
lock_kernel(); lock_kernel();
sync_inodes_sb(sb); sync_inodes_sb(sb);
...@@ -331,14 +354,13 @@ int fsync_super(struct super_block *sb) ...@@ -331,14 +354,13 @@ int fsync_super(struct super_block *sb)
unlock_super(sb); unlock_super(sb);
unlock_kernel(); unlock_kernel();
return sync_buffers(dev, 1); return sync_buffers(sb->s_bdev, 1);
} }
int fsync_no_super(struct block_device *bdev) int fsync_no_super(struct block_device *bdev)
{ {
kdev_t dev = to_kdev_t(bdev->bd_dev); sync_buffers(bdev, 0);
sync_buffers(dev, 0); return sync_buffers(bdev, 1);
return sync_buffers(dev, 1);
} }
int fsync_dev(kdev_t dev) int fsync_dev(kdev_t dev)
...@@ -365,7 +387,7 @@ int fsync_bdev(struct block_device *bdev) ...@@ -365,7 +387,7 @@ int fsync_bdev(struct block_device *bdev)
asmlinkage long sys_sync(void) asmlinkage long sys_sync(void)
{ {
sync_buffers(NODEV, 0); sync_all_buffers(0);
lock_kernel(); lock_kernel();
sync_inodes(); sync_inodes();
...@@ -373,7 +395,7 @@ asmlinkage long sys_sync(void) ...@@ -373,7 +395,7 @@ asmlinkage long sys_sync(void)
sync_supers(); sync_supers();
unlock_kernel(); unlock_kernel();
sync_buffers(NODEV, 1); sync_all_buffers(1);
return 0; return 0;
} }
...@@ -385,7 +407,6 @@ int file_fsync(struct file *filp, struct dentry *dentry, int datasync) ...@@ -385,7 +407,6 @@ int file_fsync(struct file *filp, struct dentry *dentry, int datasync)
{ {
struct inode * inode = dentry->d_inode; struct inode * inode = dentry->d_inode;
struct super_block * sb; struct super_block * sb;
kdev_t dev;
int ret; int ret;
lock_kernel(); lock_kernel();
...@@ -400,8 +421,7 @@ int file_fsync(struct file *filp, struct dentry *dentry, int datasync) ...@@ -400,8 +421,7 @@ int file_fsync(struct file *filp, struct dentry *dentry, int datasync)
unlock_super(sb); unlock_super(sb);
/* .. finally sync the buffers to disk */ /* .. finally sync the buffers to disk */
dev = inode->i_dev; ret = sync_buffers(sb->s_bdev, 1);
ret = sync_buffers(dev, 1);
unlock_kernel(); unlock_kernel();
return ret; return ret;
} }
......
...@@ -1215,7 +1215,7 @@ extern void __invalidate_buffers(kdev_t dev, int); ...@@ -1215,7 +1215,7 @@ extern void __invalidate_buffers(kdev_t dev, int);
extern void sync_inodes(void); extern void sync_inodes(void);
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(struct block_device *, int);
extern int fsync_dev(kdev_t); extern int fsync_dev(kdev_t);
extern int fsync_bdev(struct block_device *); extern int fsync_bdev(struct block_device *);
extern int fsync_super(struct super_block *); extern int fsync_super(struct super_block *);
......
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