Blame view

fs/cifs/cifsglob.h 68.3 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
  /*
   *   fs/cifs/cifsglob.h
   *
366781c19   Steve French   [CIFS] DFS build ...
4
   *   Copyright (C) International Business Machines  Corp., 2002,2008
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
5
   *   Author(s): Steve French (sfrench@us.ibm.com)
7ee1af765   Jeremy Allison   [CIFS]
6
   *              Jeremy Allison (jra@samba.org)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
7
8
9
10
11
12
13
14
15
16
   *
   *   This library is free software; you can redistribute it and/or modify
   *   it under the terms of the GNU Lesser General Public License as published
   *   by the Free Software Foundation; either version 2.1 of the License, or
   *   (at your option) any later version.
   *
   *   This library is distributed in the hope that it will be useful,
   *   but WITHOUT ANY WARRANTY; without even the implied warranty of
   *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
   *   the GNU Lesser General Public License for more details.
d38d8c74c   Steve French   [CIFS] whitespace...
17
   *
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
18
   */
abd2e44dc   Suresh Jayaraman   cifs: guard cifsg...
19
20
  #ifndef _CIFS_GLOB_H
  #define _CIFS_GLOB_H
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
21
22
  #include <linux/in.h>
  #include <linux/in6.h>
5a0e3ad6a   Tejun Heo   include cleanup: ...
23
  #include <linux/slab.h>
2dc7e1c03   Pavel Shilovsky   CIFS: Make transp...
24
  #include <linux/mempool.h>
9b6469724   Tejun Heo   cifs: use workque...
25
  #include <linux/workqueue.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
26
  #include "cifs_fs_sb.h"
442aa310f   Steve French   [CIFS] Support fo...
27
  #include "cifsacl.h"
d2b915210   Shirish Pargaonkar   NTLM auth and sig...
28
29
  #include <crypto/internal/hash.h>
  #include <linux/scatterlist.h>
8c3a2b4c4   Scott Lovenberg   cifs: Move string...
30
  #include <uapi/linux/cifs/cifs_mount.h>
d60622eb5   Pavel Shilovsky   CIFS: Allow SMB2 ...
31
  #include "smb2pdu.h"
d2b915210   Shirish Pargaonkar   NTLM auth and sig...
32

76ec5e338   Pavel Shilovsky   CIFS: Move statfs...
33
  #define CIFS_MAGIC_NUMBER 0xFF534D42      /* the first four bytes of SMB PDUs */
8d8b26e58   Ronnie Sahlberg   cifs: add support...
34
  #define SMB_PATH_MAX 260
e2292430c   Aurelien Aptel   CIFS: move defaul...
35
36
  #define CIFS_PORT 445
  #define RFC1001_PORT 139
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
37
38
39
40
41
42
  /*
   * The sizes of various internal tables and strings
   */
  #define MAX_UID_INFO 16
  #define MAX_SES_INFO 2
  #define MAX_TCON_INFO 4
cdf1246ff   Scott Lovenberg   cifs: Move and ex...
43
  #define MAX_TREE_SIZE (2 + CIFS_NI_MAXHOST + 1 + CIFS_MAX_SHARE_LEN + 1)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
44
45
  
  #define CIFS_MIN_RCV_POOL 4
2c0c2a08b   Shirish Pargaonkar   cifs: fix oops wh...
46
  #define MAX_REOPEN_ATT	5 /* these many maximum attempts to reopen a file */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
47
  /*
6d20e8406   Suresh Jayaraman   cifs: add attribu...
48
49
50
51
52
53
54
55
56
57
   * default attribute cache timeout (jiffies)
   */
  #define CIFS_DEF_ACTIMEO (1 * HZ)
  
  /*
   * max attribute cache timeout (jiffies) - 2^30
   */
  #define CIFS_MAX_ACTIMEO (1 << 30)
  
  /*
ca567eb2b   Steve French   SMB3: Allow persi...
58
59
60
61
62
63
   * Max persistent and resilient handle timeout (milliseconds).
   * Windows durable max was 960000 (16 minutes)
   */
  #define SMB3_MAX_HANDLE_TIMEOUT 960000
  
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
64
   * MAX_REQ is the maximum number of requests that WE will send
10b9b98e4   Pavel Shilovsky   CIFS: Respect neg...
65
   * on one socket concurrently.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
66
   */
10b9b98e4   Pavel Shilovsky   CIFS: Respect neg...
67
  #define CIFS_MAX_REQ 32767
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
68

8ecaf67a8   Jeff Layton   cifs: account for...
69
70
  #define RFC1001_NAME_LEN 15
  #define RFC1001_NAME_LEN_WITH_NULL (RFC1001_NAME_LEN + 1)
b327a717e   Aurelien Aptel   CIFS: make IPC a ...
71
72
  /* maximum length of ip addr as a string (including ipv6 and sctp) */
  #define SERVER_NAME_LENGTH 80
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
73
  #define SERVER_NAME_LEN_WITH_NULL     (SERVER_NAME_LENGTH + 1)
adfeb3e00   Steve French   cifs: Make echo i...
74
75
76
77
  /* echo interval in seconds */
  #define SMB_ECHO_INTERVAL_MIN 1
  #define SMB_ECHO_INTERVAL_MAX 600
  #define SMB_ECHO_INTERVAL_DEFAULT 60
9094fad1e   Pavel Shilovsky   CIFS: Add echo re...
78

b24df3e30   Ronnie Sahlberg   cifs: update rece...
79
80
  /* maximum number of PDUs in one compound */
  #define MAX_COMPOUND 5
141891f47   Steve French   SMB3: Add mount p...
81
82
83
84
85
86
87
88
89
90
91
  /*
   * Default number of credits to keep available for SMB3.
   * This value is chosen somewhat arbitrarily. The Windows client
   * defaults to 128 credits, the Windows server allows clients up to
   * 512 credits (or 8K for later versions), and the NetApp server
   * does not limit clients at all.  Choose a high enough default value
   * such that the client shouldn't limit performance, but allow mount
   * to override (until you approach 64K, where we limit credits to 65000
   * to reduce possibility of seeing more server credit overflow bugs.
   */
  #define SMB2_MAX_CREDITS_AVAILABLE 32000
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
92
  #include "cifspdu.h"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
93
94
95
96
97
  #ifndef XATTR_DOS_ATTRIB
  #define XATTR_DOS_ATTRIB "user.DOSATTRIB"
  #endif
  
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
98
99
   * CIFS vfs client Status information (based on what we know.)
   */
6c0f6218b   Steve French   [CIFS] Fix checkp...
100
  /* associated with each tcp and smb session */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
101
102
103
104
  enum statusEnum {
  	CifsNew = 0,
  	CifsGood,
  	CifsExiting,
fd88ce931   Steve French   [CIFS] cifs: clar...
105
106
  	CifsNeedReconnect,
  	CifsNeedNegotiate
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
107
108
109
  };
  
  enum securityEnum {
515d82ffd   Jeff Layton   cifs: add new "Un...
110
111
  	Unspecified = 0,	/* not specified */
  	LANMAN,			/* Legacy LANMAN auth */
3979877e5   Steve French   [CIFS] Support fo...
112
  	NTLM,			/* Legacy NTLM012 auth with NTLM hash */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
113
  	NTLMv2,			/* Legacy NTLM auth with NTLMv2 hash */
ac6839246   Steve French   [CIFS] Allow raw ...
114
  	RawNTLMSSP,		/* NTLMSSP without SPNEGO, NTLMv2 hash */
c16fefa56   Steve French   [CIFS] distinguis...
115
  	Kerberos,		/* Kerberos via SPNEGO */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
116
  };
5f98ca9af   Shirish Pargaonkar   cifs NTLMv2/NTLMS...
117
  struct session_key {
b609f06ac   Steve French   [CIFS] Fix packet...
118
  	unsigned int len;
21e733930   Shirish Pargaonkar   NTLM auth and sig...
119
  	char *response;
b609f06ac   Steve French   [CIFS] Fix packet...
120
  };
d2b915210   Shirish Pargaonkar   NTLM auth and sig...
121
122
123
124
125
  /* crypto security descriptor definition */
  struct sdesc {
  	struct shash_desc shash;
  	char ctx[];
  };
f7c5445a9   Shirish Pargaonkar   NTLM auth and sig...
126
  /* crypto hashing related structure/fields, not specific to a sec mech */
d2b915210   Shirish Pargaonkar   NTLM auth and sig...
127
128
129
  struct cifs_secmech {
  	struct crypto_shash *hmacmd5; /* hmac-md5 hash function */
  	struct crypto_shash *md5; /* md5 hash function */
3c1bf7e48   Pavel Shilovsky   CIFS: Enable sign...
130
  	struct crypto_shash *hmacsha256; /* hmac-sha256 hash function */
429b46f4f   Steve French   [CIFS] SMB3 Signi...
131
  	struct crypto_shash *cmacaes; /* block-cipher based MAC function */
5fcd7f3f9   Aurelien Aptel   CIFS: add sha512 ...
132
  	struct crypto_shash *sha512; /* sha512 hash function */
d2b915210   Shirish Pargaonkar   NTLM auth and sig...
133
134
  	struct sdesc *sdeschmacmd5;  /* ctxt to generate ntlmv2 hash, CR1 */
  	struct sdesc *sdescmd5; /* ctxt to generate cifs/smb signature */
3c1bf7e48   Pavel Shilovsky   CIFS: Enable sign...
135
  	struct sdesc *sdeschmacsha256;  /* ctxt to generate smb2 signature */
429b46f4f   Steve French   [CIFS] SMB3 Signi...
136
  	struct sdesc *sdesccmacaes;  /* ctxt to generate smb3 signature */
5fcd7f3f9   Aurelien Aptel   CIFS: add sha512 ...
137
  	struct sdesc *sdescsha512; /* ctxt to generate smb3.11 signing key */
026e93dc0   Pavel Shilovsky   CIFS: Encrypt SMB...
138
139
  	struct crypto_aead *ccmaesencrypt; /* smb3 encryption aead */
  	struct crypto_aead *ccmaesdecrypt; /* smb3 decryption aead */
d2b915210   Shirish Pargaonkar   NTLM auth and sig...
140
  };
d3686d54c   Shirish Pargaonkar   cifs: Cleanup and...
141
  /* per smb session structure/fields */
d2b915210   Shirish Pargaonkar   NTLM auth and sig...
142
  struct ntlmssp_auth {
5c234aa5e   Shirish Pargaonkar   cifs: Add a varia...
143
  	bool sesskey_per_smbsess; /* whether session key is per smb session */
d2b915210   Shirish Pargaonkar   NTLM auth and sig...
144
145
146
  	__u32 client_flags; /* sent by client in type 1 ntlmsssp exchange */
  	__u32 server_flags; /* sent by server in type 2 ntlmssp exchange */
  	unsigned char ciphertext[CIFS_CPHTXT_SIZE]; /* sent to server */
d3686d54c   Shirish Pargaonkar   cifs: Cleanup and...
147
  	char cryptkey[CIFS_CRYPTO_KEY_SIZE]; /* used by ntlmssp */
d2b915210   Shirish Pargaonkar   NTLM auth and sig...
148
  };
