[PATCH] Fix unconditional write_super() call in file_fsync()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: OGAWA Hirofumi
Date: Tuesday, April 22, 2008 - 5:06 am

This fixes file_fsync(). we need to check ->s_dirt before calling
write_super(). It became the cause of an unneeded write.

This bug was noticed by Sudhanshu Saxena.

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
---

 fs/sync.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -puN fs/sync.c~file_fsync-fix fs/sync.c
--- linux-2.6/fs/sync.c~file_fsync-fix	2008-04-22 15:14:50.000000000 +0900
+++ linux-2.6-hirofumi/fs/sync.c	2008-04-22 15:16:58.000000000 +0900
@@ -64,7 +64,7 @@ int file_fsync(struct file *filp, struct
 	/* sync the superblock to buffers */
 	sb = inode->i_sb;
 	lock_super(sb);
-	if (sb->s_op->write_super)
+	if (sb->s_dirt && sb->s_op->write_super)
 		sb->s_op->write_super(sb);
 	unlock_super(sb);
 
_

-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] Fix unconditional write_super() call in file_fsync(), OGAWA Hirofumi, (Tue Apr 22, 5:06 am)