diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 1f192a581fb2..ac612c02ced9 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -790,6 +790,13 @@ bool cleanup_offline_cgwb(struct bdi_writeback *wb) new_wb = &wb->bdi->wb; /* wb_get() is noop for bdi's wb */ nr = 0; + /* + * The scan moves walked inodes to the newest end of b_dirty_time, + * past ones it didn't reach. If one of those was dirtied after a + * sync's cutoff, the sync's queue_io() stops there and misses the + * moved ones. Exclude syncs as process_inode_switch_wbs() does. + */ + down_read(&wb->bdi->wb_switch_rwsem); spin_lock(&wb->list_lock); /* * In addition to the inodes that have completed writeback, also switch @@ -804,6 +811,7 @@ bool cleanup_offline_cgwb(struct bdi_writeback *wb) restart = isw_prepare_wbs_switch(new_wb, isw, &wb->b_dirty_time, &nr); spin_unlock(&wb->list_lock); + up_read(&wb->bdi->wb_switch_rwsem); /* no attached inodes? bail out */ if (nr == 0) {