442aa310f   Steve French   [CIFS] Support fo...
149
150
151
152
153
154
155
156
157
158
  struct cifs_cred {
  	int uid;
  	int gid;
  	int mode;
  	int cecount;
  	struct cifs_sid osid;
  	struct cifs_sid gsid;
  	struct cifs_ntace *ntaces;
  	struct cifs_ace *aces;
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
159
160
161
162
163
164
  /*
   *****************************************************************
   * Except the CIFS PDUs themselves all the
   * globally interesting structs should go here
   *****************************************************************
   */
bf5ea0e2f   Jeff Layton   cifs: change sign...
165
166
167
168
169
170
171
172
173
  /*
   * A smb_rqst represents a complete request to be issued to a server. It's
   * formed by a kvec array, followed by an array of pages. Page data is assumed
   * to start at the beginning of the first page.
   */
  struct smb_rqst {
  	struct kvec	*rq_iov;	/* array of kvecs */
  	unsigned int	rq_nvec;	/* number of kvecs in array */
  	struct page	**rq_pages;	/* pointer to array of page ptrs */
57a929a66   Long Li   CIFS: Introduce o...
174
  	unsigned int	rq_offset;	/* the offset to the 1st page */
bf5ea0e2f   Jeff Layton   cifs: change sign...
175
176
177
178
  	unsigned int	rq_npages;	/* number pages in array */
  	unsigned int	rq_pagesz;	/* page size to use */
  	unsigned int	rq_tailsz;	/* length of last page */
  };
121b046af   Jeff Layton   cifs: convert sen...
179
180
  struct mid_q_entry;
  struct TCP_Server_Info;
55157dfbb   Pavel Shilovsky   CIFS: Separate pr...
181
  struct cifsFileInfo;
082d0642c   Pavel Shilovsky   CIFS: Move protoc...
182
  struct cifs_ses;
2e6e02ab6   Pavel Shilovsky   CIFS: Move protoc...
183
  struct cifs_tcon;
b669f33ca   Pavel Shilovsky   CIFS: Move gettin...
184
  struct dfs_info3_param;
1208ef1f7   Pavel Shilovsky   CIFS: Move query ...
185
  struct cifs_fattr;
9224dfc2f   Pavel Shilovsky   CIFS: Move buildi...
186
  struct smb_vol;
fb1214e48   Pavel Shilovsky   CIFS: Move open c...
187
  struct cifs_fid;
fc9c59662   Pavel Shilovsky   CIFS: Move async ...
188
  struct cifs_readdata;
c9de5c80d   Pavel Shilovsky   CIFS: Move async ...
189
  struct cifs_writedata;
f9c6e234c   Pavel Shilovsky   CIFS: Move readpa...
190
  struct cifs_io_parms;
92fc65a74   Pavel Shilovsky   CIFS: Move readdi...
191
  struct cifs_search_info;
95a3f2f37   Pavel Shilovsky   CIFS: Move oplock...
192
  struct cifsInodeInfo;
226730b4d   Pavel Shilovsky   CIFS: Introduce c...
193
  struct cifs_open_parms;
335b7b62f   Pavel Shilovsky   CIFS: Respect rec...
194
  struct cifs_credits;
121b046af   Jeff Layton   cifs: convert sen...
195

23db65f51   Jeff Layton   cifs: add a smb_v...
196
  struct smb_version_operations {
fb2036d81   Pavel Shilovsky   CIFS: Make send_c...
197
  	int (*send_cancel)(struct TCP_Server_Info *, struct smb_rqst *,
121b046af   Jeff Layton   cifs: convert sen...
198
  			   struct mid_q_entry *);
55157dfbb   Pavel Shilovsky   CIFS: Separate pr...
199
  	bool (*compare_fids)(struct cifsFileInfo *, struct cifsFileInfo *);
082d0642c   Pavel Shilovsky   CIFS: Move protoc...
200
  	/* setup request: allocate mid, sign message */
fec344e3f   Jeff Layton   cifs: change cifs...
201
  	struct mid_q_entry *(*setup_request)(struct cifs_ses *,
f780bd3fe   Aurelien Aptel   cifs: add server ...
202
203
  					     struct TCP_Server_Info *,
  					     struct smb_rqst *);
45740847e   Pavel Shilovsky   CIFS: Setup async...
204
  	/* setup async request: allocate mid, sign message */
fec344e3f   Jeff Layton   cifs: change cifs...
205
206
  	struct mid_q_entry *(*setup_async_request)(struct TCP_Server_Info *,
  						struct smb_rqst *);
082d0642c   Pavel Shilovsky   CIFS: Move protoc...
207
208
209
  	/* check response: verify signature, map error */
  	int (*check_receive)(struct mid_q_entry *, struct TCP_Server_Info *,
  			     bool);
335b7b62f   Pavel Shilovsky   CIFS: Respect rec...
210
211
212
  	void (*add_credits)(struct TCP_Server_Info *server,
  			    const struct cifs_credits *credits,
  			    const int optype);
452757897   Pavel Shilovsky   CIFS: Move add/se...
213
  	void (*set_credits)(struct TCP_Server_Info *, const int);
a891f0f89   Pavel Shilovsky   CIFS: Extend cred...
214
215
  	int * (*get_credits_field)(struct TCP_Server_Info *, const int);
  	unsigned int (*get_credits)(struct mid_q_entry *);
882573606   Pavel Shilovsky   CIFS: Move get_ne...
216
  	__u64 (*get_next_mid)(struct TCP_Server_Info *);
c781af7e0   Pavel Shilovsky   CIFS: Do not skip...
217
218
  	void (*revert_current_mid)(struct TCP_Server_Info *server,
  				   const unsigned int val);
eb3787111   Pavel Shilovsky   CIFS: Move protoc...
219
220
  	/* data offset from read response message */
  	unsigned int (*read_data_offset)(char *);
74dcf418f   Long Li   CIFS: SMBD: Read ...
221
222
223
224
225
226
227
228
  	/*
  	 * Data length from read response message
  	 * When in_remaining is true, the returned data length is in
  	 * message field DataRemaining for out-of-band data read (e.g through
  	 * Memory Registration RDMA write in SMBD).
  	 * Otherwise, the returned data length is in message field DataLength.
  	 */
  	unsigned int (*read_data_length)(char *, bool in_remaining);
eb3787111   Pavel Shilovsky   CIFS: Move protoc...
229
230
  	/* map smb to linux error */
  	int (*map_error)(char *, bool);
8aa26f3ed   Pavel Shilovsky   CIFS: Move protoc...
231
232
  	/* find mid corresponding to the response message */
  	struct mid_q_entry * (*find_mid)(struct TCP_Server_Info *, char *);
14547f7d7   Ronnie Sahlberg   cifs: add server ...
233
  	void (*dump_detail)(void *buf, struct TCP_Server_Info *ptcp_info);
44c581866   Pavel Shilovsky   CIFS: Move clear/...
234
235
  	void (*clear_stats)(struct cifs_tcon *);
  	void (*print_stats)(struct seq_file *m, struct cifs_tcon *);
769ee6a40   Steve French   Add ability to di...
236
  	void (*dump_share_caps)(struct seq_file *, struct cifs_tcon *);
8aa26f3ed   Pavel Shilovsky   CIFS: Move protoc...
237
  	/* verify the message */
373512ec5   Steve French   Prepare for encry...
238
  	int (*check_message)(char *, unsigned int, struct TCP_Server_Info *);
8aa26f3ed   Pavel Shilovsky   CIFS: Move protoc...
239
  	bool (*is_oplock_break)(char *, struct TCP_Server_Info *);
38bd49064   Sachin Prabhu   Handle mismatched...
240
  	int (*handle_cancelled_mid)(char *, struct TCP_Server_Info *);
9bd454083   Pavel Shilovsky   CIFS: Properly pr...
241
242
243
  	void (*downgrade_oplock)(struct TCP_Server_Info *server,
  				 struct cifsInodeInfo *cinode, __u32 oplock,
  				 unsigned int epoch, bool *purge_cache);
316cf94a9   Pavel Shilovsky   CIFS: Move trans2...
244
245
246
  	/* process transaction2 response */
  	bool (*check_trans2)(struct mid_q_entry *, struct TCP_Server_Info *,
  			     char *, int);
286170aa2   Pavel Shilovsky   CIFS: Move protoc...
247
248
249
250
  	/* check if we need to negotiate */
  	bool (*need_neg)(struct TCP_Server_Info *);
  	/* negotiate to the server */
  	int (*negotiate)(const unsigned int, struct cifs_ses *);
24985c53d   Pavel Shilovsky   CIFS: Move r/wsiz...
251
252
253
254
  	/* set negotiated write size */
  	unsigned int (*negotiate_wsize)(struct cifs_tcon *, struct smb_vol *);
  	/* set negotiated read size */
  	unsigned int (*negotiate_rsize)(struct cifs_tcon *, struct smb_vol *);
58c45c58a   Pavel Shilovsky   CIFS: Move protoc...
255
256
257
258
259
  	/* setup smb sessionn */
  	int (*sess_setup)(const unsigned int, struct cifs_ses *,
  			  const struct nls_table *);
  	/* close smb session */
  	int (*logoff)(const unsigned int, struct cifs_ses *);
2e6e02ab6   Pavel Shilovsky   CIFS: Move protoc...
260
261
262
263
264
  	/* connect to a server share */
  	int (*tree_connect)(const unsigned int, struct cifs_ses *, const char *,
  			    struct cifs_tcon *, const struct nls_table *);
  	/* close tree connecion */
  	int (*tree_disconnect)(const unsigned int, struct cifs_tcon *);
b669f33ca   Pavel Shilovsky   CIFS: Move gettin...
265
266
267
268
  	/* get DFS referrals */
  	int (*get_dfs_refer)(const unsigned int, struct cifs_ses *,
  			     const char *, struct dfs_info3_param **,
  			     unsigned int *, const struct nls_table *, int);
af4281dc2   Pavel Shilovsky   CIFS: Move inform...
269
  	/* informational QFS call */
0f060936e   Amir Goldstein   SMB3: Backup inte...
270
271
  	void (*qfs_tcon)(const unsigned int, struct cifs_tcon *,
  			 struct cifs_sb_info *);
68889f269   Pavel Shilovsky   CIFS: Move is_pat...
272
273
274
  	/* check if a path is accessible or not */
  	int (*is_path_accessible)(const unsigned int, struct cifs_tcon *,
  				  struct cifs_sb_info *, const char *);
1208ef1f7   Pavel Shilovsky   CIFS: Move query ...
275
276
277
  	/* query path data from the server */
  	int (*query_path_info)(const unsigned int, struct cifs_tcon *,
  			       struct cifs_sb_info *, const char *,
eb85d94bd   Pavel Shilovsky   CIFS: Fix symboli...
278
  			       FILE_ALL_INFO *, bool *, bool *);
4ad650445   Pavel Shilovsky   CIFS: Move guery ...
279
280
281
  	/* query file data from the server */
  	int (*query_file_info)(const unsigned int, struct cifs_tcon *,
  			       struct cifs_fid *, FILE_ALL_INFO *);
2e4564b31   Steve French   smb3: add support...
282
283
284
285
  	/* query reparse tag from srv to determine which type of special file */
  	int (*query_reparse_tag)(const unsigned int xid, struct cifs_tcon *tcon,
  				struct cifs_sb_info *cifs_sb, const char *path,
  				__u32 *reparse_tag);
1208ef1f7   Pavel Shilovsky   CIFS: Move query ...
286
287
288
289
  	/* get server index number */
  	int (*get_srv_inum)(const unsigned int, struct cifs_tcon *,
  			    struct cifs_sb_info *, const char *,
  			    u64 *uniqueid, FILE_ALL_INFO *);
d14334181   Pavel Shilovsky   CIFS: Move set_fi...
290
291
292
293
294
295
  	/* set size by path */
  	int (*set_path_size)(const unsigned int, struct cifs_tcon *,
  			     const char *, __u64, struct cifs_sb_info *, bool);
  	/* set size by file handle */
  	int (*set_file_size)(const unsigned int, struct cifs_tcon *,
  			     struct cifsFileInfo *, __u64, bool);
6bdf6dbd6   Pavel Shilovsky   CIFS: Move set_fi...
296
297
298
  	/* set attributes */
  	int (*set_file_info)(struct inode *, const char *, FILE_BASIC_INFO *,
  			     const unsigned int);
64a5cfa6d   Steve French   Allow setting per...
299
300
  	int (*set_compression)(const unsigned int, struct cifs_tcon *,
  			       struct cifsFileInfo *);
f6d761786   Pavel Shilovsky   CIFS: Move echo c...
301
302
303
304
  	/* check if we can send an echo or nor */
  	bool (*can_echo)(struct TCP_Server_Info *);
  	/* send echo request */
  	int (*echo)(struct TCP_Server_Info *);
f436720e9   Pavel Shilovsky   CIFS: Separate pr...
305
  	/* create directory */
bea851b8b   Steve French   smb3: Fix mode on...
306
307
308
309
  	int (*posix_mkdir)(const unsigned int xid, struct inode *inode,
  			umode_t mode, struct cifs_tcon *tcon,
  			const char *full_path,
  			struct cifs_sb_info *cifs_sb);
c3ca78e21   Steve French   smb3: pass mode b...
310
311
312
  	int (*mkdir)(const unsigned int xid, struct inode *inode, umode_t mode,
  		     struct cifs_tcon *tcon, const char *name,
  		     struct cifs_sb_info *sb);
f436720e9   Pavel Shilovsky   CIFS: Separate pr...
313
314
315
316
  	/* set info on created directory */
  	void (*mkdir_setinfo)(struct inode *, const char *,
  			      struct cifs_sb_info *, struct cifs_tcon *,
  			      const unsigned int);
f958ca5d8   Pavel Shilovsky   CIFS: Move rmdir ...
317
318
319
  	/* remove directory */
  	int (*rmdir)(const unsigned int, struct cifs_tcon *, const char *,
  		     struct cifs_sb_info *);
ed6875e0d   Pavel Shilovsky   CIFS: Move unlink...
320
321
322
323
324
325
  	/* unlink file */
  	int (*unlink)(const unsigned int, struct cifs_tcon *, const char *,
  		      struct cifs_sb_info *);
  	/* open, rename and delete file */
  	int (*rename_pending_delete)(const char *, struct dentry *,
  				     const unsigned int);
8ceb98437   Pavel Shilovsky   CIFS: Move rename...
326
327
328
  	/* send rename request */
  	int (*rename)(const unsigned int, struct cifs_tcon *, const char *,
  		      const char *, struct cifs_sb_info *);
d6e906f1b   Steve French   CIFS: Move hardli...
329
330
331
332
  	/* send create hardlink request */
  	int (*create_hardlink)(const unsigned int, struct cifs_tcon *,
  			       const char *, const char *,
  			       struct cifs_sb_info *);
b42bf8882   Pavel Shilovsky   CIFS: Implement f...
333
334
  	/* query symlink target */
  	int (*query_symlink)(const unsigned int, struct cifs_tcon *,
ebaf546a5   Ronnie Sahlberg   SMB3: Clean up qu...
335
336
  			     struct cifs_sb_info *, const char *,
  			     char **, bool);
fb1214e48   Pavel Shilovsky   CIFS: Move open c...
337
  	/* open a file for non-posix mounts */
226730b4d   Pavel Shilovsky   CIFS: Introduce c...
338
339
  	int (*open)(const unsigned int, struct cifs_open_parms *,
  		    __u32 *, FILE_ALL_INFO *);
fb1214e48   Pavel Shilovsky   CIFS: Move open c...
340
341
  	/* set fid protocol-specific info */
  	void (*set_fid)(struct cifsFileInfo *, struct cifs_fid *, __u32);
0ff78a221   Pavel Shilovsky   CIFS: Move close ...
342
  	/* close a file */
760ad0cac   Pavel Shilovsky   CIFS: Make ops->c...
343
344
  	void (*close)(const unsigned int, struct cifs_tcon *,
  		      struct cifs_fid *);
43f8a6a74   Steve French   smb3: query attri...
345
346
347
  	/* close a file, returning file attributes and timestamps */
  	void (*close_getattr)(const unsigned int xid, struct cifs_tcon *tcon,
  		      struct cifsFileInfo *pfile_info);
1d8c4c000   Pavel Shilovsky   CIFS: Make flush ...
348
349
  	/* send a flush request to the server */
  	int (*flush)(const unsigned int, struct cifs_tcon *, struct cifs_fid *);
fc9c59662   Pavel Shilovsky   CIFS: Move async ...
350
351
  	/* async read from the server */
  	int (*async_readv)(struct cifs_readdata *);
c9de5c80d   Pavel Shilovsky   CIFS: Move async ...
352
  	/* async write to the server */
4a5c80d7b   Steve French   [CIFS] clean up p...
353
354
  	int (*async_writev)(struct cifs_writedata *,
  			    void (*release)(struct kref *));
f9c6e234c   Pavel Shilovsky   CIFS: Move readpa...
355
  	/* sync read from the server */
db8b631d4   Steve French   Allow mknod and m...
356
  	int (*sync_read)(const unsigned int, struct cifs_fid *,
f9c6e234c   Pavel Shilovsky   CIFS: Move readpa...
357
358
  			 struct cifs_io_parms *, unsigned int *, char **,
  			 int *);
ba9ad7257   Pavel Shilovsky   CIFS: Move writep...
359
  	/* sync write to the server */
db8b631d4   Steve French   Allow mknod and m...
360
  	int (*sync_write)(const unsigned int, struct cifs_fid *,
ba9ad7257   Pavel Shilovsky   CIFS: Move writep...
361
362
  			  struct cifs_io_parms *, unsigned int *, struct kvec *,
  			  unsigned long);
92fc65a74   Pavel Shilovsky   CIFS: Move readdi...
363
364
365
366
367
368
369
370
371
372
373
374
375
  	/* open dir, start readdir */
  	int (*query_dir_first)(const unsigned int, struct cifs_tcon *,
  			       const char *, struct cifs_sb_info *,
  			       struct cifs_fid *, __u16,
  			       struct cifs_search_info *);
  	/* continue readdir */
  	int (*query_dir_next)(const unsigned int, struct cifs_tcon *,
  			      struct cifs_fid *,
  			      __u16, struct cifs_search_info *srch_inf);
  	/* close dir */
  	int (*close_dir)(const unsigned int, struct cifs_tcon *,
  			 struct cifs_fid *);
  	/* calculate a size of SMB message */
9ec672bd1   Ronnie Sahlberg   cifs: update calc...
376
  	unsigned int (*calc_smb_size)(void *buf, struct TCP_Server_Info *ptcpi);
66265f134   Pavel Shilovsky   CIFS: Count SMB3 ...
377
378
  	/* check for STATUS_PENDING and process the response if yes */
  	bool (*is_status_pending)(char *buf, struct TCP_Server_Info *server);
511c54a2f   Pavel Shilovsky   CIFS: Reconnect e...
379
380
  	/* check for STATUS_NETWORK_SESSION_EXPIRED */
  	bool (*is_session_expired)(char *);
95a3f2f37   Pavel Shilovsky   CIFS: Move oplock...
381
382
383
  	/* send oplock break response */
  	int (*oplock_response)(struct cifs_tcon *, struct cifs_fid *,
  			       struct cifsInodeInfo *);
76ec5e338   Pavel Shilovsky   CIFS: Move statfs...
384
385
  	/* query remote filesystem */
  	int (*queryfs)(const unsigned int, struct cifs_tcon *,
0f060936e   Amir Goldstein   SMB3: Backup inte...
386
  		       struct cifs_sb_info *, struct kstatfs *);
d39a4f710   Pavel Shilovsky   CIFS: Move brlock...
387
388
389
390
391
392
393
394
  	/* send mandatory brlock to the server */
  	int (*mand_lock)(const unsigned int, struct cifsFileInfo *, __u64,
  			 __u64, __u32, int, int, bool);
  	/* unlock range of mandatory locks */
  	int (*mand_unlock_range)(struct cifsFileInfo *, struct file_lock *,
  				 const unsigned int);
  	/* push brlocks from the cache to the server */
  	int (*push_mand_locks)(struct cifsFileInfo *);
b8c32dbb0   Pavel Shilovsky   CIFS: Request SMB...
395
  	/* get lease key of the inode */
a41a28bda   Pavel Shilovsky   CIFS: Move creati...
396
  	void (*get_lease_key)(struct inode *, struct cifs_fid *);
b8c32dbb0   Pavel Shilovsky   CIFS: Request SMB...
397
  	/* set lease key of the inode */
a41a28bda   Pavel Shilovsky   CIFS: Move creati...
398
  	void (*set_lease_key)(struct inode *, struct cifs_fid *);
b8c32dbb0   Pavel Shilovsky   CIFS: Request SMB...
399
  	/* generate new lease key */
a41a28bda   Pavel Shilovsky   CIFS: Move creati...
400
  	void (*new_lease_key)(struct cifs_fid *);
32811d242   Shirish Pargaonkar   cifs: Start using...
401
  	int (*generate_signingkey)(struct cifs_ses *);
eda1c54f1   Long Li   cifs: Allocate cr...
402
403
  	int (*calc_signature)(struct smb_rqst *, struct TCP_Server_Info *,
  				bool allocate_crypto);
b3152e2c7   Steve French   Add ioctl to set ...
404
405
  	int (*set_integrity)(const unsigned int, struct cifs_tcon *tcon,
  			     struct cifsFileInfo *src_file);
834170c85   Steve French   Enable previous v...
406
407
  	int (*enum_snapshots)(const unsigned int xid, struct cifs_tcon *tcon,
  			     struct cifsFileInfo *src_file, void __user *);
d26c2ddd3   Steve French   cifs: add SMB3 ch...
408
409
  	int (*notify)(const unsigned int xid, struct file *pfile,
  			     void __user *pbuf);
b5be1a1c4   Sachin Prabhu   cifs: Rename and ...
410
411
412
  	int (*query_mf_symlink)(unsigned int, struct cifs_tcon *,
  				struct cifs_sb_info *, const unsigned char *,
  				char *, unsigned int *);
cbb0aba6f   Sachin Prabhu   cifs: Add create ...
413
414
415
  	int (*create_mf_symlink)(unsigned int, struct cifs_tcon *,
  				 struct cifs_sb_info *, const unsigned char *,
  				 char *, unsigned int *);
53ef1016f   Pavel Shilovsky   CIFS: Store lease...
416
417
418
  	/* if we can do cache read operations */
  	bool (*is_read_op)(__u32);
  	/* set oplock level for the inode */
42873b0a2   Pavel Shilovsky   CIFS: Respect epo...
419
420
  	void (*set_oplock_level)(struct cifsInodeInfo *, __u32, unsigned int,
  				 bool *);
a41a28bda   Pavel Shilovsky   CIFS: Move creati...
421
  	/* create lease context buffer for CREATE request */
729c0c9dd   Stefano Brivio   cifs: Fix stack o...
422
  	char * (*create_lease_buf)(u8 *lease_key, u8 oplock);
42873b0a2   Pavel Shilovsky   CIFS: Respect epo...
423
  	/* parse lease context buffer and return oplock/epoch info */
96164ab2d   Ronnie Sahlberg   cifs: store the l...
424
  	__u8 (*parse_lease_buf)(void *buf, unsigned int *epoch, char *lkey);
620d8745b   Sachin Prabhu   Introduce cifs_co...
425
  	ssize_t (*copychunk_range)(const unsigned int,
312bbc594   Sachin Prabhu   SMB3: Rename clon...
426
  			struct cifsFileInfo *src_file,
620d8745b   Sachin Prabhu   Introduce cifs_co...
427
428
  			struct cifsFileInfo *target_file,
  			u64 src_off, u64 len, u64 dest_off);
02b166654   Steve French   Add reflink copy ...
429
430
431
  	int (*duplicate_extents)(const unsigned int, struct cifsFileInfo *src,
  			struct cifsFileInfo *target_file, u64 src_off, u64 len,
  			u64 dest_off);
ff1c038ad   Steve French   Check SMB3 dialec...
432
  	int (*validate_negotiate)(const unsigned int, struct cifs_tcon *);
666753c3e   Steve French   [CIFS] Fix SMB2 m...
433
434
  	ssize_t (*query_all_EAs)(const unsigned int, struct cifs_tcon *,
  			const unsigned char *, const unsigned char *, char *,
67b4c889c   Steve French   [CIFS] Minor clea...
435
  			size_t, struct cifs_sb_info *);
666753c3e   Steve French   [CIFS] Fix SMB2 m...
436
437
  	int (*set_EA)(const unsigned int, struct cifs_tcon *, const char *,
  			const char *, const void *, const __u16,
5517554e4   Ronnie Sahlberg   cifs: Add support...
438
  			const struct nls_table *, struct cifs_sb_info *);
83e3bc23e   Steve French   retrieving CIFS A...
439
440
  	struct cifs_ntsd * (*get_acl)(struct cifs_sb_info *, struct inode *,
  			const char *, u32 *);
42eacf9e5   Steve French   [CIFS] Fix cifsac...
441
442
  	struct cifs_ntsd * (*get_acl_by_fid)(struct cifs_sb_info *,
  			const struct cifs_fid *, u32 *);
83e3bc23e   Steve French   retrieving CIFS A...
443
444
  	int (*set_acl)(struct cifs_ntsd *, __u32, struct inode *, const char *,
  			int);
7f6c50086   Pavel Shilovsky   CIFS: Fix cifs_wr...
445
446
  	/* writepages retry size */
  	unsigned int (*wp_retry_size)(struct inode *);
cb7e9eabb   Pavel Shilovsky   CIFS: Use multicr...
447
448
  	/* get mtu credits */
  	int (*wait_mtu_credits)(struct TCP_Server_Info *, unsigned int,
335b7b62f   Pavel Shilovsky   CIFS: Respect rec...
449
  				unsigned int *, struct cifs_credits *);
9a1c67e8d   Pavel Shilovsky   CIFS: Adjust MTU ...
450
451
452
453
  	/* adjust previously taken mtu credits to request size */
  	int (*adjust_credits)(struct TCP_Server_Info *server,
  			      struct cifs_credits *credits,
  			      const unsigned int payload_size);
52755808d   Pavel Shilovsky   CIFS: Fix SMB2 re...
454
455
  	/* check if we need to issue closedir */
  	bool (*dir_needs_close)(struct cifsFileInfo *);
31742c5a3   Steve French   enable fallocate ...
456
457
  	long (*fallocate)(struct file *, struct cifs_tcon *, int, loff_t,
  			  loff_t);
7fb8986e7   Pavel Shilovsky   CIFS: Add capabil...
458
  	/* init transform request - used for encryption for now */
b2c96de7f   Ronnie Sahlberg   cifs: update init...
459
460
  	int (*init_transform_rq)(struct TCP_Server_Info *, int num_rqst,
  				 struct smb_rqst *, struct smb_rqst *);
9bb17e091   Pavel Shilovsky   CIFS: Add transfo...
461
462
  	int (*is_transform_hdr)(void *buf);
  	int (*receive_transform)(struct TCP_Server_Info *,
b24df3e30   Ronnie Sahlberg   cifs: update rece...
463
  				 struct mid_q_entry **, char **, int *);
ef65aaede   Sachin Prabhu   smb2: Enforce sec...
464
465
  	enum securityEnum (*select_sectype)(struct TCP_Server_Info *,
  			    enum securityEnum);
8ce79ec35   Ronnie Sahlberg   cifs: update mult...
466
  	int (*next_header)(char *);
f5b05d622   Ronnie Sahlberg   cifs: add IOCTL f...
467
468
  	/* ioctl passthrough for query_info */
  	int (*ioctl_query_info)(const unsigned int xid,
8d8b26e58   Ronnie Sahlberg   cifs: add support...
469
  				struct cifs_tcon *tcon,
0f060936e   Amir Goldstein   SMB3: Backup inte...
470
  				struct cifs_sb_info *cifs_sb,
8d8b26e58   Ronnie Sahlberg   cifs: add support...
471
  				__le16 *path, int is_dir,
f5b05d622   Ronnie Sahlberg   cifs: add IOCTL f...
472
  				unsigned long p);
c847dccfb   Aurelien Aptel   CIFS: make mknod(...
473
474
475
476
477
478
479
480
  	/* make unix special files (block, char, fifo, socket) */
  	int (*make_node)(unsigned int xid,
  			 struct inode *inode,
  			 struct dentry *dentry,
  			 struct cifs_tcon *tcon,
  			 char *full_path,
  			 umode_t mode,
  			 dev_t device_number);
2f3ebaba1   Ronnie Sahlberg   cifs: add fiemap ...
481
482
483
  	/* version specific fiemap implementation */
  	int (*fiemap)(struct cifs_tcon *tcon, struct cifsFileInfo *,
  		      struct fiemap_extent_info *, u64, u64);
dece44e38   Ronnie Sahlberg   cifs: add support...
484
485
  	/* version specific llseek implementation */
  	loff_t (*llseek)(struct file *, struct cifs_tcon *, loff_t, int);
8e670f77c   Rohith Surabattula   Handle STATUS_IO_...
486
487
  	/* Check for STATUS_IO_TIMEOUT */
  	bool (*is_status_io_timeout)(char *buf);
23db65f51   Jeff Layton   cifs: add a smb_v...
488
489
490
491
  };
  
  struct smb_version_values {
  	char		*version_string;
e4aa25e78   Steve French   [CIFS] Fix SMB2 n...
492
493
  	__u16		protocol_id;
  	__u32		req_capabilities;
106dc538a   Pavel Shilovsky   CIFS: Separate pr...
494
495
496
497
  	__u32		large_lock_type;
  	__u32		exclusive_lock_type;
  	__u32		shared_lock_type;
  	__u32		unlock_lock_type;
93012bf98   Ronnie Sahlberg   cifs: add server-...
498
  	size_t		header_preamble_size;
1887f6010   Pavel Shilovsky   CIFS: Move header...
499
500
  	size_t		header_size;
  	size_t		max_header_size;
eb3787111   Pavel Shilovsky   CIFS: Move protoc...
501
  	size_t		read_rsp_size;
2dc7e1c03   Pavel Shilovsky   CIFS: Make transp...
502
  	__le16		lock_cmd;
29e20f9c6   Pavel Shilovsky   CIFS: Make CAP_* ...
503
504
505
  	unsigned int	cap_unix;
  	unsigned int	cap_nt_find;
  	unsigned int	cap_large_files;
50285882f   Jeff Layton   cifs: fix SMB2 si...
506
507
  	__u16		signing_enabled;
  	__u16		signing_required;
a41a28bda   Pavel Shilovsky   CIFS: Move creati...
508
  	size_t		create_lease_size;
23db65f51   Jeff Layton   cifs: add a smb_v...
509
  };
1887f6010   Pavel Shilovsky   CIFS: Move header...
510
511
  #define HEADER_SIZE(server) (server->vals->header_size)
  #define MAX_HEADER_SIZE(server) (server->vals->max_header_size)
f87d39d95   Steve French   [CIFS] Migrate fr...
512
513
514
515
516
  struct smb_vol {
  	char *username;
  	char *password;
  	char *domainname;
  	char *UNC;
f87d39d95   Steve French   [CIFS] Migrate fr...
517
518
519
  	char *iocharset;  /* local code page for mapping to and from Unicode */
  	char source_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* clnt nb name */
  	char target_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* srvr nb name */
3da465650   Eric W. Biederman   cifs: Modify stru...
520
521
522
523
524
  	kuid_t cred_uid;
  	kuid_t linux_uid;
  	kgid_t linux_gid;
  	kuid_t backupuid;
  	kgid_t backupgid;
5206efd62   Al Viro   cifs: propagate u...
525
526
  	umode_t file_mode;
  	umode_t dir_mode;
1e3cc57e4   Jeff Layton   add new fields to...
527
528
  	enum securityEnum sectype; /* sectype requested via mnt opts */
  	bool sign; /* was signing requested via mnt opts? */
4f5c10f1a   Steve French   smb3: allow skipp...
529
  	bool ignore_signature:1;
f87d39d95   Steve French   [CIFS] Migrate fr...
530
531
532
  	bool retry:1;
  	bool intr:1;
  	bool setuids:1;
959326553   Steve French   CIFS: Add new mou...
533
  	bool setuidfromacl:1;
f87d39d95   Steve French   [CIFS] Migrate fr...
534
535
536
537
  	bool override_uid:1;
  	bool override_gid:1;
  	bool dynperm:1;
  	bool noperm:1;
82e9367c4   Steve French   smb3: Add new par...
538
  	bool nodelete:1;
412094a8f   Steve French   smb3: add new mou...
539
  	bool mode_ace:1;
f87d39d95   Steve French   [CIFS] Migrate fr...
540
541
  	bool no_psx_acl:1; /* set if posix acl support should be disabled */
  	bool cifs_acl:1;
3d3ea8e64   Shirish Pargaonkar   cifs: Add mount o...
542
543
  	bool backupuid_specified; /* mount option  backupuid  is specified */
  	bool backupgid_specified; /* mount option  backupgid  is specified */
f87d39d95   Steve French   [CIFS] Migrate fr...
544
545
546
547
  	bool no_xattr:1;   /* set if xattr (EA) support should be disabled*/
  	bool server_ino:1; /* use inode numbers from server ie UniqueId */
  	bool direct_io:1;
  	bool strict_io:1; /* strict cache behavior */
83bbfa706   Steve French   smb3: add mount o...
548
  	bool cache_ro:1;
41e033fec   Steve French   smb3: add mount o...
549
  	bool cache_rw:1;
f87d39d95   Steve French   [CIFS] Migrate fr...
550
  	bool remap:1;      /* set to remap seven reserved chars in filenames */
2baa26825   Steve French   Remap reserved po...
551
  	bool sfu_remap:1;  /* remap seven reserved chars ala SFU */
f87d39d95   Steve French   [CIFS] Migrate fr...
552
553
  	bool posix_paths:1; /* unset to not ask for posix pathnames. */
  	bool no_linux_ext:1;
b326614ea   Steve French   smb3: allow "posi...
554
  	bool linux_ext:1;
f87d39d95   Steve French   [CIFS] Migrate fr...
555
556
557
558
  	bool sfu_emul:1;
  	bool nullauth:1;   /* attempt to authenticate with null user */
  	bool nocase:1;     /* request case insensitive filenames */
  	bool nobrl:1;      /* disable sending byte range locks to srv */
3d4ef9a15   Steve French   smb3: fix redunda...
559
  	bool nohandlecache:1; /* disable caching dir handles if srvr probs */
f87d39d95   Steve French   [CIFS] Migrate fr...
560
561
562
563
564
565
566
  	bool mand_lock:1;  /* send mandatory not posix byte range lock reqs */
  	bool seal:1;       /* request transport encryption on share */
  	bool nodfs:1;      /* Do not request DFS, even if available */
  	bool local_lease:1; /* check leases only on local system, not remote */
  	bool noblocksnd:1;
  	bool noautotune:1;
  	bool nostrictsync:1; /* do not force expensive SMBflush on every sync */
3e7a02d47   Steve French   smb3: allow disab...
567
  	bool no_lease:1;     /* disable requesting leases */
f87d39d95   Steve French   [CIFS] Migrate fr...
568
569
570
  	bool fsc:1;	/* enable fscache */
  	bool mfsymlinks:1; /* use Minshall+French Symlinks */
  	bool multiuser:1;
d4ffff1fa   Pavel Shilovsky   CIFS: Add rwpidfo...
571
  	bool rwpidforward:1; /* pid forward for read/write operations */
b2a307741   Steve French   [SMB3] Add parsin...
572
573
574
  	bool nosharesock:1;
  	bool persistent:1;
  	bool nopersistent:1;
592fafe64   Steve French   Add resilienthand...
575
  	bool resilient:1; /* noresilient not required since not fored for CA */
395664439   Germano Percossi   Fix default behav...
576
  	bool domainauto:1;
8339dd32f   Long Li   CIFS: SMBD: Add r...
577
  	bool rdma:1;
bcc888011   Aurelien Aptel   cifs: add multich...
578
579
580
581
  	bool multichannel:1;
  	bool use_client_guid:1;
  	/* reuse existing guid for multichannel */
  	u8 client_guid[SMB2_CLIENT_GUID_SIZE];
e8506d25f   Steve French   smb3: make defaul...
582
  	unsigned int bsize;
f87d39d95   Steve French   [CIFS] Migrate fr...
583
584
  	unsigned int rsize;
  	unsigned int wsize;
563317ec3   Steve French   smb3: enable offl...
585
  	unsigned int min_offload;
f87d39d95   Steve French   [CIFS] Migrate fr...
586
  	bool sockopt_tcp_nodelay:1;
f87d39d95   Steve French   [CIFS] Migrate fr...
587
  	unsigned long actimeo; /* attribute cache timeout (jiffies) */
23db65f51   Jeff Layton   cifs: add a smb_v...
588
589
  	struct smb_version_operations *ops;
  	struct smb_version_values *vals;
f87d39d95   Steve French   [CIFS] Migrate fr...
590
  	char *prepath;
b979aaa17   Jeff Layton   cifs: get rid of ...
591
  	struct sockaddr_storage dstaddr; /* destination address */
f87d39d95   Steve French   [CIFS] Migrate fr...
592
593
  	struct sockaddr_storage srcaddr; /* allow binding to a local IP */
  	struct nls_table *local_nls;
adfeb3e00   Steve French   cifs: Make echo i...
594
  	unsigned int echo_interval; /* echo interval in secs */
8b217fe7f   Steve French   SMB3: parsing for...
595
  	__u64 snapshot_time; /* needed for timewarp tokens */
ca567eb2b   Steve French   SMB3: Allow persi...
596
  	__u32 handle_timeout; /* persistent and durable handle timeout in ms */
141891f47   Steve French   SMB3: Add mount p...
597
  	unsigned int max_credits; /* smb3 max_credits 10 < credits < 60000 */
bcc888011   Aurelien Aptel   cifs: add multich...
598
  	unsigned int max_channels;
9fe5ff1c5   Steve French   smb3: do not send...
599
  	__u16 compression; /* compression algorithm 0xFFFF default 0=disabled */
8eecd1c2e   Paulo Alcantara (SUSE)   cifs: Add support...
600
  	bool rootfs:1; /* if it's a SMB root file system */
f87d39d95   Steve French   [CIFS] Migrate fr...
601
  };
d070f9dd6   Aurelien Aptel   CIFS: check CIFS_...
602
603
604
605
  /**
   * CIFS superblock mount flags (mnt_cifs_flags) to consider when
   * trying to reuse existing superblock for a new mount
   */
25c7f41e9   Pavel Shilovsky   CIFS: Migrate to ...
606
607
608
  #define CIFS_MOUNT_MASK (CIFS_MOUNT_NO_PERM | CIFS_MOUNT_SET_UID | \
  			 CIFS_MOUNT_SERVER_INUM | CIFS_MOUNT_DIRECT_IO | \
  			 CIFS_MOUNT_NO_XATTR | CIFS_MOUNT_MAP_SPECIAL_CHR | \
2baa26825   Steve French   Remap reserved po...
609
  			 CIFS_MOUNT_MAP_SFM_CHR | \
25c7f41e9   Pavel Shilovsky   CIFS: Migrate to ...
610
611
612
613
614
  			 CIFS_MOUNT_UNX_EMUL | CIFS_MOUNT_NO_BRL | \
  			 CIFS_MOUNT_CIFS_ACL | CIFS_MOUNT_OVERR_UID | \
  			 CIFS_MOUNT_OVERR_GID | CIFS_MOUNT_DYNPERM | \
  			 CIFS_MOUNT_NOPOSIXBRL | CIFS_MOUNT_NOSSYNC | \
  			 CIFS_MOUNT_FSCACHE | CIFS_MOUNT_MF_SYMLINKS | \
3d3ea8e64   Shirish Pargaonkar   cifs: Add mount o...
615
  			 CIFS_MOUNT_MULTIUSER | CIFS_MOUNT_STRICT_IO | \
d070f9dd6   Aurelien Aptel   CIFS: check CIFS_...
616
  			 CIFS_MOUNT_CIFS_BACKUPUID | CIFS_MOUNT_CIFS_BACKUPGID | \
6552d6a02   Steve French   cifs: Fix check f...
617
  			 CIFS_MOUNT_UID_FROM_ACL | CIFS_MOUNT_NO_HANDLE_CACHE | \
83bbfa706   Steve French   smb3: add mount o...
618
  			 CIFS_MOUNT_NO_DFS | CIFS_MOUNT_MODE_FROM_SID | \
41e033fec   Steve French   smb3: add mount o...
619
  			 CIFS_MOUNT_RO_CACHE | CIFS_MOUNT_RW_CACHE)
25c7f41e9   Pavel Shilovsky   CIFS: Migrate to ...
620

d070f9dd6   Aurelien Aptel   CIFS: check CIFS_...
621
622
623
624
  /**
   * Generic VFS superblock mount flags (s_flags) to consider when
   * trying to reuse existing superblock for a new mount
   */
1751e8a6c   Linus Torvalds   Rename superblock...
625
626
  #define CIFS_MS_MASK (SB_RDONLY | SB_MANDLOCK | SB_NOEXEC | SB_NOSUID | \
  		      SB_NODEV | SB_SYNCHRONOUS)
