fs: mpage: account cgroup ownership after the folio is added to the bio
PATCH 1/1 fs: mpage: account cgroup ownership after the folio is added to the bio
mpage_write_folio() accounts the folio before trying to add it to the bio. When bio_add_folio() fails, the bio is submitted and the folio is retried from alloc_new, which accounts the same folio again. A folio that needs several attempts is therefore counted several times in the round's cgroup ownership arbitration.
Account the folio after bio_add_folio() succeeded. Failed attempts no longer contribute, successful ones contribute exactly once, and the bio submission order is unchanged.
Signed-off-by Xavier Xia <[email protected]>
--- fs/mpage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/mpage.c +1 -1
@@ -607,12 +607,12 @@ static int mpage_write_folio(struct writeback_control *wbc, struct folio *folio,* the confused fail path above (OOM) will be very confused when * it finds all bh marked clean (i.e. it will not write anything) */ -wbc_account_cgroup_owner (wbc, folio,folio_size (folio)); length = first_unmapped << blkbits;if (!bio_add_folio (bio, folio, length,0 )) { bio =mpage_bio_submit_write (bio); goto alloc_new; } +wbc_account_cgroup_owner (wbc, folio,folio_size (folio));clean_buffers (folio, first_unmapped);