Move the zero-depth check inside the optimized path case to enable early exit. It avoids redundant condition checks for non-optimized paths, and eliminates the per-iteration check at the end of the loop, improving the performance.
Cc: Aviv Coro <[email protected]> Cc: Bart Van Assche <[email protected]> Cc: Benjamin Marzinski <[email protected]> Cc: Brian Bunker <[email protected]> Cc: Caleb Sander <[email protected]> Cc: Chaitanya Kulkarni <[email protected]> Cc: Chris Leech <[email protected]> Cc: Christophe Varoqui <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Clayton Skaggs <[email protected]> Cc: Constantine Gavrilov <[email protected]> Cc: Daniel Wagner <[email protected]> Cc: David SantamarĂa Rogado <[email protected]> Cc: Dmitry V. Levin <[email protected]> Cc: Ewan D. Milne <[email protected]> Cc: Ewan Milne <[email protected]> Cc: Hannes Reinecke <[email protected]> Cc: James Smart <[email protected]> Cc: Jens Axboe <[email protected]> Cc: John Meneghini <[email protected]> Cc: Jyoti Rani <[email protected]> Cc: Keith Busch <[email protected]> Cc: Li Xiaokeng <[email protected]> Cc: Marco Patalano <[email protected]> Cc: Martin Belanger <[email protected]> Cc: Martin George <[email protected]> Cc: Martin Wilck <[email protected]> Cc: Matthias Rudolph <[email protected]> Cc: Maurizio Lombardi <[email protected]> Cc: NetApp RDAC team <[email protected]> Cc: Nilay Shroff <[email protected]> Cc: Randy Jennings <[email protected]> Cc: Sagi Grimberg <[email protected]> Cc: Simon Schricker <[email protected]> Cc: Steven Schremmer <[email protected]> Cc: Thomas Song <[email protected]> Cc: Uday Shankar <[email protected]> Cc: Vasuki Manikarnike <[email protected]> Cc: Wayne Berthiaume <[email protected]> Cc: Zou Ming <[email protected]> Cc: BLOCK-ML <[email protected]> Cc: DM_DEVEL-ML <[email protected]> Cc: NVME-ML <[email protected]> Cc: SCSI-ML <[email protected]> Signed-off-by: Xose Vazquez Perez <[email protected]> --- Status: Compile-tested only. UNTESTED on real hardware. [I do not have access to this kind of hardware] Feedback and testing are highly welcome. --- drivers/nvme/host/multipath.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c index 263161cb8ac0..7d212f6e865d 100644 --- a/drivers/nvme/host/multipath.c +++ b/drivers/nvme/host/multipath.c @@ -409,6 +409,8 @@ static struct nvme_ns *nvme_queue_depth_path(struct nvme_ns_head *head) min_depth_opt = depth; best_opt = ns; } + if (min_depth_opt == 0) + goto out; break; case NVME_ANA_NONOPTIMIZED: if (depth < min_depth_nonopt) { @@ -419,11 +421,8 @@ static struct nvme_ns *nvme_queue_depth_path(struct nvme_ns_head *head) default: break; } - - if (min_depth_opt == 0) - return best_opt; } - +out: return best_opt ? best_opt : best_nonopt; } -- 2.54.0