25c7f41e9   Pavel Shilovsky   CIFS: Migrate to ...
627
628
629
630
631
632
  
  struct cifs_mnt_data {
  	struct cifs_sb_info *cifs_sb;
  	struct smb_vol *vol;
  	int flags;
  };
792af7b05   Pavel Shilovsky   CIFS: Separate pr...
633
634
635
  static inline unsigned int
  get_rfc1002_length(void *buf)
  {
dca1c8d17   Jeff Layton   cifs: mask off to...
636
  	return be32_to_cpu(*((__be32 *)buf)) & 0xffffff;
792af7b05   Pavel Shilovsky   CIFS: Separate pr...
637
  }
ec2e4523f   Pavel Shilovsky   CIFS: Add capabil...
638
639
640
641
642
  static inline void
  inc_rfc1001_len(void *buf, int count)
  {
  	be32_add_cpu((__be32 *)buf, count);
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
643
  struct TCP_Server_Info {
3b7952109   Steve French   [CIFS] Fix cifs r...
644
645
  	struct list_head tcp_ses_list;
  	struct list_head smb_ses_list;
e7ddee903   Jeff Layton   cifs: disable sha...
646
  	int srv_count; /* reference counter */
a10faeb2a   Steve French   [CIFS] Support fo...
647
  	/* 15 character server name + 0x20 16th byte indicating type = srv */
8ecaf67a8   Jeff Layton   cifs: account for...
648
  	char server_RFC1001_name[RFC1001_NAME_LEN_WITH_NULL];
23db65f51   Jeff Layton   cifs: add a smb_v...
649
650
  	struct smb_version_operations	*ops;
  	struct smb_version_values	*vals;
c3dccf481   Jeff Layton   cifs: TCP_Server_...
651
  	enum statusEnum tcpStatus; /* what we think the status is */
c359cf3c6   Jeff Layton   [CIFS] add hostna...
652
  	char *hostname; /* hostname portion of UNC string */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
653
  	struct socket *ssocket;
a9f1b85e5   Pavel Shilovsky   CIFS: Simplify ip...
654
  	struct sockaddr_storage dstaddr;
3eb9a8893   Ben Greear   cifs: Allow bindi...
655
  	struct sockaddr_storage srcaddr; /* locally bind to this IP */
f1d0c9986   Rob Landley   Make CIFS mount w...
656
657
658
  #ifdef CONFIG_NET_NS
  	struct net *net;
  #endif
d38d8c74c   Steve French   [CIFS] whitespace...
659
  	wait_queue_head_t response_q;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
660
661
  	wait_queue_head_t request_q; /* if more than maxmpx to srvr must block*/
  	struct list_head pending_mid_q;
edf1ae403   Steve French   [CIFS] Reduce num...
662
663
  	bool noblocksnd;		/* use blocking sendmsg */
  	bool noautotune;		/* do not autotune send buf sizes */
6a5fa2362   Steve French   [CIFS] Add suppor...
664
  	bool tcp_nodelay;
141891f47   Steve French   SMB3: Add mount p...
665
666
  	unsigned int credits;  /* send no more requests at once */
  	unsigned int max_credits; /* can override large 32000 default at mnt */
fc40f9cf8   Pavel Shilovsky   CIFS: Simplify in...
667
  	unsigned int in_flight;  /* number of requests on the wire to server */
1b63f1840   Steve French   smb3: display max...
668
  	unsigned int max_in_flight; /* max number of requests that were on wire */
2d86dbc97   Pavel Shilovsky   CIFS: Introduce c...
669
  	spinlock_t req_lock;  /* protect the two values above */
72ca545b2   Jeff Layton   cifs: convert tcp...
670
  	struct mutex srv_mutex;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
671
672
  	struct task_struct *tsk;
  	char server_GUID[16];
286170aa2   Pavel Shilovsky   CIFS: Move protoc...
673
  	__u16 sec_mode;
38d77c50b   Jeff Layton   cifs: track the e...
674
  	bool sign; /* is signing enabled on this connection? */
4f5c10f1a   Steve French   smb3: allow skipp...
675
  	bool ignore_signature:1; /* skip validation of signatures in SMB2/3 rsp */
c3dccf481   Jeff Layton   cifs: TCP_Server_...
676
  	bool session_estab; /* mark when very first sess is established */
28ea5290d   Pavel Shilovsky   CIFS: Add SMB2 cr...
677
678
679
  	int echo_credits;  /* echo reserved slots */
  	int oplock_credits;  /* oplock break reserved slots */
  	bool echoes:1; /* enable echoes */
39552ea81   Sachin Prabhu   cifs: Set client ...
680
  	__u8 client_guid[SMB2_CLIENT_GUID_SIZE]; /* Client GUID */
c3dccf481   Jeff Layton   cifs: TCP_Server_...
681
  	u16 dialect; /* dialect index that server chose */
10b9b98e4   Pavel Shilovsky   CIFS: Respect neg...
682
  	bool oplocks:1; /* enable oplocks */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
683
684
  	unsigned int maxReq;	/* Clients should submit no more */
  	/* than maxReq distinct unanswered SMBs to the server when using  */
11911b956   Steve French   cifs: make minor ...
685
  	/* multiplexed reads or writes (for SMB1/CIFS only, not SMB2/SMB3) */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
686
687
  	unsigned int maxBuf;	/* maxBuf specifies the maximum */
  	/* message size the server can send or receive for non-raw SMBs */
7e90d705f   Steve French   [CIFS] Do not sen...
688
689
  	/* maxBuf is returned by SMB NegotiateProtocol so maxBuf is only 0 */
  	/* when socket is setup (and during reconnect) before NegProt sent */
eca6acf91   Steve French   [CIFS] Fix multiu...
690
  	unsigned int max_rw;	/* maxRw specifies the maximum */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
691
692
  	/* message size the server can send or receive for */
  	/* SMB_COM_WRITE_RAW or SMB_COM_READ_RAW. */
29e20f9c6   Pavel Shilovsky   CIFS: Make CAP_* ...
693
  	unsigned int capabilities; /* selective disabling of caps by smb sess */
de7ed55db   Steve French   [CIFS] Make use o...
694
  	int timeAdj;  /* Adjust for difference in server time zone in sec */
243d04b6e   Pavel Shilovsky   CIFS: Expand Curr...
695
  	__u64 CurrentMid;         /* multiplex id - rotating counter */
d3ba50b17   Shirish Pargaonkar   NTLM auth and sig...
696
  	char cryptkey[CIFS_CRYPTO_KEY_SIZE]; /* used by ntlm, ntlmv2 etc */
a10faeb2a   Steve French   [CIFS] Support fo...
697
  	/* 16th byte of RFC1001 workstation name is always null */
8ecaf67a8   Jeff Layton   cifs: account for...
698
  	char workstation_RFC1001_name[RFC1001_NAME_LEN_WITH_NULL];
a0f8b4fb4   Jeff Layton   cifs: remove unne...
699
  	__u32 sequence_number; /* for signing, protected by srv_mutex */
9e1a37dad   Steve French   smb3: track the i...
700
  	__u32 reconnect_instance; /* incremented on each reconnect */
5f98ca9af   Shirish Pargaonkar   cifs NTLMv2/NTLMS...
701
  	struct session_key session_key;
3a5ff61c1   Steve French   [CIFS] Do not tim...
702
  	unsigned long lstrp; /* when we got last response from this server */
d2b915210   Shirish Pargaonkar   NTLM auth and sig...
703
  	struct cifs_secmech secmech; /* crypto sec mech functs, descriptors */
e598d1d8f   Jeff Layton   cifs: track the f...
704
705
706
707
  #define	CIFS_NEGFLAVOR_LANMAN	0	/* wct == 13, LANMAN */
  #define	CIFS_NEGFLAVOR_UNENCAP	1	/* wct == 17, but no ext_sec */
  #define	CIFS_NEGFLAVOR_EXTENDED	2	/* wct == 17, ext_sec bit set */
  	char	negflavor;	/* NEGOTIATE response flavor */
26efa0bac   Jeff Layton   cifs: have decode...
708
  	/* extended security flavors that server supports */
c3dccf481   Jeff Layton   cifs: TCP_Server_...
709
710
  	bool	sec_ntlmssp;		/* supports NTLMSSP */
  	bool	sec_kerberosu2u;	/* supports U2U Kerberos */
26efa0bac   Jeff Layton   cifs: have decode...
711
712
  	bool	sec_kerberos;		/* supports plain Kerberos */
  	bool	sec_mskerberos;		/* supports legacy MS Kerberos */
2a37ef94b   Jeff Layton   cifs: move buffer...
713
  	bool	large_buf;		/* is current buffer large? */
8339dd32f   Long Li   CIFS: SMBD: Add r...
714
715
716
717
  	/* use SMBD connection instead of socket */
  	bool	rdma;
  	/* point to the SMBD connection if RDMA is used instead of socket */
  	struct smbd_connection *smbd_conn;
c74093b69   Jeff Layton   cifs: set up recu...
718
  	struct delayed_work	echo; /* echo ping workqueue job */
2a37ef94b   Jeff Layton   cifs: move buffer...
719
720
  	char	*smallbuf;	/* pointer to current "small" buffer */
  	char	*bigbuf;	/* pointer to current "big" buffer */
2e96467d9   Ronnie Sahlberg   cifs: add pdu_siz...
721
722
  	/* Total size of this PDU. Only valid from cifs_demultiplex_thread */
  	unsigned int pdu_size;
2a37ef94b   Jeff Layton   cifs: move buffer...
723
  	unsigned int total_read; /* total amount of data read in this pass */
1ae9a5a55   Steve French   smb3: dump in_sen...
724
725
  	atomic_t in_send; /* requests trying to send */
  	atomic_t num_waiters;   /* blocked waiting to get in sendrecv */
488f1d2d6   Suresh Jayaraman   cifs: define serv...
726
727
728
  #ifdef CONFIG_CIFS_FSCACHE
  	struct fscache_cookie   *fscache; /* client index cache cookie */
  #endif
c3dccf481   Jeff Layton   cifs: TCP_Server_...
729
  #ifdef CONFIG_CIFS_STATS2
433b8dd76   Steve French   SMB3: Track total...
730
  	atomic_t num_cmds[NUMBER_OF_SMB2_COMMANDS]; /* total requests by cmd */
468d67795   Steve French   smb3: display sta...
731
  	atomic_t smb2slowcmd[NUMBER_OF_SMB2_COMMANDS]; /* count resps > 1 sec */
433b8dd76   Steve French   SMB3: Track total...
732
733
734
  	__u64 time_per_cmd[NUMBER_OF_SMB2_COMMANDS]; /* total time per cmd */
  	__u32 slowest_cmd[NUMBER_OF_SMB2_COMMANDS];
  	__u32 fastest_cmd[NUMBER_OF_SMB2_COMMANDS];
468d67795   Steve French   smb3: display sta...
735
  #endif /* STATS2 */
ec2e4523f   Pavel Shilovsky   CIFS: Add capabil...
736
737
  	unsigned int	max_read;
  	unsigned int	max_write;
563317ec3   Steve French   smb3: enable offl...
738
  	unsigned int	min_offload;
26ea888f6   Steve French   Negotiate and sav...
739
  	__le16	compress_algorithm;
5100d8a3f   Steve French   SMB311: Improve c...
740
  	__le16	cipher_type;
8bd68c6e4   Aurelien Aptel   CIFS: implement v...
741
742
  	 /* save initital negprot hash */
  	__u8	preauth_sha_hash[SMB2_PREAUTH_HASH_SIZE];
fcef0db6d   Steve French   smb3: add support...
743
  	bool	posix_ext_supported;
53e0e11ef   Pavel Shilovsky   CIFS: Fix a possi...
744
745
  	struct delayed_work reconnect; /* reconnect workqueue job */
  	struct mutex reconnect_mutex; /* prevent simultaneous reconnects */
adfeb3e00   Steve French   cifs: Make echo i...
746
  	unsigned long echo_interval;
93d5cb517   Paulo Alcantara   cifs: Add support...
747
748
749
750
751
752
753
  
  	/*
  	 * Number of targets available for reconnect. The more targets
  	 * the more tasks have to wait to let the demultiplex thread
  	 * reconnect.
  	 */
  	int nr_targets;
8eecd1c2e   Paulo Alcantara (SUSE)   cifs: Add support...
754
  	bool noblockcnt; /* use non-blocking connect() */
3345bb44b   Paulo Alcantara (SUSE)   cifs: Fix lookup ...
755
  	bool is_channel; /* if a session channel */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
756
  };
335b7b62f   Pavel Shilovsky   CIFS: Respect rec...
757
758
759
760
  struct cifs_credits {
  	unsigned int value;
  	unsigned int instance;
  };
fc40f9cf8   Pavel Shilovsky   CIFS: Simplify in...
761
762
763
764
765
766
767
768
769
  static inline unsigned int
  in_flight(struct TCP_Server_Info *server)
  {
  	unsigned int num;
  	spin_lock(&server->req_lock);
  	num = server->in_flight;
  	spin_unlock(&server->req_lock);
  	return num;
  }
2d86dbc97   Pavel Shilovsky   CIFS: Introduce c...
770
  static inline bool
b227d215d   Ronnie Sahlberg   cifs: wait_for_fr...
771
  has_credits(struct TCP_Server_Info *server, int *credits, int num_credits)
fc40f9cf8   Pavel Shilovsky   CIFS: Simplify in...
772
  {
2d86dbc97   Pavel Shilovsky   CIFS: Introduce c...
773
  	int num;
fc40f9cf8   Pavel Shilovsky   CIFS: Simplify in...
774
  	spin_lock(&server->req_lock);
bc205ed19   Pavel Shilovsky   CIFS: Prepare cre...
775
  	num = *credits;
fc40f9cf8   Pavel Shilovsky   CIFS: Simplify in...
776
  	spin_unlock(&server->req_lock);
b227d215d   Ronnie Sahlberg   cifs: wait_for_fr...
777
  	return num >= num_credits;
fc40f9cf8   Pavel Shilovsky   CIFS: Simplify in...
778
  }
452757897   Pavel Shilovsky   CIFS: Move add/se...
779
  static inline void
34f4deb7c   Pavel Shilovsky   CIFS: Respect rec...
780
  add_credits(struct TCP_Server_Info *server, const struct cifs_credits *credits,
a891f0f89   Pavel Shilovsky   CIFS: Extend cred...
781
  	    const int optype)
452757897   Pavel Shilovsky   CIFS: Move add/se...
782
  {
34f4deb7c   Pavel Shilovsky   CIFS: Respect rec...
783
  	server->ops->add_credits(server, credits, optype);
452757897   Pavel Shilovsky   CIFS: Move add/se...
784
785
786
  }
  
  static inline void
335b7b62f   Pavel Shilovsky   CIFS: Respect rec...
787
788
  add_credits_and_wake_if(struct TCP_Server_Info *server,
  			const struct cifs_credits *credits, const int optype)
cb7e9eabb   Pavel Shilovsky   CIFS: Use multicr...
789
  {
335b7b62f   Pavel Shilovsky   CIFS: Respect rec...
790
791
  	if (credits->value) {
  		server->ops->add_credits(server, credits, optype);
cb7e9eabb   Pavel Shilovsky   CIFS: Use multicr...
792
793
794
795
796
  		wake_up(&server->request_q);
  	}
  }
  
  static inline void
452757897   Pavel Shilovsky   CIFS: Move add/se...
797
798
799
800
  set_credits(struct TCP_Server_Info *server, const int val)
  {
  	server->ops->set_credits(server, val);
  }
9a1c67e8d   Pavel Shilovsky   CIFS: Adjust MTU ...
801
802
803
804
805
806
807
  static inline int
  adjust_credits(struct TCP_Server_Info *server, struct cifs_credits *credits,
  	       const unsigned int payload_size)
  {
  	return server->ops->adjust_credits ?
  		server->ops->adjust_credits(server, credits, payload_size) : 0;
  }
9235d0987   Sachin Prabhu   Convert MessageID...
808
  static inline __le64
3d378d3fd   Tim Gardner   cifs: Make big en...
809
  get_next_mid64(struct TCP_Server_Info *server)
882573606   Pavel Shilovsky   CIFS: Move get_ne...
810
  {
9235d0987   Sachin Prabhu   Convert MessageID...
811
  	return cpu_to_le64(server->ops->get_next_mid(server));
882573606   Pavel Shilovsky   CIFS: Move get_ne...
812
  }
3d378d3fd   Tim Gardner   cifs: Make big en...
813
814
815
  static inline __le16
  get_next_mid(struct TCP_Server_Info *server)
  {
9235d0987   Sachin Prabhu   Convert MessageID...
816
  	__u16 mid = server->ops->get_next_mid(server);
3d378d3fd   Tim Gardner   cifs: Make big en...
817
818
819
820
821
822
  	/*
  	 * The value in the SMB header should be little endian for easy
  	 * on-the-wire decoding.
  	 */
  	return cpu_to_le16(mid);
  }
c781af7e0   Pavel Shilovsky   CIFS: Do not skip...
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
  static inline void
  revert_current_mid(struct TCP_Server_Info *server, const unsigned int val)
  {
  	if (server->ops->revert_current_mid)
  		server->ops->revert_current_mid(server, val);
  }
  
  static inline void
  revert_current_mid_from_hdr(struct TCP_Server_Info *server,
  			    const struct smb2_sync_hdr *shdr)
  {
  	unsigned int num = le16_to_cpu(shdr->CreditCharge);
  
  	return revert_current_mid(server, num > 0 ? num : 1);
  }
3d378d3fd   Tim Gardner   cifs: Make big en...
838
839
840
841
842
843
844
845
846
847
848
  static inline __u16
  get_mid(const struct smb_hdr *smb)
  {
  	return le16_to_cpu(smb->Mid);
  }
  
  static inline bool
  compare_mid(__u16 mid, const struct smb_hdr *smb)
  {
  	return mid == le16_to_cpu(smb->Mid);
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
849
  /*
24985c53d   Pavel Shilovsky   CIFS: Move r/wsiz...
850
851
852
853
854
855
   * When the server supports very large reads and writes via POSIX extensions,
   * we can allow up to 2^24-1, minus the size of a READ/WRITE_AND_X header, not
   * including the RFC1001 length.
   *
   * Note that this might make for "interesting" allocation problems during
   * writeback however as we have to allocate an array of pointers for the
ea1754a08   Kirill A. Shutemov   mm, fs: remove re...
856
   * pages. A 16M write means ~32kb page array with PAGE_SIZE == 4096.
24985c53d   Pavel Shilovsky   CIFS: Move r/wsiz...
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
   *
   * For reads, there is a similar problem as we need to allocate an array
   * of kvecs to handle the receive, though that should only need to be done
   * once.
   */
  #define CIFS_MAX_WSIZE ((1<<24) - 1 - sizeof(WRITE_REQ) + 4)
  #define CIFS_MAX_RSIZE ((1<<24) - sizeof(READ_RSP) + 4)
  
  /*
   * When the server doesn't allow large posix writes, only allow a rsize/wsize
   * of 2^17-1 minus the size of the call header. That allows for a read or
   * write up to the maximum size described by RFC1002.
   */
  #define CIFS_MAX_RFC1002_WSIZE ((1<<17) - 1 - sizeof(WRITE_REQ) + 4)
  #define CIFS_MAX_RFC1002_RSIZE ((1<<17) - 1 - sizeof(READ_RSP) + 4)
  
  /*
   * The default wsize is 1M. find_get_pages seems to return a maximum of 256
ea1754a08   Kirill A. Shutemov   mm, fs: remove re...
875
   * pages in a single call. With PAGE_SIZE == 4k, this means we can fill
24985c53d   Pavel Shilovsky   CIFS: Move r/wsiz...
876
877
878
   * a single wsize request with a single call.
   */
  #define CIFS_DEFAULT_IOSIZE (1024 * 1024)
3d621230b   Steve French   smb3: update defa...
879
  #define SMB3_DEFAULT_IOSIZE (4 * 1024 * 1024)
24985c53d   Pavel Shilovsky   CIFS: Move r/wsiz...
880
881
882
883
884
885
886
887
888
889
  
  /*
   * Windows only supports a max of 60kb reads and 65535 byte writes. Default to
   * those values when posix extensions aren't in force. In actuality here, we
   * use 65536 to allow for a write that is a multiple of 4k. Most servers seem
   * to be ok with the extra byte even though Windows doesn't send writes that
   * are that large.
   *
   * Citation:
   *
cba22b1c5   Alexander A. Klimov   Replace HTTP link...
890
   * https://blogs.msdn.com/b/openspecification/archive/2009/04/10/smb-maximum-transmit-buffer-size-and-performance-tuning.aspx
24985c53d   Pavel Shilovsky   CIFS: Move r/wsiz...
891
892
893
894
895
   */
  #define CIFS_DEFAULT_NON_POSIX_RSIZE (60 * 1024)
  #define CIFS_DEFAULT_NON_POSIX_WSIZE (65536)
  
  /*
f1d0c9986   Rob Landley   Make CIFS mount w...
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
   * Macros to allow the TCP_Server_Info->net field and related code to drop out
   * when CONFIG_NET_NS isn't set.
   */
  
  #ifdef CONFIG_NET_NS
  
  static inline struct net *cifs_net_ns(struct TCP_Server_Info *srv)
  {
  	return srv->net;
  }
  
  static inline void cifs_set_net_ns(struct TCP_Server_Info *srv, struct net *net)
  {
  	srv->net = net;
  }
  
  #else
  
  static inline struct net *cifs_net_ns(struct TCP_Server_Info *srv)
  {
  	return &init_net;
  }
  
  static inline void cifs_set_net_ns(struct TCP_Server_Info *srv, struct net *net)
  {
  }
  
  #endif
b6f0dd5d7   Aurelien Aptel   CIFS: add iface i...
924
925
926
927
928
929
  struct cifs_server_iface {
  	size_t speed;
  	unsigned int rdma_capable : 1;
  	unsigned int rss_capable : 1;
  	struct sockaddr_storage sockaddr;
  };
bcc888011   Aurelien Aptel   cifs: add multich...
930
931
932
933
  struct cifs_chan {
  	struct TCP_Server_Info *server;
  	__u8 signkey[SMB3_SIGN_KEY_SIZE];
  };
f1d0c9986   Rob Landley   Make CIFS mount w...
934
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
935
936
   * Session structure.  One of these for each uid session with a particular host
   */
96daf2b09   Steve French   [CIFS] Rename thr...
937
  struct cifs_ses {
14fbf50d6   Jeff Layton   cifs: reinstate s...
938
  	struct list_head smb_ses_list;
3b7952109   Steve French   [CIFS] Fix cifs r...
939
  	struct list_head tcon_list;
b327a717e   Aurelien Aptel   CIFS: make IPC a ...
940
  	struct cifs_tcon *tcon_ipc;
d7b619cf5   Steve French   [CIFS] pSesInfo->...
941
  	struct mutex session_mutex;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
942
  	struct TCP_Server_Info *server;	/* pointer to server info */
14fbf50d6   Jeff Layton   cifs: reinstate s...
943
  	int ses_count;		/* reference counter */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
944
  	enum statusEnum status;
750d1151a   Steve French   [CIFS] Fix alloca...
945
  	unsigned overrideSecFlg;  /* if non-zero override global sec flags */
ad009ac96   Steve French   [PATCH] cifs: Fix...
946
947
  	char *serverOS;		/* name of operating system underlying server */
  	char *serverNOS;	/* name of network operating system of server */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
948
  	char *serverDomain;	/* security realm of server */
286170aa2   Pavel Shilovsky   CIFS: Move protoc...
949
  	__u64 Suid;		/* remote smb uid  */
64ed39dd1   Eric W. Biederman   cifs: Convert str...
950
951
  	kuid_t linux_uid;	/* overriding owner of files on the mount */
  	kuid_t cred_uid;	/* owner of credentials */
29e20f9c6   Pavel Shilovsky   CIFS: Make CAP_* ...
952
  	unsigned int capabilities;
b327a717e   Aurelien Aptel   CIFS: make IPC a ...
953
  	char serverName[SERVER_NAME_LEN_WITH_NULL];
34c87901e   Steve French   Shrink stack spac...
954
955
  	char *user_name;	/* must not be null except during init of sess
  				   and after mount option parsing we fill it */
d38d8c74c   Steve French   [CIFS] whitespace...
956
957
  	char *domainName;
  	char *password;
5d0d28824   Shirish Pargaonkar   NTLM authenticati...
958
  	struct session_key auth_key;
d3686d54c   Shirish Pargaonkar   cifs: Cleanup and...
959
  	struct ntlmssp_auth *ntlmssp; /* ciphertext, flags, server challenge */
28e11bd86   Jeff Layton   cifs: add new fie...
960
961
  	enum securityEnum sectype; /* what security flavor was specified? */
  	bool sign;		/* is signing required? */
3b7952109   Steve French   [CIFS] Fix cifs r...
962
  	bool need_reconnect:1; /* connection reset, uid now invalid */
395664439   Germano Percossi   Fix default behav...
963
  	bool domainAuto:1;
f6a6bf7c4   Aurelien Aptel   cifs: switch serv...
964
  	bool binding:1; /* are we binding the session? */
5478f9ba9   Pavel Shilovsky   CIFS: Add session...
965
  	__u16 session_flags;
373512ec5   Steve French   Prepare for encry...
966
967
968
  	__u8 smb3signingkey[SMB3_SIGN_KEY_SIZE];
  	__u8 smb3encryptionkey[SMB3_SIGN_KEY_SIZE];
  	__u8 smb3decryptionkey[SMB3_SIGN_KEY_SIZE];
8bd68c6e4   Aurelien Aptel   CIFS: implement v...
969
  	__u8 preauth_sha_hash[SMB2_PREAUTH_HASH_SIZE];
b6f0dd5d7   Aurelien Aptel   CIFS: add iface i...
970

d70e9fa55   Aurelien Aptel   cifs: try opening...
971
  	__u8 binding_preauth_sha_hash[SMB2_PREAUTH_HASH_SIZE];
b6f0dd5d7   Aurelien Aptel   CIFS: add iface i...
972
973
974
975
976
977
978
979
980
981
982
983
984
  	/*
  	 * Network interfaces available on the server this session is
  	 * connected to.
  	 *
  	 * Other channels can be opened by connecting and binding this
  	 * session to interfaces from this list.
  	 *
  	 * iface_lock should be taken when accessing any of these fields
  	 */
  	spinlock_t iface_lock;
  	struct cifs_server_iface *iface_list;
  	size_t iface_count;
  	unsigned long iface_last_update; /* jiffies */
bcc888011   Aurelien Aptel   cifs: add multich...
985
986
987
  
  #define CIFS_MAX_CHANNELS 16
  	struct cifs_chan chans[CIFS_MAX_CHANNELS];
8eec79540   Aurelien Aptel   cifs: multichanne...
988
  	struct cifs_chan *binding_chan;
bcc888011   Aurelien Aptel   cifs: add multich...
989
990
991
  	size_t chan_count;
  	size_t chan_max;
  	atomic_t chan_seq; /* round robin state */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
992
  };
233839b1d   Pavel Shilovsky   CIFS: Fix fast le...
993

d70e9fa55   Aurelien Aptel   cifs: try opening...
994
995
  /*
   * When binding a new channel, we need to access the channel which isn't fully
8eec79540   Aurelien Aptel   cifs: multichanne...
996
   * established yet.
d70e9fa55   Aurelien Aptel   cifs: try opening...
997
998
999
1000
1001
1002
   */
  
  static inline
  struct cifs_chan *cifs_ses_binding_channel(struct cifs_ses *ses)
  {
  	if (ses->binding)
8eec79540   Aurelien Aptel   cifs: multichanne...
1003
  		return ses->binding_chan;
d70e9fa55   Aurelien Aptel   cifs: try opening...
1004
1005
1006
  	else
  		return NULL;
  }
8eec79540   Aurelien Aptel   cifs: multichanne...
1007
1008
1009
1010
1011
1012
1013
1014
  /*
   * Returns the server pointer of the session. When binding a new
   * channel this returns the last channel which isn't fully established
   * yet.
   *
   * This function should be use for negprot/sess.setup codepaths. For
   * the other requests see cifs_pick_channel().
   */
f6a6bf7c4   Aurelien Aptel   cifs: switch serv...
1015
1016
1017
1018
  static inline
  struct TCP_Server_Info *cifs_ses_server(struct cifs_ses *ses)
  {
  	if (ses->binding)
8eec79540   Aurelien Aptel   cifs: multichanne...
1019
  		return ses->binding_chan->server;
f6a6bf7c4   Aurelien Aptel   cifs: switch serv...
1020
1021
1022
  	else
  		return ses->server;
  }
29e20f9c6   Pavel Shilovsky   CIFS: Make CAP_* ...
1023
1024
1025
1026
1027
  static inline bool
  cap_unix(struct cifs_ses *ses)
  {
  	return ses->server->vals->cap_unix & ses->capabilities;
  }
a93864d93   Ronnie Sahlberg   cifs: add lease t...
1028
1029
  struct cached_fid {
  	bool is_valid:1;	/* Do we have a useable root fid */
b0f6df737   Ronnie Sahlberg   cifs: cache FILE_...
1030
  	bool file_all_info_is_valid:1;
d91913193   Pavel Shilovsky   CIFS: Close cache...
1031
  	bool has_lease:1;
9da6ec777   Ronnie Sahlberg   cifs: use a refco...
1032
  	struct kref refcount;
a93864d93   Ronnie Sahlberg   cifs: add lease t...
1033
1034
1035
1036
  	struct cifs_fid *fid;
  	struct mutex fid_mutex;
  	struct cifs_tcon *tcon;
  	struct work_struct lease_break;
b0f6df737   Ronnie Sahlberg   cifs: cache FILE_...
1037
  	struct smb2_file_all_info file_all_info;
a93864d93   Ronnie Sahlberg   cifs: add lease t...
1038
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1039
1040
  /*
   * there is one of these for each connection to a resource on a particular
d38d8c74c   Steve French   [CIFS] whitespace...
1041
   * session
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1042
   */
96daf2b09   Steve French   [CIFS] Rename thr...
1043
  struct cifs_tcon {
f1987b44f   Jeff Layton   cifs: reinstate s...
1044
1045
  	struct list_head tcon_list;
  	int tc_count;
53e0e11ef   Pavel Shilovsky   CIFS: Fix a possi...
1046
  	struct list_head rlist; /* reconnect list */
fae8044c0   Steve French   smb3: show number...
1047
1048
  	atomic_t num_local_opens;  /* num of all opens including disconnected */
  	atomic_t num_remote_opens; /* num of all network opens on server */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1049
  	struct list_head openFileList;
3afca265b   Steve French   Clarify locking o...
1050
  	spinlock_t open_file_lock; /* protects list above */
96daf2b09   Steve French   [CIFS] Rename thr...
1051
  	struct cifs_ses *ses;	/* pointer to session associated with */
254e55ed0   Steve French   CIFS] Support for...
1052
  	char treeName[MAX_TREE_SIZE + 1]; /* UNC name of resource in ASCII */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1053
  	char *nativeFileSystem;
00e485b01   Jeff Layton   cifs: store passw...
1054
  	char *password;		/* for share-level security */
faaf946a7   Pavel Shilovsky   CIFS: Add tree co...
1055
  	__u32 tid;		/* The 4 byte tree id */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1056
1057
  	__u16 Flags;		/* optional support bits */
  	enum statusEnum tidStatus;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1058
  	atomic_t num_smbs_sent;
44c581866   Pavel Shilovsky   CIFS: Move clear/...
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
  	union {
  		struct {
  			atomic_t num_writes;
  			atomic_t num_reads;
  			atomic_t num_flushes;
  			atomic_t num_oplock_brks;
  			atomic_t num_opens;
  			atomic_t num_closes;
  			atomic_t num_deletes;
  			atomic_t num_mkdirs;
  			atomic_t num_posixopens;
  			atomic_t num_posixmkdirs;
  			atomic_t num_rmdirs;
  			atomic_t num_renames;
  			atomic_t num_t2renames;
  			atomic_t num_ffirst;
  			atomic_t num_fnext;
  			atomic_t num_fclose;
  			atomic_t num_hardlinks;
  			atomic_t num_symlinks;
  			atomic_t num_locks;
  			atomic_t num_acl_get;
  			atomic_t num_acl_set;
  		} cifs_stats;
d60622eb5   Pavel Shilovsky   CIFS: Allow SMB2 ...
1083
1084
1085
1086
  		struct {
  			atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
  			atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
  		} smb2_stats;
44c581866   Pavel Shilovsky   CIFS: Move clear/...
1087
  	} stats;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1088
1089
  	__u64    bytes_read;
  	__u64    bytes_written;
3afca265b   Steve French   Clarify locking o...
1090
  	spinlock_t stat_lock;  /* protects the two fields above */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1091
  	FILE_SYSTEM_DEVICE_INFO fsDevInfo;
254e55ed0   Steve French   CIFS] Support for...
1092
  	FILE_SYSTEM_ATTRIBUTE_INFO fsAttrInfo; /* ok if fs name truncated */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1093
  	FILE_SYSTEM_UNIX_INFO fsUnixInfo;
b327a717e   Aurelien Aptel   CIFS: make IPC a ...
1094
1095
1096
  	bool ipc:1;   /* set if connection to IPC$ share (always also pipe) */
  	bool pipe:1;  /* set if connection to pipe share */
  	bool print:1; /* set if connection to printer share */
4b18f2a9c   Steve French   [CIFS] convert us...
1097
1098
  	bool retry:1;
  	bool nocase:1;
3d4ef9a15   Steve French   smb3: fix redunda...
1099
  	bool nohandlecache:1; /* if strange server resource prob can turn off */
82e9367c4   Steve French   smb3: Add new par...
1100
  	bool nodelete:1;
95b1cb90b   Steve French   [CIFS] enable par...
1101
  	bool seal:1;      /* transport encryption for this mounted share */
4b18f2a9c   Steve French   [CIFS] convert us...
1102
  	bool unix_ext:1;  /* if false disable Linux extensions to CIFS protocol
c18c842b1   Steve French   [CIFS] Allow disa...
1103
  				for this mount even if server would support */
b326614ea   Steve French   smb3: allow "posi...
1104
  	bool posix_extensions; /* if true SMB3.11 posix extensions enabled */
84210e912   Steve French   [CIFS] improve se...
1105
  	bool local_lease:1; /* check leases (only) on local system not remote */
64cc2c636   Steve French   [CIFS] work aroun...
1106
  	bool broken_posix_open; /* e.g. Samba server versions < 3.3.2, 3.2.9 */
3d1a3745d   Steve French   Add sparse file s...
1107
  	bool broken_sparse_sup; /* if server or share does not support sparse */
3b7952109   Steve French   [CIFS] Fix cifs r...
1108
  	bool need_reconnect:1; /* connection reset, tid now invalid */
96a988ffe   Pavel Shilovsky   CIFS: Fix a possi...
1109
  	bool need_reopen_files:1; /* need to reopen tcon file handles */
592fafe64   Steve French   Add resilienthand...
1110
  	bool use_resilient:1; /* use resilient instead of durable handles */
b618f001a   Steve French   [SMB3] Enable che...
1111
  	bool use_persistent:1; /* use persistent instead of durable handles */
3e7a02d47   Steve French   smb3: allow disab...
1112
  	bool no_lease:1;    /* Do not request leases on files or directories */
769ee6a40   Steve French   Add ability to di...
1113
  	__le32 capabilities;
faaf946a7   Pavel Shilovsky   CIFS: Add tree co...
1114
1115
1116
1117
  	__u32 share_flags;
  	__u32 maximal_access;
  	__u32 vol_serial_number;
  	__le64 vol_create_time;
8b217fe7f   Steve French   SMB3: parsing for...
1118
  	__u64 snapshot_time; /* for timewarp tokens - timestamp of snapshot */
ca567eb2b   Steve French   SMB3: Allow persi...
1119
  	__u32 handle_timeout; /* persistent and durable handle timeout in ms */
af6a12ea8   Steven French   Query File System...
1120
1121
  	__u32 ss_flags;		/* sector size flags */
  	__u32 perf_sector_size; /* best sector size for perf */
de9f68df6   Steve French   [CIFS] Set copych...
1122
1123
1124
  	__u32 max_chunks;
  	__u32 max_bytes_chunk;
  	__u32 max_bytes_copy;
d03382ce9   Suresh Jayaraman   cifs: define supe...
1125
1126
1127
1128
  #ifdef CONFIG_CIFS_FSCACHE
  	u64 resource_id;		/* server resource id */
  	struct fscache_cookie *fscache;	/* cookie for share */
  #endif
233839b1d   Pavel Shilovsky   CIFS: Fix fast le...
1129
  	struct list_head pending_opens;	/* list of incomplete opens */
a93864d93   Ronnie Sahlberg   cifs: add lease t...
1130
  	struct cached_fid crfid; /* Cached root fid */
c18c842b1   Steve French   [CIFS] Allow disa...
1131
  	/* BB add field for back pointer to sb struct(s)? */
54be1f6c1   Paulo Alcantara   cifs: Add DFS cac...
1132
1133
1134
1135
1136
  #ifdef CONFIG_CIFS_DFS_UPCALL
  	char *dfs_path;
  	int remap:2;
  	struct list_head ulist; /* cache update list */
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1137
1138
1139
  };
  
  /*
7ffec3724   Jeff Layton   cifs: add refcoun...
1140
1141
1142
1143
1144
1145
   * This is a refcounted and timestamped container for a tcon pointer. The
   * container holds a tcon reference. It is considered safe to free one of
   * these when the tl_count goes to 0. The tl_time is the time of the last
   * "get" on the container.
   */
  struct tcon_link {
b647c35f7   Jeff Layton   cifs: convert tli...
1146
  	struct rb_node		tl_rbnode;
6d4a08320   Eric W. Biederman   cifs: Convert str...
1147
  	kuid_t			tl_uid;
9d002df49   Jeff Layton   cifs: add routine...
1148
1149
1150
1151
1152
1153
  	unsigned long		tl_flags;
  #define TCON_LINK_MASTER	0
  #define TCON_LINK_PENDING	1
  #define TCON_LINK_IN_TREE	2
  	unsigned long		tl_time;
  	atomic_t		tl_count;
96daf2b09   Steve French   [CIFS] Rename thr...
1154
  	struct cifs_tcon	*tl_tcon;
7ffec3724   Jeff Layton   cifs: add refcoun...
1155
  };
9d002df49   Jeff Layton   cifs: add routine...
1156
  extern struct tcon_link *cifs_sb_tlink(struct cifs_sb_info *cifs_sb);
b2c96de7f   Ronnie Sahlberg   cifs: update init...
1157
  extern void smb3_free_compound_rqst(int num_rqst, struct smb_rqst *rqst);
7ffec3724   Jeff Layton   cifs: add refcoun...
1158

96daf2b09   Steve French   [CIFS] Rename thr...
1159
  static inline struct cifs_tcon *
7ffec3724   Jeff Layton   cifs: add refcoun...
1160
1161
  tlink_tcon(struct tcon_link *tlink)
  {
9d002df49   Jeff Layton   cifs: add routine...
1162
  	return tlink->tl_tcon;
7ffec3724   Jeff Layton   cifs: add refcoun...
1163
  }
8ddecf5fd   Aurelien Aptel   CIFS: Fix NULL pt...
1164
1165
1166
1167
1168
  static inline struct tcon_link *
  cifs_sb_master_tlink(struct cifs_sb_info *cifs_sb)
  {
  	return cifs_sb->master_tlink;
  }
9d002df49   Jeff Layton   cifs: add routine...
1169
  extern void cifs_put_tlink(struct tcon_link *tlink);
7ffec3724   Jeff Layton   cifs: add refcoun...
1170

13cfb7334   Jeff Layton   cifs: have cifsFi...
1171
1172
1173
  static inline struct tcon_link *
  cifs_get_tlink(struct tcon_link *tlink)
  {
9d002df49   Jeff Layton   cifs: add routine...
1174
1175
  	if (tlink && !IS_ERR(tlink))
  		atomic_inc(&tlink->tl_count);
13cfb7334   Jeff Layton   cifs: have cifsFi...
1176
1177
  	return tlink;
  }
7ffec3724   Jeff Layton   cifs: add refcoun...
1178
  /* This function is always expected to succeed */
96daf2b09   Steve French   [CIFS] Rename thr...
1179
  extern struct cifs_tcon *cifs_sb_master_tcon(struct cifs_sb_info *cifs_sb);
7ffec3724   Jeff Layton   cifs: add refcoun...
1180

233839b1d   Pavel Shilovsky   CIFS: Fix fast le...
1181
1182
1183
1184
1185
1186
1187
1188
  #define CIFS_OPLOCK_NO_CHANGE 0xfe
  
  struct cifs_pending_open {
  	struct list_head olist;
  	struct tcon_link *tlink;
  	__u8 lease_key[16];
  	__u32 oplock;
  };
7ffec3724   Jeff Layton   cifs: add refcoun...
1189
  /*
7ee1af765   Jeremy Allison   [CIFS]
1190
1191
   * This info hangs off the cifsFileInfo structure, pointed to by llist.
   * This is used to track byte stream locks on the file
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1192
1193
   */
  struct cifsLockInfo {
7ee1af765   Jeremy Allison   [CIFS]
1194
  	struct list_head llist;	/* pointer to next cifsLockInfo */
85160e03a   Pavel Shilovsky   CIFS: Implement c...
1195
1196
  	struct list_head blist; /* pointer to locks blocked on this */
  	wait_queue_head_t block_q;
7ee1af765   Jeremy Allison   [CIFS]
1197
1198
  	__u64 offset;
  	__u64 length;
03776f451   Pavel Shilovsky   CIFS: Simplify by...
1199
  	__u32 pid;
9645759ce   Ronnie Sahlberg   cifs: OFD locks d...
1200
1201
  	__u16 type;
  	__u16 flags;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
  };
  
  /*
   * One of these for each open instance of a file
   */
  struct cifs_search_info {
  	loff_t index_of_last_entry;
  	__u16 entries_in_buffer;
  	__u16 info_level;
  	__u32 resume_key;
d38d8c74c   Steve French   [CIFS] whitespace...
1212
1213
  	char *ntwrk_buf_start;
  	char *srch_entries_start;
0752f1522   Steve French   [CIFS] make sure ...
1214
  	char *last_entry;
eaf35b1ea   Christoph Hellwig   cifs: use cifs_di...
1215
  	const char *presume_name;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1216
  	unsigned int resume_name_len;
4b18f2a9c   Steve French   [CIFS] convert us...
1217
1218
1219
1220
  	bool endOfSearch:1;
  	bool emptyDir:1;
  	bool unicode:1;
  	bool smallBuf:1; /* so we know which buf_release function to call */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1221
  };
d0959b080   Steve French   smb3: remove nois...
1222
  #define ACL_NO_MODE	((umode_t)(-1))
226730b4d   Pavel Shilovsky   CIFS: Introduce c...
1223
1224
1225
1226
1227
1228
1229
1230
  struct cifs_open_parms {
  	struct cifs_tcon *tcon;
  	struct cifs_sb_info *cifs_sb;
  	int disposition;
  	int desired_access;
  	int create_options;
  	const char *path;
  	struct cifs_fid *fid;
ce558b0e1   Steve French   smb3: Add posix c...
1231
  	umode_t mode;
9cbc0b733   Pavel Shilovsky   CIFS: Reconnect d...
1232
  	bool reconnect:1;
226730b4d   Pavel Shilovsky   CIFS: Introduce c...
1233
  };
4b4de76e3   Pavel Shilovsky   CIFS: Replace net...
1234
1235
  struct cifs_fid {
  	__u16 netfid;
f0df737ee   Pavel Shilovsky   CIFS: Add open/cl...
1236
1237
  	__u64 persistent_fid;	/* persist file id for smb2 */
  	__u64 volatile_fid;	/* volatile file id for smb2 */
b8c32dbb0   Pavel Shilovsky   CIFS: Request SMB...
1238
  	__u8 lease_key[SMB2_LEASE_KEY_SIZE];	/* lease key for smb2 */
b56eae4df   Steve French   [SMB3] Send durab...
1239
  	__u8 create_guid[16];
86f740f2a   Aurelien Aptel   cifs: fix rename(...
1240
  	__u32 access;
233839b1d   Pavel Shilovsky   CIFS: Fix fast le...
1241
  	struct cifs_pending_open *pending_open;
42873b0a2   Pavel Shilovsky   CIFS: Respect epo...
1242
  	unsigned int epoch;
dfe33f9ab   Steve French   smb3: allow more ...
1243
1244
1245
  #ifdef CONFIG_CIFS_DEBUG2
  	__u64 mid;
  #endif /* CIFS_DEBUG2 */
42873b0a2   Pavel Shilovsky   CIFS: Respect epo...
1246
  	bool purge_cache;
4b4de76e3   Pavel Shilovsky   CIFS: Replace net...
1247
  };
f45d34167   Pavel Shilovsky   CIFS: Remove spin...
1248
1249
1250
1251
1252
  struct cifs_fid_locks {
  	struct list_head llist;
  	struct cifsFileInfo *cfile;	/* fid that owns locks */
  	struct list_head locks;		/* locks held by fid above */
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1253
  struct cifsFileInfo {
3afca265b   Steve French   Clarify locking o...
1254
  	/* following two lists are protected by tcon->open_file_lock */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1255
1256
  	struct list_head tlist;	/* pointer to next fid owned by tcon */
  	struct list_head flist;	/* next fid (file instance) for this inode */
3afca265b   Steve French   Clarify locking o...
1257
  	/* lock list below protected by cifsi->lock_sem */
f45d34167   Pavel Shilovsky   CIFS: Remove spin...
1258
  	struct cifs_fid_locks *llist;	/* brlocks held by this fid */
fef59fd72   Eric W. Biederman   cifs: Convert str...
1259
  	kuid_t uid;		/* allows finding which FileInfo structure */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1260
  	__u32 pid;		/* process id who opened file */
4b4de76e3   Pavel Shilovsky   CIFS: Replace net...
1261
  	struct cifs_fid fid;	/* file id from remote */
f2cca6a7c   Pavel Shilovsky   CIFS: Fix persist...
1262
  	struct list_head rlist; /* reconnect list */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1263
1264
  	/* BB add lock scope info here if needed */ ;
  	/* lock scope id (0 if none) */
a5e18bc36   Jeff Layton   cifs: keep dentry...
1265
  	struct dentry *dentry;
13cfb7334   Jeff Layton   cifs: have cifsFi...
1266
  	struct tcon_link *tlink;
3afca265b   Steve French   Clarify locking o...
1267
  	unsigned int f_flags;
4b18f2a9c   Steve French   [CIFS] convert us...
1268
  	bool invalidHandle:1;	/* file closed via session abend */
4e8aea30f   Steve French   smb3: enable swap...
1269
  	bool swapfile:1;
3bc303c25   Jeff Layton   cifs: convert opl...
1270
  	bool oplock_break_cancelled:1;
9bd454083   Pavel Shilovsky   CIFS: Properly pr...
1271
1272
  	unsigned int oplock_epoch; /* epoch from the lease break */
  	__u32 oplock_level; /* oplock/lease level from the lease break */
3afca265b   Steve French   Clarify locking o...
1273
1274
  	int count;
  	spinlock_t file_info_lock; /* protects four flag/count fields above */
a6ce4932f   Steve French   [CIFS] Add suppor...
1275
  	struct mutex fh_mutex; /* prevents reopen race after dead ses*/
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1276
  	struct cifs_search_info srch_inf;
9b6469724   Tejun Heo   cifs: use workque...
1277
  	struct work_struct oplock_break; /* work for oplock breaks */
32546a958   Ronnie Sahlberg   cifs: move cifsFi...
1278
  	struct work_struct put; /* work for the final part of _put */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1279
  };
fa2989f44   Pavel Shilovsky   CIFS: Use pid sav...
1280
1281
  struct cifs_io_parms {
  	__u16 netfid;
09a4707e7   Pavel Shilovsky   CIFS: Add SMB2 su...
1282
1283
  	__u64 persistent_fid;	/* persist file id for smb2 */
  	__u64 volatile_fid;	/* volatile file id for smb2 */
fa2989f44   Pavel Shilovsky   CIFS: Use pid sav...
1284
1285
1286
  	__u32 pid;
  	__u64 offset;
  	unsigned int length;
96daf2b09   Steve French   [CIFS] Rename thr...
1287
  	struct cifs_tcon *tcon;
352d96f3a   Aurelien Aptel   cifs: multichanne...
1288
  	struct TCP_Server_Info *server;
fa2989f44   Pavel Shilovsky   CIFS: Use pid sav...
1289
  };
ccf7f4088   Pavel Shilovsky   CIFS: Add asynchr...
1290
1291
1292
1293
1294
1295
1296
1297
1298
  struct cifs_aio_ctx {
  	struct kref		refcount;
  	struct list_head	list;
  	struct mutex		aio_mutex;
  	struct completion	done;
  	struct iov_iter		iter;
  	struct kiocb		*iocb;
  	struct cifsFileInfo	*cfile;
  	struct bio_vec		*bv;
c610c4b61   Pavel Shilovsky   CIFS: Add asynchr...
1299
  	loff_t			pos;
ccf7f4088   Pavel Shilovsky   CIFS: Add asynchr...
1300
1301
1302
1303
1304
  	unsigned int		npages;
  	ssize_t			rc;
  	unsigned int		len;
  	unsigned int		total_len;
  	bool			should_dirty;
6e6e2b86c   Long Li   CIFS: Add support...
1305
1306
1307
1308
1309
  	/*
  	 * Indicates if this aio_ctx is for direct_io,
  	 * If yes, iter is a copy of the user passed iov_iter
  	 */
  	bool			direct_io;
ccf7f4088   Pavel Shilovsky   CIFS: Add asynchr...
1310
  };
09a4707e7   Pavel Shilovsky   CIFS: Add SMB2 su...
1311
1312
1313
1314
1315
1316
1317
1318
1319
  struct cifs_readdata;
  
  /* asynchronous read support */
  struct cifs_readdata {
  	struct kref			refcount;
  	struct list_head		list;
  	struct completion		done;
  	struct cifsFileInfo		*cfile;
  	struct address_space		*mapping;
6685c5e2d   Pavel Shilovsky   CIFS: Add asynchr...
1320
  	struct cifs_aio_ctx		*ctx;
09a4707e7   Pavel Shilovsky   CIFS: Add SMB2 su...
1321
1322
  	__u64				offset;
  	unsigned int			bytes;
34a54d617   Pavel Shilovsky   CIFS: Use separat...
1323
  	unsigned int			got_bytes;
09a4707e7   Pavel Shilovsky   CIFS: Add SMB2 su...
1324
1325
  	pid_t				pid;
  	int				result;
09a4707e7   Pavel Shilovsky   CIFS: Add SMB2 su...
1326
  	struct work_struct		work;
8321fec43   Jeff Layton   cifs: convert asy...
1327
1328
1329
  	int (*read_into_pages)(struct TCP_Server_Info *server,
  				struct cifs_readdata *rdata,
  				unsigned int len);
d70b9104b   Pavel Shilovsky   CIFS: Add copy in...
1330
1331
1332
  	int (*copy_into_pages)(struct TCP_Server_Info *server,
  				struct cifs_readdata *rdata,
  				struct iov_iter *iter);
738f9de5c   Pavel Shilovsky   CIFS: Send RFC100...
1333
  	struct kvec			iov[2];
352d96f3a   Aurelien Aptel   cifs: multichanne...
1334
  	struct TCP_Server_Info		*server;
74dcf418f   Long Li   CIFS: SMBD: Read ...
1335
1336
1337
  #ifdef CONFIG_CIFS_SMB_DIRECT
  	struct smbd_mr			*mr;
  #endif
8321fec43   Jeff Layton   cifs: convert asy...
1338
  	unsigned int			pagesz;
57a929a66   Long Li   CIFS: Introduce o...
1339
  	unsigned int			page_offset;
8321fec43   Jeff Layton   cifs: convert asy...
1340
  	unsigned int			tailsz;
335b7b62f   Pavel Shilovsky   CIFS: Respect rec...
1341
  	struct cifs_credits		credits;
c5fab6f4f   Jeff Layton   cifs: turn the pa...
1342
  	unsigned int			nr_pages;
f9f5aca11   Long Li   CIFS: Add support...
1343
  	struct page			**pages;
09a4707e7   Pavel Shilovsky   CIFS: Add SMB2 su...
1344
  };
333191412   Pavel Shilovsky   CIFS: Add SMB2 su...
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
  struct cifs_writedata;
  
  /* asynchronous write support */
  struct cifs_writedata {
  	struct kref			refcount;
  	struct list_head		list;
  	struct completion		done;
  	enum writeback_sync_modes	sync_mode;
  	struct work_struct		work;
  	struct cifsFileInfo		*cfile;
c610c4b61   Pavel Shilovsky   CIFS: Add asynchr...
1355
  	struct cifs_aio_ctx		*ctx;
333191412   Pavel Shilovsky   CIFS: Add SMB2 su...
1356
1357
1358
1359
  	__u64				offset;
  	pid_t				pid;
  	unsigned int			bytes;
  	int				result;
352d96f3a   Aurelien Aptel   cifs: multichanne...
1360
  	struct TCP_Server_Info		*server;
db223a590   Long Li   CIFS: SMBD: Upper...
1361
1362
1363
  #ifdef CONFIG_CIFS_SMB_DIRECT
  	struct smbd_mr			*mr;
  #endif
eddb079de   Jeff Layton   cifs: convert asy...
1364
  	unsigned int			pagesz;
57a929a66   Long Li   CIFS: Introduce o...
1365
  	unsigned int			page_offset;
eddb079de   Jeff Layton   cifs: convert asy...
1366
  	unsigned int			tailsz;
335b7b62f   Pavel Shilovsky   CIFS: Respect rec...
1367
  	struct cifs_credits		credits;
333191412   Pavel Shilovsky   CIFS: Add SMB2 su...
1368
  	unsigned int			nr_pages;
8e7360f67   Long Li   CIFS: Add support...
1369
  	struct page			**pages;
333191412   Pavel Shilovsky   CIFS: Add SMB2 su...
1370
  };
5f6dbc9e4   Jeff Layton   cifs: convert cif...
1371
1372
  /*
   * Take a reference on the file private data. Must be called with
3afca265b   Steve French   Clarify locking o...
1373
   * cfile->file_info_lock held.
5f6dbc9e4   Jeff Layton   cifs: convert cif...
1374
   */
764a1b1ac   Jeff Layton   cifs: ensure that...
1375
1376
  static inline void
  cifsFileInfo_get_locked(struct cifsFileInfo *cifs_file)
6ab409b53   Dave Kleikamp   cifs: Replace wrt...
1377
  {
5f6dbc9e4   Jeff Layton   cifs: convert cif...
1378
  	++cifs_file->count;
6ab409b53   Dave Kleikamp   cifs: Replace wrt...
1379
  }
764a1b1ac   Jeff Layton   cifs: ensure that...
1380
  struct cifsFileInfo *cifsFileInfo_get(struct cifsFileInfo *cifs_file);
32546a958   Ronnie Sahlberg   cifs: move cifsFi...
1381
1382
  void _cifsFileInfo_put(struct cifsFileInfo *cifs_file, bool wait_oplock_hdlr,
  		       bool offload);
b33879aa8   Jeff Layton   cifs: move cifsFi...
1383
  void cifsFileInfo_put(struct cifsFileInfo *cifs_file);
6ab409b53   Dave Kleikamp   cifs: Replace wrt...
1384

18cceb6a7   Pavel Shilovsky   CIFS: Replace cli...
1385
1386
  #define CIFS_CACHE_READ_FLG	1
  #define CIFS_CACHE_HANDLE_FLG	2
42873b0a2   Pavel Shilovsky   CIFS: Respect epo...
1387
  #define CIFS_CACHE_RH_FLG	(CIFS_CACHE_READ_FLG | CIFS_CACHE_HANDLE_FLG)
18cceb6a7   Pavel Shilovsky   CIFS: Replace cli...
1388
  #define CIFS_CACHE_WRITE_FLG	4
42873b0a2   Pavel Shilovsky   CIFS: Respect epo...
1389
1390
  #define CIFS_CACHE_RW_FLG	(CIFS_CACHE_READ_FLG | CIFS_CACHE_WRITE_FLG)
  #define CIFS_CACHE_RHW_FLG	(CIFS_CACHE_RW_FLG | CIFS_CACHE_HANDLE_FLG)
18cceb6a7   Pavel Shilovsky   CIFS: Replace cli...
1391

83bbfa706   Steve French   smb3: add mount o...
1392
  #define CIFS_CACHE_READ(cinode) ((cinode->oplock & CIFS_CACHE_READ_FLG) || (CIFS_SB(cinode->vfs_inode.i_sb)->mnt_cifs_flags & CIFS_MOUNT_RO_CACHE))
53ef1016f   Pavel Shilovsky   CIFS: Store lease...
1393
  #define CIFS_CACHE_HANDLE(cinode) (cinode->oplock & CIFS_CACHE_HANDLE_FLG)
41e033fec   Steve French   smb3: add mount o...
1394
  #define CIFS_CACHE_WRITE(cinode) ((cinode->oplock & CIFS_CACHE_WRITE_FLG) || (CIFS_SB(cinode->vfs_inode.i_sb)->mnt_cifs_flags & CIFS_MOUNT_RW_CACHE))
18cceb6a7   Pavel Shilovsky   CIFS: Replace cli...
1395

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1396
1397
1398
1399
1400
  /*
   * One of these for each file inode
   */
  
  struct cifsInodeInfo {
d59dad2be   Pavel Shilovsky   CIFS: Move byte r...
1401
  	bool can_cache_brlcks;
f45d34167   Pavel Shilovsky   CIFS: Remove spin...
1402
  	struct list_head llist;	/* locks helb by this inode */
d46b0da7a   Dave Wysochanski   cifs: Fix cifsIno...
1403
1404
  	/*
  	 * NOTE: Some code paths call down_read(lock_sem) twice, so
a03f507de   Randy Dunlap   cifs: delete dupl...
1405
  	 * we must always use cifs_down_write() instead of down_write()
d46b0da7a   Dave Wysochanski   cifs: Fix cifsIno...
1406
1407
  	 * for this semaphore to avoid deadlocks.
  	 */
1b4b55a1d   Pavel Shilovsky   CIFS: Turn lock m...
1408
  	struct rw_semaphore lock_sem;	/* protect the fields above */
d38d8c74c   Steve French   [CIFS] whitespace...
1409
  	/* BB add in lists for dirty pages i.e. write caching info for oplock */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1410
  	struct list_head openFileList;
487317c99   Ronnie Sahlberg   cifs: add spinloc...
1411
  	spinlock_t	open_file_lock;	/* protects openFileList */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1412
  	__u32 cifsAttrs; /* e.g. DOS archive bit, sparse, compressed, system */
18cceb6a7   Pavel Shilovsky   CIFS: Replace cli...
1413
  	unsigned int oplock;		/* oplock/lease level we have */
42873b0a2   Pavel Shilovsky   CIFS: Respect epo...
1414
  	unsigned int epoch;		/* used to track lease state changes */
c11f1df50   Sachin Prabhu   cifs: Wait for wr...
1415
1416
  #define CIFS_INODE_PENDING_OPLOCK_BREAK   (0) /* oplock break in progress */
  #define CIFS_INODE_PENDING_WRITERS	  (1) /* Writes in progress */
9bd454083   Pavel Shilovsky   CIFS: Properly pr...
1417
  #define CIFS_INODE_FLAG_UNUSED		  (2) /* Unused flag */
aff8d5ca7   Jeff Layton   cifs: convert boo...
1418
1419
  #define CIFS_INO_DELETE_PENDING		  (3) /* delete pending on server */
  #define CIFS_INO_INVALID_MAPPING	  (4) /* pagecache is invalid */
4f73c7d34   Jeff Layton   cifs: fix potenti...
1420
  #define CIFS_INO_LOCK			  (5) /* lock bit for synchronization */
aff8d5ca7   Jeff Layton   cifs: convert boo...
1421
  	unsigned long flags;
c11f1df50   Sachin Prabhu   cifs: Wait for wr...
1422
1423
  	spinlock_t writers_lock;
  	unsigned int writers;		/* Number of writers on this inode */
aae62fdb6   Jeff Layton   cifs: move time f...
1424
  	unsigned long time;		/* jiffies of last update of inode */
597b027f6   Jeff Layton   cifs: call cifs_u...
1425
  	u64  server_eof;		/* current file size on server -- protected by i_lock */
cc0bad755   Jeff Layton   cifs: add new cif...
1426
  	u64  uniqueid;			/* server inode number */
20054bd65   Jeff Layton   cifs: use Creatio...
1427
  	u64  createtime;		/* creation time on server */
b8c32dbb0   Pavel Shilovsky   CIFS: Request SMB...
1428
  	__u8 lease_key[SMB2_LEASE_KEY_SIZE];	/* lease key for this inode */
9451a9a52   Suresh Jayaraman   cifs: define inod...
1429
1430
1431
  #ifdef CONFIG_CIFS_FSCACHE
  	struct fscache_cookie *fscache;
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
  	struct inode vfs_inode;
  };
  
  static inline struct cifsInodeInfo *
  CIFS_I(struct inode *inode)
  {
  	return container_of(inode, struct cifsInodeInfo, vfs_inode);
  }
  
  static inline struct cifs_sb_info *
  CIFS_SB(struct super_block *sb)
  {
  	return sb->s_fs_info;
  }
7119e220a   Al Viro   cifs: get rid of ...
1446
1447
1448
1449
1450
  static inline struct cifs_sb_info *
  CIFS_FILE_SB(struct file *file)
  {
  	return CIFS_SB(file_inode(file)->i_sb);
  }
ab2f218f4   Steve French   [CIFS] Fix compil...
1451
  static inline char CIFS_DIR_SEP(const struct cifs_sb_info *cifs_sb)
ac67055ef   Jeremy Allison   [CIFS] POSIX exte...
1452
1453
1454
1455
1456
1457
  {
  	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)
  		return '/';
  	else
  		return '\\';
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1458

f87d39d95   Steve French   [CIFS] Migrate fr...
1459
1460
1461
  static inline void
  convert_delimiter(char *path, char delim)
  {
1cc9bd686   Steve French   make convert_deli...
1462
  	char old_delim, *pos;
f87d39d95   Steve French   [CIFS] Migrate fr...
1463
1464
1465
1466
1467
  
  	if (delim == '/')
  		old_delim = '\\';
  	else
  		old_delim = '/';
1cc9bd686   Steve French   make convert_deli...
1468
1469
1470
  	pos = path;
  	while ((pos = strchr(pos, old_delim)))
  		*pos = delim;
f87d39d95   Steve French   [CIFS] Migrate fr...
1471
  }
a45443475   Steve French   CIFS: Reduce CONF...
1472
  #define cifs_stats_inc atomic_inc
96daf2b09   Steve French   [CIFS] Rename thr...
1473
  static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
a45443475   Steve French   CIFS: Reduce CONF...
1474
1475
1476
1477
1478
1479
1480
1481
  					    unsigned int bytes)
  {
  	if (bytes) {
  		spin_lock(&tcon->stat_lock);
  		tcon->bytes_written += bytes;
  		spin_unlock(&tcon->stat_lock);
  	}
  }
96daf2b09   Steve French   [CIFS] Rename thr...
1482
  static inline void cifs_stats_bytes_read(struct cifs_tcon *tcon,
a45443475   Steve French   CIFS: Reduce CONF...
1483
1484
1485
1486
1487
1488
  					 unsigned int bytes)
  {
  	spin_lock(&tcon->stat_lock);
  	tcon->bytes_read += bytes;
  	spin_unlock(&tcon->stat_lock);
  }
a45443475   Steve French   CIFS: Reduce CONF...
1489

2b84a36c5   Jeff Layton   cifs: allow for d...
1490
1491
  
  /*
44d22d846   Jeff Layton   cifs: add a callb...
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
   * This is the prototype for the mid receive function. This function is for
   * receiving the rest of the SMB frame, starting with the WordCount (which is
   * just after the MID in struct smb_hdr). Note:
   *
   * - This will be called by cifsd, with no locks held.
   * - The mid will still be on the pending_mid_q.
   * - mid->resp_buf will point to the current buffer.
   *
   * Returns zero on a successful receive, or an error. The receive state in
   * the TCP_Server_Info will also be updated.
   */
  typedef int (mid_receive_t)(struct TCP_Server_Info *server,
  			    struct mid_q_entry *mid);
  
  /*
   * This is the prototype for the mid callback function. This is called once the
   * mid has been received off of the socket. When creating one, take special
   * care to avoid deadlocks. Things to bear in mind:
2b84a36c5   Jeff Layton   cifs: allow for d...
1510
   *
3c1105df6   Jeff Layton   cifs: don't call ...
1511
1512
   * - it will be called by cifsd, with no locks held
   * - the mid will be removed from any lists
2b84a36c5   Jeff Layton   cifs: allow for d...
1513
1514
   */
  typedef void (mid_callback_t)(struct mid_q_entry *mid);
9b7c18a2d   Pavel Shilovsky   CIFS: Add mid han...
1515
1516
1517
1518
1519
1520
  /*
   * This is the protopyte for mid handle function. This is called once the mid
   * has been recognized after decryption of the message.
   */
  typedef int (mid_handle_t)(struct TCP_Server_Info *server,
  			    struct mid_q_entry *mid);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1521
1522
1523
  /* one of these for every pending CIFS request to the server */
  struct mid_q_entry {
  	struct list_head qhead;	/* mids waiting on reply from this server */
696e420bb   Lars Persson   cifs: Fix use aft...
1524
  	struct kref refcount;
2dc7e1c03   Pavel Shilovsky   CIFS: Make transp...
1525
  	struct TCP_Server_Info *server;	/* server corresponding to this mid */
7c9421e1a   Pavel Shilovsky   CIFS: Change mid_...
1526
  	__u64 mid;		/* multiplex id */
c781af7e0   Pavel Shilovsky   CIFS: Do not skip...
1527
  	__u16 credits;		/* number of credits consumed by this mid */
86a7964be   Pavel Shilovsky   CIFS: Fix NULL po...
1528
  	__u16 credits_received;	/* number of credits from the response */
7c9421e1a   Pavel Shilovsky   CIFS: Change mid_...
1529
  	__u32 pid;		/* process id */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1530
  	__u32 sequence_number;  /* for CIFS signing */
1047abc15   Steve French   [CIFS] CIFS Stats...
1531
1532
1533
1534
1535
  	unsigned long when_alloc;  /* when mid was created */
  #ifdef CONFIG_CIFS_STATS2
  	unsigned long when_sent; /* time when smb send finished */
  	unsigned long when_received; /* when demux complete (taken off wire) */
  #endif
44d22d846   Jeff Layton   cifs: add a callb...
1536
  	mid_receive_t *receive; /* call receive callback */
2b84a36c5   Jeff Layton   cifs: allow for d...
1537
  	mid_callback_t *callback; /* call completion callback */
9b7c18a2d   Pavel Shilovsky   CIFS: Add mid han...
1538
  	mid_handle_t *handle; /* call handle mid callback */
2b84a36c5   Jeff Layton   cifs: allow for d...
1539
  	void *callback_data;	  /* general purpose pointer for callback */
f1f27ad74   Vincent Whitchurch   CIFS: Fix task st...
1540
  	struct task_struct *creator;
d4e4854fd   Pavel Shilovsky   CIFS: Separate pr...
1541
  	void *resp_buf;		/* pointer to received SMB header */
e19b2bc07   Ronnie Sahlberg   cifs: add resp_bu...
1542
  	unsigned int resp_buf_size;
7c9421e1a   Pavel Shilovsky   CIFS: Change mid_...
1543
  	int mid_state;	/* wish this were enum but can not pass to wait_event */
38bd49064   Sachin Prabhu   Handle mismatched...
1544
  	unsigned int mid_flags;
7c9421e1a   Pavel Shilovsky   CIFS: Change mid_...
1545
  	__le16 command;		/* smb command code */
8a26f0f78   Pavel Shilovsky   CIFS: Fix credits...
1546
  	unsigned int optype;	/* operation type */
7c9421e1a   Pavel Shilovsky   CIFS: Change mid_...
1547
  	bool large_buf:1;	/* if valid response, is pointer to large buf */
4b18f2a9c   Steve French   [CIFS] convert us...
1548
1549
  	bool multiRsp:1;	/* multiple trans2 responses for one request  */
  	bool multiEnd:1;	/* both received */
4326ed2f6   Pavel Shilovsky   CIFS: Decrypt and...
1550
  	bool decrypted:1;	/* decrypted entry */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1551
  };
38bd49064   Sachin Prabhu   Handle mismatched...
1552
1553
1554
1555
  struct close_cancelled_open {
  	struct cifs_fid         fid;
  	struct cifs_tcon        *tcon;
  	struct work_struct      work;
87bc2376f   Ronnie Sahlberg   smb3: add debug m...
1556
1557
  	__u64 mid;
  	__u16 cmd;
38bd49064   Sachin Prabhu   Handle mismatched...
1558
  };
789e66612   Steve French   [CIFS] Cleanup us...
1559
1560
  /*	Make code in transport.c a little cleaner by moving
  	update of optional stats into function below */
789e66612   Steve French   [CIFS] Cleanup us...
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
  static inline void cifs_in_send_inc(struct TCP_Server_Info *server)
  {
  	atomic_inc(&server->in_send);
  }
  
  static inline void cifs_in_send_dec(struct TCP_Server_Info *server)
  {
  	atomic_dec(&server->in_send);
  }
  
  static inline void cifs_num_waiters_inc(struct TCP_Server_Info *server)
  {
  	atomic_inc(&server->num_waiters);
  }
  
  static inline void cifs_num_waiters_dec(struct TCP_Server_Info *server)
  {
  	atomic_dec(&server->num_waiters);
  }
1ae9a5a55   Steve French   smb3: dump in_sen...
1580
  #ifdef CONFIG_CIFS_STATS2
789e66612   Steve French   [CIFS] Cleanup us...
1581
1582
1583
1584
1585
  static inline void cifs_save_when_sent(struct mid_q_entry *mid)
  {
  	mid->when_sent = jiffies;
  }
  #else
789e66612   Steve French   [CIFS] Cleanup us...
1586
1587
1588
1589
  static inline void cifs_save_when_sent(struct mid_q_entry *mid)
  {
  }
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1590

ff5dbd9ea   Steve French   [CIFS] Change not...
1591
1592
  /* for pending dnotify requests */
  struct dir_notify_req {
13cd4b7f7   Steve French   [CIFS] Various sm...
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
  	struct list_head lhead;
  	__le16 Pid;
  	__le16 PidHigh;
  	__u16 Mid;
  	__u16 Tid;
  	__u16 Uid;
  	__u16 netfid;
  	__u32 filter; /* CompletionFilter (for multishot) */
  	int multishot;
  	struct file *pfile;
ff5dbd9ea   Steve French   [CIFS] Change not...
1603
  };
366781c19   Steve French   [CIFS] DFS build ...
1604
1605
  struct dfs_info3_param {
  	int flags; /* DFSREF_REFERRAL_SERVER, DFSREF_STORAGE_SERVER*/
8aad018b6   Igor Mammedov   [CIFS] Fix mixed ...
1606
  	int path_consumed;
366781c19   Steve French   [CIFS] DFS build ...
1607
1608
1609
1610
  	int server_type;
  	int ref_flag;
  	char *path_name;
  	char *node_name;
e7b602f43   Paulo Alcantara   cifs: Save TTL va...
1611
  	int ttl;
366781c19   Steve French   [CIFS] DFS build ...
1612
  };
cc0bad755   Jeff Layton   cifs: add new cif...
1613
1614
1615
1616
1617
1618
  /*
   * common struct for holding inode info when searching for or updating an
   * inode with new info
   */
  
  #define CIFS_FATTR_DFS_REFERRAL		0x1
0b8f18e35   Jeff Layton   cifs: convert cif...
1619
1620
  #define CIFS_FATTR_DELETE_PENDING	0x2
  #define CIFS_FATTR_NEED_REVAL		0x4
3d6943803   Jeff Layton   cifs: guard again...
1621
  #define CIFS_FATTR_INO_COLLISION	0x8
74d290da4   Jim McDonough   [CIFS] Provide sa...
1622
  #define CIFS_FATTR_UNKNOWN_NLINK	0x10
7ea884c77   Steve French   smb3: Fix root di...
1623
  #define CIFS_FATTR_FAKE_ROOT_INO	0x20
cc0bad755   Jeff Layton   cifs: add new cif...
1624
1625
1626
1627
1628
1629
1630
  
  struct cifs_fattr {
  	u32		cf_flags;
  	u32		cf_cifsattrs;
  	u64		cf_uniqueid;
  	u64		cf_eof;
  	u64		cf_bytes;
20054bd65   Jeff Layton   cifs: use Creatio...
1631
  	u64		cf_createtime;
4a2c8cf56   Eric W. Biederman   cifs: Convert str...
1632
1633
  	kuid_t		cf_uid;
  	kgid_t		cf_gid;
cc0bad755   Jeff Layton   cifs: add new cif...
1634
1635
1636
1637
  	umode_t		cf_mode;
  	dev_t		cf_rdev;
  	unsigned int	cf_nlink;
  	unsigned int	cf_dtype;
95390201e   Arnd Bergmann   cifs: use timespe...
1638
1639
1640
  	struct timespec64 cf_atime;
  	struct timespec64 cf_mtime;
  	struct timespec64 cf_ctime;
046aca3c2   Paulo Alcantara (SUSE)   cifs: Optimize re...
1641
  	u32             cf_cifstag;
cc0bad755   Jeff Layton   cifs: add new cif...
1642
  };
366781c19   Steve French   [CIFS] DFS build ...
1643
1644
1645
1646
1647
  static inline void free_dfs_info_param(struct dfs_info3_param *param)
  {
  	if (param) {
  		kfree(param->path_name);
  		kfree(param->node_name);
366781c19   Steve French   [CIFS] DFS build ...
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
  	}
  }
  
  static inline void free_dfs_info_array(struct dfs_info3_param *param,
  				       int number_of_items)
  {
  	int i;
  	if ((number_of_items == 0) || (param == NULL))
  		return;
  	for (i = 0; i < number_of_items; i++) {
  		kfree(param[i].path_name);
  		kfree(param[i].node_name);
  	}
  	kfree(param);
  }
9a66396f1   Pavel Shilovsky   CIFS: Fix error p...
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
  static inline bool is_interrupt_error(int error)
  {
  	switch (error) {
  	case -EINTR:
  	case -ERESTARTSYS:
  	case -ERESTARTNOHAND:
  	case -ERESTARTNOINTR:
  		return true;
  	}
  	return false;
  }
  
  static inline bool is_retryable_error(int error)
  {
  	if (is_interrupt_error(error) || error == -EAGAIN)
  		return true;
  	return false;
  }
86f740f2a   Aurelien Aptel   cifs: fix rename(...
1681
1682
1683
1684
1685
  
  /* cifs_get_writable_file() flags */
  #define FIND_WR_ANY         0
  #define FIND_WR_FSUID_ONLY  1
  #define FIND_WR_WITH_DELETE 2
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1686
1687
1688
1689
1690
  #define   MID_FREE 0
  #define   MID_REQUEST_ALLOCATED 1
  #define   MID_REQUEST_SUBMITTED 2
  #define   MID_RESPONSE_RECEIVED 4
  #define   MID_RETRY_NEEDED      8 /* session closed while this request out */
71823baff   Jeff Layton   cifs: don't alway...
1691
  #define   MID_RESPONSE_MALFORMED 0x10
3c1105df6   Jeff Layton   cifs: don't call ...
1692
  #define   MID_SHUTDOWN		 0x20
ec637e3ff   Steve French   [CIFS] Avoid extr...
1693

38bd49064   Sachin Prabhu   Handle mismatched...
1694
1695
  /* Flags */
  #define   MID_WAIT_CANCELLED	 1 /* Cancelled while waiting for response */
ddf83afb9   Ronnie Sahlberg   cifs: add a warni...
1696
  #define   MID_DELETED            2 /* Mid has been dequeued/deleted */
38bd49064   Sachin Prabhu   Handle mismatched...
1697

ec637e3ff   Steve French   [CIFS] Avoid extr...
1698
1699
1700
1701
1702
  /* Types of response buffer returned from SendReceive2 */
  #define   CIFS_NO_BUFFER        0    /* Response buffer not returned */
  #define   CIFS_SMALL_BUFFER     1
  #define   CIFS_LARGE_BUFFER     2
  #define   CIFS_IOVEC            4    /* array of response buffers */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1703

133672efb   Steve French   [CIFS] Fix buffer...
1704
  /* Type of Request to SendReceive2 */
7749981ec   Jeff Layton   cifs: remove code...
1705
  #define   CIFS_BLOCKING_OP      1    /* operation can block */
392e1c5dc   Ronnie Sahlberg   cifs: rename and ...
1706
  #define   CIFS_NON_BLOCKING     2    /* do not block waiting for credits */
7749981ec   Jeff Layton   cifs: remove code...
1707
  #define   CIFS_TIMEOUT_MASK 0x003    /* only one of above set in req */
133672efb   Steve French   [CIFS] Fix buffer...
1708
1709
  #define   CIFS_LOG_ERROR    0x010    /* log NT STATUS if non-zero */
  #define   CIFS_LARGE_BUF_OP 0x020    /* large request buffer */
392e1c5dc   Ronnie Sahlberg   cifs: rename and ...
1710
  #define   CIFS_NO_RSP_BUF   0x040    /* no response buffer required */
133672efb   Steve French   [CIFS] Fix buffer...
1711

a891f0f89   Pavel Shilovsky   CIFS: Extend cred...
1712
1713
1714
  /* Type of request operation */
  #define   CIFS_ECHO_OP      0x080    /* echo request */
  #define   CIFS_OBREAK_OP   0x0100    /* oplock break request */
ec2e4523f   Pavel Shilovsky   CIFS: Add capabil...
1715
1716
  #define   CIFS_NEG_OP      0x0200    /* negotiate request */
  #define   CIFS_OP_MASK     0x0380    /* mask request type */
7fb8986e7   Pavel Shilovsky   CIFS: Add capabil...
1717

cb7e9eabb   Pavel Shilovsky   CIFS: Use multicr...
1718
  #define   CIFS_HAS_CREDITS 0x0400    /* already has credits */
7fb8986e7   Pavel Shilovsky   CIFS: Add capabil...
1719
  #define   CIFS_TRANSFORM_REQ 0x0800    /* transform request before sending */
d69cb728e   Ronnie Sahlberg   cifs: fix credits...
1720
  #define   CIFS_NO_SRV_RSP    0x1000    /* there is no server response */
a891f0f89   Pavel Shilovsky   CIFS: Extend cred...
1721

3979877e5   Steve French   [CIFS] Support fo...
1722
1723
1724
1725
1726
1727
1728
1729
  /* Security Flags: indicate type of session setup needed */
  #define   CIFSSEC_MAY_SIGN	0x00001
  #define   CIFSSEC_MAY_NTLM	0x00002
  #define   CIFSSEC_MAY_NTLMV2	0x00004
  #define   CIFSSEC_MAY_KRB5	0x00008
  #ifdef CONFIG_CIFS_WEAK_PW_HASH
  #define   CIFSSEC_MAY_LANMAN	0x00010
  #define   CIFSSEC_MAY_PLNTXT	0x00020
516897a20   Steve French   [CIFS] fix build ...
1730
1731
1732
  #else
  #define   CIFSSEC_MAY_LANMAN    0
  #define   CIFSSEC_MAY_PLNTXT    0
3979877e5   Steve French   [CIFS] Support fo...
1733
1734
  #endif /* weak passwords */
  #define   CIFSSEC_MAY_SEAL	0x00040 /* not supported yet */
ac6839246   Steve French   [CIFS] Allow raw ...
1735
  #define   CIFSSEC_MAY_NTLMSSP	0x00080 /* raw ntlmssp with ntlmv2 */
3979877e5   Steve French   [CIFS] Support fo...
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
  
  #define   CIFSSEC_MUST_SIGN	0x01001
  /* note that only one of the following can be set so the
  result of setting MUST flags more than once will be to
  require use of the stronger protocol */
  #define   CIFSSEC_MUST_NTLM	0x02002
  #define   CIFSSEC_MUST_NTLMV2	0x04004
  #define   CIFSSEC_MUST_KRB5	0x08008
  #ifdef CONFIG_CIFS_WEAK_PW_HASH
  #define   CIFSSEC_MUST_LANMAN	0x10010
  #define   CIFSSEC_MUST_PLNTXT	0x20020
0d3a01fad   Jeff Layton   [CIFS] Break up u...
1747
  #ifdef CONFIG_CIFS_UPCALL
20d1752f3   Chuck Ebbert   [CIFS] Re-enable ...
1748
  #define   CIFSSEC_MASK          0xBF0BF /* allows weak security but also krb5 */
0d3a01fad   Jeff Layton   [CIFS] Break up u...
1749
  #else
20d1752f3   Chuck Ebbert   [CIFS] Re-enable ...
1750
  #define   CIFSSEC_MASK          0xB70B7 /* current flags supported if weak */
016ec75f1   Steve French   [CIFS] missing #e...
1751
  #endif /* UPCALL */
0d3a01fad   Jeff Layton   [CIFS] Break up u...
1752
  #else /* do not allow weak pw hash */
88a4412b7   Steve French   [CIFS] Fix build ...
1753
1754
  #define   CIFSSEC_MUST_LANMAN	0
  #define   CIFSSEC_MUST_PLNTXT	0
0d3a01fad   Jeff Layton   [CIFS] Break up u...
1755
  #ifdef CONFIG_CIFS_UPCALL
ac6839246   Steve French   [CIFS] Allow raw ...
1756
  #define   CIFSSEC_MASK          0x8F08F /* flags supported if no weak allowed */
d38d8c74c   Steve French   [CIFS] whitespace...
1757
  #else
ac6839246   Steve French   [CIFS] Allow raw ...
1758
  #define	  CIFSSEC_MASK          0x87087 /* flags supported if no weak allowed */
016ec75f1   Steve French   [CIFS] missing #e...
1759
  #endif /* UPCALL */
3979877e5   Steve French   [CIFS] Support fo...
1760
1761
  #endif /* WEAK_PW_HASH */
  #define   CIFSSEC_MUST_SEAL	0x40040 /* not supported yet */
ac6839246   Steve French   [CIFS] Allow raw ...
1762
  #define   CIFSSEC_MUST_NTLMSSP	0x80080 /* raw ntlmssp with ntlmv2 */
3979877e5   Steve French   [CIFS] Support fo...
1763

896a8fc25   Jeff Layton   cifs: update the ...
1764
  #define   CIFSSEC_DEF (CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_NTLMSSP)
ef571cadd   Shirish Pargaonkar   [CIFS] Fix warnin...
1765
  #define   CIFSSEC_MAX (CIFSSEC_MUST_SIGN | CIFSSEC_MUST_NTLMV2)
ac6839246   Steve French   [CIFS] Allow raw ...
1766
  #define   CIFSSEC_AUTH_MASK (CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_PLNTXT | CIFSSEC_MAY_KRB5 | CIFSSEC_MAY_NTLMSSP)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
  /*
   *****************************************************************
   * All constants go here
   *****************************************************************
   */
  
  #define UID_HASH (16)
  
  /*
   * Note that ONE module should define _DECLARE_GLOBALS_HERE to cause the
   * following to be declared.
   */
  
  /****************************************************************************
   *  Locking notes.  All updates to global variables and lists should be
   *                  protected by spinlocks or semaphores.
   *
   *  Spinlocks
   *  ---------
   *  GlobalMid_Lock protects:
   *	list operations on pending_mid_q and oplockQ
   *      updates to XID counters, multiplex id  and SMB sequence numbers
655258028   Steve French   cifs: minor docum...
1789
   *      list operations on global DnotifyReqList
3afca265b   Steve French   Clarify locking o...
1790
1791
1792
   *  tcp_ses_lock protects:
   *	list operations on tcp and SMB session lists
   *  tcon->open_file_lock protects the list of open files hanging off the tcon
487317c99   Ronnie Sahlberg   cifs: add spinloc...
1793
   *  inode->open_file_lock protects the openFileList hanging off the inode
3afca265b   Steve French   Clarify locking o...
1794
   *  cfile->file_info_lock protects counters and fields in cifs file struct
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1795
1796
1797
   *  f_owner.lock protects certain per file struct operations
   *  mapping->page_lock protects certain per page operations
   *
487317c99   Ronnie Sahlberg   cifs: add spinloc...
1798
1799
1800
   *  Note that the cifs_tcon.open_file_lock should be taken before
   *  not after the cifsInodeInfo.open_file_lock
   *
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1801
1802
1803
1804
   *  Semaphores
   *  ----------
   *  sesSem     operations on smb session
   *  tconSem    operations on tree connection
d38d8c74c   Steve French   [CIFS] whitespace...
1805
   *  fh_sem      file handle reconnection operations
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1806
1807
1808
1809
1810
1811
1812
1813
   *
   ****************************************************************************/
  
  #ifdef DECLARE_GLOBALS_HERE
  #define GLOBAL_EXTERN
  #else
  #define GLOBAL_EXTERN extern
  #endif
e7ddee903   Jeff Layton   cifs: disable sha...
1814
1815
  /*
   * the list of TCP_Server_Info structures, ie each of the sockets
fb3960166   Steve French   [CIFS] remove unu...
1816
   * connecting our client to a distinct server (ip address), is
e7ddee903   Jeff Layton   cifs: disable sha...
1817
   * chained together by cifs_tcp_ses_list. The list of all our SMB
fb3960166   Steve French   [CIFS] remove unu...
1818
   * sessions (and from that the tree connections) can be found
e7ddee903   Jeff Layton   cifs: disable sha...
1819
1820
1821
   * by iterating over cifs_tcp_ses_list
   */
  GLOBAL_EXTERN struct list_head		cifs_tcp_ses_list;
f1987b44f   Jeff Layton   cifs: reinstate s...
1822
1823
1824
  /*
   * This lock protects the cifs_tcp_ses_list, the list of smb sessions per
   * tcp session, and the list of tcon's per smb session. It also protects
d92c7ce41   Steve French   cifs: minor updat...
1825
1826
   * the reference counters for the server, smb session, and tcon. It also
   * protects some fields in the TCP_Server_Info struct such as dstaddr. Finally,
f1987b44f   Jeff Layton   cifs: reinstate s...
1827
   * changes to the tcon->tidStatus should be done while holding this lock.
3afca265b   Steve French   Clarify locking o...
1828
1829
1830
   * generally the locks should be taken in order tcp_ses_lock before
   * tcon->open_file_lock and that before file->file_info_lock since the
   * structure order is cifs_socket-->cifs_ses-->cifs_tcon-->cifs_file
f1987b44f   Jeff Layton   cifs: reinstate s...
1831
   */
3f9bcca78   Suresh Jayaraman   cifs: convert cif...
1832
  GLOBAL_EXTERN spinlock_t		cifs_tcp_ses_lock;
ddb4cbfc5   Steve French   [CIFS] Do not att...
1833

0eff0e267   Steve French   Remove unused CIF...
1834
  #ifdef CONFIG_CIFS_DNOTIFY_EXPERIMENTAL /* unused temporarily */
99ee4dbd7   Steve French   [CIFS] Remove som...
1835
1836
1837
1838
  /* Outstanding dir notify requests */
  GLOBAL_EXTERN struct list_head GlobalDnotifyReqList;
  /* DirNotify response queue */
  GLOBAL_EXTERN struct list_head GlobalDnotifyRsp_Q;
0eff0e267   Steve French   Remove unused CIF...
1839
  #endif /* was needed for dnotify, and will be needed for inotify when VFS fix */
ff5dbd9ea   Steve French   [CIFS] Change not...
1840

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1841
1842
1843
1844
  /*
   * Global transaction id (XID) information
   */
  GLOBAL_EXTERN unsigned int GlobalCurrentXid;	/* protected by GlobalMid_Sem */
254e55ed0   Steve French   CIFS] Support for...
1845
  GLOBAL_EXTERN unsigned int GlobalTotalActiveXid; /* prot by GlobalMid_Sem */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1846
  GLOBAL_EXTERN unsigned int GlobalMaxActiveXid;	/* prot by GlobalMid_Sem */
254e55ed0   Steve French   CIFS] Support for...
1847
1848
  GLOBAL_EXTERN spinlock_t GlobalMid_Lock;  /* protects above & list operations */
  					  /* on midQ entries */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1849
1850
1851
1852
1853
1854
1855
1856
  /*
   *  Global counters, updated atomically
   */
  GLOBAL_EXTERN atomic_t sesInfoAllocCount;
  GLOBAL_EXTERN atomic_t tconInfoAllocCount;
  GLOBAL_EXTERN atomic_t tcpSesAllocCount;
  GLOBAL_EXTERN atomic_t tcpSesReconnectCount;
  GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
aaa9bbe03   Steve French   [CIFS] remove unu...
1857
  /* Various Debug counters */
4498eed50   Steve French   [CIFS] Add extend...
1858
1859
1860
1861
  GLOBAL_EXTERN atomic_t bufAllocCount;    /* current number allocated  */
  #ifdef CONFIG_CIFS_STATS2
  GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
  GLOBAL_EXTERN atomic_t totSmBufAllocCount;
00778e229   Steve French   smb3: add way to ...
1862
  extern unsigned int slow_rsp_threshold; /* number of secs before logging */
4498eed50   Steve French   [CIFS] Add extend...
1863
1864
  #endif
  GLOBAL_EXTERN atomic_t smBufAllocCount;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1865
1866
1867
  GLOBAL_EXTERN atomic_t midCount;
  
  /* Misc globals */
f92a720ee   Steve French   cifs: allow disab...
1868
1869
1870
  extern bool enable_oplocks; /* enable or disable oplocks */
  extern bool lookupCacheEnabled;
  extern unsigned int global_secflags;	/* if on, session setup sent
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1871
  				with more secure ntlmssp2 challenge/resp */
f92a720ee   Steve French   cifs: allow disab...
1872
  extern unsigned int sign_CIFS_PDUs;  /* enable smb packet signing */
29e279230   Steve French   smb3.1.1: add new...
1873
  extern bool enable_gcm_256; /* allow optional negotiate of strongest signing (aes-gcm-256) */
fbfd0b46a   Steve French   smb3.1.1: add new...
1874
  extern bool require_gcm_256; /* require use of strongest signing (aes-gcm-256) */
f92a720ee   Steve French   cifs: allow disab...
1875
1876
1877
1878
1879
1880
  extern bool linuxExtEnabled;/*enable Linux/Unix CIFS extensions*/
  extern unsigned int CIFSMaxBufSize;  /* max size not including hdr */
  extern unsigned int cifs_min_rcv;    /* min size of big ntwrk buf pool */
  extern unsigned int cifs_min_small;  /* min size of small buf pool */
  extern unsigned int cifs_max_pending; /* MAX requests at once to server*/
  extern bool disable_legacy_dialects;  /* forbid vers=1.0 and vers=2.0 mounts */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1881

4d79dba0e   Shirish Pargaonkar   cifs: Add idmap k...
1882
1883
1884
1885
  GLOBAL_EXTERN struct rb_root uidtree;
  GLOBAL_EXTERN struct rb_root gidtree;
  GLOBAL_EXTERN spinlock_t siduidlock;
  GLOBAL_EXTERN spinlock_t sidgidlock;
21fed0d5b   Shirish Pargaonkar   cifs: Add data st...
1886
1887
1888
1889
  GLOBAL_EXTERN struct rb_root siduidtree;
  GLOBAL_EXTERN struct rb_root sidgidtree;
  GLOBAL_EXTERN spinlock_t uidsidlock;
  GLOBAL_EXTERN spinlock_t gidsidlock;
4d79dba0e   Shirish Pargaonkar   cifs: Add idmap k...
1890

9b6469724   Tejun Heo   cifs: use workque...
1891
  void cifs_oplock_break(struct work_struct *work);
b98749cac   Aurelien Aptel   CIFS: keep FileIn...
1892
  void cifs_queue_oplock_break(struct cifsFileInfo *cfile);
3b7433b8a   Linus Torvalds   Merge branch 'for...
1893

3bc303c25   Jeff Layton   cifs: convert opl...
1894
  extern const struct slow_work_ops cifs_oplock_break_ops;
da472fc84   Jeff Layton   cifs: add new cif...
1895
  extern struct workqueue_struct *cifsiod_wq;
35cf94a39   Steve French   smb3: allow paral...
1896
  extern struct workqueue_struct *decrypt_wq;
32546a958   Ronnie Sahlberg   cifs: move cifsFi...
1897
  extern struct workqueue_struct *fileinfo_put_wq;
3998e6b87   Rabin Vincent   CIFS: fix oplock ...
1898
  extern struct workqueue_struct *cifsoplockd_wq;
3d22462ae   Jeff Layton   cifs: stuff the f...
1899
  extern __u32 cifs_lock_secret;
abd2e44dc   Suresh Jayaraman   cifs: guard cifsg...
1900

2dc7e1c03   Pavel Shilovsky   CIFS: Make transp...
1901
  extern mempool_t *cifs_mid_poolp;
23db65f51   Jeff Layton   cifs: add a smb_v...
1902
1903
1904
1905
  /* Operations for different SMB versions */
  #define SMB1_VERSION_STRING	"1.0"
  extern struct smb_version_operations smb1_operations;
  extern struct smb_version_values smb1_values;
e4aa25e78   Steve French   [CIFS] Fix SMB2 n...
1906
  #define SMB20_VERSION_STRING	"2.0"
53ef1016f   Pavel Shilovsky   CIFS: Store lease...
1907
  extern struct smb_version_operations smb20_operations;
e4aa25e78   Steve French   [CIFS] Fix SMB2 n...
1908
  extern struct smb_version_values smb20_values;
1080ef758   Steve French   CIFS: Introduce S...
1909
1910
1911
  #define SMB21_VERSION_STRING	"2.1"
  extern struct smb_version_operations smb21_operations;
  extern struct smb_version_values smb21_values;
9764c02fc   Steve French   SMB3: Add support...
1912
1913
1914
1915
  #define SMBDEFAULT_VERSION_STRING "default"
  extern struct smb_version_values smbdefault_values;
  #define SMB3ANY_VERSION_STRING "3"
  extern struct smb_version_values smb3any_values;
e4aa25e78   Steve French   [CIFS] Fix SMB2 n...
1916
  #define SMB30_VERSION_STRING	"3.0"
38107d45c   Steve French   Do not send SMB2 ...
1917
  extern struct smb_version_operations smb30_operations;
e4aa25e78   Steve French   [CIFS] Fix SMB2 n...
1918
  extern struct smb_version_values smb30_values;
20b6d8b42   Steve French   Add SMB3.02 diale...
1919
  #define SMB302_VERSION_STRING	"3.02"
4a3b38aec   Kenneth D'souza   Add vers=3.0.2 as...
1920
  #define ALT_SMB302_VERSION_STRING "3.0.2"
20b6d8b42   Steve French   Add SMB3.02 diale...
1921
1922
  /*extern struct smb_version_operations smb302_operations;*/ /* not needed yet */
  extern struct smb_version_values smb302_values;
5f7fbf733   Steve French   Allow parsing ver...
1923
  #define SMB311_VERSION_STRING	"3.1.1"
aab1893d5   Steve French   Add SMB3.11 mount...
1924
1925
  #define ALT_SMB311_VERSION_STRING "3.11"
  extern struct smb_version_operations smb311_operations;
5f7fbf733   Steve French   Allow parsing ver...
1926
  extern struct smb_version_values smb311_values;
b8f7442bc   Aurelien Aptel   CIFS: refactor ci...
1927

0b0430c6a   Kenneth D'souza   cifs: Add get_sec...
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
  static inline char *get_security_type_str(enum securityEnum sectype)
  {
  	switch (sectype) {
  	case RawNTLMSSP:
  		return "RawNTLMSSP";
  	case Kerberos:
  		return "Kerberos";
  	case NTLMv2:
  		return "NTLMv2";
  	case NTLM:
  		return "NTLM";
  	case LANMAN:
  		return "LANMAN";
  	default:
  		return "Unknown";
  	}
  }
b8f7442bc   Aurelien Aptel   CIFS: refactor ci...
1945
1946
1947
1948
  static inline bool is_smb1_server(struct TCP_Server_Info *server)
  {
  	return strcmp(server->vals->version_string, SMB1_VERSION_STRING) == 0;
  }
e183785f2   Paulo Alcantara   cifs: fix check o...
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
  static inline bool is_tcon_dfs(struct cifs_tcon *tcon)
  {
  	/*
  	 * For SMB1, see MS-CIFS 2.4.55 SMB_COM_TREE_CONNECT_ANDX (0x75) and MS-CIFS 3.3.4.4 DFS
  	 * Subsystem Notifies That a Share Is a DFS Share.
  	 *
  	 * For SMB2+, see MS-SMB2 2.2.10 SMB2 TREE_CONNECT Response and MS-SMB2 3.3.4.14 Server
  	 * Application Updates a Share.
  	 */
  	if (!tcon || !tcon->ses || !tcon->ses->server)
  		return false;
  	return is_smb1_server(tcon->ses->server) ? tcon->Flags & SMB_SHARE_IS_IN_DFS :
  		tcon->share_flags & (SHI1005_FLAGS_DFS | SHI1005_FLAGS_DFS_ROOT);
  }
abd2e44dc   Suresh Jayaraman   cifs: guard cifsg...
1963
  #endif	/* _CIFS_GLOB_H */