Skip to contentSkip to conversation

Do not skip records with nonblocking connections (take 2)

PATCH In review Steve Dickson 2 participants 3 messages Jun 18, 2011 – Jun 21, 2011

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

PATCH 1/1 Do not skip records with nonblocking connections (take 2)

With non-blocking connections, do not skip records when receiving the streams since entire value messages can be ignored which in cause the entire stream to become out of sync.

For example, two mounts simultaneously send two unmaps commands. The first one is read, then the second thrown away due to skipping the record. Skipping this record will cause XDR error later in processing of the stream.

---
 src/svc_vc.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
src/svc_vc.c +5 -1
index aaaf2d7..87406f1 100644
@@ -610,7 +610,11 @@ svc_vc_recv(xprt, msg)
 	}
 
 	xdrs->x_op = XDR_DECODE;
-	(void)xdrrec_skiprecord(xdrs);
+	/*
+	 * No need skip records with nonblocking connections
+	 */
+	if (cd->nonblock == FALSE)
+		(void)xdrrec_skiprecord(xdrs);
 	if (xdr_callmsg(xdrs, msg)) {
 		cd->x_id = msg->rm_xid;
 		return (TRUE);
Signature · 1 line
1.7.4.4
#1 lore raw
Quoted 8 lines · Steve Dickson

With non-blocking connections, do not skip records when receiving the streams since entire value messages can be ignored which in cause the entire stream to become out of sync.

For example, two mounts simultaneously send two unmaps commands. The first one is read, then the second thrown away due to skipping the record. Skipping this record will cause XDR error later in processing of the stream.

I notice that xdrrec_skiprecord() also does a __xdrrec_getrec() on nonblocking connections. In the current code, then, __xdrrec_getrec() is likely invoked twice in svc_vc_recv() on non-blocking connections. After this patch, it is only invoked once.

Invoking __xdrrec_getrec() just once in both the blocking and non-blocking cases feels more correct to me, but I don't have a deep understanding of this code. So this patch seems like the right thing to do.

Quoted 10 lines

---
src/svc_vc.c | 6 +++++-

1 files changed, 5 insertions(+), 1 deletions(-)
src/svc_vc.c +0 -0
index aaaf2d7..87406f1 100644

src/svc_vc.c svc_vc_recv(xprt, msg) · line 617

Quoted 9 lines
src/svc_vc.c +5 -1
@@ -610,7 +610,11 @@ svc_vc_recv(xprt, msg)
 	}
 
 	xdrs->x_op = XDR_DECODE;
-	(void)xdrrec_skiprecord(xdrs);
+	/*
+	 * No need skip records with nonblocking connections
+	 */
+	if (cd->nonblock == FALSE)
+		(void)xdrrec_skiprecord(xdrs);

cd->nonblock is already checked just before this code block. As a minor optimization, I'd suggest reordering slightly so cd->nonblock is checked only once:

	xdrs->x_op = XDR_DECODE;
	if (cd->nonblock) {
		if (!__xdrrec_getrec(xdrs, &cd->strm_stat, TRUE))
			return FALSE;
	} else 
		(void)xdrrec_skiprecord(xdrs);

As long as __xdrrec_getrec() doesn't care about the value of xdrs->x_op, this should be OK to do.

Quoted 3 lines
src/svc_vc.c +0 -0
 	if (xdr_callmsg(xdrs, msg)) {
 		cd->x_id = msg->rm_xid;
 		return (TRUE);
Signature · 2 lines
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
#2 lore raw
In reply to Steve Dickson

Committed...

steved.

Quoted 31 lines · Steve Dickson

With non-blocking connections, do not skip records when receiving the streams since entire value messages can be ignored which in cause the entire stream to become out of sync.

For example, two mounts simultaneously send two unmaps commands. The first one is read, then the second thrown away due to skipping the record. Skipping this record will cause XDR error later in processing of the stream.

---
 src/svc_vc.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
src/svc_vc.c +5 -1
index aaaf2d7..87406f1 100644
@@ -610,7 +610,11 @@ svc_vc_recv(xprt, msg)
 	}
 
 	xdrs->x_op = XDR_DECODE;
-	(void)xdrrec_skiprecord(xdrs);
+	/*
+	 * No need skip records with nonblocking connections
+	 */
+	if (cd->nonblock == FALSE)
+		(void)xdrrec_skiprecord(xdrs);
 	if (xdr_callmsg(xdrs, msg)) {
 		cd->x_id = msg->rm_xid;
 		return (TRUE);