unsigned long nr_dirty = global_page_state(NR_FILE_DIRTY); unsigned long nr_unstable = global_page_state(NR_UNSTABLE_NFS);

wbc.nr_to_write = nr_dirty + nr_unstable + (inodes_stat.nr_inodes - inodes_stat.nr_unused) + nr_dirty + nr_unstable;

wbc.nr_to_write += wbc.nr_to_write / 2; /* Bit more for luck */

The computed value should usually suffice to cover all dirty pages of the system, but 50 percent more is added. This ensures that absolutely all dirty pages of the inode are written back, but avoids some concurrency problems that can appear if no limit is set on the number of pages that may be written.

Thereafter, the familiar sync_sb_inodes function is invoked to call the low-level synchronization routines of the various filesystems.

□ The low-level synchronization routines of most filesystems simply mark buffers or pages as dirty but do not perform actual writeback. For this reason, the kernel then invokes sync_blockdev to synchronize all mappings of the block device on which the filesystem resides (in this step, the kernel is not restricted to a specific filesystem). This ensures that the data are actually written back.

Continue reading here: Synchronization of Individual Files

Was this article helpful?

0 0