Skip to contentSkip to conversation

tcmu: wait for nl reply only if there are listeners

PATCH Applied Mike Christie 3 participants 5 messages Feb 2, 2019 – Mar 6, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tcmu: wait for nl reply only if there are listeners

genlmsg_multicast_allns used to return -ESRCH even if the message was successfully sent to a listener. With commit:

commit cb9f7a9a5c96a773bbc9c70660dc600cfff82f82

Author: Nicolas Dichtel <[email protected]>
Date:   Tue Feb 6 14:48:32 2018 +0100

netlink: ensure to loop over all netns in genlmsg_multicast_allns()

it now will return success if the message was sent to a listener. With that patch, tcmu can now immediately fail if -ESRCH is returned because we know there will be no reply.

---
 drivers/target/target_core_user.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/target/target_core_user.c +0 -3
index 5831e0e..dccc13c 100644
@@ -1794,9 +1794,6 @@ static int tcmu_netlink_event_send(struct tcmu_dev *udev,
 
 	ret = genlmsg_multicast_allns(&tcmu_genl_family, skb, 0,
 				      TCMU_MCGRP_CONFIG, GFP_KERNEL);
-	/* We don't care if no one is listening */
-	if (ret = -ESRCH)
-		ret = 0;
 	if (!ret)
 		ret = tcmu_wait_genl_cmd_reply(udev);
 	return ret;
Signature · 1 line
1.8.3.1
#1 lore raw

Martin, I am self nacking this patch for now.

Quoted 34 lines · Mike Christie

genlmsg_multicast_allns used to return -ESRCH even if the message was successfully sent to a listener. With commit:

commit cb9f7a9a5c96a773bbc9c70660dc600cfff82f82

Author: Nicolas Dichtel <[email protected]>
Date:   Tue Feb 6 14:48:32 2018 +0100

netlink: ensure to loop over all netns in genlmsg_multicast_allns()

it now will return success if the message was sent to a listener. With that patch, tcmu can now immediately fail if -ESRCH is returned because we know there will be no reply.

---
 drivers/target/target_core_user.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/target/target_core_user.c +0 -3
index 5831e0e..dccc13c 100644
@@ -1794,9 +1794,6 @@ static int tcmu_netlink_event_send(struct tcmu_dev *udev,
 
 	ret = genlmsg_multicast_allns(&tcmu_genl_family, skb, 0,
 				      TCMU_MCGRP_CONFIG, GFP_KERNEL);
-	/* We don't care if no one is listening */
-	if (ret = -ESRCH)
-		ret = 0;
 	if (!ret)
 		ret = tcmu_wait_genl_cmd_reply(udev);
 	return ret;
#2 lore raw

PATCH 1/1 tcmu: wait for nl reply only if there are listeners or during an add

In reply to Mike Christie

genlmsg_multicast_allns now returns the correct statuses when a message is sent to a listener. However in the case of adding a device we want to wait for the listener otherwise we may miss the the device during startup.

---
 drivers/target/target_core_user.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/target/target_core_user.c +6 -5
index 5831e0eecea1..2d3f8f5403d8 100644
@@ -1794,11 +1794,12 @@ static int tcmu_netlink_event_send(struct tcmu_dev *udev,
 
 	ret = genlmsg_multicast_allns(&tcmu_genl_family, skb, 0,
 				      TCMU_MCGRP_CONFIG, GFP_KERNEL);
-	/* We don't care if no one is listening */
-	if (ret = -ESRCH)
-		ret = 0;
-	if (!ret)
-		ret = tcmu_wait_genl_cmd_reply(udev);
+
+	/* Wait during an add as the listener may not be up yet */
+	if (ret = 0 ||
+	   (ret = -ESRCH && cmd = TCMU_CMD_ADDED_DEVICE))
+		return tcmu_wait_genl_cmd_reply(udev);
+
 	return ret;
 }
 
Signature · 1 line
2.19.1
author Acked-by on v1 1/1
#3 lore raw

Re: [PATCH] tcmu: wait for nl reply only if there are listeners or during an add

In reply to Mike Christie
Quoted 21 lines · Cathy Avery

genlmsg_multicast_allns now returns the correct statuses when a message is sent to a listener. However in the case of adding a device we want to wait for the listener otherwise we may miss the the device during startup.

---
 drivers/target/target_core_user.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/target/target_core_user.c +0 -3
index 5831e0eecea1..2d3f8f5403d8 100644
@@ -1794,11 +1794,12 @@ static int tcmu_netlink_event_send(struct tcmu_dev *udev,
 
 	ret = genlmsg_multicast_allns(&tcmu_genl_family, skb, 0,
 				      TCMU_MCGRP_CONFIG, GFP_KERNEL);
-	/* We don't care if no one is listening */
-	if (ret = -ESRCH)
-		ret = 0;

drivers/target/target_core_user.c static int tcmu_netlink_event_send(struct tcmu_dev *udev, · line 1804

Quoted 10 lines
drivers/target/target_core_user.c +6 -2
-	if (!ret)
-		ret = tcmu_wait_genl_cmd_reply(udev);
+
+	/* Wait during an add as the listener may not be up yet */
+	if (ret = 0 ||
+	   (ret = -ESRCH && cmd = TCMU_CMD_ADDED_DEVICE))
+		return tcmu_wait_genl_cmd_reply(udev);
+
 	return ret;
 }

Looks ok to me.

#4 lore raw

Re: [PATCH] tcmu: wait for nl reply only if there are listeners or during an add

In reply to Mike Christie

Cathy,

Quoted 4 lines

genlmsg_multicast_allns now returns the correct statuses when a message is sent to a listener. However in the case of adding a device we want to wait for the listener otherwise we may miss the the device during startup.

Applied to 5.1/scsi-queue, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering