[PATCH 5/5] mm: simplify bdi refcounting

Christoph Hellwig hch at lst.de
Wed Oct 27 00:42:07 PDT 2021


On Fri, Oct 22, 2021 at 11:02:03AM +0200, Jan Kara wrote:
> On Thu 21-10-21 14:44:41, Christoph Hellwig wrote:
> > Move grabbing and releasing the bdi refcount out of the common
> > wb_init/wb_exit helpers into code that is only used for the non-default
> > memcg driven bdi_writeback structures.
> > 
> > Signed-off-by: Christoph Hellwig <hch at lst.de>
> 
> Can we perhaps add a comment to struct bdi_writeback definition (or maybe
> wb_init()?) mentioning that it holds a reference to 'bdi' if it is
> bdi_writeback struct for a cgroup? I don't see it mentioned anywhere and
> now that you've changed the code, it isn't that obvious from the code
> either... Otherwise the patch looks good so feel free to add:

Like this?

diff --git a/include/linux/backing-dev-defs.h b/include/linux/backing-dev-defs.h
index 33207004cfded..a3d7dd1cc30a1 100644
--- a/include/linux/backing-dev-defs.h
+++ b/include/linux/backing-dev-defs.h
@@ -103,6 +103,9 @@ struct wb_completion {
  * change as blkcg is disabled and enabled higher up in the hierarchy, a wb
  * is tested for blkcg after lookup and removed from index on mismatch so
  * that a new wb for the combination can be created.
+ *
+ * Each bdi_writeback that is no embedded into the backing_dev_info must hold
+ * a reference to the parent backing_dev_info.  See cgwb_create() for details.
  */
 struct bdi_writeback {
 	struct backing_dev_info *bdi;	/* our parent bdi */



More information about the linux-mtd mailing list