Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netsmb add support for asynchronous execution of SMB req...



details:   https://anonhg.NetBSD.org/src/rev/f5dae615eef5
branches:  trunk
changeset: 545359:f5dae615eef5
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Mon Apr 07 11:23:02 2003 +0000

description:
add support for asynchronous execution of SMB requests:
* add receive hook - if set, this function is called when request is finished
* unstatic smb_rq_enqueue(), smb_rq_reply() so that code can use that
  independant of smb_rq_simple() et al
this is needed for NT DIRECTORY CHANGE NOTIFY SMB, since they typically
take very long to complete and we want to be able to use single kernel thread
to handle them all

add support for 'nowait' requests (flag SMBR_NOWAIT), which don't expect
and answer from server and are marked as 'processed' immediatelly
after they are sent to server - needed for NT CANCEL SMB

diffstat:

 sys/netsmb/smb_iod.c |  14 +++++++++++---
 sys/netsmb/smb_rq.c  |  18 ++++++++++++------
 sys/netsmb/smb_rq.h  |   9 ++++++++-
 3 files changed, 31 insertions(+), 10 deletions(-)

diffs (144 lines):

diff -r ad0b112dce2e -r f5dae615eef5 sys/netsmb/smb_iod.c
--- a/sys/netsmb/smb_iod.c      Mon Apr 07 11:13:24 2003 +0000
+++ b/sys/netsmb/smb_iod.c      Mon Apr 07 11:23:02 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: smb_iod.c,v 1.18 2003/04/05 11:12:23 jdolecek Exp $    */
+/*     $NetBSD: smb_iod.c,v 1.19 2003/04/07 11:23:02 jdolecek Exp $    */
 
 /*
  * Copyright (c) 2000-2001 Boris Popov
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: smb_iod.c,v 1.18 2003/04/05 11:12:23 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smb_iod.c,v 1.19 2003/04/07 11:23:02 jdolecek Exp $");
  
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -79,6 +79,8 @@
        rqp->sr_state = SMBRQ_NOTIFIED;
        wakeup(&rqp->sr_state);
        callout_stop(&rqp->sr_timo_ch);
+       if (rqp->sr_recvcallback)
+               (*rqp->sr_recvcallback)(rqp->sr_recvarg);
        SMBRQ_SUNLOCK(rqp);
 }
 
@@ -264,12 +266,18 @@
                        callout_reset(&rqp->sr_timo_ch, rqp->sr_timo,
                                smb_iod_rqtimedout, rqp);
                }
+
+               if (rqp->sr_flags & SMBR_NOWAIT) {
+                       /* caller doesn't want to wait, flag as processed */
+                       smb_iod_rqprocessed(rqp, 0);
+                       return (0);
+               }
+
 #if 0
                iod->iod_lastrqsent = ts;
 #endif
                rqp->sr_flags |= SMBR_SENT;
                rqp->sr_state = SMBRQ_SENT;
-               smb_iod_wakeup(iod);
                return 0;
        }
        /*
diff -r ad0b112dce2e -r f5dae615eef5 sys/netsmb/smb_rq.c
--- a/sys/netsmb/smb_rq.c       Mon Apr 07 11:13:24 2003 +0000
+++ b/sys/netsmb/smb_rq.c       Mon Apr 07 11:23:02 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: smb_rq.c,v 1.18 2003/04/02 15:01:52 jdolecek Exp $     */
+/*     $NetBSD: smb_rq.c,v 1.19 2003/04/07 11:23:02 jdolecek Exp $     */
 
 /*
  * Copyright (c) 2000-2001, Boris Popov
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: smb_rq.c,v 1.18 2003/04/02 15:01:52 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smb_rq.c,v 1.19 2003/04/07 11:23:02 jdolecek Exp $");
  
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -60,8 +60,6 @@
 MODULE_DEPEND(netsmb, libmchain, 1, 1, 1);
 #endif
 
-static int  smb_rq_reply(struct smb_rq *rqp);
-static int  smb_rq_enqueue(struct smb_rq *rqp);
 static int  smb_rq_getenv(struct smb_connobj *layer,
                struct smb_vc **vcpp, struct smb_share **sspp);
 static int  smb_rq_new(struct smb_rq *rqp, u_char cmd);
@@ -173,7 +171,7 @@
        return error;
 }
 
-static int
+int
 smb_rq_enqueue(struct smb_rq *rqp)
 {
        struct smb_share *ssp = rqp->sr_share;
@@ -317,7 +315,7 @@
 /*
  * Wait for reply on the request
  */
-static int
+int
 smb_rq_reply(struct smb_rq *rqp)
 {
        struct mdchain *mdp = &rqp->sr_rp;
@@ -359,6 +357,14 @@
        return (error);
 }
 
+void
+smb_rq_setcallback(struct smb_rq *rqp, void (*recvcallb)(void *), void *arg)
+{
+       SMBRQ_SLOCK(rqp);
+       rqp->sr_recvcallback = recvcallb;
+       rqp->sr_recvarg = arg;
+       SMBRQ_SLOCK(rqp);
+}
 
 #define ALIGN4(a)      (((a) + 3) & ~3)
 
diff -r ad0b112dce2e -r f5dae615eef5 sys/netsmb/smb_rq.h
--- a/sys/netsmb/smb_rq.h       Mon Apr 07 11:13:24 2003 +0000
+++ b/sys/netsmb/smb_rq.h       Mon Apr 07 11:23:02 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: smb_rq.h,v 1.7 2003/03/30 11:58:17 jdolecek Exp $      */
+/*     $NetBSD: smb_rq.h,v 1.8 2003/04/07 11:23:02 jdolecek Exp $      */
 
 /*
  * Copyright (c) 2000-2001, Boris Popov
@@ -50,6 +50,7 @@
 #define        SMBR_INTERNAL           0x0080  /* request is internal to smbrqd */
 #define        SMBR_XLOCK              0x0100  /* request locked and can't be moved */
 #define        SMBR_XLOCKWANT          0x0200  /* waiter on XLOCK */
+#define        SMBR_NOWAIT             0x0400  /* don't wait for reply */
 
 #define SMBT2_ALLSENT          0x0001  /* all data and params are sent */
 #define SMBT2_ALLRECV          0x0002  /* all data and params are received */
@@ -101,6 +102,9 @@
        u_int16_t               sr_rpmid;
        struct smb_slock        sr_slock;       /* short term locks */
        SIMPLEQ_ENTRY(smb_rq)   sr_link;
+
+       void                    (*sr_recvcallback)(void *);
+       void                    *sr_recvarg;
 };
 
 struct smb_t2rq {
@@ -136,6 +140,9 @@
 void smb_rq_bend(struct smb_rq *rqp);
 int  smb_rq_intr(struct smb_rq *rqp);
 int  smb_rq_simple(struct smb_rq *rqp);
+int  smb_rq_enqueue(struct smb_rq *rqp);
+int  smb_rq_reply(struct smb_rq *rqp);
+void smb_rq_setcallback(struct smb_rq *, void (*)(void *), void *);
 
 int  smb_t2_alloc(struct smb_connobj *layer, u_short setup, struct smb_cred *scred,
        struct smb_t2rq **rqpp);



Home | Main Index | Thread Index | Old Index