diff options
Diffstat (limited to 'fs/cifs/misc.c')
| -rw-r--r-- | fs/cifs/misc.c | 150 |
1 files changed, 76 insertions, 74 deletions
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c index 0211e0651b50..7590fd3d958c 100644 --- a/fs/cifs/misc.c +++ b/fs/cifs/misc.c | |||
| @@ -16,7 +16,7 @@ | |||
| 16 | * | 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public License | 17 | * You should have received a copy of the GNU Lesser General Public License |
| 18 | * along with this library; if not, write to the Free Software | 18 | * along with this library; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 | */ | 20 | */ |
| 21 | 21 | ||
| 22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
| @@ -32,12 +32,12 @@ | |||
| 32 | 32 | ||
| 33 | extern mempool_t *cifs_sm_req_poolp; | 33 | extern mempool_t *cifs_sm_req_poolp; |
| 34 | extern mempool_t *cifs_req_poolp; | 34 | extern mempool_t *cifs_req_poolp; |
| 35 | extern struct task_struct * oplockThread; | 35 | extern struct task_struct *oplockThread; |
| 36 | 36 | ||
| 37 | /* The xid serves as a useful identifier for each incoming vfs request, | 37 | /* The xid serves as a useful identifier for each incoming vfs request, |
| 38 | in a similar way to the mid which is useful to track each sent smb, | 38 | in a similar way to the mid which is useful to track each sent smb, |
| 39 | and CurrentXid can also provide a running counter (although it | 39 | and CurrentXid can also provide a running counter (although it |
| 40 | will eventually wrap past zero) of the total vfs operations handled | 40 | will eventually wrap past zero) of the total vfs operations handled |
| 41 | since the cifs fs was mounted */ | 41 | since the cifs fs was mounted */ |
| 42 | 42 | ||
| 43 | unsigned int | 43 | unsigned int |
| @@ -50,7 +50,7 @@ _GetXid(void) | |||
| 50 | if (GlobalTotalActiveXid > GlobalMaxActiveXid) | 50 | if (GlobalTotalActiveXid > GlobalMaxActiveXid) |
| 51 | GlobalMaxActiveXid = GlobalTotalActiveXid; /* keep high water mark for number of simultaneous vfs ops in our filesystem */ | 51 | GlobalMaxActiveXid = GlobalTotalActiveXid; /* keep high water mark for number of simultaneous vfs ops in our filesystem */ |
| 52 | if (GlobalTotalActiveXid > 65000) | 52 | if (GlobalTotalActiveXid > 65000) |
| 53 | cFYI(1,("warning: more than 65000 requests active")); | 53 | cFYI(1, ("warning: more than 65000 requests active")); |
| 54 | xid = GlobalCurrentXid++; | 54 | xid = GlobalCurrentXid++; |
| 55 | spin_unlock(&GlobalMid_Lock); | 55 | spin_unlock(&GlobalMid_Lock); |
| 56 | return xid; | 56 | return xid; |
| @@ -144,9 +144,9 @@ cifs_buf_get(void) | |||
| 144 | { | 144 | { |
| 145 | struct smb_hdr *ret_buf = NULL; | 145 | struct smb_hdr *ret_buf = NULL; |
| 146 | 146 | ||
| 147 | /* We could use negotiated size instead of max_msgsize - | 147 | /* We could use negotiated size instead of max_msgsize - |
| 148 | but it may be more efficient to always alloc same size | 148 | but it may be more efficient to always alloc same size |
| 149 | albeit slightly larger than necessary and maxbuffersize | 149 | albeit slightly larger than necessary and maxbuffersize |
| 150 | defaults to this and can not be bigger */ | 150 | defaults to this and can not be bigger */ |
| 151 | ret_buf = | 151 | ret_buf = |
| 152 | (struct smb_hdr *) mempool_alloc(cifs_req_poolp, GFP_KERNEL | GFP_NOFS); | 152 | (struct smb_hdr *) mempool_alloc(cifs_req_poolp, GFP_KERNEL | GFP_NOFS); |
| @@ -172,7 +172,7 @@ cifs_buf_release(void *buf_to_free) | |||
| 172 | /* cFYI(1, ("Null buffer passed to cifs_buf_release"));*/ | 172 | /* cFYI(1, ("Null buffer passed to cifs_buf_release"));*/ |
| 173 | return; | 173 | return; |
| 174 | } | 174 | } |
| 175 | mempool_free(buf_to_free,cifs_req_poolp); | 175 | mempool_free(buf_to_free, cifs_req_poolp); |
| 176 | 176 | ||
| 177 | atomic_dec(&bufAllocCount); | 177 | atomic_dec(&bufAllocCount); |
| 178 | return; | 178 | return; |
| @@ -183,9 +183,9 @@ cifs_small_buf_get(void) | |||
| 183 | { | 183 | { |
| 184 | struct smb_hdr *ret_buf = NULL; | 184 | struct smb_hdr *ret_buf = NULL; |
| 185 | 185 | ||
| 186 | /* We could use negotiated size instead of max_msgsize - | 186 | /* We could use negotiated size instead of max_msgsize - |
| 187 | but it may be more efficient to always alloc same size | 187 | but it may be more efficient to always alloc same size |
| 188 | albeit slightly larger than necessary and maxbuffersize | 188 | albeit slightly larger than necessary and maxbuffersize |
| 189 | defaults to this and can not be bigger */ | 189 | defaults to this and can not be bigger */ |
| 190 | ret_buf = | 190 | ret_buf = |
| 191 | (struct smb_hdr *) mempool_alloc(cifs_sm_req_poolp, GFP_KERNEL | GFP_NOFS); | 191 | (struct smb_hdr *) mempool_alloc(cifs_sm_req_poolp, GFP_KERNEL | GFP_NOFS); |
| @@ -209,30 +209,30 @@ cifs_small_buf_release(void *buf_to_free) | |||
| 209 | cFYI(1, ("Null buffer passed to cifs_small_buf_release")); | 209 | cFYI(1, ("Null buffer passed to cifs_small_buf_release")); |
| 210 | return; | 210 | return; |
| 211 | } | 211 | } |
| 212 | mempool_free(buf_to_free,cifs_sm_req_poolp); | 212 | mempool_free(buf_to_free, cifs_sm_req_poolp); |
| 213 | 213 | ||
| 214 | atomic_dec(&smBufAllocCount); | 214 | atomic_dec(&smBufAllocCount); |
| 215 | return; | 215 | return; |
| 216 | } | 216 | } |
| 217 | 217 | ||
| 218 | /* | 218 | /* |
| 219 | Find a free multiplex id (SMB mid). Otherwise there could be | 219 | Find a free multiplex id (SMB mid). Otherwise there could be |
| 220 | mid collisions which might cause problems, demultiplexing the | 220 | mid collisions which might cause problems, demultiplexing the |
| 221 | wrong response to this request. Multiplex ids could collide if | 221 | wrong response to this request. Multiplex ids could collide if |
| 222 | one of a series requests takes much longer than the others, or | 222 | one of a series requests takes much longer than the others, or |
| 223 | if a very large number of long lived requests (byte range | 223 | if a very large number of long lived requests (byte range |
| 224 | locks or FindNotify requests) are pending. No more than | 224 | locks or FindNotify requests) are pending. No more than |
| 225 | 64K-1 requests can be outstanding at one time. If no | 225 | 64K-1 requests can be outstanding at one time. If no |
| 226 | mids are available, return zero. A future optimization | 226 | mids are available, return zero. A future optimization |
| 227 | could make the combination of mids and uid the key we use | 227 | could make the combination of mids and uid the key we use |
| 228 | to demultiplex on (rather than mid alone). | 228 | to demultiplex on (rather than mid alone). |
| 229 | In addition to the above check, the cifs demultiplex | 229 | In addition to the above check, the cifs demultiplex |
| 230 | code already used the command code as a secondary | 230 | code already used the command code as a secondary |
| 231 | check of the frame and if signing is negotiated the | 231 | check of the frame and if signing is negotiated the |
| 232 | response would be discarded if the mid were the same | 232 | response would be discarded if the mid were the same |
| 233 | but the signature was wrong. Since the mid is not put in the | 233 | but the signature was wrong. Since the mid is not put in the |
| 234 | pending queue until later (when it is about to be dispatched) | 234 | pending queue until later (when it is about to be dispatched) |
| 235 | we do have to limit the number of outstanding requests | 235 | we do have to limit the number of outstanding requests |
| 236 | to somewhat less than 64K-1 although it is hard to imagine | 236 | to somewhat less than 64K-1 although it is hard to imagine |
| 237 | so many threads being in the vfs at one time. | 237 | so many threads being in the vfs at one time. |
| 238 | */ | 238 | */ |
| @@ -240,7 +240,7 @@ __u16 GetNextMid(struct TCP_Server_Info *server) | |||
| 240 | { | 240 | { |
| 241 | __u16 mid = 0; | 241 | __u16 mid = 0; |
| 242 | __u16 last_mid; | 242 | __u16 last_mid; |
| 243 | int collision; | 243 | int collision; |
| 244 | 244 | ||
| 245 | if (server == NULL) | 245 | if (server == NULL) |
| 246 | return mid; | 246 | return mid; |
| @@ -249,13 +249,13 @@ __u16 GetNextMid(struct TCP_Server_Info *server) | |||
| 249 | last_mid = server->CurrentMid; /* we do not want to loop forever */ | 249 | last_mid = server->CurrentMid; /* we do not want to loop forever */ |
| 250 | server->CurrentMid++; | 250 | server->CurrentMid++; |
| 251 | /* This nested loop looks more expensive than it is. | 251 | /* This nested loop looks more expensive than it is. |
| 252 | In practice the list of pending requests is short, | 252 | In practice the list of pending requests is short, |
| 253 | fewer than 50, and the mids are likely to be unique | 253 | fewer than 50, and the mids are likely to be unique |
| 254 | on the first pass through the loop unless some request | 254 | on the first pass through the loop unless some request |
| 255 | takes longer than the 64 thousand requests before it | 255 | takes longer than the 64 thousand requests before it |
| 256 | (and it would also have to have been a request that | 256 | (and it would also have to have been a request that |
| 257 | did not time out) */ | 257 | did not time out) */ |
| 258 | while(server->CurrentMid != last_mid) { | 258 | while (server->CurrentMid != last_mid) { |
| 259 | struct list_head *tmp; | 259 | struct list_head *tmp; |
| 260 | struct mid_q_entry *mid_entry; | 260 | struct mid_q_entry *mid_entry; |
| 261 | 261 | ||
| @@ -290,11 +290,11 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ , | |||
| 290 | const struct cifsTconInfo *treeCon, int word_count | 290 | const struct cifsTconInfo *treeCon, int word_count |
| 291 | /* length of fixed section (word count) in two byte units */) | 291 | /* length of fixed section (word count) in two byte units */) |
| 292 | { | 292 | { |
| 293 | struct list_head* temp_item; | 293 | struct list_head *temp_item; |
| 294 | struct cifsSesInfo * ses; | 294 | struct cifsSesInfo *ses; |
| 295 | char *temp = (char *) buffer; | 295 | char *temp = (char *) buffer; |
| 296 | 296 | ||
| 297 | memset(temp,0,256); /* bigger than MAX_CIFS_HDR_SIZE */ | 297 | memset(temp, 0, 256); /* bigger than MAX_CIFS_HDR_SIZE */ |
| 298 | 298 | ||
| 299 | buffer->smb_buf_length = | 299 | buffer->smb_buf_length = |
| 300 | (2 * word_count) + sizeof (struct smb_hdr) - | 300 | (2 * word_count) + sizeof (struct smb_hdr) - |
| @@ -348,7 +348,7 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ , | |||
| 348 | /* flag were disabled. */ | 348 | /* flag were disabled. */ |
| 349 | 349 | ||
| 350 | /* BB Add support for establishing new tCon and SMB Session */ | 350 | /* BB Add support for establishing new tCon and SMB Session */ |
| 351 | /* with userid/password pairs found on the smb session */ | 351 | /* with userid/password pairs found on the smb session */ |
| 352 | /* for other target tcp/ip addresses BB */ | 352 | /* for other target tcp/ip addresses BB */ |
| 353 | if (current->fsuid != treeCon->ses->linux_uid) { | 353 | if (current->fsuid != treeCon->ses->linux_uid) { |
| 354 | cFYI(1,("Multiuser mode and UID did not match tcon uid")); | 354 | cFYI(1,("Multiuser mode and UID did not match tcon uid")); |
| @@ -357,12 +357,12 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ , | |||
| 357 | ses = list_entry(temp_item, struct cifsSesInfo, cifsSessionList); | 357 | ses = list_entry(temp_item, struct cifsSesInfo, cifsSessionList); |
| 358 | if (ses->linux_uid == current->fsuid) { | 358 | if (ses->linux_uid == current->fsuid) { |
| 359 | if (ses->server == treeCon->ses->server) { | 359 | if (ses->server == treeCon->ses->server) { |
| 360 | cFYI(1,("found matching uid substitute right smb_uid")); | 360 | cFYI(1, ("found matching uid substitute right smb_uid")); |
| 361 | buffer->Uid = ses->Suid; | 361 | buffer->Uid = ses->Suid; |
| 362 | break; | 362 | break; |
| 363 | } else { | 363 | } else { |
| 364 | /* BB eventually call cifs_setup_session here */ | 364 | /* BB eventually call cifs_setup_session here */ |
| 365 | cFYI(1,("local UID found but smb sess with this server does not exist")); | 365 | cFYI(1, ("local UID found but no smb sess with this server exists")); |
| 366 | } | 366 | } |
| 367 | } | 367 | } |
| 368 | } | 368 | } |
| @@ -388,18 +388,18 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ , | |||
| 388 | static int | 388 | static int |
| 389 | checkSMBhdr(struct smb_hdr *smb, __u16 mid) | 389 | checkSMBhdr(struct smb_hdr *smb, __u16 mid) |
| 390 | { | 390 | { |
| 391 | /* Make sure that this really is an SMB, that it is a response, | 391 | /* Make sure that this really is an SMB, that it is a response, |
| 392 | and that the message ids match */ | 392 | and that the message ids match */ |
| 393 | if ((*(__le32 *) smb->Protocol == cpu_to_le32(0x424d53ff)) && | 393 | if ((*(__le32 *) smb->Protocol == cpu_to_le32(0x424d53ff)) && |
| 394 | (mid == smb->Mid)) { | 394 | (mid == smb->Mid)) { |
| 395 | if (smb->Flags & SMBFLG_RESPONSE) | 395 | if (smb->Flags & SMBFLG_RESPONSE) |
| 396 | return 0; | 396 | return 0; |
| 397 | else { | 397 | else { |
| 398 | /* only one valid case where server sends us request */ | 398 | /* only one valid case where server sends us request */ |
| 399 | if (smb->Command == SMB_COM_LOCKING_ANDX) | 399 | if (smb->Command == SMB_COM_LOCKING_ANDX) |
| 400 | return 0; | 400 | return 0; |
| 401 | else | 401 | else |
| 402 | cERROR(1, ("Rcvd Request not response")); | 402 | cERROR(1, ("Received Request not response")); |
| 403 | } | 403 | } |
| 404 | } else { /* bad signature or mid */ | 404 | } else { /* bad signature or mid */ |
| 405 | if (*(__le32 *) smb->Protocol != cpu_to_le32(0x424d53ff)) | 405 | if (*(__le32 *) smb->Protocol != cpu_to_le32(0x424d53ff)) |
| @@ -426,9 +426,9 @@ checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length) | |||
| 426 | smb->WordCount = 0; | 426 | smb->WordCount = 0; |
| 427 | /* some error cases do not return wct and bcc */ | 427 | /* some error cases do not return wct and bcc */ |
| 428 | return 0; | 428 | return 0; |
| 429 | } else if ((length == sizeof(struct smb_hdr) + 1) && | 429 | } else if ((length == sizeof(struct smb_hdr) + 1) && |
| 430 | (smb->WordCount == 0)) { | 430 | (smb->WordCount == 0)) { |
| 431 | char * tmp = (char *)smb; | 431 | char *tmp = (char *)smb; |
| 432 | /* Need to work around a bug in two servers here */ | 432 | /* Need to work around a bug in two servers here */ |
| 433 | /* First, check if the part of bcc they sent was zero */ | 433 | /* First, check if the part of bcc they sent was zero */ |
| 434 | if (tmp[sizeof(struct smb_hdr)] == 0) { | 434 | if (tmp[sizeof(struct smb_hdr)] == 0) { |
| @@ -442,7 +442,7 @@ checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length) | |||
| 442 | tmp[sizeof(struct smb_hdr)+1] = 0; | 442 | tmp[sizeof(struct smb_hdr)+1] = 0; |
| 443 | return 0; | 443 | return 0; |
| 444 | } | 444 | } |
| 445 | cERROR(1,("rcvd invalid byte count (bcc)")); | 445 | cERROR(1, ("rcvd invalid byte count (bcc)")); |
| 446 | } else { | 446 | } else { |
| 447 | cERROR(1, ("Length less than smb header size")); | 447 | cERROR(1, ("Length less than smb header size")); |
| 448 | } | 448 | } |
| @@ -468,15 +468,15 @@ checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length) | |||
| 468 | if ((len > 64 * 1024) && (len > clc_len)) { | 468 | if ((len > 64 * 1024) && (len > clc_len)) { |
| 469 | /* check if lengths match mod 64K */ | 469 | /* check if lengths match mod 64K */ |
| 470 | if (((4 + len) & 0xFFFF) == (clc_len & 0xFFFF)) | 470 | if (((4 + len) & 0xFFFF) == (clc_len & 0xFFFF)) |
| 471 | return 0; /* bcc wrapped */ | 471 | return 0; /* bcc wrapped */ |
| 472 | } | 472 | } |
| 473 | cFYI(1, ("Calculated size %d vs length %d mismatch for mid %d", | 473 | cFYI(1, ("Calculated size %d vs length %d mismatch for mid %d", |
| 474 | clc_len, 4 + len, smb->Mid)); | 474 | clc_len, 4 + len, smb->Mid)); |
| 475 | /* Windows XP can return a few bytes too much, presumably | 475 | /* Windows XP can return a few bytes too much, presumably |
| 476 | an illegal pad, at the end of byte range lock responses | 476 | an illegal pad, at the end of byte range lock responses |
| 477 | so we allow for that three byte pad, as long as actual | 477 | so we allow for that three byte pad, as long as actual |
| 478 | received length is as long or longer than calculated length */ | 478 | received length is as long or longer than calculated length */ |
| 479 | /* We have now had to extend this more, since there is a | 479 | /* We have now had to extend this more, since there is a |
| 480 | case in which it needs to be bigger still to handle a | 480 | case in which it needs to be bigger still to handle a |
| 481 | malformed response to transact2 findfirst from WinXP when | 481 | malformed response to transact2 findfirst from WinXP when |
| 482 | access denied is returned and thus bcc and wct are zero | 482 | access denied is returned and thus bcc and wct are zero |
| @@ -495,37 +495,38 @@ checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length) | |||
| 495 | } | 495 | } |
| 496 | int | 496 | int |
| 497 | is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv) | 497 | is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv) |
| 498 | { | 498 | { |
| 499 | struct smb_com_lock_req * pSMB = (struct smb_com_lock_req *)buf; | 499 | struct smb_com_lock_req *pSMB = (struct smb_com_lock_req *)buf; |
| 500 | struct list_head *tmp; | 500 | struct list_head *tmp; |
| 501 | struct list_head *tmp1; | 501 | struct list_head *tmp1; |
| 502 | struct cifsTconInfo *tcon; | 502 | struct cifsTconInfo *tcon; |
| 503 | struct cifsFileInfo *netfile; | 503 | struct cifsFileInfo *netfile; |
| 504 | 504 | ||
| 505 | cFYI(1,("Checking for oplock break or dnotify response")); | 505 | cFYI(1, ("Checking for oplock break or dnotify response")); |
| 506 | if ((pSMB->hdr.Command == SMB_COM_NT_TRANSACT) && | 506 | if ((pSMB->hdr.Command == SMB_COM_NT_TRANSACT) && |
| 507 | (pSMB->hdr.Flags & SMBFLG_RESPONSE)) { | 507 | (pSMB->hdr.Flags & SMBFLG_RESPONSE)) { |
| 508 | struct smb_com_transaction_change_notify_rsp * pSMBr = | 508 | struct smb_com_transaction_change_notify_rsp *pSMBr = |
| 509 | (struct smb_com_transaction_change_notify_rsp *)buf; | 509 | (struct smb_com_transaction_change_notify_rsp *)buf; |
| 510 | struct file_notify_information * pnotify; | 510 | struct file_notify_information *pnotify; |
| 511 | __u32 data_offset = 0; | 511 | __u32 data_offset = 0; |
| 512 | if (pSMBr->ByteCount > sizeof(struct file_notify_information)) { | 512 | if (pSMBr->ByteCount > sizeof(struct file_notify_information)) { |
| 513 | data_offset = le32_to_cpu(pSMBr->DataOffset); | 513 | data_offset = le32_to_cpu(pSMBr->DataOffset); |
| 514 | 514 | ||
| 515 | pnotify = (struct file_notify_information *) | 515 | pnotify = (struct file_notify_information *) |
| 516 | ((char *)&pSMBr->hdr.Protocol + data_offset); | 516 | ((char *)&pSMBr->hdr.Protocol + data_offset); |
| 517 | cFYI(1,("dnotify on %s Action: 0x%x",pnotify->FileName, | 517 | cFYI(1,("dnotify on %s Action: 0x%x", pnotify->FileName, |
| 518 | pnotify->Action)); /* BB removeme BB */ | 518 | pnotify->Action)); /* BB removeme BB */ |
| 519 | /* cifs_dump_mem("Rcvd notify Data: ",buf, | 519 | /* cifs_dump_mem("Rcvd notify Data: ",buf, |
| 520 | sizeof(struct smb_hdr)+60); */ | 520 | sizeof(struct smb_hdr)+60); */ |
| 521 | return TRUE; | 521 | return TRUE; |
| 522 | } | 522 | } |
| 523 | if (pSMBr->hdr.Status.CifsError) { | 523 | if (pSMBr->hdr.Status.CifsError) { |
| 524 | cFYI(1,("notify err 0x%d",pSMBr->hdr.Status.CifsError)); | 524 | cFYI(1, ("notify err 0x%d", |
| 525 | pSMBr->hdr.Status.CifsError)); | ||
| 525 | return TRUE; | 526 | return TRUE; |
| 526 | } | 527 | } |
| 527 | return FALSE; | 528 | return FALSE; |
| 528 | } | 529 | } |
| 529 | if (pSMB->hdr.Command != SMB_COM_LOCKING_ANDX) | 530 | if (pSMB->hdr.Command != SMB_COM_LOCKING_ANDX) |
| 530 | return FALSE; | 531 | return FALSE; |
| 531 | if (pSMB->hdr.Flags & SMBFLG_RESPONSE) { | 532 | if (pSMB->hdr.Flags & SMBFLG_RESPONSE) { |
| @@ -533,13 +534,13 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv) | |||
| 533 | break - harmless race between close request and oplock | 534 | break - harmless race between close request and oplock |
| 534 | break response is expected from time to time writing out | 535 | break response is expected from time to time writing out |
| 535 | large dirty files cached on the client */ | 536 | large dirty files cached on the client */ |
| 536 | if ((NT_STATUS_INVALID_HANDLE) == | 537 | if ((NT_STATUS_INVALID_HANDLE) == |
| 537 | le32_to_cpu(pSMB->hdr.Status.CifsError)) { | 538 | le32_to_cpu(pSMB->hdr.Status.CifsError)) { |
| 538 | cFYI(1,("invalid handle on oplock break")); | 539 | cFYI(1, ("invalid handle on oplock break")); |
| 539 | return TRUE; | 540 | return TRUE; |
| 540 | } else if (ERRbadfid == | 541 | } else if (ERRbadfid == |
| 541 | le16_to_cpu(pSMB->hdr.Status.DosError.Error)) { | 542 | le16_to_cpu(pSMB->hdr.Status.DosError.Error)) { |
| 542 | return TRUE; | 543 | return TRUE; |
| 543 | } else { | 544 | } else { |
| 544 | return FALSE; /* on valid oplock brk we get "request" */ | 545 | return FALSE; /* on valid oplock brk we get "request" */ |
| 545 | } | 546 | } |
| @@ -547,9 +548,10 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv) | |||
| 547 | if (pSMB->hdr.WordCount != 8) | 548 | if (pSMB->hdr.WordCount != 8) |
| 548 | return FALSE; | 549 | return FALSE; |
| 549 | 550 | ||
| 550 | cFYI(1,(" oplock type 0x%d level 0x%d",pSMB->LockType,pSMB->OplockLevel)); | 551 | cFYI(1, ("oplock type 0x%d level 0x%d", |
| 552 | pSMB->LockType, pSMB->OplockLevel)); | ||
| 551 | if (!(pSMB->LockType & LOCKING_ANDX_OPLOCK_RELEASE)) | 553 | if (!(pSMB->LockType & LOCKING_ANDX_OPLOCK_RELEASE)) |
| 552 | return FALSE; | 554 | return FALSE; |
| 553 | 555 | ||
| 554 | /* look up tcon based on tid & uid */ | 556 | /* look up tcon based on tid & uid */ |
| 555 | read_lock(&GlobalSMBSeslock); | 557 | read_lock(&GlobalSMBSeslock); |
| @@ -557,14 +559,14 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv) | |||
| 557 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); | 559 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); |
| 558 | if ((tcon->tid == buf->Tid) && (srv == tcon->ses->server)) { | 560 | if ((tcon->tid == buf->Tid) && (srv == tcon->ses->server)) { |
| 559 | cifs_stats_inc(&tcon->num_oplock_brks); | 561 | cifs_stats_inc(&tcon->num_oplock_brks); |
| 560 | list_for_each(tmp1,&tcon->openFileList){ | 562 | list_for_each(tmp1, &tcon->openFileList) { |
| 561 | netfile = list_entry(tmp1,struct cifsFileInfo, | 563 | netfile = list_entry(tmp1, struct cifsFileInfo, |
| 562 | tlist); | 564 | tlist); |
| 563 | if (pSMB->Fid == netfile->netfid) { | 565 | if (pSMB->Fid == netfile->netfid) { |
| 564 | struct cifsInodeInfo *pCifsInode; | 566 | struct cifsInodeInfo *pCifsInode; |
| 565 | read_unlock(&GlobalSMBSeslock); | 567 | read_unlock(&GlobalSMBSeslock); |
| 566 | cFYI(1,("file id match, oplock break")); | 568 | cFYI(1,("file id match, oplock break")); |
| 567 | pCifsInode = | 569 | pCifsInode = |
| 568 | CIFS_I(netfile->pInode); | 570 | CIFS_I(netfile->pInode); |
| 569 | pCifsInode->clientCanCacheAll = FALSE; | 571 | pCifsInode->clientCanCacheAll = FALSE; |
| 570 | if (pSMB->OplockLevel == 0) | 572 | if (pSMB->OplockLevel == 0) |
| @@ -581,12 +583,12 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv) | |||
| 581 | } | 583 | } |
| 582 | } | 584 | } |
| 583 | read_unlock(&GlobalSMBSeslock); | 585 | read_unlock(&GlobalSMBSeslock); |
| 584 | cFYI(1,("No matching file for oplock break")); | 586 | cFYI(1, ("No matching file for oplock break")); |
| 585 | return TRUE; | 587 | return TRUE; |
| 586 | } | 588 | } |
| 587 | } | 589 | } |
| 588 | read_unlock(&GlobalSMBSeslock); | 590 | read_unlock(&GlobalSMBSeslock); |
| 589 | cFYI(1,("Can not process oplock break for non-existent connection")); | 591 | cFYI(1, ("Can not process oplock break for non-existent connection")); |
| 590 | return TRUE; | 592 | return TRUE; |
| 591 | } | 593 | } |
| 592 | 594 | ||
| @@ -643,13 +645,13 @@ dump_smb(struct smb_hdr *smb_buf, int smb_buf_length) | |||
| 643 | only legal in POSIX-like OS (if they are present in the string). Path | 645 | only legal in POSIX-like OS (if they are present in the string). Path |
| 644 | names are little endian 16 bit Unicode on the wire */ | 646 | names are little endian 16 bit Unicode on the wire */ |
| 645 | int | 647 | int |
| 646 | cifs_convertUCSpath(char *target, const __le16 * source, int maxlen, | 648 | cifs_convertUCSpath(char *target, const __le16 *source, int maxlen, |
| 647 | const struct nls_table * cp) | 649 | const struct nls_table *cp) |
| 648 | { | 650 | { |
| 649 | int i,j,len; | 651 | int i, j, len; |
| 650 | __u16 src_char; | 652 | __u16 src_char; |
| 651 | 653 | ||
| 652 | for(i = 0, j = 0; i < maxlen; i++) { | 654 | for (i = 0, j = 0; i < maxlen; i++) { |
| 653 | src_char = le16_to_cpu(source[i]); | 655 | src_char = le16_to_cpu(source[i]); |
| 654 | switch (src_char) { | 656 | switch (src_char) { |
| 655 | case 0: | 657 | case 0: |
| @@ -678,8 +680,8 @@ cifs_convertUCSpath(char *target, const __le16 * source, int maxlen, | |||
| 678 | case UNI_LESSTHAN: | 680 | case UNI_LESSTHAN: |
| 679 | target[j] = '<'; | 681 | target[j] = '<'; |
| 680 | break; | 682 | break; |
| 681 | default: | 683 | default: |
| 682 | len = cp->uni2char(src_char, &target[j], | 684 | len = cp->uni2char(src_char, &target[j], |
| 683 | NLS_MAX_CHARSET_SIZE); | 685 | NLS_MAX_CHARSET_SIZE); |
| 684 | if (len > 0) { | 686 | if (len > 0) { |
| 685 | j += len; | 687 | j += len; |
| @@ -703,10 +705,10 @@ cUCS_out: | |||
| 703 | only legal in POSIX-like OS (if they are present in the string). Path | 705 | only legal in POSIX-like OS (if they are present in the string). Path |
| 704 | names are little endian 16 bit Unicode on the wire */ | 706 | names are little endian 16 bit Unicode on the wire */ |
| 705 | int | 707 | int |
| 706 | cifsConvertToUCS(__le16 * target, const char *source, int maxlen, | 708 | cifsConvertToUCS(__le16 *target, const char *source, int maxlen, |
| 707 | const struct nls_table * cp, int mapChars) | 709 | const struct nls_table *cp, int mapChars) |
| 708 | { | 710 | { |
| 709 | int i,j,charlen; | 711 | int i, j, charlen; |
| 710 | int len_remaining = maxlen; | 712 | int len_remaining = maxlen; |
| 711 | char src_char; | 713 | char src_char; |
| 712 | __u16 temp; | 714 | __u16 temp; |
| @@ -714,7 +716,7 @@ cifsConvertToUCS(__le16 * target, const char *source, int maxlen, | |||
| 714 | if (!mapChars) | 716 | if (!mapChars) |
| 715 | return cifs_strtoUCS(target, source, PATH_MAX, cp); | 717 | return cifs_strtoUCS(target, source, PATH_MAX, cp); |
| 716 | 718 | ||
| 717 | for(i = 0, j = 0; i < maxlen; j++) { | 719 | for (i = 0, j = 0; i < maxlen; j++) { |
| 718 | src_char = source[i]; | 720 | src_char = source[i]; |
| 719 | switch (src_char) { | 721 | switch (src_char) { |
| 720 | case 0: | 722 | case 0: |
| @@ -737,7 +739,7 @@ cifsConvertToUCS(__le16 * target, const char *source, int maxlen, | |||
| 737 | break; | 739 | break; |
| 738 | case '|': | 740 | case '|': |
| 739 | target[j] = cpu_to_le16(UNI_PIPE); | 741 | target[j] = cpu_to_le16(UNI_PIPE); |
| 740 | break; | 742 | break; |
| 741 | /* BB We can not handle remapping slash until | 743 | /* BB We can not handle remapping slash until |
| 742 | all the calls to build_path_from_dentry | 744 | all the calls to build_path_from_dentry |
| 743 | are modified, as they use slash as separator BB */ | 745 | are modified, as they use slash as separator BB */ |
| @@ -758,7 +760,7 @@ cifsConvertToUCS(__le16 * target, const char *source, int maxlen, | |||
| 758 | /* character may take more than one byte in the | 760 | /* character may take more than one byte in the |
| 759 | the source string, but will take exactly two | 761 | the source string, but will take exactly two |
| 760 | bytes in the target string */ | 762 | bytes in the target string */ |
| 761 | i+= charlen; | 763 | i += charlen; |
| 762 | continue; | 764 | continue; |
| 763 | } | 765 | } |
| 764 | i++; /* move to next char in source string */ | 766 | i++; /* move to next char in source string */ |
