void __sync_inodes (int wait);
sync_inodes goes through each super block's dirty inode list, writes the inodes out, waits on the writeout and puts the inodes back on the normal list.
This is for sys_sync. fsync_dev uses the same algorithm. The subtle part of the sync functions is that the blockdev ``superblock'' is processed last. This is because the write_inode function of a typical fs will perform no I/O, but will mark buffers in the blockdev mapping as dirty. What we want to do is to perform all that dirtying first, and then write back all those inode blocks via the blockdev mapping in one sweep. So the additional (somewhat redundant) sync_blockdev calls here are to make sure that really happens. Because if we call sync_inodes_sb(wait=1) with outstanding dirty inodes, the writeback goes block-at-a-time within the filesystem's write_inode. This is extremely slow.