wakeup_flusher_threads(0) will queue work doing complete writeback for eachflusher thread. Thus there is not much point in submitting another work doingfull inode WB_SYNC_NONE writeback by writeback_inodes_sb().

After this change it does not make sense to call nonblocking ->sync_fs andblock device flush before calling sync_inodes_sb() becausewakeup_flusher_threads() is completely asynchronous and thus these functionswould be called in parallel with inode writeback running which will effectivelyvoid any work they do. So we move sync_inodes_sb() call before these twofunctions.

/*- * sync everything. Start out by waking pdflush, because that writes back- * all queues in parallel.+ * Sync everything. We start by waking flusher threads so that most of+ * writeback runs on all devices in parallel. Then we sync all inodes reliably+ * which effectively also waits for all flusher threads to finish doing+ * writeback. At this point all data is on disk so metadata should be stable+ * and we tell filesystems to sync their metadata via ->sync_fs() calls.+ * Finally, we writeout all block devices because some filesystems (e.g. ext2)+ * just write metadata (such as inodes or bitmaps) to block device page cache+ * and do not sync it on their own in ->sync_fs(). */ SYSCALL_DEFINE0(sync) { int nowait = 0, wait = 1;