Merge patch series "writeback: fix timestamp and dirty-state handling in wb switches"

Julian Sun <sunjunchao@bytedance.com> says:

This series fixes two issues when moving inodes between writeback
structures:

1. Update dirtied_when rather than dirtied_time_when when inserting an
   inode at the newest end of the target dirty list. This maintains the
   list ordering without resetting the lazytime expiration timestamp.
2. Clear the source wb's dirty-I/O state and bandwidth contribution when
   inode migration leaves its dirty-I/O lists empty.

* patches from https://patch.msgid.link/20261016115230.3640770-1-sunjunchao@bytedance.com:
  writeback: clear old wb dirty state after inode switches
  writeback: reset dirtied_when when switching wbs

Link: https://patch.msgid.link/20261016115230.3640770-1-sunjunchao@bytedance.com
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
This commit is contained in:
Christian Brauner 2026-10-21 12:19:14 +02:00
commit 46e66d41fa
No known key found for this signature in database
GPG Key ID: 91C61BC06578DCA2
2 changed files with 7 additions and 4 deletions

View File

@ -468,12 +468,12 @@ static bool inode_do_switch_wbs(struct inode *inode,
if (inode_state_read(inode) & I_DIRTY_ALL) {
/*
* We need to keep b_dirty list sorted by
* dirtied_time_when. However properly sorting the
* dirtied_when. However properly sorting the
* inode in the list gets too expensive when switching
* many inodes. So just attach inode at the end of the
* dirty list and clobber the dirtied_time_when.
* dirty list and clobber the dirtied_when.
*/
inode->dirtied_time_when = jiffies;
inode->dirtied_when = jiffies;
inode_io_list_move_locked(inode, new_wb,
&new_wb->b_dirty);
} else {
@ -566,6 +566,7 @@ static void process_inode_switch_wbs(struct bdi_writeback *new_wb,
}
}
wb_io_lists_depopulated(old_wb);
spin_unlock(&new_wb->list_lock);
spin_unlock(&old_wb->list_lock);

View File

@ -815,7 +815,9 @@ struct inode {
/* 32-bit hole */
struct rw_semaphore i_rwsem;
unsigned long dirtied_when; /* jiffies of first dirtying */
/* Timestamp for writeback list ordering and age checks (jiffies). */
unsigned long dirtied_when;
/* Start time for deciding when lazytime updates need writeback (jiffies). */
unsigned long dirtied_time_when;
struct hlist_node i_hash;