]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - fs/sync.c
vfs: Make sys_sync() use fsync_super() (version 4)
[net-next-2.6.git] / fs / sync.c
index ec95a69d17aa73e058bedd5c61e42d23f87a4f91..be0798cc33d78608aa4c702697e383573b9e8421 100644 (file)
--- a/fs/sync.c
+++ b/fs/sync.c
 #include <linux/pagemap.h>
 #include <linux/quotaops.h>
 #include <linux/buffer_head.h>
+#include "internal.h"
 
 #define VALID_FLAGS (SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE| \
                        SYNC_FILE_RANGE_WAIT_AFTER)
 
-/*
- * sync everything.  Start out by waking pdflush, because that writes back
- * all queues in parallel.
- */
-static void do_sync(unsigned long wait)
+SYSCALL_DEFINE0(sync)
 {
-       wakeup_pdflush(0);
-       sync_inodes(0);         /* All mappings, inodes and their blockdevs */
-       DQUOT_SYNC(NULL);
-       sync_supers();          /* Write the superblocks */
-       sync_filesystems(0);    /* Start syncing the filesystems */
-       sync_filesystems(wait); /* Waitingly sync the filesystems */
-       sync_inodes(wait);      /* Mappings, inodes and blockdevs, again. */
-       if (!wait)
-               printk("Emergency Sync complete\n");
+       sync_filesystems(0);
+       sync_filesystems(1);
        if (unlikely(laptop_mode))
                laptop_sync_completion();
-}
-
-SYSCALL_DEFINE0(sync)
-{
-       do_sync(1);
        return 0;
 }
 
 static void do_sync_work(struct work_struct *work)
 {
-       do_sync(0);
+       /*
+        * Sync twice to reduce the possibility we skipped some inodes / pages
+        * because they were temporarily locked
+        */
+       sync_filesystems(0);
+       sync_filesystems(0);
+       printk("Emergency Sync complete\n");
        kfree(work);
 }