diff options
Diffstat (limited to 'fs/cifs/cifsglob.h')
-rw-r--r-- | fs/cifs/cifsglob.h | 107 |
1 files changed, 80 insertions, 27 deletions
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 4ff6313f0a91..20350a93ed99 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h | |||
@@ -43,6 +43,7 @@ | |||
43 | 43 | ||
44 | #define CIFS_MIN_RCV_POOL 4 | 44 | #define CIFS_MIN_RCV_POOL 4 |
45 | 45 | ||
46 | #define MAX_REOPEN_ATT 5 /* these many maximum attempts to reopen a file */ | ||
46 | /* | 47 | /* |
47 | * default attribute cache timeout (jiffies) | 48 | * default attribute cache timeout (jiffies) |
48 | */ | 49 | */ |
@@ -150,6 +151,57 @@ struct cifs_cred { | |||
150 | ***************************************************************** | 151 | ***************************************************************** |
151 | */ | 152 | */ |
152 | 153 | ||
154 | enum smb_version { | ||
155 | Smb_1 = 1, | ||
156 | Smb_21, | ||
157 | }; | ||
158 | |||
159 | struct mid_q_entry; | ||
160 | struct TCP_Server_Info; | ||
161 | struct cifsFileInfo; | ||
162 | struct cifs_ses; | ||
163 | |||
164 | struct smb_version_operations { | ||
165 | int (*send_cancel)(struct TCP_Server_Info *, void *, | ||
166 | struct mid_q_entry *); | ||
167 | bool (*compare_fids)(struct cifsFileInfo *, struct cifsFileInfo *); | ||
168 | /* setup request: allocate mid, sign message */ | ||
169 | int (*setup_request)(struct cifs_ses *, struct kvec *, unsigned int, | ||
170 | struct mid_q_entry **); | ||
171 | /* check response: verify signature, map error */ | ||
172 | int (*check_receive)(struct mid_q_entry *, struct TCP_Server_Info *, | ||
173 | bool); | ||
174 | void (*add_credits)(struct TCP_Server_Info *, const unsigned int); | ||
175 | void (*set_credits)(struct TCP_Server_Info *, const int); | ||
176 | int * (*get_credits_field)(struct TCP_Server_Info *); | ||
177 | /* data offset from read response message */ | ||
178 | unsigned int (*read_data_offset)(char *); | ||
179 | /* data length from read response message */ | ||
180 | unsigned int (*read_data_length)(char *); | ||
181 | /* map smb to linux error */ | ||
182 | int (*map_error)(char *, bool); | ||
183 | /* find mid corresponding to the response message */ | ||
184 | struct mid_q_entry * (*find_mid)(struct TCP_Server_Info *, char *); | ||
185 | void (*dump_detail)(void *); | ||
186 | /* verify the message */ | ||
187 | int (*check_message)(char *, unsigned int); | ||
188 | bool (*is_oplock_break)(char *, struct TCP_Server_Info *); | ||
189 | }; | ||
190 | |||
191 | struct smb_version_values { | ||
192 | char *version_string; | ||
193 | __u32 large_lock_type; | ||
194 | __u32 exclusive_lock_type; | ||
195 | __u32 shared_lock_type; | ||
196 | __u32 unlock_lock_type; | ||
197 | size_t header_size; | ||
198 | size_t max_header_size; | ||
199 | size_t read_rsp_size; | ||
200 | }; | ||
201 | |||
202 | #define HEADER_SIZE(server) (server->vals->header_size) | ||
203 | #define MAX_HEADER_SIZE(server) (server->vals->max_header_size) | ||
204 | |||
153 | struct smb_vol { | 205 | struct smb_vol { |
154 | char *username; | 206 | char *username; |
155 | char *password; | 207 | char *password; |
@@ -205,6 +257,8 @@ struct smb_vol { | |||
205 | bool sockopt_tcp_nodelay:1; | 257 | bool sockopt_tcp_nodelay:1; |
206 | unsigned short int port; | 258 | unsigned short int port; |
207 | unsigned long actimeo; /* attribute cache timeout (jiffies) */ | 259 | unsigned long actimeo; /* attribute cache timeout (jiffies) */ |
260 | struct smb_version_operations *ops; | ||
261 | struct smb_version_values *vals; | ||
208 | char *prepath; | 262 | char *prepath; |
209 | struct sockaddr_storage srcaddr; /* allow binding to a local IP */ | 263 | struct sockaddr_storage srcaddr; /* allow binding to a local IP */ |
210 | struct nls_table *local_nls; | 264 | struct nls_table *local_nls; |
@@ -242,6 +296,8 @@ struct TCP_Server_Info { | |||
242 | int srv_count; /* reference counter */ | 296 | int srv_count; /* reference counter */ |
243 | /* 15 character server name + 0x20 16th byte indicating type = srv */ | 297 | /* 15 character server name + 0x20 16th byte indicating type = srv */ |
244 | char server_RFC1001_name[RFC1001_NAME_LEN_WITH_NULL]; | 298 | char server_RFC1001_name[RFC1001_NAME_LEN_WITH_NULL]; |
299 | struct smb_version_operations *ops; | ||
300 | struct smb_version_values *vals; | ||
245 | enum statusEnum tcpStatus; /* what we think the status is */ | 301 | enum statusEnum tcpStatus; /* what we think the status is */ |
246 | char *hostname; /* hostname portion of UNC string */ | 302 | char *hostname; /* hostname portion of UNC string */ |
247 | struct socket *ssocket; | 303 | struct socket *ssocket; |
@@ -321,16 +377,6 @@ in_flight(struct TCP_Server_Info *server) | |||
321 | return num; | 377 | return num; |
322 | } | 378 | } |
323 | 379 | ||
324 | static inline int* | ||
325 | get_credits_field(struct TCP_Server_Info *server) | ||
326 | { | ||
327 | /* | ||
328 | * This will change to switch statement when we reserve slots for echos | ||
329 | * and oplock breaks. | ||
330 | */ | ||
331 | return &server->credits; | ||
332 | } | ||
333 | |||
334 | static inline bool | 380 | static inline bool |
335 | has_credits(struct TCP_Server_Info *server, int *credits) | 381 | has_credits(struct TCP_Server_Info *server, int *credits) |
336 | { | 382 | { |
@@ -341,16 +387,16 @@ has_credits(struct TCP_Server_Info *server, int *credits) | |||
341 | return num > 0; | 387 | return num > 0; |
342 | } | 388 | } |
343 | 389 | ||
344 | static inline size_t | 390 | static inline void |
345 | header_size(void) | 391 | add_credits(struct TCP_Server_Info *server, const unsigned int add) |
346 | { | 392 | { |
347 | return sizeof(struct smb_hdr); | 393 | server->ops->add_credits(server, add); |
348 | } | 394 | } |
349 | 395 | ||
350 | static inline size_t | 396 | static inline void |
351 | max_header_size(void) | 397 | set_credits(struct TCP_Server_Info *server, const int val) |
352 | { | 398 | { |
353 | return MAX_CIFS_HDR_SIZE; | 399 | server->ops->set_credits(server, val); |
354 | } | 400 | } |
355 | 401 | ||
356 | /* | 402 | /* |
@@ -547,8 +593,7 @@ struct cifsLockInfo { | |||
547 | __u64 offset; | 593 | __u64 offset; |
548 | __u64 length; | 594 | __u64 length; |
549 | __u32 pid; | 595 | __u32 pid; |
550 | __u8 type; | 596 | __u32 type; |
551 | __u16 netfid; | ||
552 | }; | 597 | }; |
553 | 598 | ||
554 | /* | 599 | /* |
@@ -573,6 +618,10 @@ struct cifs_search_info { | |||
573 | struct cifsFileInfo { | 618 | struct cifsFileInfo { |
574 | struct list_head tlist; /* pointer to next fid owned by tcon */ | 619 | struct list_head tlist; /* pointer to next fid owned by tcon */ |
575 | struct list_head flist; /* next fid (file instance) for this inode */ | 620 | struct list_head flist; /* next fid (file instance) for this inode */ |
621 | struct list_head llist; /* | ||
622 | * brlocks held by this fid, protected by | ||
623 | * lock_mutex from cifsInodeInfo structure | ||
624 | */ | ||
576 | unsigned int uid; /* allows finding which FileInfo structure */ | 625 | unsigned int uid; /* allows finding which FileInfo structure */ |
577 | __u32 pid; /* process id who opened file */ | 626 | __u32 pid; /* process id who opened file */ |
578 | __u16 netfid; /* file id from remote */ | 627 | __u16 netfid; /* file id from remote */ |
@@ -615,9 +664,12 @@ void cifsFileInfo_put(struct cifsFileInfo *cifs_file); | |||
615 | */ | 664 | */ |
616 | 665 | ||
617 | struct cifsInodeInfo { | 666 | struct cifsInodeInfo { |
618 | struct list_head llist; /* brlocks for this inode */ | ||
619 | bool can_cache_brlcks; | 667 | bool can_cache_brlcks; |
620 | struct mutex lock_mutex; /* protect two fields above */ | 668 | struct mutex lock_mutex; /* |
669 | * protect the field above and llist | ||
670 | * from every cifsFileInfo structure | ||
671 | * from openFileList | ||
672 | */ | ||
621 | /* BB add in lists for dirty pages i.e. write caching info for oplock */ | 673 | /* BB add in lists for dirty pages i.e. write caching info for oplock */ |
622 | struct list_head openFileList; | 674 | struct list_head openFileList; |
623 | __u32 cifsAttrs; /* e.g. DOS archive bit, sparse, compressed, system */ | 675 | __u32 cifsAttrs; /* e.g. DOS archive bit, sparse, compressed, system */ |
@@ -703,7 +755,6 @@ static inline void cifs_stats_bytes_read(struct cifs_tcon *tcon, | |||
703 | 755 | ||
704 | #endif | 756 | #endif |
705 | 757 | ||
706 | struct mid_q_entry; | ||
707 | 758 | ||
708 | /* | 759 | /* |
709 | * This is the prototype for the mid receive function. This function is for | 760 | * This is the prototype for the mid receive function. This function is for |
@@ -1042,12 +1093,7 @@ GLOBAL_EXTERN atomic_t smBufAllocCount; | |||
1042 | GLOBAL_EXTERN atomic_t midCount; | 1093 | GLOBAL_EXTERN atomic_t midCount; |
1043 | 1094 | ||
1044 | /* Misc globals */ | 1095 | /* Misc globals */ |
1045 | GLOBAL_EXTERN unsigned int multiuser_mount; /* if enabled allows new sessions | 1096 | GLOBAL_EXTERN bool enable_oplocks; /* enable or disable oplocks */ |
1046 | to be established on existing mount if we | ||
1047 | have the uid/password or Kerberos credential | ||
1048 | or equivalent for current user */ | ||
1049 | /* enable or disable oplocks */ | ||
1050 | GLOBAL_EXTERN bool enable_oplocks; | ||
1051 | GLOBAL_EXTERN unsigned int lookupCacheEnabled; | 1097 | GLOBAL_EXTERN unsigned int lookupCacheEnabled; |
1052 | GLOBAL_EXTERN unsigned int global_secflags; /* if on, session setup sent | 1098 | GLOBAL_EXTERN unsigned int global_secflags; /* if on, session setup sent |
1053 | with more secure ntlmssp2 challenge/resp */ | 1099 | with more secure ntlmssp2 challenge/resp */ |
@@ -1074,4 +1120,11 @@ void cifs_oplock_break(struct work_struct *work); | |||
1074 | extern const struct slow_work_ops cifs_oplock_break_ops; | 1120 | extern const struct slow_work_ops cifs_oplock_break_ops; |
1075 | extern struct workqueue_struct *cifsiod_wq; | 1121 | extern struct workqueue_struct *cifsiod_wq; |
1076 | 1122 | ||
1123 | /* Operations for different SMB versions */ | ||
1124 | #define SMB1_VERSION_STRING "1.0" | ||
1125 | extern struct smb_version_operations smb1_operations; | ||
1126 | extern struct smb_version_values smb1_values; | ||
1127 | #define SMB21_VERSION_STRING "2.1" | ||
1128 | extern struct smb_version_operations smb21_operations; | ||
1129 | extern struct smb_version_values smb21_values; | ||
1077 | #endif /* _CIFS_GLOB_H */ | 1130 | #endif /* _CIFS_GLOB_H */ |