From: Damien Le Moal <dlemoal@kernel.org>
To: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>,
linux-scsi@vger.kernel.org, linux-block@vger.kernel.org
Cc: Christoph Hellwig <hch@lst.de>,
Coelho@web.codeaurora.org, Luciano <luciano.coelho@intel.com>,
Saarinen@web.codeaurora.org, Jani <jani.saarinen@intel.com>
Subject: Re: [PATCH] scsi: sd: Move sd_read_cpr() out of the q->limits_lock region
Date: Thu, 1 Aug 2024 16:09:44 +0900 [thread overview]
Message-ID: <c4ab8a9e-aca5-43c5-a49b-6bb4307d8757@kernel.org> (raw)
In-Reply-To: <20240801054234.540532-1-shinichiro.kawasaki@wdc.com>
On 8/1/24 2:42 PM, Shin'ichiro Kawasaki wrote:
> Commit 804e498e0496 ("sd: convert to the atomic queue limits API")
> introduced pairs of function calls to queue_limits_start_update() and
> queue_limits_commit_update(). These two functions lock and unlock
> q->limits_lock. In sd_revalidate_disk(), sd_read_cpr() is called after
> queue_limits_start_update() call and before
> queue_limits_commit_update() call. sd_read_cpr() locks q->sysfs_dir_lock
> and &q->sysfs_lock. Then new lock dependencies were created between
> q->limits_lock, q->sysfs_dir_lock and q->sysfs_lock, as follows:
>
> sd_revalidate_disk
> queue_limits_start_update
> mutex_lock(&q->limits_lock)
> sd_read_cpr
> disk_set_independent_access_ranges
> mutex_lock(&q->sysfs_dir_lock)
> mutex_lock(&q->sysfs_lock)
> mutex_unlock(&q->sysfs_lock)
> mutex_unlock(&q->sysfs_dir_lock)
> queue_limits_commit_update
> mutex_unlock(&q->limits_lock)
>
> However, the three locks already had reversed dependencies in other
> places. Then the new dependencies triggered the lockdep WARN "possible
> circular locking dependency detected" [1]. This WARN was observed by
> running the blktests test case srp/002.
>
> To avoid the WARN, move the sd_read_cpr() call in sd_revalidate_disk()
> after the queue_limits_commit_update() call. In other words, move the
> sd_read_cpr() call out of the q->limits_lock region.
>
> [1] https://lore.kernel.org/linux-scsi/vlmv53ni3ltwxplig5qnw4xsl2h6ccxijfbqzekx76vxoim5a5@dekv7q3es3tx/
>
> Fixes: 804e498e0496 ("sd: convert to the atomic queue limits API")
> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Given that sd_read_cpr() does not change any limit, looks good to me.
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2024-08-01 7:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-01 5:42 [PATCH] scsi: sd: Move sd_read_cpr() out of the q->limits_lock region Shin'ichiro Kawasaki
2024-08-01 5:49 ` Coelho, Luciano
2024-08-01 7:09 ` Damien Le Moal [this message]
2024-08-01 14:20 ` Christoph Hellwig
2024-08-01 16:07 ` Bart Van Assche
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=c4ab8a9e-aca5-43c5-a49b-6bb4307d8757@kernel.org \
--to=dlemoal@kernel.org \
--cc=Coelho@web.codeaurora.org \
--cc=Saarinen@web.codeaurora.org \
--cc=hch@lst.de \
--cc=jani.saarinen@intel.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=luciano.coelho@intel.com \
--cc=shinichiro.kawasaki@wdc.com \
/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