CVS commit: [netbsd-5] src/sys/netsmb
Module Name:src Committed By: bouyer Date: Sun Jan 13 16:08:23 UTC 2013 Modified Files: src/sys/netsmb [netbsd-5]: smb_iod.c smb_rq.c Log Message: Pull up following revision(s) (requested by nakayama in ticket #1825): sys/netsmb/smb_rq.c: revision 1.32 sys/netsmb/smb_iod.c: revision 1.31 sys/netsmb/smb_iod.c: revision 1.32 sys/netsmb/smb_iod.c: revision 1.33 sys/netsmb/smb_iod.c: revision 1.34 sys/netsmb/smb_iod.c: revision 1.35 Do not call callout_stop() unless the structure was previoulsy initialised for a non null timeout. Do initialise the callout when fetching a new request structure from the pool, not when starting the timer. Likewise, destroy the callout when giving back the item to the pool. Send data for as long as there is new data available. Otherwise there was a danger of smb_iod_recvall() blocking, hence releasing the kernel lock, new data creeping into the queue, and a wakeup being missed (well, there's still a race, but since it's theoretical enough for me to never have encountered it, I'll rather solve it by periodic wakeups). defensive programming: wake up iod thread once a second just in case add comment to previous stating periodic wakeups can be nuked once smb is mpsafe. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.29.6.1 src/sys/netsmb/smb_iod.c cvs rdiff -u -r1.30 -r1.30.6.1 src/sys/netsmb/smb_rq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/netsmb/smb_iod.c diff -u src/sys/netsmb/smb_iod.c:1.29 src/sys/netsmb/smb_iod.c:1.29.6.1 --- src/sys/netsmb/smb_iod.c:1.29 Tue Jun 24 10:37:19 2008 +++ src/sys/netsmb/smb_iod.c Sun Jan 13 16:08:23 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: smb_iod.c,v 1.29 2008/06/24 10:37:19 gmcgarry Exp $ */ +/* $NetBSD: smb_iod.c,v 1.29.6.1 2013/01/13 16:08:23 bouyer Exp $ */ /* * Copyright (c) 2000-2001 Boris Popov @@ -35,7 +35,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: smb_iod.c,v 1.29 2008/06/24 10:37:19 gmcgarry Exp $); +__KERNEL_RCSID(0, $NetBSD: smb_iod.c,v 1.29.6.1 2013/01/13 16:08:23 bouyer Exp $); #include sys/param.h #include sys/systm.h @@ -670,7 +670,11 @@ smb_iod_thread(void *arg) if (iod-iod_flags SMBIOD_SHUTDOWN) break; SMBIODEBUG((going to sleep\n)); - tsleep(iod-iod_flags, PSOCK, smbidle, 0); + /* + * technically wakeup every hz is unnecessary, but keep + * this here until smb has been made mpsafe. + */ + tsleep(iod-iod_flags, PSOCK, smbidle, hz); } splx(s); kthread_exit(0); Index: src/sys/netsmb/smb_rq.c diff -u src/sys/netsmb/smb_rq.c:1.30 src/sys/netsmb/smb_rq.c:1.30.6.1 --- src/sys/netsmb/smb_rq.c:1.30 Tue Jun 24 10:37:19 2008 +++ src/sys/netsmb/smb_rq.c Sun Jan 13 16:08:23 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: smb_rq.c,v 1.30 2008/06/24 10:37:19 gmcgarry Exp $ */ +/* $NetBSD: smb_rq.c,v 1.30.6.1 2013/01/13 16:08:23 bouyer Exp $ */ /* * Copyright (c) 2000-2001, Boris Popov @@ -35,7 +35,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: smb_rq.c,v 1.30 2008/06/24 10:37:19 gmcgarry Exp $); +__KERNEL_RCSID(0, $NetBSD: smb_rq.c,v 1.30.6.1 2013/01/13 16:08:23 bouyer Exp $); #include sys/param.h #include sys/systm.h @@ -95,6 +95,7 @@ smb_rq_alloc(struct smb_connobj *layer, rqp = pool_get(smbrq_pool, PR_WAITOK); error = smb_rq_init(rqp, layer, cmd, scred); rqp-sr_flags |= SMBR_ALLOCED; + callout_init(rqp-sr_timo_ch, 0); if (error) { smb_rq_done(rqp); return error; @@ -166,8 +167,10 @@ smb_rq_done(struct smb_rq *rqp) mb_done(rqp-sr_rq); md_done(rqp-sr_rp); smb_sl_destroy(rqp-sr_slock); - if (rqp-sr_flags SMBR_ALLOCED) + if (rqp-sr_flags SMBR_ALLOCED) { + callout_destroy(rqp-sr_timo_ch); pool_put(smbrq_pool, rqp); + } } /*
CVS commit: [netbsd-5] src/sys/netsmb
Module Name:src Committed By: riz Date: Sat May 19 17:03:09 UTC 2012 Modified Files: src/sys/netsmb [netbsd-5]: subr_mchain.c Log Message: Pull up following revision(s) (requested by nakayama in ticket #1758): sys/netsmb/subr_mchain.c: revision 1.21 Since len has changed to (unsinged) size_t, the while loop condition (len 0) became less able to detect its underflow. So check the subtrahend to avoid the underflow. Should fix PR kern/44092. To generate a diff of this commit: cvs rdiff -u -r1.15.6.1 -r1.15.6.2 src/sys/netsmb/subr_mchain.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/netsmb/subr_mchain.c diff -u src/sys/netsmb/subr_mchain.c:1.15.6.1 src/sys/netsmb/subr_mchain.c:1.15.6.2 --- src/sys/netsmb/subr_mchain.c:1.15.6.1 Fri Jul 16 18:47:10 2010 +++ src/sys/netsmb/subr_mchain.c Sat May 19 17:03:09 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_mchain.c,v 1.15.6.1 2010/07/16 18:47:10 riz Exp $ */ +/* $NetBSD: subr_mchain.c,v 1.15.6.2 2012/05/19 17:03:09 riz Exp $ */ /* * Copyright (c) 2000, 2001 Boris Popov @@ -35,7 +35,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: subr_mchain.c,v 1.15.6.1 2010/07/16 18:47:10 riz Exp $); +__KERNEL_RCSID(0, $NetBSD: subr_mchain.c,v 1.15.6.2 2012/05/19 17:03:09 riz Exp $); #include sys/param.h #include sys/systm.h @@ -67,7 +67,7 @@ m_getm(struct mbuf *m, size_t len, int h } } mp-m_len = 0; -len -= M_TRAILINGSPACE(mp); +len -= min(len, M_TRAILINGSPACE(mp)); if (m != NULL) for (mtail = m; mtail-m_next != NULL; mtail = mtail-m_next); @@ -89,7 +89,7 @@ m_getm(struct mbuf *m, size_t len, int h } mp-m_len = 0; -len -= M_TRAILINGSPACE(mp); +len -= min(len, M_TRAILINGSPACE(mp)); } if (mtail != NULL)
CVS commit: [netbsd-5] src/sys/netsmb
Module Name:src Committed By: bouyer Date: Tue Oct 27 20:31:15 UTC 2009 Modified Files: src/sys/netsmb [netbsd-5]: smb_smb.c Log Message: Pull up following revision(s) (requested by tron in ticket #1104): sys/netsmb/smb_smb.c: revision 1.31 sys/netsmb/smb_smb.c: revision 1.32 Fix detection of SMB capabilities according to the CIFS spec: 1.) SMB_CAP_LARGE_FILES advertises support for 64-bit file offsets. 2.) SMB_CAP_LARGE_READX and SMB_CAP_LARGE_WRITEX advertise support for large reads and writes (larger than 64KB). The code previously only used SMB_CAP_LARGE_READX and SMB_CAP_LARGE_WRITEX which is not correct and doesn't work for the Apple Time Capsule which only supports SMB_CAP_LARGE_FILES. With these changes SMBFS can copy a 5GB to a Time Capsule and read it back without problems. Thanks a lot to Allen Briggs for pointing out the broke assumptions and explaining the CIFS spec to me. This fixes PR kern/42175. Fix cut paste error spotted by Nicolas Joly. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.29.6.1 src/sys/netsmb/smb_smb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/netsmb/smb_smb.c diff -u src/sys/netsmb/smb_smb.c:1.29 src/sys/netsmb/smb_smb.c:1.29.6.1 --- src/sys/netsmb/smb_smb.c:1.29 Tue Jun 24 10:37:19 2008 +++ src/sys/netsmb/smb_smb.c Tue Oct 27 20:31:15 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: smb_smb.c,v 1.29 2008/06/24 10:37:19 gmcgarry Exp $ */ +/* $NetBSD: smb_smb.c,v 1.29.6.1 2009/10/27 20:31:15 bouyer Exp $ */ /* * Copyright (c) 2000-2001 Boris Popov @@ -38,7 +38,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: smb_smb.c,v 1.29 2008/06/24 10:37:19 gmcgarry Exp $); +__KERNEL_RCSID(0, $NetBSD: smb_smb.c,v 1.29.6.1 2009/10/27 20:31:15 bouyer Exp $); #include sys/param.h #include sys/systm.h @@ -594,6 +594,22 @@ u_int16_t residhi, residlo, off, doff; u_int32_t resid; + if (!(SMB_CAPS(SSTOVC(ssp)) SMB_CAP_LARGE_FILES) + uio-uio_offset = (1LL 32)) { + /* Cannot read at/beyond 4G */ + return (EFBIG); + } + + if (!(SMB_CAPS(SSTOVC(ssp)) SMB_CAP_LARGE_READX)) { + size_t blksz; + + blksz = SSTOVC(ssp)-vc_txmax - SMB_HDRLEN - 64; + if (blksz 0x) + blksz = 0x; + + *len = min(blksz, *len); + } + error = smb_rq_alloc(SSTOCP(ssp), SMB_COM_READ_ANDX, scred, rqp); if (error) return error; @@ -674,8 +690,26 @@ u_int8_t wc; u_int16_t resid; + if (!(SMB_CAPS(SSTOVC(ssp)) SMB_CAP_LARGE_FILES) + uio-uio_offset = (1LL 32)) { + /* Cannot write at/beyond 4G */ + return (EFBIG); + } + + if (SMB_CAPS(SSTOVC(ssp)) SMB_CAP_LARGE_WRITEX) { + *len = min(SSTOVC(ssp)-vc_wxmax, *len); + } else { + size_t blksz; + + blksz = SSTOVC(ssp)-vc_txmax - SMB_HDRLEN - 64; + if (blksz 0x) + blksz = 0x; + + *len = min(blksz, *len); + } + error = smb_rq_alloc(SSTOCP(ssp), SMB_COM_WRITE_ANDX, scred, rqp); - if (error) + if (error != 0) return (error); smb_rq_getrequest(rqp, mbp); smb_rq_wstart(rqp); @@ -687,7 +721,6 @@ mb_put_uint32le(mbp, 0); /* MBZ (timeout) */ mb_put_uint16le(mbp, 0); /* !write-thru */ mb_put_uint16le(mbp, 0); - *len = min(SSTOVC(ssp)-vc_wxmax, *len); mb_put_uint16le(mbp, *len 16); mb_put_uint16le(mbp, *len); mb_put_uint16le(mbp, 64); /* data offset from header start */ @@ -785,7 +818,8 @@ { size_t tsize, len, resid; int error = 0; - int rx = (SMB_CAPS(SSTOVC(ssp)) SMB_CAP_LARGE_READX); + bool rx = (SMB_CAPS(SSTOVC(ssp)) + (SMB_CAP_LARGE_FILES|SMB_CAP_LARGE_READX)) != 0; resid = 0; /* XXX gcc */ @@ -866,7 +900,8 @@ { int error = 0; size_t len, tsize, resid; - int wx = (SMB_CAPS(SSTOVC(ssp)) SMB_CAP_LARGE_WRITEX); + bool wx = (SMB_CAPS(SSTOVC(ssp)) + (SMB_CAP_LARGE_FILES|SMB_CAP_LARGE_WRITEX)) != 0; resid = 0; /* XXX gcc */ @@ -877,7 +912,7 @@ error = smb_smb_writex(ssp, fid, len, resid, uio, scred); else error = smb_smb_write(ssp, fid, len, resid, uio, scred); - if (error) + if (error != 0) break; if (resid len) { error = EIO;