[linux-cifs-client] A question about SQL-over-CIFS

Peter Chacko peterchacko35 at gmail.com
Thu Oct 15 11:56:37 MDT 2009


Could any one share their experience with SQL server over a CIFS share
?  Assuming that i am not hosting transactional work load on the
database, does any one think that SQL-CIFS stack is not a good
solution ?  Here i use Database as a file level storage appliance
where i store write-once, read-mostly IO pattern is more common.  DBAs
are happy with MySQL or ORACLE over NFS. Does that hold true for
database-over-CIFS as well ?

Thanks a lot for your input/thoughts.
Peter chacko,


On Thu, Oct 15, 2009 at 11:10 PM,
<linux-cifs-client-request at lists.samba.org> wrote:
> Send linux-cifs-client mailing list submissions to
>        linux-cifs-client at lists.samba.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        https://lists.samba.org/mailman/listinfo/linux-cifs-client
> or, via email, send a message with subject or body 'help' to
>        linux-cifs-client-request at lists.samba.org
>
> You can reach the person managing the list at
>        linux-cifs-client-owner at lists.samba.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of linux-cifs-client digest..."
>
>
> Today's Topics:
>
>   1. TCP_NODELAY and CORK - should they be added for   network fs
>      case? (Steve French)
>   2. [patch][0/3] Add support infrastructure for       Named Pipe
>      (Shirish Pargaonkar)
>   3. [patch][1/3] Data structures and defines for      Named Pipes
>      (Shirish Pargaonkar)
>   4. [patch][2/3] SMBTrans functions for Named Pipes
>      (Shirish Pargaonkar)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 15 Oct 2009 12:32:28 -0500
> From: Steve French <smfrench at gmail.com>
> To: linux-net at vger.kernel.org
> Cc: linux-cifs-client at lists.samba.org
> Subject: [linux-cifs-client] TCP_NODELAY and CORK - should they be
>        added for       network fs case?
> Message-ID:
>        <524f69650910151032q3a5e9ee0k18415f5c8212890e at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Looking at calls to kernel_sendmsg, and thinking about why I only see
> a few places that do TCP_NODELAY and TCP_CORK in kernel.
>
> Looking at the cifs example.  cifs is trying to send packets which
> vary from about 50-100 bytes for common calls (like lookup) to about
> 56K for file writes (can be larger if override wsize and max buffer
> size via insmod parameter), and cifs always uses kernel_sendmsg.   For
> the cifs case, sending individual SMB/CIFS requests to a particular
> server (socket) are serialized, protected by a mutex, even if many
> processes are writing to different remote files at one time.
> Usually one kernel_sendmsg is all that is needed to send an SMB
> request - does kernel_sendmsg implicitly "cork" the request so that
> the SMB is not unnecessarily fragmented?  If the socket is full, and
> only a few bytes are sent, multiple sendmsg's may be required to send
> one smb - should cifs be doing a cork before the loop which calls
> kernel_sendmsg in smb_sendv in fs/cifs/transport.c and uncork
> afterward (since the server can't do much processing without getting
> the whole SMB request except in one narrow case of receivefile on
> certain write requests)?    Especially if we add code to allow setting
> "TCP_NODELAY" ... to improve GigE performance
>
> Are there any cases where we should be setting LOWDELAY instead for
> this kind of socket?
>
> --
> Thanks,
>
> Steve
>
>
> ------------------------------
>
> Message: 2
> Date: Thu, 15 Oct 2009 12:36:23 -0500
> From: Shirish Pargaonkar <shirishpargaonkar at gmail.com>
> To: linux-cifs-client at lists.samba.org,  linux-fsdevel
>        <linux-fsdevel at vger.kernel.org>
> Subject: [linux-cifs-client] [patch][0/3] Add support infrastructure
>        for     Named Pipe
> Message-ID:
>        <4a4634330910151036m7ba50246ld70f2800bc4afc6b at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Add Named Pipe support in cifs client.
>
> Since there are no equivalent kernel APIs for transactions, most of the
> SMBTrans
> functions are implemented using ioctls which are handle based, like the
> APIs used for Named Pipes.
>
> A path based function, WaitNamedPipe is not implemented at this time.
> Also not implemented support for multiple fragments in TransactNmPipe
> function.
>
>
> Signed-off-by: Shirish Pargaonkar shirishpargaonkar at gmail.com
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://lists.samba.org/pipermail/linux-cifs-client/attachments/20091015/37c584b2/attachment-0001.html>
>
> ------------------------------
>
> Message: 3
> Date: Thu, 15 Oct 2009 12:40:00 -0500
> From: Shirish Pargaonkar <shirishpargaonkar at gmail.com>
> To: linux-cifs-client at lists.samba.org,  linux-fsdevel
>        <linux-fsdevel at vger.kernel.org>
> Subject: [linux-cifs-client] [patch][1/3] Data structures and defines
>        for     Named Pipes
> Message-ID:
>        <4a4634330910151040r3a61019m66b6ddcb648111cd at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Add data structures and defines (ioctl commands etc.) for Named Pipe
> support in cifs
>
> >From 02cc49c80d125beac34cf82d312f5f221311dd62 Mon Sep 17 00:00:00 2001
> From: Shirish Pargaonkar <shirishpargaonkar at gmail.com>
> Date: Thu, 15 Oct 2009 08:14:44 -0500
> Subject: [PATCH] Header file changes for Named Pipe support
>
> ---
>  fs/cifs/cifsglob.h  |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
>  fs/cifs/cifspdu.h   |   45 +++++++++++++++++++++++++++++++++++++++++++++
>  fs/cifs/cifsproto.h |   15 +++++++++++++++
>  3 files changed, 108 insertions(+), 0 deletions(-)
>
> diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
> index 5d0fde1..6ee9dae 100644
> --- a/fs/cifs/cifsglob.h
> +++ b/fs/cifs/cifsglob.h
> @@ -612,6 +612,54 @@ require use of the stronger protocol */
>  *****************************************************************
>  */
>
> +/*
> + *****************************************************************
> + * Named Pipe data structures and ioctl commands
> + *****************************************************************
> + */
> +
> +#define MAXPIPENAMELEN 256
> +#define MAXPEEKNMBUFSIZE 8192
> +
> +struct qnmp_info {
> +       unsigned short outbuf;
> +       unsigned short inbuf;
> +       unsigned char maxinst;
> +       unsigned char curinst;
> +       unsigned char length;
> +       char pipename[MAXPIPENAMELEN];
> +};
> +
> +struct qnmp_hinfo {
> +       unsigned short mode;
> +};
> +
> +struct peeknmp_info {
> +       unsigned int size;
> +       unsigned short bavail;
> +       unsigned short bremain;
> +       unsigned short conntype;
> +       char buffer[MAXPEEKNMBUFSIZE];
> +};
> +
> +struct transnmp_info {
> +       unsigned int wsize;
> +       char sendbuf[MAXPEEKNMBUFSIZE];
> +       unsigned rsize;
> +       char recvbuf[MAXPEEKNMBUFSIZE];
> +};
> +
> +#define CIFS_QUERYNMPIPE _IOR(0xCF, 0x3, struct qnmp_info)
> +#define CIFS_PEEKNMPIPE _IOWR(0xCF, 0x4, struct peeknmp_info)
> +#define CIFS_GETNMPIPEHANDSTATE _IOR(0xCF, 0x5, struct qnmp_hinfo)
> +#define CIFS_SETNMPIPEHANDSTATE _IOW(0xCF, 0x6, struct qnmp_hinfo)
> +#define CIFS_TRANSACTNMPIPE _IOWR(0xCF, 0x7, struct qnmp_hinfo)
> +
> +#define NONBLOCKINGNMPIPE 0x0008
> +#define BLOCKINGNMPIPE 0x0004
> +#define MESSAGENMREAD 0x0002
> +#define BYTESTREAMNMREAD 0x0001
> +
>  #define UID_HASH (16)
>
>  /*
> diff --git a/fs/cifs/cifspdu.h b/fs/cifs/cifspdu.h
> index 2d07f89..df922dc 100644
> --- a/fs/cifs/cifspdu.h
> +++ b/fs/cifs/cifspdu.h
> @@ -49,6 +49,7 @@
>  #define SMB_COM_QUERY_INFORMATION     0x08 /* aka getattr */
>  #define SMB_COM_SETATTR               0x09 /* trivial response */
>  #define SMB_COM_LOCKING_ANDX          0x24 /* trivial response */
> +#define SMB_COM_TRANSACTION           0x25
>  #define SMB_COM_COPY                  0x29 /* trivial rsp, fail
> filename ignrd*/
>  #define SMB_COM_OPEN_ANDX             0x2D /* Legacy open for old servers */
>  #define SMB_COM_READ_ANDX             0x2E
> @@ -1269,6 +1270,50 @@ typedef struct smb_com_ntransact_rsp {
>        /* parms and data follow */
>  } __attribute__((packed)) NTRANSACT_RSP;
>
> +typedef struct smb_com_transact_req {
> +       struct smb_hdr hdr; /* wct >= 19 */
> +       __le16 TotalParameterCount;
> +       __le16 TotalDataCount;
> +       __le16 MaxParameterCount;
> +       __le16 MaxDataCount;
> +       __u8 MaxSetupCount;
> +       __u8 Reserved;
> +       __u16 Flags;
> +       __le32 Timeout;
> +       __le16 Reserved1;
> +       __le16 ParameterCount;
> +       __le16 ParameterOffset;
> +       __le16 DataCount;
> +       __le16 DataOffset;
> +       __u8 SetupCount;
> +       __u8 Reserved2;
> +       __le16 Function;
> +       __le16 Fid;
> +       __le16 ByteCount;
> +       unsigned char pad[1];
> +       unsigned char Name[1];
> +       unsigned char Param[1];
> +       unsigned char Data[1];
> +} __attribute__((packed)) TRANS_REQ;
> +
> +typedef struct smb_com_transact_rsp {
> +       struct smb_hdr hdr;     /* wct = 18 */
> +       __u16 Reserved;
> +       __le16 TotalParameterCount;
> +       __le16 TotalDataCount;
> +       __le16 ParameterCount;
> +       __le16 ParameterOffset;
> +       __le16 ParameterDisplacement;
> +       __le16 DataCount;
> +       __le16 DataOffset;
> +       __le16 DataDisplacement;
> +       __u8 SetupCount;   /* 0 */
> +       __u16 ByteCount;
> +       __u8 Reserved1;
> +       /* __u8 Pad[3]; */
> +       /* parms and data follow */
> +} __attribute__((packed)) TRANS_RSP;
> +
>  typedef struct smb_com_transaction_ioctl_req {
>        struct smb_hdr hdr;     /* wct = 23 */
>        __u8 MaxSetupCount;
> diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
> index 6928c24..21e553f 100644
> --- a/fs/cifs/cifsproto.h
> +++ b/fs/cifs/cifsproto.h
> @@ -388,4 +388,19 @@ extern int CIFSSMBSetPosixACL(const int xid,
> struct cifsTconInfo *tcon,
>                const struct nls_table *nls_codepage, int remap_special_chars);
>  extern int CIFSGetExtAttr(const int xid, struct cifsTconInfo *tcon,
>                        const int netfid, __u64 *pExtAttrBits, __u64 *pMask);
> +extern int CIFSSMBTransQNmPipe(const int, struct cifsTconInfo *,
> +                unsigned long, __u16, const struct nls_table *, int);
> +extern int CIFSSMBTransSetNmPHState(const int, struct cifsTconInfo *,
> +               unsigned long, __u16, const struct nls_table *, int);
> +extern int CIFSSMBTranWaitNmPipe(const int, struct cifsTconInfo *,
> +                const unsigned char *, unsigned char *,
> +               __u16, const struct nls_table *, int);
> +extern int CIFSSMBTransPeekNmPipe(const int, struct cifsTconInfo *,
> +                unsigned long, __u16, const struct nls_table *, int);
> +extern int CIFSSMBTransGetNmPHState(const int, struct cifsTconInfo *,
> +               unsigned long, __u16, const struct nls_table *, int);
> +extern int CIFSSMBTransNmPipe(const int, struct cifsTconInfo *,
> +               unsigned char *, __u16, const struct nls_table *, int);
> +extern int ChkNMPHmode(unsigned short);
> +extern unsigned short SetNMPHmode(unsigned short, unsigned short);
>  #endif                 /* _CIFSPROTO_H */
> --
> 1.5.2
>
>
> ------------------------------
>
> Message: 4
> Date: Thu, 15 Oct 2009 12:41:51 -0500
> From: Shirish Pargaonkar <shirishpargaonkar at gmail.com>
> To: linux-cifs-client at lists.samba.org,  linux-fsdevel
>        <linux-fsdevel at vger.kernel.org>
> Subject: [linux-cifs-client] [patch][2/3] SMBTrans functions for Named
>        Pipes
> Message-ID:
>        <4a4634330910151041i33a3036ft8d7f729b5ec77618 at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> SMB Trans commands (except WaitNamedPipe)
>
> >From d11c8d19f9e1bf5d3ed615a38ce99e97dfe0b7dd Mon Sep 17 00:00:00 2001
> From: Shirish Pargaonkar <shirishpargaonkar at gmail.com>
> Date: Thu, 15 Oct 2009 08:16:26 -0500
> Subject: [PATCH] SMB Trans functions for Named Pipe support
>
> ---
>  fs/cifs/cifssmb.c |  488 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 488 insertions(+), 0 deletions(-)
>
> diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
> index 941441d..9d6b77b 100644
> --- a/fs/cifs/cifssmb.c
> +++ b/fs/cifs/cifssmb.c
> @@ -5675,4 +5675,492 @@ SetEARetry:
>        return rc;
>  }
>
> +int
> +CIFSSMBTransQNmPipe(const int xid, struct cifsTconInfo *tcon,
> +               unsigned long arg, __u16 netfid,
> +               const struct nls_table *nls_codepage, int remap)
> +{
> +       TRANS_REQ *pSMB = NULL;
> +       TRANS_RSP *pSMBr = NULL;
> +       int rc = 0;
> +       int name_len, param_len;
> +       int pad;
> +       int bytes_returned = 0;
> +       __u16 offset;
> +       __u16 byte_count = 0;
> +       char *fileName = "\\PIPE\\";
> +       char *bcc_ptr;
> +       struct qnmp_info qnmpipeinfo;
> +
> +       cFYI(1, ("In CIFSSMBTransQNmPipe"));
> +qnmpiperetry:
> +       rc = smb_init(SMB_COM_TRANSACTION, 16, tcon, (void **) &pSMB,
> +                     (void **) &pSMBr);
> +       if (rc)
> +               return rc;
> +
> +       offset = offsetof(TRANS_REQ, Name) - 4;
> +       pad = offset % 4;
> +       if (pad)
> +               offset += pad;
> +       bcc_ptr = (char *)pSMB + offset + 4;
> +       if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
> +               name_len =
> +                   cifsConvertToUCS((__le16 *) bcc_ptr, fileName,
> +                                    PATH_MAX, nls_codepage, remap);
> +               name_len++;     /* trailing null */
> +               name_len *= 2;
> +       } else {        /* BB improve the check for buffer overruns BB */
> +               name_len = strnlen(fileName, PATH_MAX);
> +               name_len++;     /* trailing null */
> +               strncpy(bcc_ptr, fileName, name_len);
> +       }
> +       byte_count += (1 + pad + name_len);
> +
> +       offset += name_len;
> +       pad = offset % 4;
> +       if (pad)
> +               offset += pad;
> +       pSMB->ParameterCount = 2;
> +       pSMB->TotalParameterCount = 2;
> +       pSMB->ParameterOffset = offset;
> +       bcc_ptr = (char *)pSMB + offset + 4;
> +       *bcc_ptr++ = 0x1;
> +       *bcc_ptr = 0x0;
> +       param_len = 2;
> +       byte_count += (pad + param_len);
> +
> +       offset += param_len;
> +       pad = offset % 4;
> +       if (pad)
> +               offset += pad;
> +       pSMB->DataOffset = 0;
> +       pSMB->DataCount = 0;
> +       pSMB->TotalDataCount = 0;
> +
> +       pSMB->MaxParameterCount = 0;
> +       /* BB find max SMB PDU from sess */
> +       pSMB->MaxDataCount = cpu_to_le16(4280);
> +       pSMB->MaxSetupCount = 0;
> +
> +       pSMB->Flags = 0;
> +       pSMB->Timeout = 0;
> +
> +       pSMB->SetupCount = 2;
> +       pSMB->Function = cpu_to_le16(TRANS_QUERY_NMPIPE_INFO);
> +       pSMB->Fid = cpu_to_le16(netfid);
> +
> +       pSMB->ByteCount = cpu_to_le16(byte_count);
> +
> +       pSMB->hdr.smb_buf_length += byte_count;
> +       rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
> +                        (struct smb_hdr *) pSMBr, &bytes_returned, 0);
> +       if (rc) {
> +               cFYI(1, ("CIFSSMBTransQNmPipe returned %d", rc));
> +       } else {
> +               offset = le16_to_cpu(pSMBr->DataOffset);
> +               bcc_ptr = (char *)pSMBr + offset + 4;
> +               qnmpipeinfo.outbuf = le16_to_cpu(*(unsigned short *)bcc_ptr);
> +               bcc_ptr += 2;
> +               qnmpipeinfo.inbuf = le16_to_cpu(*(unsigned short *)bcc_ptr);
> +               bcc_ptr += 2;
> +               qnmpipeinfo.maxinst = le16_to_cpu(*(unsigned short *)bcc_ptr);
> +               bcc_ptr += 2;
> +               qnmpipeinfo.curinst = *bcc_ptr;
> +               bcc_ptr += 2;
> +               qnmpipeinfo.length = *bcc_ptr;
> +               bcc_ptr += 2;
> +               if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) {
> +                       rc = cifs_from_ucs2(qnmpipeinfo.pipename,
> +                               (__le16 *)bcc_ptr,
> +                               (int)qnmpipeinfo.length,
> +                               (int)(qnmpipeinfo.length - 2),
> +                               nls_codepage, 0);
> +               } else
> +                       strncpy(qnmpipeinfo.pipename, bcc_ptr,
> +                               qnmpipeinfo.length);
> +               memcpy((char *)arg, &qnmpipeinfo, sizeof(struct qnmp_info));
> +       }
> +
> +       cifs_buf_release(pSMB);
> +
> +       if (rc == -EAGAIN)
> +               goto qnmpiperetry;
> +
> +       return rc;
> +}
> +
> +int
> +CIFSSMBTransSetNmPHState(const int xid, struct cifsTconInfo *tcon,
> +               unsigned long arg, __u16 netfid,
> +               const struct nls_table *nls_codepage, int remap)
> +{
> +       TRANS_REQ *pSMB = NULL;
> +       TRANS_RSP *pSMBr = NULL;
> +       int rc = 0;
> +       int name_len, param_len;
> +       int pad;
> +       int bytes_returned = 0;
> +       __u16 offset;
> +       __u16 byte_count = 0;
> +       char *fileName = "\\PIPE\\";
> +       char *bcc_ptr;
> +       unsigned short mode;
> +
> +       cFYI(1, ("In CIFSSMBTransSetNmPHandState"));
> +setnmaphandstateretry:
> +       rc = smb_init(SMB_COM_TRANSACTION, 16, tcon, (void **) &pSMB,
> +                     (void **) &pSMBr);
> +       if (rc)
> +               return rc;
> +
> +       offset = offsetof(TRANS_REQ, Name) - 4;
> +       pad = offset % 4;
> +       if (pad)
> +               offset += pad;
> +       bcc_ptr = (char *)pSMB + offset + 4;
> +       if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
> +               name_len =
> +                   cifsConvertToUCS((__le16 *) bcc_ptr, fileName,
> +                                    PATH_MAX, nls_codepage, remap);
> +               name_len++;     /* trailing null */
> +               name_len *= 2;
> +       } else {        /* BB improve the check for buffer overruns BB */
> +               name_len = strnlen(fileName, PATH_MAX);
> +               name_len++;     /* trailing null */
> +               strncpy(bcc_ptr, fileName, name_len);
> +       }
> +       byte_count += (1 + pad + name_len);
> +
> +       offset += name_len;
> +       pad = offset % 4;
> +       if (pad)
> +               offset += pad;
> +       pSMB->ParameterCount = 2;
> +       pSMB->TotalParameterCount = 2;
> +       pSMB->ParameterOffset = offset;
> +       bcc_ptr = (char *)pSMB + offset + 4;
> +       mode = (*(unsigned short *)(arg));
> +       *(unsigned short *)bcc_ptr = cpu_to_le16(mode);
> +       bcc_ptr += 2;
> +       param_len = 2;
> +       byte_count += (pad + param_len);
> +
> +       offset += param_len;
> +       pad = offset % 4;
> +       if (pad)
> +               offset += pad;
> +       pSMB->DataOffset = 0;
> +       pSMB->DataCount = 0;
> +       pSMB->TotalDataCount = 0;
> +
> +       pSMB->MaxParameterCount = 0;
> +       pSMB->MaxDataCount = 0;
> +       pSMB->MaxSetupCount = 0;
> +
> +       pSMB->Flags = 0;
> +       pSMB->Timeout = 0;
> +
> +       pSMB->SetupCount = 2;
> +       pSMB->Function = cpu_to_le16(TRANS_SET_NMPIPE_STATE);
> +       pSMB->Fid = cpu_to_le16(netfid);
> +
> +       pSMB->ByteCount = cpu_to_le16(byte_count);
> +
> +       pSMB->hdr.smb_buf_length += byte_count;
> +       rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
> +                        (struct smb_hdr *) pSMBr, &bytes_returned, 0);
> +       if (rc)
> +               cFYI(1, ("CIFSSMBTranSetNmPHandState returned %d", rc));
> +
> +       cifs_buf_release(pSMB);
> +
> +       if (rc == -EAGAIN)
> +               goto setnmaphandstateretry;
> +
> +       return rc;
> +}
> +
> +int
> +CIFSSMBTransPeekNmPipe(const int xid, struct cifsTconInfo *tcon,
> +               unsigned long arg, __u16 netfid,
> +               const struct nls_table *nls_codepage, int remap)
> +{
> +       TRANS_REQ *pSMB = NULL;
> +       TRANS_RSP *pSMBr = NULL;
> +       int rc = 0;
> +       int name_len;
> +       int pad;
> +       int bytes_returned = 0;
> +       int size;
> +       __u16 offset;
> +       __u16 byte_count = 0;
> +       char *fileName = "\\PIPE\\";
> +       char *bcc_ptr;
> +
> +       cFYI(1, ("In CIFSSMBTransPeekNmPipe"));
> +peeknmpiperetry:
> +       rc = smb_init(SMB_COM_TRANSACTION, 16, tcon, (void **) &pSMB,
> +                     (void **) &pSMBr);
> +       if (rc)
> +               return rc;
> +
> +       offset = offsetof(TRANS_REQ, Name) - 4;
> +       pad = offset % 4;
> +       if (pad)
> +               offset += pad;
> +       bcc_ptr = (char *)pSMB + offset + 4;
> +       if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
> +               name_len =
> +                   cifsConvertToUCS((__le16 *) bcc_ptr, fileName,
> +                                    PATH_MAX, nls_codepage, remap);
> +               name_len++;     /* trailing null */
> +               name_len *= 2;
> +       } else {        /* BB improve the check for buffer overruns BB */
> +               name_len = strnlen(fileName, PATH_MAX);
> +               name_len++;     /* trailing null */
> +               strncpy(bcc_ptr, fileName, name_len);
> +       }
> +       byte_count += (1 + pad + name_len);
> +
> +       offset += name_len;
> +       pad = offset % 4;
> +       if (pad)
> +               offset += pad;
> +       pSMB->ParameterCount = 0;
> +       pSMB->TotalParameterCount = 0;
> +       pSMB->ParameterOffset = offset;
> +       byte_count += pad;
> +
> +       pSMB->DataOffset = 0;
> +       pSMB->DataCount = 0;
> +       pSMB->TotalDataCount = 0;
> +
> +       pSMB->MaxParameterCount = 6;
> +       /* BB find max SMB PDU from sess */
> +       pSMB->MaxDataCount = cpu_to_le16(4280);
> +       pSMB->MaxSetupCount = 0;
> +
> +       pSMB->Flags = 0;
> +       pSMB->Timeout = 0;
> +
> +       pSMB->SetupCount = 2;
> +       pSMB->Function = cpu_to_le16(TRANS_PEEK_NMPIPE);
> +       pSMB->Fid = cpu_to_le16(netfid);
> +
> +       pSMB->ByteCount = cpu_to_le16(byte_count);
> +
> +       pSMB->hdr.smb_buf_length += byte_count;
> +       rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
> +                        (struct smb_hdr *) pSMBr, &bytes_returned, 0);
> +       if (rc) {
> +               cFYI(1, ("CIFSSMBTranPeekNmPipe returned %d", rc));
> +       } else {
> +               offset = le16_to_cpu(pSMBr->ParameterOffset);
> +               bcc_ptr = (char *)pSMBr + offset + 4;
> +               ((struct peeknmp_info *)arg)->bavail =
> +                               le16_to_cpu(*(unsigned short *)bcc_ptr);
> +               bcc_ptr += 2;
> +               ((struct peeknmp_info *)arg)->bremain =
> +                       le16_to_cpu(*(unsigned short *)bcc_ptr);
> +               bcc_ptr += 2;
> +               ((struct peeknmp_info *)arg)->conntype =
> +                       le16_to_cpu(*(unsigned short *)bcc_ptr);
> +               bcc_ptr += 2;
> +               if (((struct peeknmp_info *)arg)->size >
> +                               ((struct peeknmp_info *)arg)->bavail)
> +                       size = ((struct peeknmp_info *)arg)->bavail;
> +               else
> +                       size = ((struct peeknmp_info *)arg)->size;
> +               memcpy(((struct peeknmp_info *)arg)->buffer, bcc_ptr, size);
> +       }
> +
> +       cifs_buf_release(pSMB);
> +
> +       if (rc == -EAGAIN)
> +               goto peeknmpiperetry;
> +
> +       return rc;
> +}
> +
> +int
> +CIFSSMBTransGetNmPHState(const int xid, struct cifsTconInfo *tcon,
> +               unsigned long arg, __u16 netfid,
> +               const struct nls_table *nls_codepage, int remap)
> +{
> +       TRANS_REQ *pSMB = NULL;
> +       TRANS_RSP *pSMBr = NULL;
> +       int rc = 0;
> +       int name_len;
> +       int pad;
> +       int bytes_returned = 0;
> +       __u16 offset;
> +       __u16 byte_count = 0;
> +       char *fileName = "\\PIPE\\";
> +       char *bcc_ptr;
> +       struct qnmp_hinfo qnmpipehinfo;
> +
> +       cFYI(1, ("In CIFSSMBTransSetNmPHandState"));
> +getnmaphandstateretry:
> +       rc = smb_init(SMB_COM_TRANSACTION, 16, tcon, (void **) &pSMB,
> +                     (void **) &pSMBr);
> +       if (rc)
> +               return rc;
> +
> +       offset = offsetof(TRANS_REQ, Name) - 4;
> +       pad = offset % 4;
> +       if (pad)
> +               offset += pad;
> +       bcc_ptr = (char *)pSMB + offset + 4;
> +       if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
> +               name_len =
> +                   cifsConvertToUCS((__le16 *) bcc_ptr, fileName,
> +                                    PATH_MAX, nls_codepage, remap);
> +               name_len++;     /* trailing null */
> +               name_len *= 2;
> +       } else {        /* BB improve the check for buffer overruns BB */
> +               name_len = strnlen(fileName, PATH_MAX);
> +               name_len++;     /* trailing null */
> +               strncpy(bcc_ptr, fileName, name_len);
> +       }
> +       byte_count += (1 + pad + name_len);
> +
> +       offset += name_len;
> +       pad = offset % 4;
> +       if (pad)
> +               offset += pad;
> +       pSMB->ParameterCount = 0;
> +       pSMB->TotalParameterCount = 0;
> +       pSMB->ParameterOffset = offset;
> +
> +       pSMB->DataCount = 0;
> +       pSMB->TotalDataCount = 0;
> +       pSMB->DataOffset = offset;
> +
> +       pSMB->MaxParameterCount = 2;
> +       pSMB->MaxDataCount = 0;
> +       pSMB->MaxSetupCount = 0;
> +
> +       pSMB->Flags = 0;
> +       pSMB->Timeout = 0;
> +
> +       pSMB->SetupCount = 2;
> +       pSMB->Function = cpu_to_le16(TRANS_QUERY_NMPIPE_STATE);
> +       pSMB->Fid = cpu_to_le16(netfid);
> +
> +       byte_count += pad;
> +       pSMB->ByteCount = cpu_to_le16(byte_count);
> +
> +       pSMB->hdr.smb_buf_length += byte_count;
> +       rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
> +                        (struct smb_hdr *) pSMBr, &bytes_returned, 0);
> +       if (rc) {
> +               cFYI(1, ("CIFSSMBTranGetNmPHandState returned %d", rc));
> +       } else {
> +               offset = le16_to_cpu(pSMBr->ParameterOffset);
> +               bcc_ptr = (char *)pSMBr + offset + 4;
> +               qnmpipehinfo.mode = le16_to_cpu(*(unsigned short *)bcc_ptr);
> +               memcpy((char *)arg, &qnmpipehinfo, sizeof(struct qnmp_hinfo));
> +       }
> +
> +       cifs_buf_release(pSMB);
> +
> +       if (rc == -EAGAIN)
> +               goto getnmaphandstateretry;
> +
> +       return rc;
> +}
> +
> +int
> +CIFSSMBTransNmPipe(const int xid, struct cifsTconInfo *tcon,
> +               unsigned char *arg, __u16 netfid,
> +               const struct nls_table *nls_codepage, int remap)
> +{
> +       TRANS_REQ *pSMB = NULL;
> +       TRANS_RSP *pSMBr = NULL;
> +       int rc = 0;
> +       int name_len;
> +       int pad;
> +       int bytes_returned = 0;
> +       __u16 offset;
> +       __u16 byte_count = 0;
> +       char *fileName = "\\PIPE\\";
> +       char *bcc_ptr;
> +
> +       cFYI(1, ("In CIFSSMBTransNmPipe"));
> +transnmpiperetry:
> +       rc = smb_init(SMB_COM_TRANSACTION, 16, tcon, (void **) &pSMB,
> +                     (void **) &pSMBr);
> +       if (rc)
> +               return rc;
> +
> +       offset = offsetof(TRANS_REQ, Name) - 4;
> +       pad = offset % 4;
> +       if (pad)
> +               offset += pad;
> +       bcc_ptr = (char *)pSMB + offset + 4;
> +       if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
> +               name_len =
> +                   cifsConvertToUCS((__le16 *) bcc_ptr, fileName,
> +                                    PATH_MAX, nls_codepage, remap);
> +               name_len++;     /* trailing null */
> +               name_len *= 2;
> +       } else {        /* BB improve the check for buffer overruns BB */
> +               name_len = strnlen(fileName, PATH_MAX);
> +               name_len++;     /* trailing null */
> +               strncpy(bcc_ptr, fileName, name_len);
> +       }
> +       byte_count += (1 + pad + name_len);
> +
> +       offset += name_len;
> +       pad = offset % 4;
> +       if (pad)
> +               offset += pad;
> +       pSMB->ParameterOffset = offset;
> +       pSMB->ParameterCount = 0;
> +       pSMB->TotalParameterCount = 0;
> +
> +       pSMB->DataOffset = offset;
> +       pSMB->DataCount = ((struct transnmp_info *)arg)->wsize;
> +       pSMB->TotalDataCount = pSMB->DataCount;
> +       bcc_ptr = (char *)pSMB + offset + 4;
> +       memcpy(bcc_ptr, ((struct transnmp_info *)arg)->sendbuf,
> +                                       pSMB->DataCount);
> +       byte_count += (pad + pSMB->DataCount);
> +
> +       pSMB->MaxParameterCount = 0;
> +       /* BB find max SMB PDU from sess */
> +       pSMB->MaxDataCount = cpu_to_le16(4280);
> +       pSMB->MaxSetupCount = 0;
> +
> +       pSMB->Flags = 0;
> +       pSMB->Timeout = 0;
> +
> +       pSMB->SetupCount = 2;
> +       pSMB->Function = cpu_to_le16(TRANS_TRANSACT_NMPIPE);
> +       pSMB->Fid = cpu_to_le16(netfid);
> +
> +       pSMB->ByteCount = cpu_to_le16(byte_count);
> +
> +       pSMB->hdr.smb_buf_length += byte_count;
> +       rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
> +                        (struct smb_hdr *) pSMBr, &bytes_returned, 0);
> +       if (rc) {
> +               cFYI(1, ("CIFSSMBTransQNmPipe returned %d", rc));
> +       } else {
> +               offset = le16_to_cpu(pSMBr->DataOffset);
> +               bcc_ptr = ((char *)pSMBr + offset + 4);
> +               byte_count = le16_to_cpu(pSMBr->DataCount);
> +               ((struct transnmp_info *)arg)->rsize = byte_count;
> +               memcpy(((struct transnmp_info *)arg)->recvbuf, bcc_ptr,
> +                               byte_count);
> +       }
> +
> +       cifs_buf_release(pSMB);
> +
> +       if (rc == -EAGAIN)
> +               goto transnmpiperetry;
> +
> +       return rc;
> +}
>  #endif
> --
> 1.5.2
>
>
> ------------------------------
>
> _______________________________________________
> linux-cifs-client mailing list
> linux-cifs-client at lists.samba.org
> https://lists.samba.org/mailman/listinfo/linux-cifs-client
>
>
> End of linux-cifs-client Digest, Vol 71, Issue 3
> ************************************************
>



-- 
Best regards,
Peter Chacko

NetDiox computing systems,
Network storage & OS  training and research.
Bangalore, India.
www.netdiox.com
080 2664 0708


More information about the linux-cifs-client mailing list