The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Baokun Li <libaokun@linux.alibaba.com>
Cc: linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk,
	brauner@kernel.org, jack@suse.cz, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] writeback: fix race between cgroup_writeback_umount() and inode_switch_wbs()
Date: Wed, 13 May 2026 10:36:40 -1000	[thread overview]
Message-ID: <22cda97d61cc9d540d4e7116d5f3f08a@kernel.org> (raw)
In-Reply-To: <20260513094829.867648-1-libaokun@linux.alibaba.com>

Hello,

Resending - earlier send dropped the Cc list. Sorry for the noise.

How rcu_barrier() got out of sync, as best I can reconstruct:

- ec084de929e4 ("fs/writeback.c: use rcu_barrier() to wait for inflight
  wb switches going into workqueue when umount", 2019) put the inc
  after call_rcu(); rcu_barrier() worked from then.

- 8826ee4fe750 ("writeback, cgroup: increment isw_nr_in_flight before
  grabbing an inode", 2021) moved the inc back ahead to cover the prep
  window, apparently reopening this gap.

- e1b849cfa6b6 ("writeback: Avoid contention on wb->list_lock when
  switching inodes", 2025) replaced call_rcu() with llist_add() +
  queue_work(); rcu_barrier() looks like a no-op for this path since.

Could SRCU work instead? srcu_read_lock around the publish (atomic_inc
through wb_queue_isw), with cgroup_writeback_umount() keeping the
counter gate but swapping rcu_barrier() for synchronize_srcu():

  if (atomic_read(&isw_nr_in_flight)) {
          synchronize_srcu(&isw_srcu);
          flush_workqueue(isw_wq);
  }

Thoughts?

Thanks.

--
tejun

  reply	other threads:[~2026-05-13 20:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-13  9:48 [PATCH] writeback: fix race between cgroup_writeback_umount() and inode_switch_wbs() Baokun Li
2026-05-13 20:36 ` Tejun Heo [this message]
2026-05-14  2:55   ` Baokun Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=22cda97d61cc9d540d4e7116d5f3f08a@kernel.org \
    --to=tj@kernel.org \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=libaokun@linux.alibaba.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox