Commit 65d466b62984 ("blk-mq-debugfs: warn about possible deadlock")
added WARN_ONCE_ON() to debugfs_create_files() to prevent potential
deadlock if the queue is frozen. We hit this warning with the stacktrace
below
WARNING: block/blk-mq-debugfs.c:620 at debugfs_create_files+0x9c/0x1d0
Workqueue: nvme-wq nvme_tcp_reconnect_ctrl_work [nvme_tcp]
RIP: 0010:debugfs_create_files+0x9c/0x1d0
Call Trace:
blk_mq_debugfs_register_hctx+0x186/0x320
blk_mq_debugfs_register_hctxs+0x80/0xa0
blk_mq_update_nr_hw_queues+0xc8f/0xd50
nvme_tcp_setup_ctrl+0xcfa/0xda0 [nvme_tcp]
nvme_tcp_reconnect_ctrl_work+0x51/0x180 [nvme_tcp]
process_scheduled_works+0x840/0xd80
worker_thread+0x36d/0x4a0
kthread+0x366/0x380
ret_from_fork+0x7b/0x670
ret_from_fork_asm+0x1a/0x30
Here __blk_mq_update_nr_hw_queues() did set PF_MEMALLOC_NOIO flag before
calling blk_mq_debugfs_register_hctxs() and this should guarantee the
described deadlock will not happen. Warn only if the queue is frozen and
NOIO flag is not set.
Fixes: 65d466b62984 ("blk-mq-debugfs: warn about possible deadlock")
Signed-off-by: Mohamed Khalfella
---
block/blk-mq-debugfs.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index faeaa1fc86a7..ec6670dc0a3d 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -612,12 +612,14 @@ static void debugfs_create_files(struct request_queue *q, struct dentry *parent,
void *data,
const struct blk_mq_debugfs_attr *attr)
{
+ unsigned int pflags = READ_ONCE(current->flags);
+
lockdep_assert_held(&q->debugfs_mutex);
/*
* Creating new debugfs entries with queue freezed has the risk of
* deadlock.
*/
- WARN_ON_ONCE(q->mq_freeze_depth != 0);
+ WARN_ON_ONCE((q->mq_freeze_depth != 0) && !(pflags & PF_MEMALLOC_NOIO));
/*
* debugfs_mutex should not be nested under other locks that can be
* grabbed while queue is frozen.
base-commit: cd7a5651db263b5384aef1950898e5e889425134
--
2.52.0