
From: Bart Samwel <bart@samwel.tk>

Move the del_timer of the laptop-mode writeback timer to a separate
function "laptop_sync_completion", which is called at the end of do_sync().
That way, the laptop mode writeback timer is also disabled when a regular
sync completes, instead of only when a laptop-mode-induced sync completes.


---

 25-akpm/fs/buffer.c               |    2 ++
 25-akpm/include/linux/writeback.h |    1 +
 25-akpm/mm/page-writeback.c       |   13 ++++++++++---
 3 files changed, 13 insertions(+), 3 deletions(-)

diff -puN fs/buffer.c~laptop-mode-sync-completion fs/buffer.c
--- 25/fs/buffer.c~laptop-mode-sync-completion	2004-04-03 02:45:38.131255520 -0800
+++ 25-akpm/fs/buffer.c	2004-04-03 02:45:38.140254152 -0800
@@ -274,6 +274,8 @@ static void do_sync(unsigned long wait)
 	sync_inodes(wait);	/* Mappings, inodes and blockdevs, again. */
 	if (!wait)
 		printk("Emergency Sync complete\n");
+	if (unlikely(laptop_mode))
+		laptop_sync_completion();
 }
 
 asmlinkage long sys_sync(void)
diff -puN include/linux/writeback.h~laptop-mode-sync-completion include/linux/writeback.h
--- 25/include/linux/writeback.h~laptop-mode-sync-completion	2004-04-03 02:45:38.132255368 -0800
+++ 25-akpm/include/linux/writeback.h	2004-04-03 02:45:38.140254152 -0800
@@ -73,6 +73,7 @@ static inline void wait_on_inode(struct 
  */
 int wakeup_bdflush(long nr_pages);
 void laptop_io_completion(void);
+void laptop_sync_completion(void);
 
 /* These are exported to sysctl. */
 extern int dirty_background_ratio;
diff -puN mm/page-writeback.c~laptop-mode-sync-completion mm/page-writeback.c
--- 25/mm/page-writeback.c~laptop-mode-sync-completion	2004-04-03 02:45:38.134255064 -0800
+++ 25-akpm/mm/page-writeback.c	2004-04-03 02:45:38.141254000 -0800
@@ -402,9 +402,6 @@ static void wb_timer_fn(unsigned long un
 static void laptop_flush(unsigned long unused)
 {
 	sys_sync();
-
-	/* Our writes will have started the laptop-mode timer */
-	del_timer(&laptop_mode_wb_timer);
 }
 
 static void laptop_timer_fn(unsigned long unused)
@@ -423,6 +420,16 @@ void laptop_io_completion(void)
 }
 
 /*
+ * We're in laptop mode and we've just synced. The sync's writes will have
+ * caused another writeback to be scheduled by laptop_io_completion.
+ * Nothing needs to be written back anymore, so we unschedule the writeback.
+ */
+void laptop_sync_completion(void)
+{
+	del_timer(&laptop_mode_wb_timer);
+}
+
+/*
  * If ratelimit_pages is too high then we can get into dirty-data overload
  * if a large number of processes all perform writes at the same time.
  * If it is too low then SMP machines will call the (expensive) get_page_state

_
