@@ -284,23 +284,23 @@ EXPORT_SYMBOL(lock_super);
284284EXPORT_SYMBOL (unlock_super );
285285
286286/*
287- * Write out and wait upon all dirty data associated with this
288- * superblock. Filesystem data as well as the underlying block
289- * device. Takes the superblock lock. Requires a second blkdev
290- * flush by the caller to complete the operation.
287+ * Do the filesystem syncing work. For simple filesystems sync_inodes_sb(sb, 0)
288+ * just dirties buffers with inodes so we have to submit IO for these buffers
289+ * via __sync_blockdev(). This also speeds up the wait == 1 case since in that
290+ * case write_inode() functions do sync_dirty_buffer() and thus effectively
291+ * write one block at a time.
291292 */
292- static int __fsync_super (struct super_block * sb )
293+ static int __fsync_super (struct super_block * sb , int wait )
293294{
294- sync_inodes_sb (sb , 0 );
295295 vfs_dq_sync (sb );
296- sync_inodes_sb (sb , 1 );
296+ sync_inodes_sb (sb , wait );
297297 lock_super (sb );
298298 if (sb -> s_dirt && sb -> s_op -> write_super )
299299 sb -> s_op -> write_super (sb );
300300 unlock_super (sb );
301301 if (sb -> s_op -> sync_fs )
302- sb -> s_op -> sync_fs (sb , 1 );
303- return sync_blockdev (sb -> s_bdev );
302+ sb -> s_op -> sync_fs (sb , wait );
303+ return __sync_blockdev (sb -> s_bdev , wait );
304304}
305305
306306/*
@@ -310,7 +310,12 @@ static int __fsync_super(struct super_block *sb)
310310 */
311311int fsync_super (struct super_block * sb )
312312{
313- return __fsync_super (sb );
313+ int ret ;
314+
315+ ret = __fsync_super (sb , 0 );
316+ if (ret < 0 )
317+ return ret ;
318+ return __fsync_super (sb , 1 );
314319}
315320EXPORT_SYMBOL_GPL (fsync_super );
316321
@@ -469,20 +474,18 @@ void sync_supers(void)
469474}
470475
471476/*
472- * Call the ->sync_fs super_op against all filesystems which are r/w and
473- * which implement it.
477+ * Sync all the data for all the filesystems (called by sys_sync() and
478+ * emergency sync)
474479 *
475480 * This operation is careful to avoid the livelock which could easily happen
476- * if two or more filesystems are being continuously dirtied. s_need_sync_fs
481+ * if two or more filesystems are being continuously dirtied. s_need_sync
477482 * is used only here. We set it against all filesystems and then clear it as
478483 * we sync them. So redirtied filesystems are skipped.
479484 *
480485 * But if process A is currently running sync_filesystems and then process B
481- * calls sync_filesystems as well, process B will set all the s_need_sync_fs
486+ * calls sync_filesystems as well, process B will set all the s_need_sync
482487 * flags again, which will cause process A to resync everything. Fix that with
483488 * a local mutex.
484- *
485- * (Fabian) Avoid sync_fs with clean fs & wait mode 0
486489 */
487490void sync_filesystems (int wait )
488491{
@@ -492,25 +495,23 @@ void sync_filesystems(int wait)
492495 mutex_lock (& mutex ); /* Could be down_interruptible */
493496 spin_lock (& sb_lock );
494497 list_for_each_entry (sb , & super_blocks , s_list ) {
495- if (!sb -> s_op -> sync_fs )
496- continue ;
497498 if (sb -> s_flags & MS_RDONLY )
498499 continue ;
499- sb -> s_need_sync_fs = 1 ;
500+ sb -> s_need_sync = 1 ;
500501 }
501502
502503restart :
503504 list_for_each_entry (sb , & super_blocks , s_list ) {
504- if (!sb -> s_need_sync_fs )
505+ if (!sb -> s_need_sync )
505506 continue ;
506- sb -> s_need_sync_fs = 0 ;
507+ sb -> s_need_sync = 0 ;
507508 if (sb -> s_flags & MS_RDONLY )
508509 continue ; /* hm. Was remounted r/o meanwhile */
509510 sb -> s_count ++ ;
510511 spin_unlock (& sb_lock );
511512 down_read (& sb -> s_umount );
512513 if (sb -> s_root )
513- sb -> s_op -> sync_fs (sb , wait );
514+ __fsync_super (sb , wait );
514515 up_read (& sb -> s_umount );
515516 /* restart only when sb is no longer on the list */
516517 spin_lock (& sb_lock );
@@ -521,33 +522,6 @@ void sync_filesystems(int wait)
521522 mutex_unlock (& mutex );
522523}
523524
524- #ifdef CONFIG_BLOCK
525- /*
526- * Sync all block devices underlying some superblock
527- */
528- void sync_blockdevs (void )
529- {
530- struct super_block * sb ;
531-
532- spin_lock (& sb_lock );
533- restart :
534- list_for_each_entry (sb , & super_blocks , s_list ) {
535- if (!sb -> s_bdev )
536- continue ;
537- sb -> s_count ++ ;
538- spin_unlock (& sb_lock );
539- down_read (& sb -> s_umount );
540- if (sb -> s_root )
541- sync_blockdev (sb -> s_bdev );
542- up_read (& sb -> s_umount );
543- spin_lock (& sb_lock );
544- if (__put_super_and_need_restart (sb ))
545- goto restart ;
546- }
547- spin_unlock (& sb_lock );
548- }
549- #endif
550-
551525/**
552526 * get_super - get the superblock of a device
553527 * @bdev: device to get the superblock for
0 commit comments