
From: Hans Reiser <reiser@namesys.com>

This patch adds new operation to struct super_operations - sync_inodes,
generic implementaion and changes fs-writeback.c:sync_sb_inodes() to call
filesystem's sync_inodes if it is defined or generic implementaion otherwise. 
This new operation allows filesystem to decide itself what to flush.

Reiser4 flushes dirty pages on basic of atoms, not of inodes.  sync_sb_inodes
used to call address space flushing method (writepages) for every dirty inode.
 For reiser4 it caused having to commit atoms unnecessarily often.  This
turned into substantial slowdown.  Having this method helped to fix that
problem.

Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/fs/fs-writeback.c  |   11 ++++++++++-
 25-akpm/include/linux/fs.h |    2 ++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff -puN fs/fs-writeback.c~reiser4-sb_sync_inodes fs/fs-writeback.c
--- 25/fs/fs-writeback.c~reiser4-sb_sync_inodes	2004-12-03 20:56:55.993247920 -0800
+++ 25-akpm/fs/fs-writeback.c	2004-12-03 20:56:55.998247160 -0800
@@ -301,7 +301,7 @@ __writeback_single_inode(struct inode *i
  * throttled threads: we don't want them all piling up on __wait_on_inode.
  */
 static void
-sync_sb_inodes(struct super_block *sb, struct writeback_control *wbc)
+generic_sync_sb_inodes(struct super_block *sb, struct writeback_control *wbc)
 {
 	const unsigned long start = jiffies;	/* livelock avoidance */
 
@@ -387,6 +387,15 @@ sync_sb_inodes(struct super_block *sb, s
 	return;		/* Leave any unwritten inodes on s_io */
 }
 
+static void
+sync_sb_inodes(struct super_block *sb, struct writeback_control *wbc)
+{
+	if (sb->s_op->sync_inodes)
+		sb->s_op->sync_inodes(sb, wbc);
+	else
+		generic_sync_sb_inodes(sb, wbc);
+}
+
 /*
  * Start writeback of dirty pagecache data against all unlocked inodes.
  *
diff -puN include/linux/fs.h~reiser4-sb_sync_inodes include/linux/fs.h
--- 25/include/linux/fs.h~reiser4-sb_sync_inodes	2004-12-03 20:56:55.994247768 -0800
+++ 25-akpm/include/linux/fs.h	2004-12-03 20:56:55.999247008 -0800
@@ -1003,6 +1003,8 @@ struct super_operations {
 	void (*clear_inode) (struct inode *);
 	void (*umount_begin) (struct super_block *);
 
+	void (*sync_inodes) (struct super_block *sb,
+				struct writeback_control *wbc);
 	int (*show_options)(struct seq_file *, struct vfsmount *);
 
 	ssize_t (*quota_read)(struct super_block *, int, char *, size_t, loff_t);
_
