Bladeren bron

drbd: don't recvmsg with zero length

This should fix a performance degradation we observed recently.

If we don't expect any subheader, we should not call into the tcp stack,
as that may add considerable latency if there is no data available at
this point.

For a synthetic synchronous write load with single outstanding writes,
this additional latency when processing the "unplug remote" packet
added up to a performance degradation factor >= 10.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Lars Ellenberg 15 jaren geleden
bovenliggende
commit
c13f7e1a94
1 gewijzigde bestanden met toevoegingen van 8 en 6 verwijderingen
  1. 8 6
      drivers/block/drbd/drbd_receiver.c

+ 8 - 6
drivers/block/drbd/drbd_receiver.c

@@ -3627,17 +3627,19 @@ static void drbdd(struct drbd_conf *mdev)
 		}
 		}
 
 
 		shs = drbd_cmd_handler[cmd].pkt_size - sizeof(union p_header);
 		shs = drbd_cmd_handler[cmd].pkt_size - sizeof(union p_header);
-		rv = drbd_recv(mdev, &header->h80.payload, shs);
-		if (unlikely(rv != shs)) {
-			dev_err(DEV, "short read while reading sub header: rv=%d\n", rv);
-			goto err_out;
-		}
-
 		if (packet_size - shs > 0 && !drbd_cmd_handler[cmd].expect_payload) {
 		if (packet_size - shs > 0 && !drbd_cmd_handler[cmd].expect_payload) {
 			dev_err(DEV, "No payload expected %s l:%d\n", cmdname(cmd), packet_size);
 			dev_err(DEV, "No payload expected %s l:%d\n", cmdname(cmd), packet_size);
 			goto err_out;
 			goto err_out;
 		}
 		}
 
 
+		if (shs) {
+			rv = drbd_recv(mdev, &header->h80.payload, shs);
+			if (unlikely(rv != shs)) {
+				dev_err(DEV, "short read while reading sub header: rv=%d\n", rv);
+				goto err_out;
+			}
+		}
+
 		rv = drbd_cmd_handler[cmd].function(mdev, cmd, packet_size - shs);
 		rv = drbd_cmd_handler[cmd].function(mdev, cmd, packet_size - shs);
 
 
 		if (unlikely(!rv)) {
 		if (unlikely(!rv)) {