Merge with Linux 2.5.48.
[linux-2.6/linux-mips.git] / fs / smbfs / request.c
blobc4cd9ddc3ffc30d05c69c84fb61addeb7265adc5
1 /*
2 * request.c
4 * Copyright (C) 2001 by Urban Widmark
6 * Please add a note about your changes to smbfs in the ChangeLog file.
7 */
9 #include <linux/types.h>
10 #include <linux/fs.h>
11 #include <linux/slab.h>
12 #include <linux/net.h>
14 #include <linux/smb_fs.h>
15 #include <linux/smbno.h>
16 #include <linux/smb_mount.h>
18 #include "smb_debug.h"
19 #include "request.h"
20 #include "proto.h"
22 /* #define SMB_SLAB_DEBUG (SLAB_RED_ZONE | SLAB_POISON) */
23 #define SMB_SLAB_DEBUG 0
25 #define ROUND_UP(x) (((x)+3) & ~3)
27 /* cache for request structures */
28 static kmem_cache_t *req_cachep;
31 /proc/slabinfo:
32 name, active, num, objsize, active_slabs, num_slaps, #pages
36 int smb_init_request_cache(void)
38 req_cachep = kmem_cache_create("smb_request",
39 sizeof(struct smb_request), 0,
40 SMB_SLAB_DEBUG | SLAB_HWCACHE_ALIGN,
41 NULL, NULL);
42 if (req_cachep == NULL)
43 return -ENOMEM;
45 return 0;
48 void smb_destroy_request_cache(void)
50 if (kmem_cache_destroy(req_cachep))
51 printk(KERN_INFO "smb_destroy_request_cache: not all structures were freed\n");
55 * Allocate and initialise a request structure
57 static struct smb_request *smb_do_alloc_request(struct smb_sb_info *server,
58 int bufsize)
60 struct smb_request *req;
61 unsigned char *buf = NULL;
63 req = kmem_cache_alloc(req_cachep, SLAB_KERNEL);
64 VERBOSE("allocating request: %p\n", req);
65 if (!req)
66 goto out;
68 if (bufsize > 0) {
69 buf = smb_kmalloc(bufsize, GFP_NOFS);
70 if (!buf) {
71 kmem_cache_free(req_cachep, req);
72 return NULL;
76 memset(req, 0, sizeof(struct smb_request));
77 req->rq_buffer = buf;
78 req->rq_bufsize = bufsize;
79 req->rq_server = server;
80 init_waitqueue_head(&req->rq_wait);
81 INIT_LIST_HEAD(&req->rq_queue);
82 atomic_set(&req->rq_count, 1);
84 out:
85 return req;
88 struct smb_request *smb_alloc_request(struct smb_sb_info *server, int bufsize)
90 struct smb_request *req = NULL;
92 for (;;) {
93 atomic_inc(&server->nr_requests);
94 if (atomic_read(&server->nr_requests) <= MAX_REQUEST_HARD) {
95 req = smb_do_alloc_request(server, bufsize);
96 if (req != NULL)
97 break;
100 #if 0
102 * Try to free up at least one request in order to stay
103 * below the hard limit
105 if (nfs_try_to_free_pages(server))
106 continue;
108 if (signalled() && (server->flags & NFS_MOUNT_INTR))
109 return ERR_PTR(-ERESTARTSYS);
110 current->policy = SCHED_YIELD;
111 schedule();
112 #else
113 /* FIXME: we want something like nfs does above, but that
114 requires changes to all callers and can wait. */
115 break;
116 #endif
118 return req;
121 static void smb_free_request(struct smb_request *req)
123 atomic_dec(&req->rq_server->nr_requests);
124 if (req->rq_buffer && !(req->rq_flags & SMB_REQ_STATIC))
125 smb_kfree(req->rq_buffer);
126 if (req->rq_trans2buffer)
127 smb_kfree(req->rq_trans2buffer);
128 kmem_cache_free(req_cachep, req);
132 * What prevents a rget to race with a rput? The count must never drop to zero
133 * while it is in use. Only rput if it is ok that it is free'd.
135 void smb_rget(struct smb_request *req)
137 atomic_inc(&req->rq_count);
139 void smb_rput(struct smb_request *req)
141 if (atomic_dec_and_test(&req->rq_count)) {
142 list_del_init(&req->rq_queue);
143 smb_free_request(req);
147 /* setup to receive the data part of the SMB */
148 static int smb_setup_bcc(struct smb_request *req)
150 int result = 0;
151 req->rq_rlen = smb_len(req->rq_header) + 4 - req->rq_bytes_recvd;
153 if (req->rq_rlen > req->rq_bufsize) {
154 PARANOIA("Packet too large %d > %d\n",
155 req->rq_rlen, req->rq_bufsize);
156 return -ENOBUFS;
159 req->rq_iov[0].iov_base = req->rq_buffer;
160 req->rq_iov[0].iov_len = req->rq_rlen;
161 req->rq_iovlen = 1;
163 return result;
167 * Prepare a "normal" request structure.
169 static int smb_setup_request(struct smb_request *req)
171 int len = smb_len(req->rq_header) + 4;
172 req->rq_slen = len;
174 /* if we expect a data part in the reply we set the iov's to read it */
175 if (req->rq_resp_bcc)
176 req->rq_setup_read = smb_setup_bcc;
178 /* This tries to support re-using the same request */
179 req->rq_bytes_sent = 0;
180 req->rq_rcls = 0;
181 req->rq_err = 0;
182 req->rq_errno = 0;
183 req->rq_fragment = 0;
184 if (req->rq_trans2buffer)
185 smb_kfree(req->rq_trans2buffer);
187 return 0;
191 * Prepare a transaction2 request structure
193 static int smb_setup_trans2request(struct smb_request *req)
195 struct smb_sb_info *server = req->rq_server;
196 int mparam, mdata;
197 static unsigned char padding[4] = { 0, };
199 /* I know the following is very ugly, but I want to build the
200 smb packet as efficiently as possible. */
202 const int smb_parameters = 15;
203 const int header = SMB_HEADER_LEN + 2 * smb_parameters + 2;
204 const int oparam = ROUND_UP(header + 3);
205 const int odata = ROUND_UP(oparam + req->rq_lparm);
206 const int bcc = (req->rq_data ? odata + req->rq_ldata :
207 oparam + req->rq_lparm) - header;
209 if ((bcc + oparam) > server->opt.max_xmit)
210 return -ENOMEM;
211 smb_setup_header(req, SMBtrans2, smb_parameters, bcc);
214 * max parameters + max data + max setup == bufsize to make NT4 happy
215 * and not abort the transfer or split into multiple responses. It also
216 * makes smbfs happy as handling packets larger than the buffer size
217 * is extra work.
219 * OS/2 is probably going to hate me for this ...
221 mparam = SMB_TRANS2_MAX_PARAM;
222 mdata = req->rq_bufsize - mparam;
224 mdata = server->opt.max_xmit - mparam - 100;
225 if (mdata < 1024) {
226 mdata = 1024;
227 mparam = 20;
230 #if 0
231 /* NT/win2k has ~4k max_xmit, so with this we request more than it wants
232 to return as one SMB. Useful for testing the fragmented trans2
233 handling. */
234 mdata = 8192;
235 #endif
237 WSET(req->rq_header, smb_tpscnt, req->rq_lparm);
238 WSET(req->rq_header, smb_tdscnt, req->rq_ldata);
239 WSET(req->rq_header, smb_mprcnt, mparam);
240 WSET(req->rq_header, smb_mdrcnt, mdata);
241 WSET(req->rq_header, smb_msrcnt, 0); /* max setup always 0 ? */
242 WSET(req->rq_header, smb_flags, 0);
243 DSET(req->rq_header, smb_timeout, 0);
244 WSET(req->rq_header, smb_pscnt, req->rq_lparm);
245 WSET(req->rq_header, smb_psoff, oparam - 4);
246 WSET(req->rq_header, smb_dscnt, req->rq_ldata);
247 WSET(req->rq_header, smb_dsoff, req->rq_data ? odata - 4 : 0);
248 *(req->rq_header + smb_suwcnt) = 0x01; /* setup count */
249 *(req->rq_header + smb_suwcnt + 1) = 0x00; /* reserved */
250 WSET(req->rq_header, smb_setup0, req->rq_trans2_command);
252 req->rq_iovlen = 2;
253 req->rq_iov[0].iov_base = (void *) req->rq_header;
254 req->rq_iov[0].iov_len = oparam;
255 req->rq_iov[1].iov_base = (req->rq_parm==NULL) ? padding : req->rq_parm;
256 req->rq_iov[1].iov_len = req->rq_lparm;
257 req->rq_slen = oparam + req->rq_lparm;
259 if (req->rq_data) {
260 req->rq_iovlen += 2;
261 req->rq_iov[2].iov_base = padding;
262 req->rq_iov[2].iov_len = odata - oparam - req->rq_lparm;
263 req->rq_iov[3].iov_base = req->rq_data;
264 req->rq_iov[3].iov_len = req->rq_ldata;
265 req->rq_slen = odata + req->rq_ldata;
268 /* always a data part for trans2 replies */
269 req->rq_setup_read = smb_setup_bcc;
271 return 0;
275 * Add a request and tell smbiod to process it
277 int smb_add_request(struct smb_request *req)
279 long timeleft;
280 struct smb_sb_info *server = req->rq_server;
281 int result = 0;
283 smb_setup_request(req);
284 if (req->rq_trans2_command) {
285 if (req->rq_buffer == NULL) {
286 PARANOIA("trans2 attempted without response buffer!\n");
287 return -EIO;
289 result = smb_setup_trans2request(req);
291 if (result < 0)
292 return result;
294 #ifdef SMB_DEBUG_PACKET_SIZE
295 add_xmit_stats(req);
296 #endif
298 /* add 'req' to the queue of requests */
299 if (smb_lock_server_interruptible(server))
300 return -EINTR;
303 * Try to send the request as the process. If that fails we queue the
304 * request and let smbiod send it later.
307 /* FIXME: each server has a number on the maximum number of parallel
308 requests. 10, 50 or so. We should not allow more requests to be
309 active. */
310 if (server->mid > 0xf000)
311 server->mid = 0;
312 req->rq_mid = server->mid++;
313 WSET(req->rq_header, smb_mid, req->rq_mid);
315 result = 0;
316 if (server->state == CONN_VALID) {
317 if (list_empty(&server->xmitq))
318 result = smb_request_send_req(req);
319 if (result < 0) {
320 /* Connection lost? */
321 server->conn_error = result;
322 server->state = CONN_INVALID;
325 if (result != 1)
326 list_add_tail(&req->rq_queue, &server->xmitq);
327 smb_rget(req);
329 if (server->state != CONN_VALID)
330 smbiod_retry(server);
332 smb_unlock_server(server);
334 smbiod_wake_up();
336 timeleft = wait_event_interruptible_timeout(req->rq_wait,
337 req->rq_flags & SMB_REQ_RECEIVED, 30*HZ);
338 if (!timeleft || signal_pending(current)) {
340 * On timeout or on interrupt we want to try and remove the
341 * request from the recvq/xmitq.
343 smb_lock_server(server);
344 if (!(req->rq_flags & SMB_REQ_RECEIVED)) {
345 list_del_init(&req->rq_queue);
346 smb_rput(req);
348 smb_unlock_server(server);
351 if (!timeleft) {
352 PARANOIA("request [%p, mid=%d] timed out!\n",
353 req, req->rq_mid);
354 VERBOSE("smb_com: %02x\n", *(req->rq_header + smb_com));
355 VERBOSE("smb_rcls: %02x\n", *(req->rq_header + smb_rcls));
356 VERBOSE("smb_flg: %02x\n", *(req->rq_header + smb_flg));
357 VERBOSE("smb_tid: %04x\n", WVAL(req->rq_header, smb_tid));
358 VERBOSE("smb_pid: %04x\n", WVAL(req->rq_header, smb_pid));
359 VERBOSE("smb_uid: %04x\n", WVAL(req->rq_header, smb_uid));
360 VERBOSE("smb_mid: %04x\n", WVAL(req->rq_header, smb_mid));
361 VERBOSE("smb_wct: %02x\n", *(req->rq_header + smb_wct));
363 req->rq_rcls = ERRSRV;
364 req->rq_err = ERRtimeout;
366 /* Just in case it was "stuck" */
367 smbiod_wake_up();
369 VERBOSE("woke up, rcls=%d\n", req->rq_rcls);
371 if (req->rq_rcls != 0)
372 req->rq_errno = smb_errno(req);
373 if (signal_pending(current))
374 req->rq_errno = -ERESTARTSYS;
375 return req->rq_errno;
379 * Send a request and place it on the recvq if successfully sent.
380 * Must be called with the server lock held.
382 int smb_request_send_req(struct smb_request *req)
384 struct smb_sb_info *server = req->rq_server;
385 int result;
387 result = smb_send_request(req);
388 if (result < 0 && result != -EAGAIN)
389 goto out;
391 result = 0;
392 if (!(req->rq_flags & SMB_REQ_TRANSMITTED))
393 goto out;
395 list_del_init(&req->rq_queue);
396 list_add_tail(&req->rq_queue, &server->recvq);
397 result = 1;
398 out:
399 return result;
403 * Sends one request for this server. (smbiod)
404 * Must be called with the server lock held.
405 * Returns: <0 on error
406 * 0 if no request could be completely sent
407 * 1 if all data for one request was sent
409 int smb_request_send_server(struct smb_sb_info *server)
411 struct list_head *head;
412 struct smb_request *req;
413 int result;
415 if (server->state != CONN_VALID)
416 return 0;
418 /* dequeue first request, if any */
419 req = NULL;
420 head = server->xmitq.next;
421 if (head != &server->xmitq) {
422 req = list_entry(head, struct smb_request, rq_queue);
424 if (!req)
425 return 0;
427 result = smb_request_send_req(req);
428 if (result < 0) {
429 server->conn_error = result;
430 list_del_init(&req->rq_queue);
431 list_add(&req->rq_queue, &server->xmitq);
432 result = -EIO;
433 goto out;
436 out:
437 return result;
441 * Try to find a request matching this "mid". Typically the first entry will
442 * be the matching one.
444 static struct smb_request *find_request(struct smb_sb_info *server, int mid)
446 struct list_head *tmp;
447 struct smb_request *req = NULL;
449 list_for_each(tmp, &server->recvq) {
450 req = list_entry(tmp, struct smb_request, rq_queue);
451 if (req->rq_mid == mid) {
452 break;
454 req = NULL;
457 if (!req) {
458 VERBOSE("received reply with mid %d but no request!\n",
459 WVAL(server->header, smb_mid));
460 server->rstate = SMB_RECV_DROP;
463 return req;
467 * Called when we have read the smb header and believe this is a response.
469 static int smb_init_request(struct smb_sb_info *server, struct smb_request *req)
471 int hdrlen, wct;
473 memcpy(req->rq_header, server->header, SMB_HEADER_LEN);
475 wct = *(req->rq_header + smb_wct);
476 if (wct > 20) {
477 PARANOIA("wct too large, %d > 20\n", wct);
478 server->rstate = SMB_RECV_DROP;
479 return 0;
482 req->rq_resp_wct = wct;
483 hdrlen = SMB_HEADER_LEN + wct*2 + 2;
484 VERBOSE("header length: %d smb_wct: %2d\n", hdrlen, wct);
486 req->rq_bytes_recvd = SMB_HEADER_LEN;
487 req->rq_rlen = hdrlen;
488 req->rq_iov[0].iov_base = req->rq_header;
489 req->rq_iov[0].iov_len = hdrlen;
490 req->rq_iovlen = 1;
491 server->rstate = SMB_RECV_PARAM;
493 #ifdef SMB_DEBUG_PACKET_SIZE
494 add_recv_stats(smb_len(server->header));
495 #endif
496 return 0;
500 * Reads the SMB parameters
502 static int smb_recv_param(struct smb_sb_info *server, struct smb_request *req)
504 int result;
506 result = smb_receive(server, req);
507 if (result < 0)
508 return result;
509 if (req->rq_bytes_recvd < req->rq_rlen)
510 return 0;
512 VERBOSE("result: %d smb_bcc: %04x\n", result,
513 WVAL(req->rq_header, SMB_HEADER_LEN +
514 (*(req->rq_header + smb_wct) * 2)));
516 result = 0;
517 req->rq_iov[0].iov_base = NULL;
518 req->rq_rlen = 0;
519 if (req->rq_callback)
520 req->rq_callback(req);
521 else if (req->rq_setup_read)
522 result = req->rq_setup_read(req);
523 if (result < 0) {
524 server->rstate = SMB_RECV_DROP;
525 return result;
528 server->rstate = req->rq_rlen > 0 ? SMB_RECV_DATA : SMB_RECV_END;
530 req->rq_bytes_recvd = 0; // recvd out of the iov
532 VERBOSE("rlen: %d\n", req->rq_rlen);
533 if (req->rq_rlen < 0) {
534 PARANOIA("Parameters read beyond end of packet!\n");
535 server->rstate = SMB_RECV_END;
536 return -EIO;
538 return 0;
542 * Reads the SMB data
544 static int smb_recv_data(struct smb_sb_info *server, struct smb_request *req)
546 int result;
548 result = smb_receive(server, req);
549 if (result < 0)
550 goto out;
551 if (req->rq_bytes_recvd < req->rq_rlen)
552 goto out;
553 server->rstate = SMB_RECV_END;
554 out:
555 VERBOSE("result: %d\n", result);
556 return result;
560 * Receive a transaction2 response
561 * Return: 0 if the response has been fully read
562 * 1 if there are further "fragments" to read
563 * <0 if there is an error
565 static int smb_recv_trans2(struct smb_sb_info *server, struct smb_request *req)
567 unsigned char *inbuf;
568 unsigned int parm_disp, parm_offset, parm_count, parm_tot;
569 unsigned int data_disp, data_offset, data_count, data_tot;
570 int hdrlen = SMB_HEADER_LEN + req->rq_resp_wct*2 - 2;
572 VERBOSE("handling trans2\n");
574 inbuf = req->rq_header;
575 data_tot = WVAL(inbuf, smb_tdrcnt);
576 parm_tot = WVAL(inbuf, smb_tprcnt);
577 parm_disp = WVAL(inbuf, smb_prdisp);
578 parm_offset = WVAL(inbuf, smb_proff);
579 parm_count = WVAL(inbuf, smb_prcnt);
580 data_disp = WVAL(inbuf, smb_drdisp);
581 data_offset = WVAL(inbuf, smb_droff);
582 data_count = WVAL(inbuf, smb_drcnt);
584 /* Modify offset for the split header/buffer we use */
585 data_offset -= hdrlen;
586 parm_offset -= hdrlen;
588 if (parm_count == parm_tot && data_count == data_tot) {
590 * This packet has all the trans2 data.
592 * We setup the request so that this will be the common
593 * case. It may be a server error to not return a
594 * response that fits.
596 VERBOSE("single trans2 response "
597 "dcnt=%d, pcnt=%d, doff=%d, poff=%d\n",
598 data_count, parm_count,
599 data_offset, parm_offset);
600 req->rq_ldata = data_count;
601 req->rq_lparm = parm_count;
602 req->rq_data = req->rq_buffer + data_offset;
603 req->rq_parm = req->rq_buffer + parm_offset;
604 return 0;
607 VERBOSE("multi trans2 response "
608 "frag=%d, dcnt=%d, pcnt=%d, doff=%d, poff=%d\n",
609 req->rq_fragment,
610 data_count, parm_count,
611 data_offset, parm_offset);
613 if (!req->rq_fragment) {
614 int buf_len;
616 /* We got the first trans2 fragment */
617 req->rq_fragment = 1;
618 req->rq_total_data = data_tot;
619 req->rq_total_parm = parm_tot;
620 req->rq_ldata = 0;
621 req->rq_lparm = 0;
623 buf_len = data_tot + parm_tot;
624 if (buf_len > SMB_MAX_PACKET_SIZE)
625 goto out_too_long;
627 req->rq_trans2bufsize = buf_len;
628 req->rq_trans2buffer = smb_kmalloc(buf_len, GFP_NOFS);
629 if (!req->rq_trans2buffer)
630 goto out_no_mem;
632 req->rq_parm = req->rq_trans2buffer;
633 req->rq_data = req->rq_trans2buffer + parm_tot;
634 } else if (req->rq_total_data < data_tot ||
635 req->rq_total_parm < parm_tot)
636 goto out_data_grew;
638 if (parm_disp + parm_count > req->rq_total_parm)
639 goto out_bad_parm;
640 if (data_disp + data_count > req->rq_total_data)
641 goto out_bad_data;
643 inbuf = req->rq_buffer;
644 memcpy(req->rq_parm + parm_disp, inbuf + parm_offset, parm_count);
645 memcpy(req->rq_data + data_disp, inbuf + data_offset, data_count);
647 req->rq_ldata += data_count;
648 req->rq_lparm += parm_count;
651 * Check whether we've received all of the data. Note that
652 * we use the packet totals -- total lengths might shrink!
654 if (req->rq_ldata >= data_tot && req->rq_lparm >= parm_tot)
655 return 0;
656 return 1;
658 out_too_long:
659 printk(KERN_ERR "smb_trans2: data/param too long, data=%d, parm=%d\n",
660 data_tot, parm_tot);
661 req->rq_errno = -EIO;
662 goto out;
663 out_no_mem:
664 printk(KERN_ERR "smb_trans2: couldn't allocate data area of %d bytes\n",
665 req->rq_trans2bufsize);
666 req->rq_errno = -ENOMEM;
667 goto out;
668 out_data_grew:
669 printk(KERN_ERR "smb_trans2: data/params grew!\n");
670 req->rq_errno = -EIO;
671 goto out;
672 out_bad_parm:
673 printk(KERN_ERR "smb_trans2: invalid parms, disp=%d, cnt=%d, tot=%d\n",
674 parm_disp, parm_count, parm_tot);
675 req->rq_errno = -EIO;
676 goto out;
677 out_bad_data:
678 printk(KERN_ERR "smb_trans2: invalid data, disp=%d, cnt=%d, tot=%d\n",
679 data_disp, data_count, data_tot);
680 req->rq_errno = -EIO;
681 out:
682 return req->rq_errno;
686 * State machine for receiving responses. We handle the fact that we can't
687 * read the full response in one try by having states telling us how much we
688 * have read.
690 * Must be called with the server lock held (only called from smbiod).
692 * Return: <0 on error
694 int smb_request_recv(struct smb_sb_info *server)
696 struct smb_request *req = NULL;
697 int result = 0;
699 if (smb_recv_available(server) <= 0)
700 return 0;
702 VERBOSE("state: %d\n", server->rstate);
703 switch (server->rstate) {
704 case SMB_RECV_DROP:
705 result = smb_receive_drop(server);
706 if (result < 0)
707 break;
708 if (server->rstate == SMB_RECV_DROP)
709 break;
710 server->rstate = SMB_RECV_START;
711 /* fallthrough */
712 case SMB_RECV_START:
713 server->smb_read = 0;
714 server->rstate = SMB_RECV_HEADER;
715 /* fallthrough */
716 case SMB_RECV_HEADER:
717 result = smb_receive_header(server);
718 if (result < 0)
719 break;
720 if (server->rstate == SMB_RECV_HEADER)
721 break;
722 if (! (*(server->header + smb_flg) & SMB_FLAGS_REPLY) ) {
723 server->rstate = SMB_RECV_REQUEST;
724 break;
726 if (server->rstate != SMB_RECV_HCOMPLETE)
727 break;
728 /* fallthrough */
729 case SMB_RECV_HCOMPLETE:
730 req = find_request(server, WVAL(server->header, smb_mid));
731 if (!req)
732 break;
733 smb_init_request(server, req);
734 req->rq_rcls = *(req->rq_header + smb_rcls);
735 req->rq_err = WVAL(req->rq_header, smb_err);
736 if (server->rstate != SMB_RECV_PARAM)
737 break;
738 /* fallthrough */
739 case SMB_RECV_PARAM:
740 if (!req)
741 req = find_request(server,WVAL(server->header,smb_mid));
742 if (!req)
743 break;
744 result = smb_recv_param(server, req);
745 if (result < 0)
746 break;
747 if (server->rstate != SMB_RECV_DATA)
748 break;
749 /* fallthrough */
750 case SMB_RECV_DATA:
751 if (!req)
752 req = find_request(server,WVAL(server->header,smb_mid));
753 if (!req)
754 break;
755 result = smb_recv_data(server, req);
756 if (result < 0)
757 break;
758 break;
760 /* We should never be called with any of these states */
761 case SMB_RECV_END:
762 case SMB_RECV_REQUEST:
763 server->rstate = SMB_RECV_END;
764 break;
767 if (result < 0) {
768 /* We saw an error */
769 return result;
772 if (server->rstate != SMB_RECV_END)
773 return 0;
775 result = 0;
776 if (req->rq_trans2_command && req->rq_rcls == SUCCESS)
777 result = smb_recv_trans2(server, req);
780 * Response completely read. Drop any extra bytes sent by the server.
781 * (Yes, servers sometimes add extra bytes to responses)
783 VERBOSE("smb_len: %d smb_read: %d\n",
784 server->smb_len, server->smb_read);
785 if (server->smb_read < server->smb_len)
786 smb_receive_drop(server);
788 server->rstate = SMB_RECV_START;
790 if (!result) {
791 list_del_init(&req->rq_queue);
792 req->rq_flags |= SMB_REQ_RECEIVED;
793 smb_rput(req);
794 wake_up_interruptible(&req->rq_wait);
796 return 0;