aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/cifsglob.h
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2012-10-09 15:20:05 -0400
committerThomas Gleixner <tglx@linutronix.de>2012-10-09 15:20:05 -0400
commitdb8c246937713e60b7628661ccc187eeb81f2bae (patch)
tree6351e8bca23eef40fce85396d1c6f6cfffbd4b66 /fs/cifs/cifsglob.h
parentc5f66e99b7cb091e3d51ae8e8156892e8feb7fa3 (diff)
parent28f2b02bc581ffc835bc1691b18d03f62fcf0395 (diff)
Merge branch 'fortglx/3.7/time' of git://git.linaro.org/people/jstultz/linux into timers/core
Diffstat (limited to 'fs/cifs/cifsglob.h')
-rw-r--r--fs/cifs/cifsglob.h202
1 files changed, 169 insertions, 33 deletions
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 6df0cbe1cbc..977dc0e85cc 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -22,11 +22,15 @@
22#include <linux/in.h> 22#include <linux/in.h>
23#include <linux/in6.h> 23#include <linux/in6.h>
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/mempool.h>
25#include <linux/workqueue.h> 26#include <linux/workqueue.h>
26#include "cifs_fs_sb.h" 27#include "cifs_fs_sb.h"
27#include "cifsacl.h" 28#include "cifsacl.h"
28#include <crypto/internal/hash.h> 29#include <crypto/internal/hash.h>
29#include <linux/scatterlist.h> 30#include <linux/scatterlist.h>
31#ifdef CONFIG_CIFS_SMB2
32#include "smb2pdu.h"
33#endif
30 34
31/* 35/*
32 * The sizes of various internal tables and strings 36 * The sizes of various internal tables and strings
@@ -72,6 +76,9 @@
72/* (max path length + 1 for null) * 2 for unicode */ 76/* (max path length + 1 for null) * 2 for unicode */
73#define MAX_NAME 514 77#define MAX_NAME 514
74 78
79/* SMB echo "timeout" -- FIXME: tunable? */
80#define SMB_ECHO_INTERVAL (60 * HZ)
81
75#include "cifspdu.h" 82#include "cifspdu.h"
76 83
77#ifndef XATTR_DOS_ATTRIB 84#ifndef XATTR_DOS_ATTRIB
@@ -160,6 +167,10 @@ struct mid_q_entry;
160struct TCP_Server_Info; 167struct TCP_Server_Info;
161struct cifsFileInfo; 168struct cifsFileInfo;
162struct cifs_ses; 169struct cifs_ses;
170struct cifs_tcon;
171struct dfs_info3_param;
172struct cifs_fattr;
173struct smb_vol;
163 174
164struct smb_version_operations { 175struct smb_version_operations {
165 int (*send_cancel)(struct TCP_Server_Info *, void *, 176 int (*send_cancel)(struct TCP_Server_Info *, void *,
@@ -168,12 +179,17 @@ struct smb_version_operations {
168 /* setup request: allocate mid, sign message */ 179 /* setup request: allocate mid, sign message */
169 int (*setup_request)(struct cifs_ses *, struct kvec *, unsigned int, 180 int (*setup_request)(struct cifs_ses *, struct kvec *, unsigned int,
170 struct mid_q_entry **); 181 struct mid_q_entry **);
182 /* setup async request: allocate mid, sign message */
183 int (*setup_async_request)(struct TCP_Server_Info *, struct kvec *,
184 unsigned int, struct mid_q_entry **);
171 /* check response: verify signature, map error */ 185 /* check response: verify signature, map error */
172 int (*check_receive)(struct mid_q_entry *, struct TCP_Server_Info *, 186 int (*check_receive)(struct mid_q_entry *, struct TCP_Server_Info *,
173 bool); 187 bool);
174 void (*add_credits)(struct TCP_Server_Info *, const unsigned int); 188 void (*add_credits)(struct TCP_Server_Info *, const unsigned int,
189 const int);
175 void (*set_credits)(struct TCP_Server_Info *, const int); 190 void (*set_credits)(struct TCP_Server_Info *, const int);
176 int * (*get_credits_field)(struct TCP_Server_Info *); 191 int * (*get_credits_field)(struct TCP_Server_Info *, const int);
192 unsigned int (*get_credits)(struct mid_q_entry *);
177 __u64 (*get_next_mid)(struct TCP_Server_Info *); 193 __u64 (*get_next_mid)(struct TCP_Server_Info *);
178 /* data offset from read response message */ 194 /* data offset from read response message */
179 unsigned int (*read_data_offset)(char *); 195 unsigned int (*read_data_offset)(char *);
@@ -184,9 +200,62 @@ struct smb_version_operations {
184 /* find mid corresponding to the response message */ 200 /* find mid corresponding to the response message */
185 struct mid_q_entry * (*find_mid)(struct TCP_Server_Info *, char *); 201 struct mid_q_entry * (*find_mid)(struct TCP_Server_Info *, char *);
186 void (*dump_detail)(void *); 202 void (*dump_detail)(void *);
203 void (*clear_stats)(struct cifs_tcon *);
204 void (*print_stats)(struct seq_file *m, struct cifs_tcon *);
187 /* verify the message */ 205 /* verify the message */
188 int (*check_message)(char *, unsigned int); 206 int (*check_message)(char *, unsigned int);
189 bool (*is_oplock_break)(char *, struct TCP_Server_Info *); 207 bool (*is_oplock_break)(char *, struct TCP_Server_Info *);
208 /* process transaction2 response */
209 bool (*check_trans2)(struct mid_q_entry *, struct TCP_Server_Info *,
210 char *, int);
211 /* check if we need to negotiate */
212 bool (*need_neg)(struct TCP_Server_Info *);
213 /* negotiate to the server */
214 int (*negotiate)(const unsigned int, struct cifs_ses *);
215 /* setup smb sessionn */
216 int (*sess_setup)(const unsigned int, struct cifs_ses *,
217 const struct nls_table *);
218 /* close smb session */
219 int (*logoff)(const unsigned int, struct cifs_ses *);
220 /* connect to a server share */
221 int (*tree_connect)(const unsigned int, struct cifs_ses *, const char *,
222 struct cifs_tcon *, const struct nls_table *);
223 /* close tree connecion */
224 int (*tree_disconnect)(const unsigned int, struct cifs_tcon *);
225 /* get DFS referrals */
226 int (*get_dfs_refer)(const unsigned int, struct cifs_ses *,
227 const char *, struct dfs_info3_param **,
228 unsigned int *, const struct nls_table *, int);
229 /* informational QFS call */
230 void (*qfs_tcon)(const unsigned int, struct cifs_tcon *);
231 /* check if a path is accessible or not */
232 int (*is_path_accessible)(const unsigned int, struct cifs_tcon *,
233 struct cifs_sb_info *, const char *);
234 /* query path data from the server */
235 int (*query_path_info)(const unsigned int, struct cifs_tcon *,
236 struct cifs_sb_info *, const char *,
237 FILE_ALL_INFO *, bool *);
238 /* get server index number */
239 int (*get_srv_inum)(const unsigned int, struct cifs_tcon *,
240 struct cifs_sb_info *, const char *,
241 u64 *uniqueid, FILE_ALL_INFO *);
242 /* build a full path to the root of the mount */
243 char * (*build_path_to_root)(struct smb_vol *, struct cifs_sb_info *,
244 struct cifs_tcon *);
245 /* check if we can send an echo or nor */
246 bool (*can_echo)(struct TCP_Server_Info *);
247 /* send echo request */
248 int (*echo)(struct TCP_Server_Info *);
249 /* create directory */
250 int (*mkdir)(const unsigned int, struct cifs_tcon *, const char *,
251 struct cifs_sb_info *);
252 /* set info on created directory */
253 void (*mkdir_setinfo)(struct inode *, const char *,
254 struct cifs_sb_info *, struct cifs_tcon *,
255 const unsigned int);
256 /* remove directory */
257 int (*rmdir)(const unsigned int, struct cifs_tcon *, const char *,
258 struct cifs_sb_info *);
190}; 259};
191 260
192struct smb_version_values { 261struct smb_version_values {
@@ -198,6 +267,10 @@ struct smb_version_values {
198 size_t header_size; 267 size_t header_size;
199 size_t max_header_size; 268 size_t max_header_size;
200 size_t read_rsp_size; 269 size_t read_rsp_size;
270 __le16 lock_cmd;
271 unsigned int cap_unix;
272 unsigned int cap_nt_find;
273 unsigned int cap_large_files;
201}; 274};
202 275
203#define HEADER_SIZE(server) (server->vals->header_size) 276#define HEADER_SIZE(server) (server->vals->header_size)
@@ -291,6 +364,12 @@ get_rfc1002_length(void *buf)
291 return be32_to_cpu(*((__be32 *)buf)); 364 return be32_to_cpu(*((__be32 *)buf));
292} 365}
293 366
367static inline void
368inc_rfc1001_len(void *buf, int count)
369{
370 be32_add_cpu((__be32 *)buf, count);
371}
372
294struct TCP_Server_Info { 373struct TCP_Server_Info {
295 struct list_head tcp_ses_list; 374 struct list_head tcp_ses_list;
296 struct list_head smb_ses_list; 375 struct list_head smb_ses_list;
@@ -319,8 +398,13 @@ struct TCP_Server_Info {
319 struct mutex srv_mutex; 398 struct mutex srv_mutex;
320 struct task_struct *tsk; 399 struct task_struct *tsk;
321 char server_GUID[16]; 400 char server_GUID[16];
322 char sec_mode; 401 __u16 sec_mode;
323 bool session_estab; /* mark when very first sess is established */ 402 bool session_estab; /* mark when very first sess is established */
403#ifdef CONFIG_CIFS_SMB2
404 int echo_credits; /* echo reserved slots */
405 int oplock_credits; /* oplock break reserved slots */
406 bool echoes:1; /* enable echoes */
407#endif
324 u16 dialect; /* dialect index that server chose */ 408 u16 dialect; /* dialect index that server chose */
325 enum securityEnum secType; 409 enum securityEnum secType;
326 bool oplocks:1; /* enable oplocks */ 410 bool oplocks:1; /* enable oplocks */
@@ -337,7 +421,7 @@ struct TCP_Server_Info {
337 unsigned int max_vcs; /* maximum number of smb sessions, at least 421 unsigned int max_vcs; /* maximum number of smb sessions, at least
338 those that can be specified uniquely with 422 those that can be specified uniquely with
339 vcnumbers */ 423 vcnumbers */
340 int capabilities; /* allow selective disabling of caps by smb sess */ 424 unsigned int capabilities; /* selective disabling of caps by smb sess */
341 int timeAdj; /* Adjust for difference in server time zone in sec */ 425 int timeAdj; /* Adjust for difference in server time zone in sec */
342 __u64 CurrentMid; /* multiplex id - rotating counter */ 426 __u64 CurrentMid; /* multiplex id - rotating counter */
343 char cryptkey[CIFS_CRYPTO_KEY_SIZE]; /* used by ntlm, ntlmv2 etc */ 427 char cryptkey[CIFS_CRYPTO_KEY_SIZE]; /* used by ntlm, ntlmv2 etc */
@@ -366,6 +450,10 @@ struct TCP_Server_Info {
366 atomic_t in_send; /* requests trying to send */ 450 atomic_t in_send; /* requests trying to send */
367 atomic_t num_waiters; /* blocked waiting to get in sendrecv */ 451 atomic_t num_waiters; /* blocked waiting to get in sendrecv */
368#endif 452#endif
453#ifdef CONFIG_CIFS_SMB2
454 unsigned int max_read;
455 unsigned int max_write;
456#endif /* CONFIG_CIFS_SMB2 */
369}; 457};
370 458
371static inline unsigned int 459static inline unsigned int
@@ -389,9 +477,10 @@ has_credits(struct TCP_Server_Info *server, int *credits)
389} 477}
390 478
391static inline void 479static inline void
392add_credits(struct TCP_Server_Info *server, const unsigned int add) 480add_credits(struct TCP_Server_Info *server, const unsigned int add,
481 const int optype)
393{ 482{
394 server->ops->add_credits(server, add); 483 server->ops->add_credits(server, add, optype);
395} 484}
396 485
397static inline void 486static inline void
@@ -453,10 +542,10 @@ struct cifs_ses {
453 char *serverOS; /* name of operating system underlying server */ 542 char *serverOS; /* name of operating system underlying server */
454 char *serverNOS; /* name of network operating system of server */ 543 char *serverNOS; /* name of network operating system of server */
455 char *serverDomain; /* security realm of server */ 544 char *serverDomain; /* security realm of server */
456 int Suid; /* remote smb uid */ 545 __u64 Suid; /* remote smb uid */
457 uid_t linux_uid; /* overriding owner of files on the mount */ 546 uid_t linux_uid; /* overriding owner of files on the mount */
458 uid_t cred_uid; /* owner of credentials */ 547 uid_t cred_uid; /* owner of credentials */
459 int capabilities; 548 unsigned int capabilities;
460 char serverName[SERVER_NAME_LEN_WITH_NULL * 2]; /* BB make bigger for 549 char serverName[SERVER_NAME_LEN_WITH_NULL * 2]; /* BB make bigger for
461 TCP names - will ipv6 and sctp addresses fit? */ 550 TCP names - will ipv6 and sctp addresses fit? */
462 char *user_name; /* must not be null except during init of sess 551 char *user_name; /* must not be null except during init of sess
@@ -466,6 +555,9 @@ struct cifs_ses {
466 struct session_key auth_key; 555 struct session_key auth_key;
467 struct ntlmssp_auth *ntlmssp; /* ciphertext, flags, server challenge */ 556 struct ntlmssp_auth *ntlmssp; /* ciphertext, flags, server challenge */
468 bool need_reconnect:1; /* connection reset, uid now invalid */ 557 bool need_reconnect:1; /* connection reset, uid now invalid */
558#ifdef CONFIG_CIFS_SMB2
559 __u16 session_flags;
560#endif /* CONFIG_CIFS_SMB2 */
469}; 561};
470/* no more than one of the following three session flags may be set */ 562/* no more than one of the following three session flags may be set */
471#define CIFS_SES_NT4 1 563#define CIFS_SES_NT4 1
@@ -475,6 +567,13 @@ struct cifs_ses {
475 which do not negotiate NTLM or POSIX dialects, but instead 567 which do not negotiate NTLM or POSIX dialects, but instead
476 negotiate one of the older LANMAN dialects */ 568 negotiate one of the older LANMAN dialects */
477#define CIFS_SES_LANMAN 8 569#define CIFS_SES_LANMAN 8
570
571static inline bool
572cap_unix(struct cifs_ses *ses)
573{
574 return ses->server->vals->cap_unix & ses->capabilities;
575}
576
478/* 577/*
479 * there is one of these for each connection to a resource on a particular 578 * there is one of these for each connection to a resource on a particular
480 * session 579 * session
@@ -487,32 +586,42 @@ struct cifs_tcon {
487 char treeName[MAX_TREE_SIZE + 1]; /* UNC name of resource in ASCII */ 586 char treeName[MAX_TREE_SIZE + 1]; /* UNC name of resource in ASCII */
488 char *nativeFileSystem; 587 char *nativeFileSystem;
489 char *password; /* for share-level security */ 588 char *password; /* for share-level security */
490 __u16 tid; /* The 2 byte tree id */ 589 __u32 tid; /* The 4 byte tree id */
491 __u16 Flags; /* optional support bits */ 590 __u16 Flags; /* optional support bits */
492 enum statusEnum tidStatus; 591 enum statusEnum tidStatus;
493#ifdef CONFIG_CIFS_STATS 592#ifdef CONFIG_CIFS_STATS
494 atomic_t num_smbs_sent; 593 atomic_t num_smbs_sent;
495 atomic_t num_writes; 594 union {
496 atomic_t num_reads; 595 struct {
497 atomic_t num_flushes; 596 atomic_t num_writes;
498 atomic_t num_oplock_brks; 597 atomic_t num_reads;
499 atomic_t num_opens; 598 atomic_t num_flushes;
500 atomic_t num_closes; 599 atomic_t num_oplock_brks;
501 atomic_t num_deletes; 600 atomic_t num_opens;
502 atomic_t num_mkdirs; 601 atomic_t num_closes;
503 atomic_t num_posixopens; 602 atomic_t num_deletes;
504 atomic_t num_posixmkdirs; 603 atomic_t num_mkdirs;
505 atomic_t num_rmdirs; 604 atomic_t num_posixopens;
506 atomic_t num_renames; 605 atomic_t num_posixmkdirs;
507 atomic_t num_t2renames; 606 atomic_t num_rmdirs;
508 atomic_t num_ffirst; 607 atomic_t num_renames;
509 atomic_t num_fnext; 608 atomic_t num_t2renames;
510 atomic_t num_fclose; 609 atomic_t num_ffirst;
511 atomic_t num_hardlinks; 610 atomic_t num_fnext;
512 atomic_t num_symlinks; 611 atomic_t num_fclose;
513 atomic_t num_locks; 612 atomic_t num_hardlinks;
514 atomic_t num_acl_get; 613 atomic_t num_symlinks;
515 atomic_t num_acl_set; 614 atomic_t num_locks;
615 atomic_t num_acl_get;
616 atomic_t num_acl_set;
617 } cifs_stats;
618#ifdef CONFIG_CIFS_SMB2
619 struct {
620 atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
621 atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
622 } smb2_stats;
623#endif /* CONFIG_CIFS_SMB2 */
624 } stats;
516#ifdef CONFIG_CIFS_STATS2 625#ifdef CONFIG_CIFS_STATS2
517 unsigned long long time_writes; 626 unsigned long long time_writes;
518 unsigned long long time_reads; 627 unsigned long long time_reads;
@@ -543,6 +652,15 @@ struct cifs_tcon {
543 bool local_lease:1; /* check leases (only) on local system not remote */ 652 bool local_lease:1; /* check leases (only) on local system not remote */
544 bool broken_posix_open; /* e.g. Samba server versions < 3.3.2, 3.2.9 */ 653 bool broken_posix_open; /* e.g. Samba server versions < 3.3.2, 3.2.9 */
545 bool need_reconnect:1; /* connection reset, tid now invalid */ 654 bool need_reconnect:1; /* connection reset, tid now invalid */
655#ifdef CONFIG_CIFS_SMB2
656 bool print:1; /* set if connection to printer share */
657 bool bad_network_name:1; /* set if ret status STATUS_BAD_NETWORK_NAME */
658 __u32 capabilities;
659 __u32 share_flags;
660 __u32 maximal_access;
661 __u32 vol_serial_number;
662 __le64 vol_create_time;
663#endif /* CONFIG_CIFS_SMB2 */
546#ifdef CONFIG_CIFS_FSCACHE 664#ifdef CONFIG_CIFS_FSCACHE
547 u64 resource_id; /* server resource id */ 665 u64 resource_id; /* server resource id */
548 struct fscache_cookie *fscache; /* cookie for share */ 666 struct fscache_cookie *fscache; /* cookie for share */
@@ -657,13 +775,13 @@ struct cifs_io_parms {
657 * Take a reference on the file private data. Must be called with 775 * Take a reference on the file private data. Must be called with
658 * cifs_file_list_lock held. 776 * cifs_file_list_lock held.
659 */ 777 */
660static inline 778static inline void
661struct cifsFileInfo *cifsFileInfo_get(struct cifsFileInfo *cifs_file) 779cifsFileInfo_get_locked(struct cifsFileInfo *cifs_file)
662{ 780{
663 ++cifs_file->count; 781 ++cifs_file->count;
664 return cifs_file;
665} 782}
666 783
784struct cifsFileInfo *cifsFileInfo_get(struct cifsFileInfo *cifs_file);
667void cifsFileInfo_put(struct cifsFileInfo *cifs_file); 785void cifsFileInfo_put(struct cifsFileInfo *cifs_file);
668 786
669/* 787/*
@@ -734,6 +852,15 @@ convert_delimiter(char *path, char delim)
734 } 852 }
735} 853}
736 854
855static inline char *
856build_path_to_root(struct smb_vol *vol, struct cifs_sb_info *cifs_sb,
857 struct cifs_tcon *tcon)
858{
859 if (!vol->ops->build_path_to_root)
860 return NULL;
861 return vol->ops->build_path_to_root(vol, cifs_sb, tcon);
862}
863
737#ifdef CONFIG_CIFS_STATS 864#ifdef CONFIG_CIFS_STATS
738#define cifs_stats_inc atomic_inc 865#define cifs_stats_inc atomic_inc
739 866
@@ -791,6 +918,7 @@ typedef void (mid_callback_t)(struct mid_q_entry *mid);
791/* one of these for every pending CIFS request to the server */ 918/* one of these for every pending CIFS request to the server */
792struct mid_q_entry { 919struct mid_q_entry {
793 struct list_head qhead; /* mids waiting on reply from this server */ 920 struct list_head qhead; /* mids waiting on reply from this server */
921 struct TCP_Server_Info *server; /* server corresponding to this mid */
794 __u64 mid; /* multiplex id */ 922 __u64 mid; /* multiplex id */
795 __u32 pid; /* process id */ 923 __u32 pid; /* process id */
796 __u32 sequence_number; /* for CIFS signing */ 924 __u32 sequence_number; /* for CIFS signing */
@@ -954,6 +1082,12 @@ static inline void free_dfs_info_array(struct dfs_info3_param *param,
954#define CIFS_LARGE_BUF_OP 0x020 /* large request buffer */ 1082#define CIFS_LARGE_BUF_OP 0x020 /* large request buffer */
955#define CIFS_NO_RESP 0x040 /* no response buffer required */ 1083#define CIFS_NO_RESP 0x040 /* no response buffer required */
956 1084
1085/* Type of request operation */
1086#define CIFS_ECHO_OP 0x080 /* echo request */
1087#define CIFS_OBREAK_OP 0x0100 /* oplock break request */
1088#define CIFS_NEG_OP 0x0200 /* negotiate request */
1089#define CIFS_OP_MASK 0x0380 /* mask request type */
1090
957/* Security Flags: indicate type of session setup needed */ 1091/* Security Flags: indicate type of session setup needed */
958#define CIFSSEC_MAY_SIGN 0x00001 1092#define CIFSSEC_MAY_SIGN 0x00001
959#define CIFSSEC_MAY_NTLM 0x00002 1093#define CIFSSEC_MAY_NTLM 0x00002
@@ -1127,6 +1261,8 @@ void cifs_oplock_break(struct work_struct *work);
1127extern const struct slow_work_ops cifs_oplock_break_ops; 1261extern const struct slow_work_ops cifs_oplock_break_ops;
1128extern struct workqueue_struct *cifsiod_wq; 1262extern struct workqueue_struct *cifsiod_wq;
1129 1263
1264extern mempool_t *cifs_mid_poolp;
1265
1130/* Operations for different SMB versions */ 1266/* Operations for different SMB versions */
1131#define SMB1_VERSION_STRING "1.0" 1267#define SMB1_VERSION_STRING "1.0"
1132extern struct smb_version_operations smb1_operations; 1268extern struct smb_version_operations smb1_operations;