Skip to contentSkip to conversation

nbd: remove the duplicated code

PATCH In review [email protected] 2 participants 3 messages Sep 10, 2019

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

PATCH 1/1 nbd: remove the duplicated code

From: Xiubo Li <[email protected]>

The followed code will do the same check, and this part is redandant.

---
 drivers/block/nbd.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/block/nbd.c +0 -3
index 478aa86fc1f2..8c10ab51a086 100644
@@ -1046,9 +1046,6 @@ static int nbd_reconnect_socket(struct nbd_device *nbd, unsigned long arg)
 	for (i = 0; i < config->num_connections; i++) {
 		struct nbd_sock *nsock = config->socks[i];
 
-		if (!nsock->dead)
-			continue;
-
 		mutex_lock(&nsock->tx_lock);
 		if (!nsock->dead) {
 			mutex_unlock(&nsock->tx_lock);
Signature · 1 line
2.21.0
#1 lore raw
Quoted 14 lines · On 09/10/2019 01:36 AM, [email protected] wrote:

From: Xiubo Li <[email protected]>

The followed code will do the same check, and this part is redandant.

---
 drivers/block/nbd.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/block/nbd.c +0 -0
index 478aa86fc1f2..8c10ab51a086 100644

drivers/block/nbd.c static int nbd_reconnect_socket(struct nbd_device *nbd, unsigned long arg) · line 1051

Quoted 6 lines
drivers/block/nbd.c +0 -3
@@ -1046,9 +1046,6 @@ static int nbd_reconnect_socket(struct nbd_device *nbd, unsigned long arg)
 	for (i = 0; i < config->num_connections; i++) {
 		struct nbd_sock *nsock = config->socks[i];
 
-		if (!nsock->dead)
-			continue;
-

Was this check to used to speed up reconnects? For example, if a send was stuck waiting on socket memory to free up in the network layer, then the above check would allow us to skip past those sockets without having to wait on the socket that was trying to send.

Quoted 4 lines
drivers/block/nbd.c +0 -0
 		mutex_lock(&nsock->tx_lock);
 		if (!nsock->dead) {
 			mutex_unlock(&nsock->tx_lock);
author
#2 lore raw
Quoted 18 lines · Mike Christie
Quoted 17 lines · On 09/10/2019 01:36 AM, [email protected] wrote:

From: Xiubo Li <[email protected]>

The followed code will do the same check, and this part is redandant.

---
  drivers/block/nbd.c | 3 ---
  1 file changed, 3 deletions(-)
drivers/block/nbd.c +0 -0
index 478aa86fc1f2..8c10ab51a086 100644
@@ -1046,9 +1046,6 @@ static int nbd_reconnect_socket(struct nbd_device *nbd, unsigned long arg)
  	for (i = 0; i < config->num_connections; i++) {
  		struct nbd_sock *nsock = config->socks[i];
 
Quoted 8 lines

drivers/block/nbd.c static int nbd_reconnect_socket(struct nbd_device *nbd, unsigned long arg) · line 1051

Quoted 3 lines
drivers/block/nbd.c +0 -3
-		if (!nsock->dead)
-			continue;
-

Was this check to used to speed up reconnects? For example, if a send was stuck waiting on socket memory to free up in the network layer, then the above check would allow us to skip past those sockets without having to wait on the socket that was trying to send.

Yeah, in this case it really could help a little bit. Or maybe in the network layer when allocating new memories but it needs to do the memory reclaim, which will be stuck for a long time ?

Thanks
BRs
Xiubo

Quoted 5 lines
Quoted 5 lines
drivers/block/nbd.c +0 -0
  		mutex_lock(&nsock->tx_lock);
  		if (!nsock->dead) {
  			mutex_unlock(&nsock->tx_lock);