Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] nvmet: prevent redundant enable/disable of nvmet_port
@ 2025-09-20 23:49 Max Gurtovoy
  2025-09-20 23:49 ` [PATCH 2/3] nvmet: use port's tr_ops in nvmet_disable_port Max Gurtovoy
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Max Gurtovoy @ 2025-09-20 23:49 UTC (permalink / raw)
  To: hch, linux-nvme, kbusch, sagi, kch; +Cc: israelr, Max Gurtovoy

Add early return checks in nvmet_enable_port() and nvmet_disable_port()
to avoid redundant operations if the port is already enabled or
disabled.

Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com>
---
 drivers/nvme/target/core.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index 0dd7bd99afa3..9f5159f04bbd 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -317,6 +317,9 @@ int nvmet_enable_port(struct nvmet_port *port)
 
 	lockdep_assert_held(&nvmet_config_sem);
 
+	if (port->enabled)
+		return 0;
+
 	if (port->disc_addr.trtype == NVMF_TRTYPE_MAX)
 		return -EINVAL;
 
@@ -382,6 +385,9 @@ void nvmet_disable_port(struct nvmet_port *port)
 
 	lockdep_assert_held(&nvmet_config_sem);
 
+	if (!port->enabled)
+		return;
+
 	port->enabled = false;
 	port->tr_ops = NULL;
 
-- 
2.18.1



^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-09-22 21:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-20 23:49 [PATCH 1/3] nvmet: prevent redundant enable/disable of nvmet_port Max Gurtovoy
2025-09-20 23:49 ` [PATCH 2/3] nvmet: use port's tr_ops in nvmet_disable_port Max Gurtovoy
2025-09-22 17:33   ` Christoph Hellwig
2025-09-20 23:49 ` [PATCH 3/3] nvmet: replace transports array with a linked list Max Gurtovoy
2025-09-22 17:35   ` Christoph Hellwig
2025-09-22 21:19     ` Max Gurtovoy
2025-09-22 21:27       ` Keith Busch
2025-09-22 21:45         ` Max Gurtovoy
2025-09-22 17:33 ` [PATCH 1/3] nvmet: prevent redundant enable/disable of nvmet_port Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox