blob: 3a8c682580269ac2adbf34e90ccdecb87c07415c [file] [log] [blame]
Steve French1080ef72011-02-24 18:07:19 +00001/*
2 * SMB2 version specific operations
3 *
4 * Copyright (c) 2012, Jeff Layton <jlayton@redhat.com>
5 *
6 * This library is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License v2 as published
8 * by the Free Software Foundation.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13 * the GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
Pavel Shilovsky3a3bab52012-09-18 16:20:28 -070020#include <linux/pagemap.h>
Pavel Shilovsky6fc05c22012-09-18 16:20:34 -070021#include <linux/vfs.h>
Steve French1080ef72011-02-24 18:07:19 +000022#include "cifsglob.h"
Pavel Shilovsky2dc7e1c2011-12-26 22:53:34 +040023#include "smb2pdu.h"
24#include "smb2proto.h"
Pavel Shilovsky28ea5292012-05-23 16:18:00 +040025#include "cifsproto.h"
26#include "cifs_debug.h"
Pavel Shilovsky2e44b282012-09-18 16:20:33 -070027#include "smb2status.h"
Pavel Shilovsky6fc05c22012-09-18 16:20:34 -070028#include "smb2glob.h"
Pavel Shilovsky28ea5292012-05-23 16:18:00 +040029
30static int
31change_conf(struct TCP_Server_Info *server)
32{
33 server->credits += server->echo_credits + server->oplock_credits;
34 server->oplock_credits = server->echo_credits = 0;
35 switch (server->credits) {
36 case 0:
37 return -1;
38 case 1:
39 server->echoes = false;
40 server->oplocks = false;
41 cERROR(1, "disabling echoes and oplocks");
42 break;
43 case 2:
44 server->echoes = true;
45 server->oplocks = false;
46 server->echo_credits = 1;
47 cFYI(1, "disabling oplocks");
48 break;
49 default:
50 server->echoes = true;
51 server->oplocks = true;
52 server->echo_credits = 1;
53 server->oplock_credits = 1;
54 }
55 server->credits -= server->echo_credits + server->oplock_credits;
56 return 0;
57}
58
59static void
60smb2_add_credits(struct TCP_Server_Info *server, const unsigned int add,
61 const int optype)
62{
63 int *val, rc = 0;
64 spin_lock(&server->req_lock);
65 val = server->ops->get_credits_field(server, optype);
66 *val += add;
67 server->in_flight--;
Pavel Shilovskyec2e4522011-12-27 16:12:43 +040068 if (server->in_flight == 0 && (optype & CIFS_OP_MASK) != CIFS_NEG_OP)
Pavel Shilovsky28ea5292012-05-23 16:18:00 +040069 rc = change_conf(server);
Pavel Shilovsky983c88a2012-09-18 16:20:33 -070070 /*
71 * Sometimes server returns 0 credits on oplock break ack - we need to
72 * rebalance credits in this case.
73 */
74 else if (server->in_flight > 0 && server->oplock_credits == 0 &&
75 server->oplocks) {
76 if (server->credits > 1) {
77 server->credits--;
78 server->oplock_credits++;
79 }
80 }
Pavel Shilovsky28ea5292012-05-23 16:18:00 +040081 spin_unlock(&server->req_lock);
82 wake_up(&server->request_q);
83 if (rc)
84 cifs_reconnect(server);
85}
86
87static void
88smb2_set_credits(struct TCP_Server_Info *server, const int val)
89{
90 spin_lock(&server->req_lock);
91 server->credits = val;
92 spin_unlock(&server->req_lock);
93}
94
95static int *
96smb2_get_credits_field(struct TCP_Server_Info *server, const int optype)
97{
98 switch (optype) {
99 case CIFS_ECHO_OP:
100 return &server->echo_credits;
101 case CIFS_OBREAK_OP:
102 return &server->oplock_credits;
103 default:
104 return &server->credits;
105 }
106}
107
108static unsigned int
109smb2_get_credits(struct mid_q_entry *mid)
110{
111 return le16_to_cpu(((struct smb2_hdr *)mid->resp_buf)->CreditRequest);
112}
Pavel Shilovsky2dc7e1c2011-12-26 22:53:34 +0400113
114static __u64
115smb2_get_next_mid(struct TCP_Server_Info *server)
116{
117 __u64 mid;
118 /* for SMB2 we need the current value */
119 spin_lock(&GlobalMid_Lock);
120 mid = server->CurrentMid++;
121 spin_unlock(&GlobalMid_Lock);
122 return mid;
123}
Steve French1080ef72011-02-24 18:07:19 +0000124
Pavel Shilovsky093b2bd2011-06-08 15:51:07 +0400125static struct mid_q_entry *
126smb2_find_mid(struct TCP_Server_Info *server, char *buf)
127{
128 struct mid_q_entry *mid;
129 struct smb2_hdr *hdr = (struct smb2_hdr *)buf;
130
131 spin_lock(&GlobalMid_Lock);
132 list_for_each_entry(mid, &server->pending_mid_q, qhead) {
133 if ((mid->mid == hdr->MessageId) &&
134 (mid->mid_state == MID_REQUEST_SUBMITTED) &&
135 (mid->command == hdr->Command)) {
136 spin_unlock(&GlobalMid_Lock);
137 return mid;
138 }
139 }
140 spin_unlock(&GlobalMid_Lock);
141 return NULL;
142}
143
144static void
145smb2_dump_detail(void *buf)
146{
147#ifdef CONFIG_CIFS_DEBUG2
148 struct smb2_hdr *smb = (struct smb2_hdr *)buf;
149
150 cERROR(1, "Cmd: %d Err: 0x%x Flags: 0x%x Mid: %llu Pid: %d",
151 smb->Command, smb->Status, smb->Flags, smb->MessageId,
152 smb->ProcessId);
153 cERROR(1, "smb buf %p len %u", smb, smb2_calc_size(smb));
154#endif
155}
156
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400157static bool
158smb2_need_neg(struct TCP_Server_Info *server)
159{
160 return server->max_read == 0;
161}
162
163static int
164smb2_negotiate(const unsigned int xid, struct cifs_ses *ses)
165{
166 int rc;
167 ses->server->CurrentMid = 0;
168 rc = SMB2_negotiate(xid, ses);
169 /* BB we probably don't need to retry with modern servers */
170 if (rc == -EAGAIN)
171 rc = -EHOSTDOWN;
172 return rc;
173}
174
Pavel Shilovsky3a3bab52012-09-18 16:20:28 -0700175static unsigned int
176smb2_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
177{
178 struct TCP_Server_Info *server = tcon->ses->server;
179 unsigned int wsize;
180
181 /* start with specified wsize, or default */
182 wsize = volume_info->wsize ? volume_info->wsize : CIFS_DEFAULT_IOSIZE;
183 wsize = min_t(unsigned int, wsize, server->max_write);
184 /*
185 * limit write size to 2 ** 16, because we don't support multicredit
186 * requests now.
187 */
188 wsize = min_t(unsigned int, wsize, 2 << 15);
189
190 /* limit to the amount that we can kmap at once */
191 wsize = min_t(unsigned int, wsize, CIFS_KMAP_SIZE_LIMIT);
192
193 return wsize;
194}
195
196static unsigned int
197smb2_negotiate_rsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
198{
199 struct TCP_Server_Info *server = tcon->ses->server;
200 unsigned int rsize;
201
202 /* start with specified rsize, or default */
203 rsize = volume_info->rsize ? volume_info->rsize : CIFS_DEFAULT_IOSIZE;
204 rsize = min_t(unsigned int, rsize, server->max_read);
205 /*
206 * limit write size to 2 ** 16, because we don't support multicredit
207 * requests now.
208 */
209 rsize = min_t(unsigned int, rsize, 2 << 15);
210
211 /* limit to the amount that we can kmap at once */
212 rsize = min_t(unsigned int, rsize, CIFS_KMAP_SIZE_LIMIT);
213
214 return rsize;
215}
216
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400217static int
218smb2_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
219 struct cifs_sb_info *cifs_sb, const char *full_path)
220{
221 int rc;
222 __u64 persistent_fid, volatile_fid;
223 __le16 *utf16_path;
Pavel Shilovsky2e44b282012-09-18 16:20:33 -0700224 __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400225
226 utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb);
227 if (!utf16_path)
228 return -ENOMEM;
229
230 rc = SMB2_open(xid, tcon, utf16_path, &persistent_fid, &volatile_fid,
Pavel Shilovsky2e44b282012-09-18 16:20:33 -0700231 FILE_READ_ATTRIBUTES, FILE_OPEN, 0, 0, &oplock, NULL);
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400232 if (rc) {
233 kfree(utf16_path);
234 return rc;
235 }
236
237 rc = SMB2_close(xid, tcon, persistent_fid, volatile_fid);
238 kfree(utf16_path);
239 return rc;
240}
241
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400242static int
243smb2_get_srv_inum(const unsigned int xid, struct cifs_tcon *tcon,
244 struct cifs_sb_info *cifs_sb, const char *full_path,
245 u64 *uniqueid, FILE_ALL_INFO *data)
246{
247 *uniqueid = le64_to_cpu(data->IndexNumber);
248 return 0;
249}
250
Pavel Shilovskyb7546bc2012-09-18 16:20:27 -0700251static int
252smb2_query_file_info(const unsigned int xid, struct cifs_tcon *tcon,
253 struct cifs_fid *fid, FILE_ALL_INFO *data)
254{
255 int rc;
256 struct smb2_file_all_info *smb2_data;
257
258 smb2_data = kzalloc(sizeof(struct smb2_file_all_info) + MAX_NAME * 2,
259 GFP_KERNEL);
260 if (smb2_data == NULL)
261 return -ENOMEM;
262
263 rc = SMB2_query_info(xid, tcon, fid->persistent_fid, fid->volatile_fid,
264 smb2_data);
265 if (!rc)
266 move_smb2_info_to_cifs(data, smb2_data);
267 kfree(smb2_data);
268 return rc;
269}
270
Pavel Shilovsky25e26632012-05-27 20:44:23 +0400271static char *
272smb2_build_path_to_root(struct smb_vol *vol, struct cifs_sb_info *cifs_sb,
273 struct cifs_tcon *tcon)
274{
275 int pplen = vol->prepath ? strlen(vol->prepath) : 0;
276 char *full_path = NULL;
277
278 /* if no prefix path, simply set path to the root of share to "" */
279 if (pplen == 0) {
280 full_path = kzalloc(2, GFP_KERNEL);
281 return full_path;
282 }
283
284 cERROR(1, "prefixpath is not supported for SMB2 now");
285 return NULL;
286}
287
Pavel Shilovsky9094fad2012-07-12 18:30:44 +0400288static bool
289smb2_can_echo(struct TCP_Server_Info *server)
290{
291 return server->echoes;
292}
293
Pavel Shilovskyd60622e2012-05-28 15:19:39 +0400294static void
295smb2_clear_stats(struct cifs_tcon *tcon)
296{
297#ifdef CONFIG_CIFS_STATS
298 int i;
299 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
300 atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
301 atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
302 }
303#endif
304}
305
306static void
307smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
308{
309#ifdef CONFIG_CIFS_STATS
310 atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
311 atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
312 seq_printf(m, "\nNegotiates: %d sent %d failed",
313 atomic_read(&sent[SMB2_NEGOTIATE_HE]),
314 atomic_read(&failed[SMB2_NEGOTIATE_HE]));
315 seq_printf(m, "\nSessionSetups: %d sent %d failed",
316 atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
317 atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
318#define SMB2LOGOFF 0x0002 /* trivial request/resp */
319 seq_printf(m, "\nLogoffs: %d sent %d failed",
320 atomic_read(&sent[SMB2_LOGOFF_HE]),
321 atomic_read(&failed[SMB2_LOGOFF_HE]));
322 seq_printf(m, "\nTreeConnects: %d sent %d failed",
323 atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
324 atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
325 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
326 atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
327 atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
328 seq_printf(m, "\nCreates: %d sent %d failed",
329 atomic_read(&sent[SMB2_CREATE_HE]),
330 atomic_read(&failed[SMB2_CREATE_HE]));
331 seq_printf(m, "\nCloses: %d sent %d failed",
332 atomic_read(&sent[SMB2_CLOSE_HE]),
333 atomic_read(&failed[SMB2_CLOSE_HE]));
334 seq_printf(m, "\nFlushes: %d sent %d failed",
335 atomic_read(&sent[SMB2_FLUSH_HE]),
336 atomic_read(&failed[SMB2_FLUSH_HE]));
337 seq_printf(m, "\nReads: %d sent %d failed",
338 atomic_read(&sent[SMB2_READ_HE]),
339 atomic_read(&failed[SMB2_READ_HE]));
340 seq_printf(m, "\nWrites: %d sent %d failed",
341 atomic_read(&sent[SMB2_WRITE_HE]),
342 atomic_read(&failed[SMB2_WRITE_HE]));
343 seq_printf(m, "\nLocks: %d sent %d failed",
344 atomic_read(&sent[SMB2_LOCK_HE]),
345 atomic_read(&failed[SMB2_LOCK_HE]));
346 seq_printf(m, "\nIOCTLs: %d sent %d failed",
347 atomic_read(&sent[SMB2_IOCTL_HE]),
348 atomic_read(&failed[SMB2_IOCTL_HE]));
349 seq_printf(m, "\nCancels: %d sent %d failed",
350 atomic_read(&sent[SMB2_CANCEL_HE]),
351 atomic_read(&failed[SMB2_CANCEL_HE]));
352 seq_printf(m, "\nEchos: %d sent %d failed",
353 atomic_read(&sent[SMB2_ECHO_HE]),
354 atomic_read(&failed[SMB2_ECHO_HE]));
355 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
356 atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
357 atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
358 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
359 atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
360 atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
361 seq_printf(m, "\nQueryInfos: %d sent %d failed",
362 atomic_read(&sent[SMB2_QUERY_INFO_HE]),
363 atomic_read(&failed[SMB2_QUERY_INFO_HE]));
364 seq_printf(m, "\nSetInfos: %d sent %d failed",
365 atomic_read(&sent[SMB2_SET_INFO_HE]),
366 atomic_read(&failed[SMB2_SET_INFO_HE]));
367 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
368 atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
369 atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
370#endif
371}
372
Pavel Shilovskyf0df7372012-09-18 16:20:26 -0700373static void
374smb2_set_fid(struct cifsFileInfo *cfile, struct cifs_fid *fid, __u32 oplock)
375{
Pavel Shilovsky2e44b282012-09-18 16:20:33 -0700376 struct cifsInodeInfo *cinode = CIFS_I(cfile->dentry->d_inode);
Pavel Shilovskyf0df7372012-09-18 16:20:26 -0700377 cfile->fid.persistent_fid = fid->persistent_fid;
378 cfile->fid.volatile_fid = fid->volatile_fid;
Pavel Shilovsky2e44b282012-09-18 16:20:33 -0700379 smb2_set_oplock_level(cinode, oplock);
Pavel Shilovskyf0df7372012-09-18 16:20:26 -0700380 /* cinode->can_cache_brlcks = cinode->clientCanCacheAll; */
381}
382
383static int
384smb2_close_file(const unsigned int xid, struct cifs_tcon *tcon,
385 struct cifs_fid *fid)
386{
387 return SMB2_close(xid, tcon, fid->persistent_fid, fid->volatile_fid);
388}
389
Pavel Shilovsky7a5cfb12012-09-18 16:20:28 -0700390static int
391smb2_flush_file(const unsigned int xid, struct cifs_tcon *tcon,
392 struct cifs_fid *fid)
393{
394 return SMB2_flush(xid, tcon, fid->persistent_fid, fid->volatile_fid);
395}
396
Pavel Shilovsky09a47072012-09-18 16:20:29 -0700397static unsigned int
398smb2_read_data_offset(char *buf)
399{
400 struct smb2_read_rsp *rsp = (struct smb2_read_rsp *)buf;
401 return rsp->DataOffset;
402}
403
404static unsigned int
405smb2_read_data_length(char *buf)
406{
407 struct smb2_read_rsp *rsp = (struct smb2_read_rsp *)buf;
408 return le32_to_cpu(rsp->DataLength);
409}
410
Pavel Shilovskyd8e05032012-09-18 16:20:30 -0700411
412static int
413smb2_sync_read(const unsigned int xid, struct cifsFileInfo *cfile,
414 struct cifs_io_parms *parms, unsigned int *bytes_read,
415 char **buf, int *buf_type)
416{
417 parms->persistent_fid = cfile->fid.persistent_fid;
418 parms->volatile_fid = cfile->fid.volatile_fid;
419 return SMB2_read(xid, parms, bytes_read, buf, buf_type);
420}
421
Pavel Shilovsky009d3442012-09-18 16:20:30 -0700422static int
423smb2_sync_write(const unsigned int xid, struct cifsFileInfo *cfile,
424 struct cifs_io_parms *parms, unsigned int *written,
425 struct kvec *iov, unsigned long nr_segs)
426{
427
428 parms->persistent_fid = cfile->fid.persistent_fid;
429 parms->volatile_fid = cfile->fid.volatile_fid;
430 return SMB2_write(xid, parms, written, iov, nr_segs);
431}
432
Pavel Shilovskyc839ff22012-09-18 16:20:32 -0700433static int
434smb2_set_file_size(const unsigned int xid, struct cifs_tcon *tcon,
435 struct cifsFileInfo *cfile, __u64 size, bool set_alloc)
436{
437 __le64 eof = cpu_to_le64(size);
438 return SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid,
439 cfile->fid.volatile_fid, cfile->pid, &eof);
440}
441
Pavel Shilovskyd324f08d2012-09-18 16:20:33 -0700442static int
443smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon,
444 const char *path, struct cifs_sb_info *cifs_sb,
445 struct cifs_fid *fid, __u16 search_flags,
446 struct cifs_search_info *srch_inf)
447{
448 __le16 *utf16_path;
449 int rc;
Pavel Shilovsky2e44b282012-09-18 16:20:33 -0700450 __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
Pavel Shilovskyd324f08d2012-09-18 16:20:33 -0700451 __u64 persistent_fid, volatile_fid;
452
453 utf16_path = cifs_convert_path_to_utf16(path, cifs_sb);
454 if (!utf16_path)
455 return -ENOMEM;
456
457 rc = SMB2_open(xid, tcon, utf16_path, &persistent_fid, &volatile_fid,
458 FILE_READ_ATTRIBUTES | FILE_READ_DATA, FILE_OPEN, 0, 0,
Pavel Shilovsky2e44b282012-09-18 16:20:33 -0700459 &oplock, NULL);
Pavel Shilovskyd324f08d2012-09-18 16:20:33 -0700460 kfree(utf16_path);
461 if (rc) {
462 cERROR(1, "open dir failed");
463 return rc;
464 }
465
466 srch_inf->entries_in_buffer = 0;
467 srch_inf->index_of_last_entry = 0;
468 fid->persistent_fid = persistent_fid;
469 fid->volatile_fid = volatile_fid;
470
471 rc = SMB2_query_directory(xid, tcon, persistent_fid, volatile_fid, 0,
472 srch_inf);
473 if (rc) {
474 cERROR(1, "query directory failed");
475 SMB2_close(xid, tcon, persistent_fid, volatile_fid);
476 }
477 return rc;
478}
479
480static int
481smb2_query_dir_next(const unsigned int xid, struct cifs_tcon *tcon,
482 struct cifs_fid *fid, __u16 search_flags,
483 struct cifs_search_info *srch_inf)
484{
485 return SMB2_query_directory(xid, tcon, fid->persistent_fid,
486 fid->volatile_fid, 0, srch_inf);
487}
488
489static int
490smb2_close_dir(const unsigned int xid, struct cifs_tcon *tcon,
491 struct cifs_fid *fid)
492{
493 return SMB2_close(xid, tcon, fid->persistent_fid, fid->volatile_fid);
494}
495
Pavel Shilovsky2e44b282012-09-18 16:20:33 -0700496/*
497* If we negotiate SMB2 protocol and get STATUS_PENDING - update
498* the number of credits and return true. Otherwise - return false.
499*/
500static bool
501smb2_is_status_pending(char *buf, struct TCP_Server_Info *server, int length)
502{
503 struct smb2_hdr *hdr = (struct smb2_hdr *)buf;
504
505 if (le32_to_cpu(hdr->Status) != STATUS_PENDING)
506 return false;
507
508 if (!length) {
509 spin_lock(&server->req_lock);
510 server->credits += le16_to_cpu(hdr->CreditRequest);
511 spin_unlock(&server->req_lock);
512 wake_up(&server->request_q);
513 }
514
515 return true;
516}
517
Pavel Shilovsky983c88a2012-09-18 16:20:33 -0700518static int
519smb2_oplock_response(struct cifs_tcon *tcon, struct cifs_fid *fid,
520 struct cifsInodeInfo *cinode)
521{
522 return SMB2_oplock_break(0, tcon, fid->persistent_fid,
523 fid->volatile_fid,
524 cinode->clientCanCacheRead ? 1 : 0);
525}
526
Pavel Shilovsky6fc05c22012-09-18 16:20:34 -0700527static int
528smb2_queryfs(const unsigned int xid, struct cifs_tcon *tcon,
529 struct kstatfs *buf)
530{
531 int rc;
532 u64 persistent_fid, volatile_fid;
533 __le16 srch_path = 0; /* Null - open root of share */
534 u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
535
536 rc = SMB2_open(xid, tcon, &srch_path, &persistent_fid, &volatile_fid,
537 FILE_READ_ATTRIBUTES, FILE_OPEN, 0, 0, &oplock, NULL);
538 if (rc)
539 return rc;
540 buf->f_type = SMB2_MAGIC_NUMBER;
541 rc = SMB2_QFS_info(xid, tcon, persistent_fid, volatile_fid, buf);
542 SMB2_close(xid, tcon, persistent_fid, volatile_fid);
543 return rc;
544}
545
Steve French1080ef72011-02-24 18:07:19 +0000546struct smb_version_operations smb21_operations = {
Pavel Shilovsky2dc7e1c2011-12-26 22:53:34 +0400547 .setup_request = smb2_setup_request,
Pavel Shilovskyc95b8ee2012-07-11 14:45:28 +0400548 .setup_async_request = smb2_setup_async_request,
Pavel Shilovsky2dc7e1c2011-12-26 22:53:34 +0400549 .check_receive = smb2_check_receive,
Pavel Shilovsky28ea5292012-05-23 16:18:00 +0400550 .add_credits = smb2_add_credits,
551 .set_credits = smb2_set_credits,
552 .get_credits_field = smb2_get_credits_field,
553 .get_credits = smb2_get_credits,
Pavel Shilovsky2dc7e1c2011-12-26 22:53:34 +0400554 .get_next_mid = smb2_get_next_mid,
Pavel Shilovsky09a47072012-09-18 16:20:29 -0700555 .read_data_offset = smb2_read_data_offset,
556 .read_data_length = smb2_read_data_length,
557 .map_error = map_smb2_to_linux_error,
Pavel Shilovsky093b2bd2011-06-08 15:51:07 +0400558 .find_mid = smb2_find_mid,
559 .check_message = smb2_check_message,
560 .dump_detail = smb2_dump_detail,
Pavel Shilovskyd60622e2012-05-28 15:19:39 +0400561 .clear_stats = smb2_clear_stats,
562 .print_stats = smb2_print_stats,
Pavel Shilovsky983c88a2012-09-18 16:20:33 -0700563 .is_oplock_break = smb2_is_valid_oplock_break,
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400564 .need_neg = smb2_need_neg,
565 .negotiate = smb2_negotiate,
Pavel Shilovsky3a3bab52012-09-18 16:20:28 -0700566 .negotiate_wsize = smb2_negotiate_wsize,
567 .negotiate_rsize = smb2_negotiate_rsize,
Pavel Shilovsky5478f9b2011-12-27 16:22:00 +0400568 .sess_setup = SMB2_sess_setup,
569 .logoff = SMB2_logoff,
Pavel Shilovskyfaaf9462011-12-27 16:04:00 +0400570 .tree_connect = SMB2_tcon,
571 .tree_disconnect = SMB2_tdis,
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400572 .is_path_accessible = smb2_is_path_accessible,
Pavel Shilovsky9094fad2012-07-12 18:30:44 +0400573 .can_echo = smb2_can_echo,
574 .echo = SMB2_echo,
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400575 .query_path_info = smb2_query_path_info,
576 .get_srv_inum = smb2_get_srv_inum,
Pavel Shilovskyb7546bc2012-09-18 16:20:27 -0700577 .query_file_info = smb2_query_file_info,
Pavel Shilovskyc839ff22012-09-18 16:20:32 -0700578 .set_path_size = smb2_set_path_size,
579 .set_file_size = smb2_set_file_size,
Pavel Shilovsky1feeaac2012-09-18 16:20:32 -0700580 .set_file_info = smb2_set_file_info,
Pavel Shilovsky25e26632012-05-27 20:44:23 +0400581 .build_path_to_root = smb2_build_path_to_root,
Pavel Shilovskya0e73182011-07-19 12:56:37 +0400582 .mkdir = smb2_mkdir,
583 .mkdir_setinfo = smb2_mkdir_setinfo,
Pavel Shilovsky1a500f02012-07-10 16:14:38 +0400584 .rmdir = smb2_rmdir,
Pavel Shilovskycbe6f432012-09-18 16:20:25 -0700585 .unlink = smb2_unlink,
Pavel Shilovsky35143eb2012-09-18 16:20:31 -0700586 .rename = smb2_rename_path,
Pavel Shilovsky568798c2012-09-18 16:20:31 -0700587 .create_hardlink = smb2_create_hardlink,
Pavel Shilovskyf0df7372012-09-18 16:20:26 -0700588 .open = smb2_open_file,
589 .set_fid = smb2_set_fid,
590 .close = smb2_close_file,
Pavel Shilovsky7a5cfb12012-09-18 16:20:28 -0700591 .flush = smb2_flush_file,
Pavel Shilovsky09a47072012-09-18 16:20:29 -0700592 .async_readv = smb2_async_readv,
Pavel Shilovsky33319142012-09-18 16:20:29 -0700593 .async_writev = smb2_async_writev,
Pavel Shilovskyd8e05032012-09-18 16:20:30 -0700594 .sync_read = smb2_sync_read,
Pavel Shilovsky009d3442012-09-18 16:20:30 -0700595 .sync_write = smb2_sync_write,
Pavel Shilovskyd324f08d2012-09-18 16:20:33 -0700596 .query_dir_first = smb2_query_dir_first,
597 .query_dir_next = smb2_query_dir_next,
598 .close_dir = smb2_close_dir,
599 .calc_smb_size = smb2_calc_size,
Pavel Shilovsky2e44b282012-09-18 16:20:33 -0700600 .is_status_pending = smb2_is_status_pending,
Pavel Shilovsky983c88a2012-09-18 16:20:33 -0700601 .oplock_response = smb2_oplock_response,
Pavel Shilovsky6fc05c22012-09-18 16:20:34 -0700602 .queryfs = smb2_queryfs,
Steve French1080ef72011-02-24 18:07:19 +0000603};
604
605struct smb_version_values smb21_values = {
606 .version_string = SMB21_VERSION_STRING,
Pavel Shilovsky093b2bd2011-06-08 15:51:07 +0400607 .header_size = sizeof(struct smb2_hdr),
608 .max_header_size = MAX_SMB2_HDR_SIZE,
Pavel Shilovsky09a47072012-09-18 16:20:29 -0700609 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
Pavel Shilovsky2dc7e1c2011-12-26 22:53:34 +0400610 .lock_cmd = SMB2_LOCK,
Pavel Shilovsky29e20f92012-07-13 13:58:14 +0400611 .cap_unix = 0,
612 .cap_nt_find = SMB2_NT_FIND,
613 .cap_large_files = SMB2_LARGE_FILES,
Steve French1080ef72011-02-24 18:07:19 +0000614};