Linux block layer
 help / color / mirror / Atom feed
From: Guixin Liu <kanie@linux.alibaba.com>
To: Jens Axboe <axboe@kernel.dk>, Christoph Hellwig <hch@lst.de>,
	Tejun Heo <tj@kernel.org>, Josef Bacik <josef@toxicpanda.com>,
	Nilay Shroff <nilay@linux.ibm.com>,
	Ming Lei <ming.lei@redhat.com>, Hannes Reinecke <hare@suse.de>
Cc: linux-block@vger.kernel.org
Subject: [PATCH 0/7] block fixes found by code inspection
Date: Thu, 19 Nov 2026 15:05:41 +0800	[thread overview]
Message-ID: <20261119070548.3125491-1-kanie@linux.alibaba.com> (raw)

Seven block layer fixes, all found by code inspection of the tags SRCU
lifetime, the hctx reuse path, and the blk-cgroup configuration writers.

Patch 1 and patch 7 close the two halves of the tags_srcu protection for
tag iterators: patch 1 frees the tags->rqs[] and tags->static_rqs[]
arrays in the SRCU callback together with the bitmaps, patch 7 unpublishes
set->tags[] before the grace period starts, so a reader can no longer
load a pointer that the grace period has already released.

Patch 2 clears a stale BLK_MQ_S_STOPPED flag when a parked hctx is
reused, so requests queued on it do not stall until the driver happens
to stop and restart the queue again.

Patch 3 and patch 4 fix the locking order of ioc_cost_model_write():
patch 3 releases rq_qos_mutex before freezing the queue like
ioc_qos_write() does, patch 4 moves the unfreeze in ioc_qos_write()
ahead of the bdev reference drop, closing the same lifetime gap in both
writers.

Patch 5 fixes the mean folding in blk_rq_stat_sum(), which silently
dropped the samples of an already folded source and kept
blk-iolatency's accumulated window mean at zero on rotating disks.

Patch 6 rejects a dead disk in the three lazy policy init helpers, so a
configuration write racing del_gendisk() can no longer attach an orphan
iocost/iolatency/throttle policy that nothing tears down again.

Found by code inspection.

Tested on a KVM q35 guest with a 7.4-rc1 based kernel (PROVE_LOCKING
enabled): hctx state flags after a stop/shrink/start/grow cycle on
nullb0 show no stale flags and IO on the reused hctx completes; iocost
cost.model and cost.qos writes against a live and a removed nullb
device behave as expected, with the removed device rejected with
-ENODEV and the live device accepting all model, qos and coefficient
writes; concurrent nullb submit_queues resizes against continuous
debugfs busy/tags reads under fio ran for six minutes without errors.

Guixin Liu (7):
  blk-mq: free the rqs arrays of tags in the SRCU callback
  blk-mq: clear stale stopped flag on hctx reuse
  blk-iocost: don't take rq_qos_mutex before the queue is frozen in cost
    model write
  blk-iocost: unfreeze the queue before dropping the bdev reference in
    qos write
  blk-stat: account for the mean of the source in blk_rq_stat_sum()
  blk-cgroup: don't attach a qos policy to a dead disk
  blk-mq: unpublish the tags before deferring their free to SRCU

 block/blk-iocost.c    | 19 ++++++++++++++-----
 block/blk-iolatency.c |  3 +++
 block/blk-mq-tag.c    |  2 ++
 block/blk-mq.c        | 24 +++++++-----------------
 block/blk-mq.h        |  1 -
 block/blk-stat.c      |  8 ++++++--
 block/blk-throttle.c  |  3 +++
 7 files changed, 35 insertions(+), 25 deletions(-)

--
2.43.7


             reply	other threads:[~2026-11-19  7:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19  7:05 Guixin Liu [this message]
2026-11-19  7:05 ` [PATCH 1/7] blk-mq: free the rqs arrays of tags in the SRCU callback Guixin Liu
2026-11-19  7:05 ` [PATCH 2/7] blk-mq: clear stale stopped flag on hctx reuse Guixin Liu
2026-11-19  7:05 ` [PATCH 3/7] blk-iocost: don't take rq_qos_mutex before the queue is frozen in cost model write Guixin Liu
2026-11-19  7:05 ` [PATCH 4/7] blk-iocost: unfreeze the queue before dropping the bdev reference in qos write Guixin Liu
2026-11-19  7:05 ` [PATCH 5/7] blk-stat: account for the mean of the source in blk_rq_stat_sum() Guixin Liu
2026-11-19  7:05 ` [PATCH 6/7] blk-cgroup: don't attach a qos policy to a dead disk Guixin Liu
2026-11-19  7:05 ` [PATCH 7/7] blk-mq: unpublish the tags before deferring their free to SRCU Guixin Liu

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=20261119070548.3125491-1-kanie@linux.alibaba.com \
    --to=kanie@linux.alibaba.com \
    --cc=axboe@kernel.dk \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=josef@toxicpanda.com \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=nilay@linux.ibm.com \
    --cc=tj@kernel.org \
    /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