Re: [PATCH v12] nvmet: add cgroup_id to charge namespace I/O to a cgroup

From: Tejun Heo

Date: Thu Nov 05 2026 - 13:49:35 EST


On Tue, Nov 03, 2026 at 11:16:00PM -0800, Peng Yu wrote:
> +/*
> + * A command of a namespace with a cgroup already runs from its own work
> + * item on the namespace's workqueue (see nvmet_blkcg_work()), so run the
> + * backend's work function right there; otherwise queue it on @wq.
> + */
> +static inline void nvmet_req_run_work(struct nvmet_req *req,
> + struct workqueue_struct *wq, struct work_struct *work,
> + work_func_t func)
> +{
> +#ifdef CONFIG_BLK_CGROUP
> + if (req->ns->blkcg_wq) {
> + func(work);
> + return;
> + }
> +#endif
> + INIT_WORK(work, func);
> + queue_work(wq, work);
> +}

With cgroup_id set, the file backend's Flush, DSM and Write Zeroes and
zone management now run synchronously in the command's blkcg_wq work
item and hold one of its max_active slots for the whole vfs_fsync(),
vfs_fallocate() or zone operation. This probably deserves at least a
comment. Can you add one?

>From the cgroup and workqueue side,

Acked-by: Tejun Heo <tj@xxxxxxxxxx>

Thanks.

--
tejun