Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 24 Nov 2002 14:34:40 +1100
From:      Tim Robbins <tjr@FreeBSD.ORG>
To:        current@FreeBSD.ORG
Subject:   smbfs workaround
Message-ID:  <20021124143440.A88845@dilbert.robbins.dropbear.id.au>

next in thread | raw e-mail | index | archive | help
I'd appreciate it if the people who were experiencing problems with
smbfs could try this patch and let me know how it goes.

The patch adds two sysctls, net.smb.readwritex and net.smb.reqdatasize.
readwritex controls whether LARGE_READX and LARGE_WRITEX requests are
used, and is off by default. reqdatasize controls the maximum number of
bytes of data to request from the user with each read request, and it
defaults to a fairly conservative value of 4096.

Setting readwritex to 0 makes smbfs work when the server OS is Windows XP.
Setting reqdatasize to 4096 makes it work when the server OS is
FreeBSD 4.7-RELEASE-p2 w/ Samba 2.2.3a.

This patch is just a temporary workaround, of course. I have not been
able to track down the real problem.


Tim


Index: src/sys/netsmb/smb_smb.c
===================================================================
RCS file: /x/freebsd/src/sys/netsmb/smb_smb.c,v
retrieving revision 1.7
diff -u -r1.7 smb_smb.c
--- src/sys/netsmb/smb_smb.c	16 Sep 2002 10:50:38 -0000	1.7
+++ src/sys/netsmb/smb_smb.c	24 Nov 2002 02:50:14 -0000
@@ -71,6 +71,22 @@
 
 #define	SMB_DIALECT_MAX	(sizeof(smb_dialects) / sizeof(struct smb_dialect) - 2)
 
+SYSCTL_DECL(_net_smb);
+
+/*
+ * XXX Something is causing requests for more than about 4 kbytes of data
+ * to fail. LARGE_READX and LARGE_WRITEX requests are disabled by default,
+ * and data is requested in 4 kbyte (or smaller) chunks.
+ */
+
+static int smb_rwx = 0;
+SYSCTL_INT(_net_smb, OID_AUTO, readwritex, CTLFLAG_RW, &smb_rwx, 0,
+    "Controls whether LARGE_READX and LARGE_WRITEX requests will be used");
+
+static int smb_reqdatasize = 4096;
+SYSCTL_INT(_net_smb, OID_AUTO, reqdatasize, CTLFLAG_RW, &smb_reqdatasize, 0, 
+    "Maximum number of bytes of data to request at a time");
+
 static u_int32_t
 smb_vc_maxread(struct smb_vc *vcp)
 {
@@ -78,7 +94,7 @@
 	 * Specs say up to 64k data bytes, but Windows traffic
 	 * uses 60k... no doubt for some good reason.
 	 */
-	if (vcp->vc_sopt.sv_caps & SMB_CAP_LARGE_READX)
+	if (smb_rwx && vcp->vc_sopt.sv_caps & SMB_CAP_LARGE_READX)
 		return (60*1024);
 	else
 		return (vcp->vc_sopt.sv_maxtx);
@@ -91,7 +107,7 @@
 	 * Specs say up to 64k data bytes, but Windows traffic
 	 * uses 60k... probably for some good reason.
 	 */
-	if (vcp->vc_sopt.sv_caps & SMB_CAP_LARGE_WRITEX)
+	if (smb_rwx && vcp->vc_sopt.sv_caps & SMB_CAP_LARGE_WRITEX)
 		return (60*1024);
 	else
 		return (vcp->vc_sopt.sv_maxtx);
@@ -239,7 +255,7 @@
 			sp->sv_maxtx = 1024;
 		else
 			sp->sv_maxtx = min(sp->sv_maxtx,
-					   63*1024 + SMB_HDRLEN + 16);
+					   smb_reqdatasize + SMB_HDRLEN + 16);
 		SMB_TRAN_GETPARAM(vcp, SMBTP_RCVSZ, &maxqsz);
 		vcp->vc_rxmax = min(smb_vc_maxread(vcp), maxqsz - 1024);
 		SMB_TRAN_GETPARAM(vcp, SMBTP_SNDSZ, &maxqsz);
@@ -735,7 +751,7 @@
 	u_int8_t wc;
 	int error, rlen, blksz;
 
-	if (SSTOVC(ssp)->vc_sopt.sv_caps & SMB_CAP_LARGE_READX)
+	if (smb_rwx && SSTOVC(ssp)->vc_sopt.sv_caps & SMB_CAP_LARGE_READX)
 		return (smb_smb_readx(ssp, fid, len, rresid, uio, scred));
 
 	error = smb_rq_alloc(SSTOCP(ssp), SMB_COM_READ, scred, &rqp);
@@ -813,7 +829,8 @@
 	u_int8_t wc;
 	int error, blksz;
 
-	if (*len && SSTOVC(ssp)->vc_sopt.sv_caps & SMB_CAP_LARGE_WRITEX)
+	if (smb_rwx && *len &&
+	    SSTOVC(ssp)->vc_sopt.sv_caps & SMB_CAP_LARGE_WRITEX)
 		return (smb_smb_writex(ssp, fid, len, rresid, uio, scred));
  
 	blksz = SSTOVC(ssp)->vc_txmax - SMB_HDRLEN - 16;

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021124143440.A88845>