]> err.no Git - linux-2.6/blobdiff - fs/cifs/cifssmb.c
[PATCH] sunrpc: print unsigned integers in stats
[linux-2.6] / fs / cifs / cifssmb.c
index b102ddb977ca0352fb2c1b3bc94f40b72204c56a..0db0b313d7150f49795c0cc2a765d1abe298f0b0 100644 (file)
@@ -75,7 +75,8 @@ static void mark_open_files_invalid(struct cifsTconInfo * pTcon)
                }
        }
        write_unlock(&GlobalSMBSeslock);
-       /* BB Add call to invalidate_inodes(sb) for all superblocks mounted to this tcon */
+       /* BB Add call to invalidate_inodes(sb) for all superblocks mounted
+          to this tcon */
 }
 
 /* If the return code is zero, this function must fill in request_buf pointer */
@@ -89,11 +90,12 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
           check for tcp and smb session status done differently
           for those three - in the calling routine */
        if(tcon) {
-               if((tcon->ses) && (tcon->ses->server)){
+               if((tcon->ses) && (tcon->ses->status != CifsExiting) &&
+                                 (tcon->ses->server)){
                        struct nls_table *nls_codepage;
                                /* Give Demultiplex thread up to 10 seconds to 
-                                       reconnect, should be greater than cifs socket
-                                       timeout which is 7 seconds */
+                                  reconnect, should be greater than cifs socket
+                                  timeout which is 7 seconds */
                        while(tcon->ses->server->tcpStatus == CifsNeedReconnect) {
                                wait_event_interruptible_timeout(tcon->ses->server->response_q,
                                        (tcon->ses->server->tcpStatus == CifsGood), 10 * HZ);
@@ -103,8 +105,9 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
                                           (tcon->ses->status == CifsExiting)) {
                                                cFYI(1,("gave up waiting on reconnect in smb_init"));
                                                return -EHOSTDOWN;
-                                       } /* else "hard" mount - keep retrying until 
-                                       process is killed or server comes back up */
+                                       } /* else "hard" mount - keep retrying
+                                            until process is killed or server
+                                            comes back on-line */
                                } else /* TCP session is reestablished now */
                                        break;
                                 
@@ -115,23 +118,24 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
                simultaneously reconnect the same SMB session */
                        down(&tcon->ses->sesSem);
                        if(tcon->ses->status == CifsNeedReconnect)
-                               rc = cifs_setup_session(0, tcon->ses, nls_codepage);
+                               rc = cifs_setup_session(0, tcon->ses, 
+                                                       nls_codepage);
                        if(!rc && (tcon->tidStatus == CifsNeedReconnect)) {
                                mark_open_files_invalid(tcon);
-                               rc = CIFSTCon(0, tcon->ses, tcon->treeName, tcon,
-                                       nls_codepage);
+                               rc = CIFSTCon(0, tcon->ses, tcon->treeName, tcon
+                                       nls_codepage);
                                up(&tcon->ses->sesSem);
                                if(rc == 0)
                                        atomic_inc(&tconInfoReconnectCount);
 
                                cFYI(1, ("reconnect tcon rc = %d", rc));
                                /* Removed call to reopen open files here - 
-                                       it is safer (and faster) to reopen files
-                                       one at a time as needed in read and write */
+                                  it is safer (and faster) to reopen files
+                                  one at a time as needed in read and write */
 
                                /* Check if handle based operation so we 
-                                       know whether we can continue or not without
-                                       returning to caller to reset file handle */
+                                  know whether we can continue or not without
+                                  returning to caller to reset file handle */
                                switch(smb_command) {
                                        case SMB_COM_READ_ANDX:
                                        case SMB_COM_WRITE_ANDX:
@@ -182,22 +186,25 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
           check for tcp and smb session status done differently
           for those three - in the calling routine */
        if(tcon) {
-               if((tcon->ses) && (tcon->ses->server)){
+               if((tcon->ses) && (tcon->ses->status != CifsExiting) && 
+                                 (tcon->ses->server)){
                        struct nls_table *nls_codepage;
-                               /* Give Demultiplex thread up to 10 seconds to 
-                                       reconnect, should be greater than cifs socket
-                                       timeout which is 7 seconds */
+                               /* Give Demultiplex thread up to 10 seconds to
+                                  reconnect, should be greater than cifs socket
+                                  timeout which is 7 seconds */
                        while(tcon->ses->server->tcpStatus == CifsNeedReconnect) {
                                wait_event_interruptible_timeout(tcon->ses->server->response_q,
                                        (tcon->ses->server->tcpStatus == CifsGood), 10 * HZ);
-                               if(tcon->ses->server->tcpStatus == CifsNeedReconnect) {
+                               if(tcon->ses->server->tcpStatus == 
+                                               CifsNeedReconnect) {
                                        /* on "soft" mounts we wait once */
                                        if((tcon->retry == FALSE) || 
                                           (tcon->ses->status == CifsExiting)) {
                                                cFYI(1,("gave up waiting on reconnect in smb_init"));
                                                return -EHOSTDOWN;
-                                       } /* else "hard" mount - keep retrying until 
-                                       process is killed or server comes back up */
+                                       } /* else "hard" mount - keep retrying
+                                            until process is killed or server
+                                            comes on-line */
                                } else /* TCP session is reestablished now */
                                        break;
                                 
@@ -208,23 +215,24 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
                simultaneously reconnect the same SMB session */
                        down(&tcon->ses->sesSem);
                        if(tcon->ses->status == CifsNeedReconnect)
-                               rc = cifs_setup_session(0, tcon->ses, nls_codepage);
+                               rc = cifs_setup_session(0, tcon->ses, 
+                                                       nls_codepage);
                        if(!rc && (tcon->tidStatus == CifsNeedReconnect)) {
                                mark_open_files_invalid(tcon);
-                               rc = CIFSTCon(0, tcon->ses, tcon->treeName, tcon,
-                                       nls_codepage);
+                               rc = CIFSTCon(0, tcon->ses, tcon->treeName,
+                                             tcon, nls_codepage);
                                up(&tcon->ses->sesSem);
                                if(rc == 0)
                                        atomic_inc(&tconInfoReconnectCount);
 
                                cFYI(1, ("reconnect tcon rc = %d", rc));
                                /* Removed call to reopen open files here - 
-                                       it is safer (and faster) to reopen files
-                                       one at a time as needed in read and write */
+                                  it is safer (and faster) to reopen files
+                                  one at a time as needed in read and write */
 
                                /* Check if handle based operation so we 
-                                       know whether we can continue or not without
-                                       returning to caller to reset file handle */
+                                  know whether we can continue or not without
+                                  returning to caller to reset file handle */
                                switch(smb_command) {
                                        case SMB_COM_READ_ANDX:
                                        case SMB_COM_WRITE_ANDX:
@@ -286,7 +294,8 @@ static int validate_t2(struct smb_t2_rsp * pSMB)
                        if(total_size < 512) {
                                total_size+=le16_to_cpu(pSMB->t2_rsp.DataCount);
                                /* BCC le converted in SendReceive */
-                               pBCC = (pSMB->hdr.WordCount * 2) + sizeof(struct smb_hdr) + 
+                               pBCC = (pSMB->hdr.WordCount * 2) + 
+                                       sizeof(struct smb_hdr) +
                                        (char *)pSMB;
                                if((total_size <= (*(u16 *)pBCC)) && 
                                   (total_size < 
@@ -337,8 +346,10 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
                         (struct smb_hdr *) pSMBr, &bytes_returned, 0);
        if (rc == 0) {
                server->secMode = pSMBr->SecurityMode;  
-               server->secType = NTLM; /* BB override default for NTLMv2 or krb*/
-               /* one byte - no need to convert this or EncryptionKeyLen from le,*/
+               server->secType = NTLM; /* BB override default for 
+                                          NTLMv2 or kerberos v5 */
+               /* one byte - no need to convert this or EncryptionKeyLen
+                  from little endian */
                server->maxReq = le16_to_cpu(pSMBr->MaxMpxCount);
                /* probably no need to store and check maxvcs */
                server->maxBuf =
@@ -374,7 +385,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
                                                pSMBr->u.extended_response.
                                                GUID, 16) != 0) {
                                                cFYI(1,
-                                                       ("UID of server does not match previous connection to same ip address"));
+                                                    ("UID of server does not match previous connection to same ip address"));
                                                memcpy(server->
                                                        server_GUID,
                                                        pSMBr->u.
@@ -454,13 +465,14 @@ CIFSSMBTDis(const int xid, struct cifsTconInfo *tcon)
                up(&tcon->tconSem);
                return -EIO;
        }
-       rc = small_smb_init(SMB_COM_TREE_DISCONNECT, 0, tcon, (void **)&smb_buffer);
+       rc = small_smb_init(SMB_COM_TREE_DISCONNECT, 0, tcon, 
+                           (void **)&smb_buffer);
        if (rc) {
                up(&tcon->tconSem);
                return rc;
        } else {
                smb_buffer_response = smb_buffer; /* BB removeme BB */
-    }
+       }
        rc = SendReceive(xid, tcon->ses, smb_buffer, smb_buffer_response,
                         &length, 0);
        if (rc)
@@ -555,11 +567,11 @@ DelFileRetry:
 
        if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
                name_len =
-                   cifsConvertToUCS((__u16 *) pSMB->fileName, fileName, 
+                   cifsConvertToUCS((__le16 *) pSMB->fileName, fileName, 
                                     PATH_MAX, nls_codepage, remap);
                name_len++;     /* trailing null */
                name_len *= 2;
-       } else {                /* BB improve the check for buffer overruns BB */
+       } else {                /* BB improve check for buffer overruns BB */
                name_len = strnlen(fileName, PATH_MAX);
                name_len++;     /* trailing null */
                strncpy(pSMB->fileName, fileName, name_len);
@@ -609,7 +621,7 @@ RmDirRetry:
                                         PATH_MAX, nls_codepage, remap);
                name_len++;     /* trailing null */
                name_len *= 2;
-       } else {                /* BB improve the check for buffer overruns BB */
+       } else {                /* BB improve check for buffer overruns BB */
                name_len = strnlen(dirName, PATH_MAX);
                name_len++;     /* trailing null */
                strncpy(pSMB->DirName, dirName, name_len);
@@ -653,11 +665,11 @@ MkDirRetry:
                return rc;
 
        if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
-               name_len = cifsConvertToUCS((__u16 *) pSMB->DirName, name, 
+               name_len = cifsConvertToUCS((__le16 *) pSMB->DirName, name, 
                                            PATH_MAX, nls_codepage, remap);
                name_len++;     /* trailing null */
                name_len *= 2;
-       } else {                /* BB improve the check for buffer overruns BB */
+       } else {                /* BB improve check for buffer overruns BB */
                name_len = strnlen(name, PATH_MAX);
                name_len++;     /* trailing null */
                strncpy(pSMB->DirName, name, name_len);
@@ -707,12 +719,12 @@ openRetry:
        if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
                count = 1;      /* account for one byte pad to word boundary */
                name_len =
-                   cifsConvertToUCS((__u16 *) (pSMB->fileName + 1),
+                   cifsConvertToUCS((__le16 *) (pSMB->fileName + 1),
                                     fileName, PATH_MAX, nls_codepage, remap);
                name_len++;     /* trailing null */
                name_len *= 2;
                pSMB->NameLength = cpu_to_le16(name_len);
-       } else {                /* BB improve the check for buffer overruns BB */
+       } else {                /* BB improve check for buffer overruns BB */
                count = 0;      /* no pad */
                name_len = strnlen(fileName, PATH_MAX);
                name_len++;     /* trailing null */
@@ -741,7 +753,8 @@ openRetry:
        pSMB->ShareAccess = cpu_to_le32(FILE_SHARE_ALL);
        pSMB->CreateDisposition = cpu_to_le32(openDisposition);
        pSMB->CreateOptions = cpu_to_le32(create_options);
-       pSMB->ImpersonationLevel = cpu_to_le32(SECURITY_IMPERSONATION); /* BB ??*/
+       /* BB Expirement with various impersonation levels and verify */
+       pSMB->ImpersonationLevel = cpu_to_le32(SECURITY_IMPERSONATION);
        pSMB->SecurityFlags =
            SECURITY_CONTEXT_TRACKING | SECURITY_EFFECTIVE_ONLY;
 
@@ -755,7 +768,7 @@ openRetry:
        if (rc) {
                cFYI(1, ("Error in Open = %d", rc));
        } else {
-               *pOplock = pSMBr->OplockLevel;  /* one byte no need to le_to_cpu */
+               *pOplock = pSMBr->OplockLevel; /* 1 byte no need to le_to_cpu */
                *netfid = pSMBr->Fid;   /* cifs fid stays in le */
                /* Let caller know file was created so we can set the mode. */
                /* Do we care about the CreateAction in any other cases? */
@@ -1012,11 +1025,13 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
        __u16 count;
 
        cFYI(1, ("In CIFSSMBLock - timeout %d numLock %d",waitFlag,numLock));
-       rc = smb_init(SMB_COM_LOCKING_ANDX, 8, tcon, (void **) &pSMB,
-                     (void **) &pSMBr);
+       rc = small_smb_init(SMB_COM_LOCKING_ANDX, 8, tcon, (void **) &pSMB);
+
        if (rc)
                return rc;
 
+       pSMBr = (LOCK_RSP *)pSMB; /* BB removeme BB */
+
        if(lockType == LOCKING_ANDX_OPLOCK_RELEASE) {
                timeout = -1; /* no response expected */
                pSMB->Timeout = 0;
@@ -1054,7 +1069,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
        if (rc) {
                cFYI(1, ("Send error in Lock = %d", rc));
        }
-       cifs_buf_release(pSMB);
+       cifs_small_buf_release(pSMB);
 
        /* Note: On -EAGAIN error only caller can retry on handle based calls 
        since file handle passed in no longer valid */
@@ -1126,7 +1141,7 @@ renameRetry:
 
        if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
                name_len =
-                   cifsConvertToUCS((__u16 *) pSMB->OldFileName, fromName, 
+                   cifsConvertToUCS((__le16 *) pSMB->OldFileName, fromName, 
                                     PATH_MAX, nls_codepage, remap);
                name_len++;     /* trailing null */
                name_len *= 2;
@@ -1134,7 +1149,7 @@ renameRetry:
        /* protocol requires ASCII signature byte on Unicode string */
                pSMB->OldFileName[name_len + 1] = 0x00;
                name_len2 =
-                   cifsConvertToUCS((__u16 *) &pSMB->OldFileName[name_len + 2],
+                   cifsConvertToUCS((__le16 *) &pSMB->OldFileName[name_len + 2],
                                     toName, PATH_MAX, nls_codepage, remap);
                name_len2 += 1 /* trailing null */  + 1 /* Signature word */ ;
                name_len2 *= 2; /* convert to bytes */
@@ -1221,10 +1236,10 @@ int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon,
        /* unicode only call */
        if(target_name == NULL) {
                sprintf(dummy_string,"cifs%x",pSMB->hdr.Mid);
-               len_of_str = cifsConvertToUCS((__u16 *)rename_info->target_name,
+               len_of_str = cifsConvertToUCS((__le16 *)rename_info->target_name,
                                        dummy_string, 24, nls_codepage, remap);
        } else {
-               len_of_str = cifsConvertToUCS((__u16 *)rename_info->target_name,
+               len_of_str = cifsConvertToUCS((__le16 *)rename_info->target_name,
                                        target_name, PATH_MAX, nls_codepage, remap);
        }
        rename_info->target_name_len = cpu_to_le32(2 * len_of_str);
@@ -1281,7 +1296,7 @@ copyRetry:
        pSMB->Flags = cpu_to_le16(flags & COPY_TREE);
 
        if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
-               name_len = cifsConvertToUCS((__u16 *) pSMB->OldFileName, 
+               name_len = cifsConvertToUCS((__le16 *) pSMB->OldFileName, 
                                            fromName, PATH_MAX, nls_codepage,
                                            remap);
                name_len++;     /* trailing null */
@@ -1289,7 +1304,7 @@ copyRetry:
                pSMB->OldFileName[name_len] = 0x04;     /* pad */
                /* protocol requires ASCII signature byte on Unicode string */
                pSMB->OldFileName[name_len + 1] = 0x00;
-               name_len2 = cifsConvertToUCS((__u16 *)&pSMB->OldFileName[name_len + 2], 
+               name_len2 = cifsConvertToUCS((__le16 *)&pSMB->OldFileName[name_len + 2], 
                                toName, PATH_MAX, nls_codepage, remap);
                name_len2 += 1 /* trailing null */  + 1 /* Signature word */ ;
                name_len2 *= 2; /* convert to bytes */
@@ -1438,7 +1453,7 @@ createHardLinkRetry:
                return rc;
 
        if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
-               name_len = cifsConvertToUCS((__u16 *) pSMB->FileName, toName,
+               name_len = cifsConvertToUCS((__le16 *) pSMB->FileName, toName,
                                            PATH_MAX, nls_codepage, remap);
                name_len++;     /* trailing null */
                name_len *= 2;
@@ -1461,7 +1476,7 @@ createHardLinkRetry:
        data_offset = (char *) (&pSMB->hdr.Protocol) + offset;
        if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
                name_len_target =
-                   cifsConvertToUCS((__u16 *) data_offset, fromName, PATH_MAX,
+                   cifsConvertToUCS((__le16 *) data_offset, fromName, PATH_MAX,
                                     nls_codepage, remap);
                name_len_target++;      /* trailing null */
                name_len_target *= 2;
@@ -1531,14 +1546,14 @@ winCreateHardLinkRetry:
 
        if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
                name_len =
-                   cifsConvertToUCS((__u16 *) pSMB->OldFileName, fromName,
+                   cifsConvertToUCS((__le16 *) pSMB->OldFileName, fromName,
                                     PATH_MAX, nls_codepage, remap);
                name_len++;     /* trailing null */
                name_len *= 2;
                pSMB->OldFileName[name_len] = 0;        /* pad */
                pSMB->OldFileName[name_len + 1] = 0x04; 
                name_len2 =
-                   cifsConvertToUCS((__u16 *)&pSMB->OldFileName[name_len + 2], 
+                   cifsConvertToUCS((__le16 *)&pSMB->OldFileName[name_len + 2], 
                                     toName, PATH_MAX, nls_codepage, remap);
                name_len2 += 1 /* trailing null */  + 1 /* Signature word */ ;
                name_len2 *= 2; /* convert to bytes */
@@ -1924,7 +1939,7 @@ queryAclRetry:
                                                                                                                                              
        if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
                name_len =
-                       cifsConvertToUCS((__u16 *) pSMB->FileName, searchName, 
+                       cifsConvertToUCS((__le16 *) pSMB->FileName, searchName, 
                                         PATH_MAX, nls_codepage, remap);
                name_len++;     /* trailing null */
                name_len *= 2;
@@ -2009,7 +2024,7 @@ setAclRetry:
                return rc;
        if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
                name_len =
-                       cifsConvertToUCS((__u16 *) pSMB->FileName, fileName, 
+                       cifsConvertToUCS((__le16 *) pSMB->FileName, fileName, 
                                      PATH_MAX, nls_codepage, remap);
                name_len++;     /* trailing null */
                name_len *= 2;
@@ -2173,7 +2188,7 @@ QPathInfoRetry:
 
        if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
                name_len =
-                   cifsConvertToUCS((__u16 *) pSMB->FileName, searchName, 
+                   cifsConvertToUCS((__le16 *) pSMB->FileName, searchName, 
                                     PATH_MAX, nls_codepage, remap);
                name_len++;     /* trailing null */
                name_len *= 2;
@@ -2254,7 +2269,7 @@ UnixQPathInfoRetry:
 
        if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
                name_len =
-                   cifsConvertToUCS((__u16 *) pSMB->FileName, searchName,
+                   cifsConvertToUCS((__le16 *) pSMB->FileName, searchName,
                                  PATH_MAX, nls_codepage, remap);
                name_len++;     /* trailing null */
                name_len *= 2;
@@ -2335,7 +2350,7 @@ findUniqueRetry:
 
        if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
                name_len =
-                   cifsConvertToUCS((wchar_t *) pSMB->FileName, searchName, PATH_MAX
+                   cifsConvertToUCS((__le16 *) pSMB->FileName, searchName, PATH_MAX
                                  /* find define for this maxpathcomponent */
                                  , nls_codepage);
                name_len++;     /* trailing null */
@@ -2420,7 +2435,7 @@ findFirstRetry:
 
        if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
                name_len =
-                   cifsConvertToUCS((__u16 *) pSMB->FileName,searchName,
+                   cifsConvertToUCS((__le16 *) pSMB->FileName,searchName,
                                 PATH_MAX, nls_codepage, remap);
                /* We can not add the asterik earlier in case
                it got remapped to 0xF03A as if it were part of the
@@ -2436,12 +2451,14 @@ findFirstRetry:
                name_len += 2;
        } else {        /* BB add check for overrun of SMB buf BB */
                name_len = strnlen(searchName, PATH_MAX);
-               name_len++;     /* trailing null */
 /* BB fix here and in unicode clause above ie
                if(name_len > buffersize-header)
                        free buffer exit; BB */
                strncpy(pSMB->FileName, searchName, name_len);
-               pSMB->FileName[name_len] = 0; /* just in case */
+               pSMB->FileName[name_len] = '\\';
+               pSMB->FileName[name_len+1] = '*';
+               pSMB->FileName[name_len+2] = 0;
+               name_len += 3;
        }
 
        params = 12 + name_len /* includes null */ ;
@@ -2504,7 +2521,6 @@ findFirstRetry:
                        psrch_inf->srch_entries_start = 
                                (char *) &pSMBr->hdr.Protocol + 
                                        le16_to_cpu(pSMBr->t2.DataOffset);
-
                        parms = (T2_FFIRST_RSP_PARMS *)((char *) &pSMBr->hdr.Protocol +
                               le16_to_cpu(pSMBr->t2.ParameterOffset));
 
@@ -2516,7 +2532,6 @@ findFirstRetry:
                        psrch_inf->entries_in_buffer  = le16_to_cpu(parms->SearchCount);
                        psrch_inf->index_of_last_entry = 
                                psrch_inf->entries_in_buffer;
-/*cFYI(1,("entries in buf %d index_of_last %d",psrch_inf->entries_in_buffer,psrch_inf->index_of_last_entry));  */
                        *pnetfid = parms->SearchHandle;
                } else {
                        cifs_buf_release(pSMB);
@@ -2587,6 +2602,9 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
        if(name_len < PATH_MAX) {
                memcpy(pSMB->ResumeFileName, psrch_inf->presume_name, name_len);
                byte_count += name_len;
+               /* 14 byte parm len above enough for 2 byte null terminator */
+               pSMB->ResumeFileName[name_len] = 0;
+               pSMB->ResumeFileName[name_len+1] = 0;
        } else {
                rc = -EINVAL;
                goto FNext2_err_exit;
@@ -2711,7 +2729,7 @@ GetInodeNumberRetry:
 
        if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
                name_len =
-                       cifsConvertToUCS((__u16 *) pSMB->FileName, searchName,
+                       cifsConvertToUCS((__le16 *) pSMB->FileName, searchName,
                                PATH_MAX,nls_codepage, remap);
                name_len++;     /* trailing null */
                name_len *= 2;
@@ -2822,7 +2840,7 @@ getDFSRetry:
        if (ses->capabilities & CAP_UNICODE) {
                pSMB->hdr.Flags2 |= SMBFLG2_UNICODE;
                name_len =
-                   cifsConvertToUCS((__u16 *) pSMB->RequestFileName,
+                   cifsConvertToUCS((__le16 *) pSMB->RequestFileName,
                                     searchName, PATH_MAX, nls_codepage, remap);
                name_len++;     /* trailing null */
                name_len *= 2;
@@ -3354,7 +3372,7 @@ SetEOFRetry:
 
        if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
                name_len =
-                   cifsConvertToUCS((__u16 *) pSMB->FileName, fileName,
+                   cifsConvertToUCS((__le16 *) pSMB->FileName, fileName,
                                     PATH_MAX, nls_codepage, remap);
                name_len++;     /* trailing null */
                name_len *= 2;
@@ -3436,11 +3454,13 @@ CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon, __u64 size,
 
        cFYI(1, ("SetFileSize (via SetFileInfo) %lld",
                        (long long)size));
-       rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB,
-                     (void **) &pSMBr);
+       rc = small_smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB);
+
        if (rc)
                return rc;
 
+       pSMBr = (struct smb_com_transaction2_sfi_rsp *)pSMB;
+
        pSMB->hdr.Pid = cpu_to_le16((__u16)pid_of_opener);
        pSMB->hdr.PidHigh = cpu_to_le16((__u16)(pid_of_opener >> 16));
     
@@ -3500,7 +3520,7 @@ CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon, __u64 size,
        }
 
        if (pSMB)
-               cifs_buf_release(pSMB);
+               cifs_small_buf_release(pSMB);
 
        /* Note: On -EAGAIN error only caller can retry on handle based calls 
                since file handle passed in no longer valid */
@@ -3526,11 +3546,13 @@ CIFSSMBSetFileTimes(const int xid, struct cifsTconInfo *tcon, const FILE_BASIC_I
        __u16 params, param_offset, offset, byte_count, count;
 
        cFYI(1, ("Set Times (via SetFileInfo)"));
-       rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB,
-                     (void **) &pSMBr);
+       rc = small_smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB);
+
        if (rc)
                return rc;
 
+       pSMBr = (struct smb_com_transaction2_sfi_rsp *)pSMB;
+
        /* At this point there is no need to override the current pid
        with the pid of the opener, but that could change if we someday
        use an existing handle (rather than opening one on the fly) */
@@ -3576,7 +3598,7 @@ CIFSSMBSetFileTimes(const int xid, struct cifsTconInfo *tcon, const FILE_BASIC_I
                cFYI(1,("Send error in Set Time (SetFileInfo) = %d",rc));
        }
 
-       cifs_buf_release(pSMB);
+       cifs_small_buf_release(pSMB);
 
        /* Note: On -EAGAIN error only caller can retry on handle based calls 
                since file handle passed in no longer valid */
@@ -3608,7 +3630,7 @@ SetTimesRetry:
 
        if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
                name_len =
-                   cifsConvertToUCS((__u16 *) pSMB->FileName, fileName,
+                   cifsConvertToUCS((__le16 *) pSMB->FileName, fileName,
                                     PATH_MAX, nls_codepage, remap);
                name_len++;     /* trailing null */
                name_len *= 2;
@@ -3689,7 +3711,7 @@ SetAttrLgcyRetry:
 
        if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
                name_len =
-                       ConvertToUCS((wchar_t *) pSMB->fileName, fileName, 
+                       ConvertToUCS((__le16 *) pSMB->fileName, fileName, 
                                PATH_MAX, nls_codepage);
                name_len++;     /* trailing null */
                name_len *= 2;
@@ -3740,7 +3762,7 @@ setPermsRetry:
 
        if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
                name_len =
-                   cifsConvertToUCS((__u16 *) pSMB->FileName, fileName, 
+                   cifsConvertToUCS((__le16 *) pSMB->FileName, fileName, 
                                     PATH_MAX, nls_codepage, remap);
                name_len++;     /* trailing null */
                name_len *= 2;
@@ -3885,7 +3907,7 @@ QAllEAsRetry:
 
        if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
                name_len =
-                   cifsConvertToUCS((wchar_t *) pSMB->FileName, searchName, 
+                   cifsConvertToUCS((__le16 *) pSMB->FileName, searchName, 
                                     PATH_MAX, nls_codepage, remap);
                name_len++;     /* trailing null */
                name_len *= 2;
@@ -4028,7 +4050,7 @@ QEARetry:
 
        if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
                name_len =
-                   cifsConvertToUCS((__u16 *) pSMB->FileName, searchName, 
+                   cifsConvertToUCS((__le16 *) pSMB->FileName, searchName, 
                                     PATH_MAX, nls_codepage, remap);
                name_len++;     /* trailing null */
                name_len *= 2;
@@ -4175,7 +4197,7 @@ SetEARetry:
 
        if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
                name_len =
-                   cifsConvertToUCS((__u16 *) pSMB->FileName, fileName, 
+                   cifsConvertToUCS((__le16 *) pSMB->FileName, fileName, 
                                     PATH_MAX, nls_codepage, remap);
                name_len++;     /* trailing null */
                name_len *= 2;