sync_fs for 2.5
Subsystems (2)
Here's my shot at a 2.5 version of the sync_fs() superblock operation. It is more elaborate than in 2.4 - it is independent of s_dirt, and does a two pass operation. The first to get IO underway, the second to wait on it.
Seeking comments...
Documentation/filesystems/Locking | 2 + fs/buffer.c | 11 ++++++-- fs/super.c | 48 +++++++++++++++++++++++++++++++++++--- include/linux/fs.h | 3 ++ 4 files changed, 58 insertions(+), 6 deletions(-)
fs/buffer.c renamed from fs/buffer.c~sync_fs +8 -3
@@ -222,6 +222,9 @@ int fsync_super(struct super_block *sb)lock_super (sb);if (sb->s_dirt && sb->s_op && sb->s_op->write_super) sb->s_op->write_super (sb); +if (sb->s_op && sb->s_op->sync_fs) { + sb->s_op->sync_fs (sb,1 ); + }unlock_super (sb);sync_blockdev (sb->s_bdev);sync_inodes_sb (sb,1 );
@@ -252,10 +255,12 @@ int fsync_bdev(struct block_device *bdevasmlinkage long sys_sync (void ) {wakeup_bdflush (0 ); -sync_inodes (0 );/* All mappings and inodes, including block devices */ +sync_inodes (0 );/* All mappings, inodes and their blockdevs */ DQUOT_SYNC (NULL ); -sync_supers ();/* Write the superblocks */ -sync_inodes (1 );/* All the mappings and inodes, again. */ +sync_supers ();/* Write the superblocks */ +sync_filesystems (0 );/* Start syncing the filesystems */ +sync_filesystems (1 );/* Waitingly sync the filesystems */ +sync_inodes (1 );/* Mappings, inodes and blockdevs, again. */ return 0 ; }
include/linux/fs.h renamed from include/linux/fs.h~sync_fs +3 -0
@@ -632,6 +632,7 @@ struct super_block {struct semaphore s_lock;int s_count;int s_syncing; +int s_need_sync_fs;atomic_t s_active;void *s_security;
@@ -810,6 +811,7 @@ struct super_operations {void (*delete_inode) (struct inode *);void (*put_super) (struct super_block *);void (*write_super) (struct super_block *); +int (*sync_fs)(struct super_block *sb,int wait);void (*write_super_lockfs) (struct super_block *);void (*unlockfs) (struct super_block *);int (*statfs) (struct super_block *,struct statfs *);
@@ -1143,6 +1145,7 @@ extern void write_inode_now(struct inodeextern int filemap_fdatawrite (struct address_space *);extern int filemap_fdatawait (struct address_space *);extern void sync_supers (void ); +extern void sync_filesystems (int wait);extern sector_t bmap (struct inode *,sector_t );extern int setattr_mask (unsigned int );extern int notify_change (struct dentry *,struct iattr *);
fs/super.c renamed from fs/super.c~sync_fs +45 -3
72 lines not on this page · raw message
Documentation/filesystems/Locking renamed from Documentation/filesystems/Locking~sync_fs +2 -0
@@ -92,6 +92,7 @@ prototypes: void (*delete_inode) (struct inode *); void (*put_super) (struct super_block *); void (*write_super) (struct super_block *); + void (*sync_fs) (struct super_block *); int (*statfs) (struct super_block *, struct statfs *); int (*remount_fs) (struct super_block *, int *, char *); void (*clear_inode) (struct inode *);
@@ -108,6 +109,7 @@ delete_inode: no clear_inode: no put_super: yes yes maybe (see below) write_super: no yes maybe (see below) +sync_fs: no no maybe (see below) statfs: no no no remount_fs: yes yes maybe (see below) umount_begin: yes no maybe (see below)
_