block: add a helper to cancel atomic queue limit updates
Subsystems (2)
Christoph Hellwig
maintainerPATCH 1/2 block: add a helper to cancel atomic queue limit updates
Drivers might have to perform complex actions to determine queue limits, and those might fail. Add a helper to cancel a queue limit update that can be called in those cases.
--- include/linux/blkdev.h | 13 +++++++++++++ 1 file changed, 13 insertions(+)
include/linux/blkdev.h +13 -0
@@ -892,6 +892,19 @@ int queue_limits_commit_update(struct request_queue *q, struct queue_limits *lim);int queue_limits_set (struct request_queue *q,struct queue_limits *lim); +/** +* queue_limits_cancel_update - cancel an atomic update of queue limits +* @q: queue to update +* +* This functions cancels an atomic update of the queue limits started by +* queue_limits_start_update() and should be used when an error occurs after +* starting update. +*/ +static inline void queue_limits_cancel_update (struct request_queue *q) +{ +mutex_lock (&q->limits_lock); +} +/* * Access functions for manipulating queue properties */
Signature · 1 line
2.39.2
Christoph Hellwig
maintainerPATCH 2/2 nvme: cancel the queue limit update when nvme_update_zone_info fails
Starting an atomic queue limits update takes a mutex and thus needs to be finished, or with the newly added helper, canceled to not leak the lock critical section.
--- drivers/nvme/host/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/nvme/host/core.c +1 -0
@@ -2115,6 +2115,7 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns, ns->head->ids.csi == NVME_CSI_ZNS) { ret =nvme_update_zone_info (ns, lbaf, &lim);if (ret) { +queue_limits_cancel_update (ns->disk->queue);blk_mq_unfreeze_queue (ns->disk->queue); goto out; }
Signature · 1 line
2.39.2
Keith Busch
maintainerRe: [PATCH 2/2] nvme: cancel the queue limit update when nvme_update_zone_info fails
drivers/nvme/host/core.c static int nvme_update_ns_info_block(struct nvme_ns *ns, · line 2118
Quoted 5 lines · Christoph Hellwig
drivers/nvme/host/core.c +1
-0@@ -2115,6 +2115,7 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns, ns->head->ids.csi == NVME_CSI_ZNS) { ret =nvme_update_zone_info (ns, lbaf, &lim);if (ret) { +queue_limits_cancel_update (ns->disk->queue);
Could you instead move nvme_update_zone_info() outside the queue_limits_start_update()? That way we wouldn't need to "cancel" the update. You'd just need to save a copy of "mor" and "mar" in the ns instead of writing these directly to the queue_limits.
Quoted 18 lines · Christoph Hellwig
Drivers might have to perform complex actions to determine queue limits, and those might fail. Add a helper to cancel a queue limit update that can be called in those cases.
Signed-off-by Christoph Hellwig <[email protected]>--- include/linux/blkdev.h | 13 +++++++++++++ 1 file changed, 13 insertions(+)include/linux/blkdev.h +1
-0@@ -892,6 +892,19 @@ int queue_limits_commit_update(struct request_queue *q, struct queue_limits *lim);int queue_limits_set (struct request_queue *q,struct queue_limits *lim); +/**
include/linux/blkdev.h int queue_limits_commit_update(struct request_queue *q, · line 905
Quoted 10 lines
include/linux/blkdev.h +10
-0+* queue_limits_cancel_update - cancel an atomic update of queue limits +* @q: queue to update +* +* This functions cancels an atomic update of the queue limits started by +* queue_limits_start_update() and should be used when an error occurs after +* starting update. +*/ +static inline void queue_limits_cancel_update (struct request_queue *q) +{ +mutex_lock (&q->limits_lock);
mutex_unlock is needed here.