forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 95099d4622f8cb224d94e314c7a8e0df60b13f87
kernel/fs/cifs/cifsglob.h
....@@ -33,6 +33,7 @@
3333
3434 #define CIFS_MAGIC_NUMBER 0xFF534D42 /* the first four bytes of SMB PDUs */
3535
36
+#define SMB_PATH_MAX 260
3637 #define CIFS_PORT 445
3738 #define RFC1001_PORT 139
3839
....@@ -57,6 +58,12 @@
5758 * max attribute cache timeout (jiffies) - 2^30
5859 */
5960 #define CIFS_MAX_ACTIMEO (1 << 30)
61
+
62
+/*
63
+ * Max persistent and resilient handle timeout (milliseconds).
64
+ * Windows durable max was 960000 (16 minutes)
65
+ */
66
+#define SMB3_MAX_HANDLE_TIMEOUT 960000
6067
6168 /*
6269 * MAX_REQ is the maximum number of requests that WE will send
....@@ -188,18 +195,6 @@
188195 unsigned int rq_tailsz; /* length of last page */
189196 };
190197
191
-enum smb_version {
192
- Smb_1 = 1,
193
- Smb_20,
194
- Smb_21,
195
- Smb_30,
196
- Smb_302,
197
- Smb_311,
198
- Smb_3any,
199
- Smb_default,
200
- Smb_version_err
201
-};
202
-
203198 struct mid_q_entry;
204199 struct TCP_Server_Info;
205200 struct cifsFileInfo;
....@@ -215,6 +210,7 @@
215210 struct cifs_search_info;
216211 struct cifsInodeInfo;
217212 struct cifs_open_parms;
213
+struct cifs_credits;
218214
219215 struct smb_version_operations {
220216 int (*send_cancel)(struct TCP_Server_Info *, struct smb_rqst *,
....@@ -222,15 +218,17 @@
222218 bool (*compare_fids)(struct cifsFileInfo *, struct cifsFileInfo *);
223219 /* setup request: allocate mid, sign message */
224220 struct mid_q_entry *(*setup_request)(struct cifs_ses *,
225
- struct smb_rqst *);
221
+ struct TCP_Server_Info *,
222
+ struct smb_rqst *);
226223 /* setup async request: allocate mid, sign message */
227224 struct mid_q_entry *(*setup_async_request)(struct TCP_Server_Info *,
228225 struct smb_rqst *);
229226 /* check response: verify signature, map error */
230227 int (*check_receive)(struct mid_q_entry *, struct TCP_Server_Info *,
231228 bool);
232
- void (*add_credits)(struct TCP_Server_Info *, const unsigned int,
233
- const int);
229
+ void (*add_credits)(struct TCP_Server_Info *server,
230
+ const struct cifs_credits *credits,
231
+ const int optype);
234232 void (*set_credits)(struct TCP_Server_Info *, const int);
235233 int * (*get_credits_field)(struct TCP_Server_Info *, const int);
236234 unsigned int (*get_credits)(struct mid_q_entry *);
....@@ -258,7 +256,7 @@
258256 /* verify the message */
259257 int (*check_message)(char *, unsigned int, struct TCP_Server_Info *);
260258 bool (*is_oplock_break)(char *, struct TCP_Server_Info *);
261
- int (*handle_cancelled_mid)(char *, struct TCP_Server_Info *);
259
+ int (*handle_cancelled_mid)(struct mid_q_entry *, struct TCP_Server_Info *);
262260 void (*downgrade_oplock)(struct TCP_Server_Info *server,
263261 struct cifsInodeInfo *cinode, __u32 oplock,
264262 unsigned int epoch, bool *purge_cache);
....@@ -288,7 +286,8 @@
288286 const char *, struct dfs_info3_param **,
289287 unsigned int *, const struct nls_table *, int);
290288 /* informational QFS call */
291
- void (*qfs_tcon)(const unsigned int, struct cifs_tcon *);
289
+ void (*qfs_tcon)(const unsigned int, struct cifs_tcon *,
290
+ struct cifs_sb_info *);
292291 /* check if a path is accessible or not */
293292 int (*is_path_accessible)(const unsigned int, struct cifs_tcon *,
294293 struct cifs_sb_info *, const char *);
....@@ -299,6 +298,10 @@
299298 /* query file data from the server */
300299 int (*query_file_info)(const unsigned int, struct cifs_tcon *,
301300 struct cifs_fid *, FILE_ALL_INFO *);
301
+ /* query reparse tag from srv to determine which type of special file */
302
+ int (*query_reparse_tag)(const unsigned int xid, struct cifs_tcon *tcon,
303
+ struct cifs_sb_info *cifs_sb, const char *path,
304
+ __u32 *reparse_tag);
302305 /* get server index number */
303306 int (*get_srv_inum)(const unsigned int, struct cifs_tcon *,
304307 struct cifs_sb_info *, const char *,
....@@ -323,8 +326,9 @@
323326 umode_t mode, struct cifs_tcon *tcon,
324327 const char *full_path,
325328 struct cifs_sb_info *cifs_sb);
326
- int (*mkdir)(const unsigned int, struct cifs_tcon *, const char *,
327
- struct cifs_sb_info *);
329
+ int (*mkdir)(const unsigned int xid, struct inode *inode, umode_t mode,
330
+ struct cifs_tcon *tcon, const char *name,
331
+ struct cifs_sb_info *sb);
328332 /* set info on created directory */
329333 void (*mkdir_setinfo)(struct inode *, const char *,
330334 struct cifs_sb_info *, struct cifs_tcon *,
....@@ -347,7 +351,8 @@
347351 struct cifs_sb_info *);
348352 /* query symlink target */
349353 int (*query_symlink)(const unsigned int, struct cifs_tcon *,
350
- const char *, char **, struct cifs_sb_info *);
354
+ struct cifs_sb_info *, const char *,
355
+ char **, bool);
351356 /* open a file for non-posix mounts */
352357 int (*open)(const unsigned int, struct cifs_open_parms *,
353358 __u32 *, FILE_ALL_INFO *);
....@@ -356,6 +361,9 @@
356361 /* close a file */
357362 void (*close)(const unsigned int, struct cifs_tcon *,
358363 struct cifs_fid *);
364
+ /* close a file, returning file attributes and timestamps */
365
+ void (*close_getattr)(const unsigned int xid, struct cifs_tcon *tcon,
366
+ struct cifsFileInfo *pfile_info);
359367 /* send a flush request to the server */
360368 int (*flush)(const unsigned int, struct cifs_tcon *, struct cifs_fid *);
361369 /* async read from the server */
....@@ -385,8 +393,8 @@
385393 struct cifs_fid *);
386394 /* calculate a size of SMB message */
387395 unsigned int (*calc_smb_size)(void *buf, struct TCP_Server_Info *ptcpi);
388
- /* check for STATUS_PENDING and process it in a positive case */
389
- bool (*is_status_pending)(char *, struct TCP_Server_Info *, int);
396
+ /* check for STATUS_PENDING and process the response if yes */
397
+ bool (*is_status_pending)(char *buf, struct TCP_Server_Info *server);
390398 /* check for STATUS_NETWORK_SESSION_EXPIRED */
391399 bool (*is_session_expired)(char *);
392400 /* send oplock break response */
....@@ -394,7 +402,7 @@
394402 struct cifsInodeInfo *);
395403 /* query remote filesystem */
396404 int (*queryfs)(const unsigned int, struct cifs_tcon *,
397
- struct kstatfs *);
405
+ struct cifs_sb_info *, struct kstatfs *);
398406 /* send mandatory brlock to the server */
399407 int (*mand_lock)(const unsigned int, struct cifsFileInfo *, __u64,
400408 __u64, __u32, int, int, bool);
....@@ -410,11 +418,14 @@
410418 /* generate new lease key */
411419 void (*new_lease_key)(struct cifs_fid *);
412420 int (*generate_signingkey)(struct cifs_ses *);
413
- int (*calc_signature)(struct smb_rqst *, struct TCP_Server_Info *);
421
+ int (*calc_signature)(struct smb_rqst *, struct TCP_Server_Info *,
422
+ bool allocate_crypto);
414423 int (*set_integrity)(const unsigned int, struct cifs_tcon *tcon,
415424 struct cifsFileInfo *src_file);
416425 int (*enum_snapshots)(const unsigned int xid, struct cifs_tcon *tcon,
417426 struct cifsFileInfo *src_file, void __user *);
427
+ int (*notify)(const unsigned int xid, struct file *pfile,
428
+ void __user *pbuf);
418429 int (*query_mf_symlink)(unsigned int, struct cifs_tcon *,
419430 struct cifs_sb_info *, const unsigned char *,
420431 char *, unsigned int *);
....@@ -454,7 +465,11 @@
454465 unsigned int (*wp_retry_size)(struct inode *);
455466 /* get mtu credits */
456467 int (*wait_mtu_credits)(struct TCP_Server_Info *, unsigned int,
457
- unsigned int *, unsigned int *);
468
+ unsigned int *, struct cifs_credits *);
469
+ /* adjust previously taken mtu credits to request size */
470
+ int (*adjust_credits)(struct TCP_Server_Info *server,
471
+ struct cifs_credits *credits,
472
+ const unsigned int payload_size);
458473 /* check if we need to issue closedir */
459474 bool (*dir_needs_close)(struct cifsFileInfo *);
460475 long (*fallocate)(struct file *, struct cifs_tcon *, int, loff_t,
....@@ -468,6 +483,27 @@
468483 enum securityEnum (*select_sectype)(struct TCP_Server_Info *,
469484 enum securityEnum);
470485 int (*next_header)(char *);
486
+ /* ioctl passthrough for query_info */
487
+ int (*ioctl_query_info)(const unsigned int xid,
488
+ struct cifs_tcon *tcon,
489
+ struct cifs_sb_info *cifs_sb,
490
+ __le16 *path, int is_dir,
491
+ unsigned long p);
492
+ /* make unix special files (block, char, fifo, socket) */
493
+ int (*make_node)(unsigned int xid,
494
+ struct inode *inode,
495
+ struct dentry *dentry,
496
+ struct cifs_tcon *tcon,
497
+ char *full_path,
498
+ umode_t mode,
499
+ dev_t device_number);
500
+ /* version specific fiemap implementation */
501
+ int (*fiemap)(struct cifs_tcon *tcon, struct cifsFileInfo *,
502
+ struct fiemap_extent_info *, u64, u64);
503
+ /* version specific llseek implementation */
504
+ loff_t (*llseek)(struct file *, struct cifs_tcon *, loff_t, int);
505
+ /* Check for STATUS_IO_TIMEOUT */
506
+ bool (*is_status_io_timeout)(char *buf);
471507 };
472508
473509 struct smb_version_values {
....@@ -511,6 +547,7 @@
511547 umode_t dir_mode;
512548 enum securityEnum sectype; /* sectype requested via mnt opts */
513549 bool sign; /* was signing requested via mnt opts? */
550
+ bool ignore_signature:1;
514551 bool retry:1;
515552 bool intr:1;
516553 bool setuids:1;
....@@ -519,6 +556,8 @@
519556 bool override_gid:1;
520557 bool dynperm:1;
521558 bool noperm:1;
559
+ bool nodelete:1;
560
+ bool mode_ace:1;
522561 bool no_psx_acl:1; /* set if posix acl support should be disabled */
523562 bool cifs_acl:1;
524563 bool backupuid_specified; /* mount option backupuid is specified */
....@@ -527,6 +566,8 @@
527566 bool server_ino:1; /* use inode numbers from server ie UniqueId */
528567 bool direct_io:1;
529568 bool strict_io:1; /* strict cache behavior */
569
+ bool cache_ro:1;
570
+ bool cache_rw:1;
530571 bool remap:1; /* set to remap seven reserved chars in filenames */
531572 bool sfu_remap:1; /* remap seven reserved chars ala SFU */
532573 bool posix_paths:1; /* unset to not ask for posix pathnames. */
....@@ -555,8 +596,14 @@
555596 bool resilient:1; /* noresilient not required since not fored for CA */
556597 bool domainauto:1;
557598 bool rdma:1;
599
+ bool multichannel:1;
600
+ bool use_client_guid:1;
601
+ /* reuse existing guid for multichannel */
602
+ u8 client_guid[SMB2_CLIENT_GUID_SIZE];
603
+ unsigned int bsize;
558604 unsigned int rsize;
559605 unsigned int wsize;
606
+ unsigned int min_offload;
560607 bool sockopt_tcp_nodelay:1;
561608 unsigned long actimeo; /* attribute cache timeout (jiffies) */
562609 struct smb_version_operations *ops;
....@@ -567,9 +614,17 @@
567614 struct nls_table *local_nls;
568615 unsigned int echo_interval; /* echo interval in secs */
569616 __u64 snapshot_time; /* needed for timewarp tokens */
617
+ __u32 handle_timeout; /* persistent and durable handle timeout in ms */
570618 unsigned int max_credits; /* smb3 max_credits 10 < credits < 60000 */
619
+ unsigned int max_channels;
620
+ __u16 compression; /* compression algorithm 0xFFFF default 0=disabled */
621
+ bool rootfs:1; /* if it's a SMB root file system */
571622 };
572623
624
+/**
625
+ * CIFS superblock mount flags (mnt_cifs_flags) to consider when
626
+ * trying to reuse existing superblock for a new mount
627
+ */
573628 #define CIFS_MOUNT_MASK (CIFS_MOUNT_NO_PERM | CIFS_MOUNT_SET_UID | \
574629 CIFS_MOUNT_SERVER_INUM | CIFS_MOUNT_DIRECT_IO | \
575630 CIFS_MOUNT_NO_XATTR | CIFS_MOUNT_MAP_SPECIAL_CHR | \
....@@ -580,8 +635,15 @@
580635 CIFS_MOUNT_NOPOSIXBRL | CIFS_MOUNT_NOSSYNC | \
581636 CIFS_MOUNT_FSCACHE | CIFS_MOUNT_MF_SYMLINKS | \
582637 CIFS_MOUNT_MULTIUSER | CIFS_MOUNT_STRICT_IO | \
583
- CIFS_MOUNT_CIFS_BACKUPUID | CIFS_MOUNT_CIFS_BACKUPGID)
638
+ CIFS_MOUNT_CIFS_BACKUPUID | CIFS_MOUNT_CIFS_BACKUPGID | \
639
+ CIFS_MOUNT_UID_FROM_ACL | CIFS_MOUNT_NO_HANDLE_CACHE | \
640
+ CIFS_MOUNT_NO_DFS | CIFS_MOUNT_MODE_FROM_SID | \
641
+ CIFS_MOUNT_RO_CACHE | CIFS_MOUNT_RW_CACHE)
584642
643
+/**
644
+ * Generic VFS superblock mount flags (s_flags) to consider when
645
+ * trying to reuse existing superblock for a new mount
646
+ */
585647 #define CIFS_MS_MASK (SB_RDONLY | SB_MANDLOCK | SB_NOEXEC | SB_NOSUID | \
586648 SB_NODEV | SB_SYNCHRONOUS)
587649
....@@ -628,12 +690,14 @@
628690 unsigned int credits; /* send no more requests at once */
629691 unsigned int max_credits; /* can override large 32000 default at mnt */
630692 unsigned int in_flight; /* number of requests on the wire to server */
693
+ unsigned int max_in_flight; /* max number of requests that were on wire */
631694 spinlock_t req_lock; /* protect the two values above */
632695 struct mutex srv_mutex;
633696 struct task_struct *tsk;
634697 char server_GUID[16];
635698 __u16 sec_mode;
636699 bool sign; /* is signing enabled on this connection? */
700
+ bool ignore_signature:1; /* skip validation of signatures in SMB2/3 rsp */
637701 bool session_estab; /* mark when very first sess is established */
638702 int echo_credits; /* echo reserved slots */
639703 int oplock_credits; /* oplock break reserved slots */
....@@ -658,6 +722,7 @@
658722 /* 16th byte of RFC1001 workstation name is always null */
659723 char workstation_RFC1001_name[RFC1001_NAME_LEN_WITH_NULL];
660724 __u32 sequence_number; /* for signing, protected by srv_mutex */
725
+ __u32 reconnect_instance; /* incremented on each reconnect */
661726 struct session_key session_key;
662727 unsigned long lstrp; /* when we got last response from this server */
663728 struct cifs_secmech secmech; /* crypto sec mech functs, descriptors */
....@@ -681,16 +746,22 @@
681746 /* Total size of this PDU. Only valid from cifs_demultiplex_thread */
682747 unsigned int pdu_size;
683748 unsigned int total_read; /* total amount of data read in this pass */
749
+ atomic_t in_send; /* requests trying to send */
750
+ atomic_t num_waiters; /* blocked waiting to get in sendrecv */
684751 #ifdef CONFIG_CIFS_FSCACHE
685752 struct fscache_cookie *fscache; /* client index cache cookie */
686753 #endif
687754 #ifdef CONFIG_CIFS_STATS2
688
- atomic_t in_send; /* requests trying to send */
689
- atomic_t num_waiters; /* blocked waiting to get in sendrecv */
755
+ atomic_t num_cmds[NUMBER_OF_SMB2_COMMANDS]; /* total requests by cmd */
690756 atomic_t smb2slowcmd[NUMBER_OF_SMB2_COMMANDS]; /* count resps > 1 sec */
757
+ __u64 time_per_cmd[NUMBER_OF_SMB2_COMMANDS]; /* total time per cmd */
758
+ __u32 slowest_cmd[NUMBER_OF_SMB2_COMMANDS];
759
+ __u32 fastest_cmd[NUMBER_OF_SMB2_COMMANDS];
691760 #endif /* STATS2 */
692761 unsigned int max_read;
693762 unsigned int max_write;
763
+ unsigned int min_offload;
764
+ __le16 compress_algorithm;
694765 __le16 cipher_type;
695766 /* save initital negprot hash */
696767 __u8 preauth_sha_hash[SMB2_PREAUTH_HASH_SIZE];
....@@ -698,6 +769,20 @@
698769 struct delayed_work reconnect; /* reconnect workqueue job */
699770 struct mutex reconnect_mutex; /* prevent simultaneous reconnects */
700771 unsigned long echo_interval;
772
+
773
+ /*
774
+ * Number of targets available for reconnect. The more targets
775
+ * the more tasks have to wait to let the demultiplex thread
776
+ * reconnect.
777
+ */
778
+ int nr_targets;
779
+ bool noblockcnt; /* use non-blocking connect() */
780
+ bool is_channel; /* if a session channel */
781
+};
782
+
783
+struct cifs_credits {
784
+ unsigned int value;
785
+ unsigned int instance;
701786 };
702787
703788 static inline unsigned int
....@@ -711,28 +796,28 @@
711796 }
712797
713798 static inline bool
714
-has_credits(struct TCP_Server_Info *server, int *credits)
799
+has_credits(struct TCP_Server_Info *server, int *credits, int num_credits)
715800 {
716801 int num;
717802 spin_lock(&server->req_lock);
718803 num = *credits;
719804 spin_unlock(&server->req_lock);
720
- return num > 0;
805
+ return num >= num_credits;
721806 }
722807
723808 static inline void
724
-add_credits(struct TCP_Server_Info *server, const unsigned int add,
809
+add_credits(struct TCP_Server_Info *server, const struct cifs_credits *credits,
725810 const int optype)
726811 {
727
- server->ops->add_credits(server, add, optype);
812
+ server->ops->add_credits(server, credits, optype);
728813 }
729814
730815 static inline void
731
-add_credits_and_wake_if(struct TCP_Server_Info *server, const unsigned int add,
732
- const int optype)
816
+add_credits_and_wake_if(struct TCP_Server_Info *server,
817
+ const struct cifs_credits *credits, const int optype)
733818 {
734
- if (add) {
735
- server->ops->add_credits(server, add, optype);
819
+ if (credits->value) {
820
+ server->ops->add_credits(server, credits, optype);
736821 wake_up(&server->request_q);
737822 }
738823 }
....@@ -741,6 +826,14 @@
741826 set_credits(struct TCP_Server_Info *server, const int val)
742827 {
743828 server->ops->set_credits(server, val);
829
+}
830
+
831
+static inline int
832
+adjust_credits(struct TCP_Server_Info *server, struct cifs_credits *credits,
833
+ const unsigned int payload_size)
834
+{
835
+ return server->ops->adjust_credits ?
836
+ server->ops->adjust_credits(server, credits, payload_size) : 0;
744837 }
745838
746839 static inline __le64
....@@ -818,6 +911,7 @@
818911 * a single wsize request with a single call.
819912 */
820913 #define CIFS_DEFAULT_IOSIZE (1024 * 1024)
914
+#define SMB3_DEFAULT_IOSIZE (4 * 1024 * 1024)
821915
822916 /*
823917 * Windows only supports a max of 60kb reads and 65535 byte writes. Default to
....@@ -828,7 +922,7 @@
828922 *
829923 * Citation:
830924 *
831
- * http://blogs.msdn.com/b/openspecification/archive/2009/04/10/smb-maximum-transmit-buffer-size-and-performance-tuning.aspx
925
+ * https://blogs.msdn.com/b/openspecification/archive/2009/04/10/smb-maximum-transmit-buffer-size-and-performance-tuning.aspx
832926 */
833927 #define CIFS_DEFAULT_NON_POSIX_RSIZE (60 * 1024)
834928 #define CIFS_DEFAULT_NON_POSIX_WSIZE (65536)
....@@ -870,6 +964,11 @@
870964 struct sockaddr_storage sockaddr;
871965 };
872966
967
+struct cifs_chan {
968
+ struct TCP_Server_Info *server;
969
+ __u8 signkey[SMB3_SIGN_KEY_SIZE];
970
+};
971
+
873972 /*
874973 * Session structure. One of these for each uid session with a particular host
875974 */
....@@ -880,7 +979,7 @@
880979 struct mutex session_mutex;
881980 struct TCP_Server_Info *server; /* pointer to server info */
882981 int ses_count; /* reference counter */
883
- enum statusEnum status;
982
+ enum statusEnum status; /* updates protected by GlobalMid_Lock */
884983 unsigned overrideSecFlg; /* if non-zero override global sec flags */
885984 char *serverOS; /* name of operating system underlying server */
886985 char *serverNOS; /* name of network operating system of server */
....@@ -900,11 +999,14 @@
900999 bool sign; /* is signing required? */
9011000 bool need_reconnect:1; /* connection reset, uid now invalid */
9021001 bool domainAuto:1;
1002
+ bool binding:1; /* are we binding the session? */
9031003 __u16 session_flags;
9041004 __u8 smb3signingkey[SMB3_SIGN_KEY_SIZE];
905
- __u8 smb3encryptionkey[SMB3_SIGN_KEY_SIZE];
906
- __u8 smb3decryptionkey[SMB3_SIGN_KEY_SIZE];
1005
+ __u8 smb3encryptionkey[SMB3_ENC_DEC_KEY_SIZE];
1006
+ __u8 smb3decryptionkey[SMB3_ENC_DEC_KEY_SIZE];
9071007 __u8 preauth_sha_hash[SMB2_PREAUTH_HASH_SIZE];
1008
+
1009
+ __u8 binding_preauth_sha_hash[SMB2_PREAUTH_HASH_SIZE];
9081010
9091011 /*
9101012 * Network interfaces available on the server this session is
....@@ -919,7 +1021,45 @@
9191021 struct cifs_server_iface *iface_list;
9201022 size_t iface_count;
9211023 unsigned long iface_last_update; /* jiffies */
1024
+
1025
+#define CIFS_MAX_CHANNELS 16
1026
+ struct cifs_chan chans[CIFS_MAX_CHANNELS];
1027
+ struct cifs_chan *binding_chan;
1028
+ size_t chan_count;
1029
+ size_t chan_max;
1030
+ atomic_t chan_seq; /* round robin state */
9221031 };
1032
+
1033
+/*
1034
+ * When binding a new channel, we need to access the channel which isn't fully
1035
+ * established yet.
1036
+ */
1037
+
1038
+static inline
1039
+struct cifs_chan *cifs_ses_binding_channel(struct cifs_ses *ses)
1040
+{
1041
+ if (ses->binding)
1042
+ return ses->binding_chan;
1043
+ else
1044
+ return NULL;
1045
+}
1046
+
1047
+/*
1048
+ * Returns the server pointer of the session. When binding a new
1049
+ * channel this returns the last channel which isn't fully established
1050
+ * yet.
1051
+ *
1052
+ * This function should be use for negprot/sess.setup codepaths. For
1053
+ * the other requests see cifs_pick_channel().
1054
+ */
1055
+static inline
1056
+struct TCP_Server_Info *cifs_ses_server(struct cifs_ses *ses)
1057
+{
1058
+ if (ses->binding)
1059
+ return ses->binding_chan->server;
1060
+ else
1061
+ return ses->server;
1062
+}
9231063
9241064 static inline bool
9251065 cap_unix(struct cifs_ses *ses)
....@@ -929,11 +1069,14 @@
9291069
9301070 struct cached_fid {
9311071 bool is_valid:1; /* Do we have a useable root fid */
1072
+ bool file_all_info_is_valid:1;
1073
+ bool has_lease:1;
9321074 struct kref refcount;
9331075 struct cifs_fid *fid;
9341076 struct mutex fid_mutex;
9351077 struct cifs_tcon *tcon;
9361078 struct work_struct lease_break;
1079
+ struct smb2_file_all_info file_all_info;
9371080 };
9381081
9391082 /*
....@@ -944,6 +1087,8 @@
9441087 struct list_head tcon_list;
9451088 int tc_count;
9461089 struct list_head rlist; /* reconnect list */
1090
+ atomic_t num_local_opens; /* num of all opens including disconnected */
1091
+ atomic_t num_remote_opens; /* num of all network opens on server */
9471092 struct list_head openFileList;
9481093 spinlock_t open_file_lock; /* protects list above */
9491094 struct cifs_ses *ses; /* pointer to session associated with */
....@@ -995,6 +1140,7 @@
9951140 bool retry:1;
9961141 bool nocase:1;
9971142 bool nohandlecache:1; /* if strange server resource prob can turn off */
1143
+ bool nodelete:1;
9981144 bool seal:1; /* transport encryption for this mounted share */
9991145 bool unix_ext:1; /* if false disable Linux extensions to CIFS protocol
10001146 for this mount even if server would support */
....@@ -1013,6 +1159,7 @@
10131159 __u32 vol_serial_number;
10141160 __le64 vol_create_time;
10151161 __u64 snapshot_time; /* for timewarp tokens - timestamp of snapshot */
1162
+ __u32 handle_timeout; /* persistent and durable handle timeout in ms */
10161163 __u32 ss_flags; /* sector size flags */
10171164 __u32 perf_sector_size; /* best sector size for perf */
10181165 __u32 max_chunks;
....@@ -1025,6 +1172,11 @@
10251172 struct list_head pending_opens; /* list of incomplete opens */
10261173 struct cached_fid crfid; /* Cached root fid */
10271174 /* BB add field for back pointer to sb struct(s)? */
1175
+#ifdef CONFIG_CIFS_DFS_UPCALL
1176
+ char *dfs_path;
1177
+ int remap:2;
1178
+ struct list_head ulist; /* cache update list */
1179
+#endif
10281180 };
10291181
10301182 /*
....@@ -1093,7 +1245,8 @@
10931245 __u64 offset;
10941246 __u64 length;
10951247 __u32 pid;
1096
- __u32 type;
1248
+ __u16 type;
1249
+ __u16 flags;
10971250 };
10981251
10991252 /*
....@@ -1115,6 +1268,7 @@
11151268 bool smallBuf:1; /* so we know which buf_release function to call */
11161269 };
11171270
1271
+#define ACL_NO_MODE ((umode_t)(-1))
11181272 struct cifs_open_parms {
11191273 struct cifs_tcon *tcon;
11201274 struct cifs_sb_info *cifs_sb;
....@@ -1133,8 +1287,12 @@
11331287 __u64 volatile_fid; /* volatile file id for smb2 */
11341288 __u8 lease_key[SMB2_LEASE_KEY_SIZE]; /* lease key for smb2 */
11351289 __u8 create_guid[16];
1290
+ __u32 access;
11361291 struct cifs_pending_open *pending_open;
11371292 unsigned int epoch;
1293
+#ifdef CONFIG_CIFS_DEBUG2
1294
+ __u64 mid;
1295
+#endif /* CIFS_DEBUG2 */
11381296 bool purge_cache;
11391297 };
11401298
....@@ -1160,6 +1318,7 @@
11601318 struct tcon_link *tlink;
11611319 unsigned int f_flags;
11621320 bool invalidHandle:1; /* file closed via session abend */
1321
+ bool swapfile:1;
11631322 bool oplock_break_cancelled:1;
11641323 unsigned int oplock_epoch; /* epoch from the lease break */
11651324 __u32 oplock_level; /* oplock/lease level from the lease break */
....@@ -1168,6 +1327,7 @@
11681327 struct mutex fh_mutex; /* prevents reopen race after dead ses*/
11691328 struct cifs_search_info srch_inf;
11701329 struct work_struct oplock_break; /* work for oplock breaks */
1330
+ struct work_struct put; /* work for the final part of _put */
11711331 };
11721332
11731333 struct cifs_io_parms {
....@@ -1178,6 +1338,7 @@
11781338 __u64 offset;
11791339 unsigned int length;
11801340 struct cifs_tcon *tcon;
1341
+ struct TCP_Server_Info *server;
11811342 };
11821343
11831344 struct cifs_aio_ctx {
....@@ -1195,6 +1356,11 @@
11951356 unsigned int len;
11961357 unsigned int total_len;
11971358 bool should_dirty;
1359
+ /*
1360
+ * Indicates if this aio_ctx is for direct_io,
1361
+ * If yes, iter is a copy of the user passed iov_iter
1362
+ */
1363
+ bool direct_io;
11981364 };
11991365
12001366 struct cifs_readdata;
....@@ -1220,13 +1386,14 @@
12201386 struct cifs_readdata *rdata,
12211387 struct iov_iter *iter);
12221388 struct kvec iov[2];
1389
+ struct TCP_Server_Info *server;
12231390 #ifdef CONFIG_CIFS_SMB_DIRECT
12241391 struct smbd_mr *mr;
12251392 #endif
12261393 unsigned int pagesz;
12271394 unsigned int page_offset;
12281395 unsigned int tailsz;
1229
- unsigned int credits;
1396
+ struct cifs_credits credits;
12301397 unsigned int nr_pages;
12311398 struct page **pages;
12321399 };
....@@ -1246,13 +1413,14 @@
12461413 pid_t pid;
12471414 unsigned int bytes;
12481415 int result;
1416
+ struct TCP_Server_Info *server;
12491417 #ifdef CONFIG_CIFS_SMB_DIRECT
12501418 struct smbd_mr *mr;
12511419 #endif
12521420 unsigned int pagesz;
12531421 unsigned int page_offset;
12541422 unsigned int tailsz;
1255
- unsigned int credits;
1423
+ struct cifs_credits credits;
12561424 unsigned int nr_pages;
12571425 struct page **pages;
12581426 };
....@@ -1268,7 +1436,8 @@
12681436 }
12691437
12701438 struct cifsFileInfo *cifsFileInfo_get(struct cifsFileInfo *cifs_file);
1271
-void _cifsFileInfo_put(struct cifsFileInfo *cifs_file, bool wait_oplock_hdlr);
1439
+void _cifsFileInfo_put(struct cifsFileInfo *cifs_file, bool wait_oplock_hdlr,
1440
+ bool offload);
12721441 void cifsFileInfo_put(struct cifsFileInfo *cifs_file);
12731442
12741443 #define CIFS_CACHE_READ_FLG 1
....@@ -1278,9 +1447,9 @@
12781447 #define CIFS_CACHE_RW_FLG (CIFS_CACHE_READ_FLG | CIFS_CACHE_WRITE_FLG)
12791448 #define CIFS_CACHE_RHW_FLG (CIFS_CACHE_RW_FLG | CIFS_CACHE_HANDLE_FLG)
12801449
1281
-#define CIFS_CACHE_READ(cinode) (cinode->oplock & CIFS_CACHE_READ_FLG)
1450
+#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))
12821451 #define CIFS_CACHE_HANDLE(cinode) (cinode->oplock & CIFS_CACHE_HANDLE_FLG)
1283
-#define CIFS_CACHE_WRITE(cinode) (cinode->oplock & CIFS_CACHE_WRITE_FLG)
1452
+#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))
12841453
12851454 /*
12861455 * One of these for each file inode
....@@ -1291,7 +1460,7 @@
12911460 struct list_head llist; /* locks helb by this inode */
12921461 /*
12931462 * NOTE: Some code paths call down_read(lock_sem) twice, so
1294
- * we must always use use cifs_down_write() instead of down_write()
1463
+ * we must always use cifs_down_write() instead of down_write()
12951464 * for this semaphore to avoid deadlocks.
12961465 */
12971466 struct rw_semaphore lock_sem; /* protect the fields above */
....@@ -1422,6 +1591,7 @@
14221591 struct TCP_Server_Info *server; /* server corresponding to this mid */
14231592 __u64 mid; /* multiplex id */
14241593 __u16 credits; /* number of credits consumed by this mid */
1594
+ __u16 credits_received; /* number of credits from the response */
14251595 __u32 pid; /* process id */
14261596 __u32 sequence_number; /* for CIFS signing */
14271597 unsigned long when_alloc; /* when mid was created */
....@@ -1433,11 +1603,13 @@
14331603 mid_callback_t *callback; /* call completion callback */
14341604 mid_handle_t *handle; /* call handle mid callback */
14351605 void *callback_data; /* general purpose pointer for callback */
1606
+ struct task_struct *creator;
14361607 void *resp_buf; /* pointer to received SMB header */
14371608 unsigned int resp_buf_size;
14381609 int mid_state; /* wish this were enum but can not pass to wait_event */
14391610 unsigned int mid_flags;
14401611 __le16 command; /* smb command code */
1612
+ unsigned int optype; /* operation type */
14411613 bool large_buf:1; /* if valid response, is pointer to large buf */
14421614 bool multiRsp:1; /* multiple trans2 responses for one request */
14431615 bool multiEnd:1; /* both received */
....@@ -1448,12 +1620,12 @@
14481620 struct cifs_fid fid;
14491621 struct cifs_tcon *tcon;
14501622 struct work_struct work;
1623
+ __u64 mid;
1624
+ __u16 cmd;
14511625 };
14521626
14531627 /* Make code in transport.c a little cleaner by moving
14541628 update of optional stats into function below */
1455
-#ifdef CONFIG_CIFS_STATS2
1456
-
14571629 static inline void cifs_in_send_inc(struct TCP_Server_Info *server)
14581630 {
14591631 atomic_inc(&server->in_send);
....@@ -1474,26 +1646,12 @@
14741646 atomic_dec(&server->num_waiters);
14751647 }
14761648
1649
+#ifdef CONFIG_CIFS_STATS2
14771650 static inline void cifs_save_when_sent(struct mid_q_entry *mid)
14781651 {
14791652 mid->when_sent = jiffies;
14801653 }
14811654 #else
1482
-static inline void cifs_in_send_inc(struct TCP_Server_Info *server)
1483
-{
1484
-}
1485
-static inline void cifs_in_send_dec(struct TCP_Server_Info *server)
1486
-{
1487
-}
1488
-
1489
-static inline void cifs_num_waiters_inc(struct TCP_Server_Info *server)
1490
-{
1491
-}
1492
-
1493
-static inline void cifs_num_waiters_dec(struct TCP_Server_Info *server)
1494
-{
1495
-}
1496
-
14971655 static inline void cifs_save_when_sent(struct mid_q_entry *mid)
14981656 {
14991657 }
....@@ -1520,6 +1678,7 @@
15201678 int ref_flag;
15211679 char *path_name;
15221680 char *node_name;
1681
+ int ttl;
15231682 };
15241683
15251684 /*
....@@ -1550,6 +1709,7 @@
15501709 struct timespec64 cf_atime;
15511710 struct timespec64 cf_mtime;
15521711 struct timespec64 cf_ctime;
1712
+ u32 cf_cifstag;
15531713 };
15541714
15551715 static inline void free_dfs_info_param(struct dfs_info3_param *param)
....@@ -1557,7 +1717,6 @@
15571717 if (param) {
15581718 kfree(param->path_name);
15591719 kfree(param->node_name);
1560
- kfree(param);
15611720 }
15621721 }
15631722
....@@ -1593,6 +1752,12 @@
15931752 return false;
15941753 }
15951754
1755
+
1756
+/* cifs_get_writable_file() flags */
1757
+#define FIND_WR_ANY 0
1758
+#define FIND_WR_FSUID_ONLY 1
1759
+#define FIND_WR_WITH_DELETE 2
1760
+
15961761 #define MID_FREE 0
15971762 #define MID_REQUEST_ALLOCATED 1
15981763 #define MID_REQUEST_SUBMITTED 2
....@@ -1613,20 +1778,22 @@
16131778
16141779 /* Type of Request to SendReceive2 */
16151780 #define CIFS_BLOCKING_OP 1 /* operation can block */
1616
-#define CIFS_ASYNC_OP 2 /* do not wait for response */
1781
+#define CIFS_NON_BLOCKING 2 /* do not block waiting for credits */
16171782 #define CIFS_TIMEOUT_MASK 0x003 /* only one of above set in req */
16181783 #define CIFS_LOG_ERROR 0x010 /* log NT STATUS if non-zero */
16191784 #define CIFS_LARGE_BUF_OP 0x020 /* large request buffer */
1620
-#define CIFS_NO_RESP 0x040 /* no response buffer required */
1785
+#define CIFS_NO_RSP_BUF 0x040 /* no response buffer required */
16211786
16221787 /* Type of request operation */
1623
-#define CIFS_ECHO_OP 0x080 /* echo request */
1624
-#define CIFS_OBREAK_OP 0x0100 /* oplock break request */
1625
-#define CIFS_NEG_OP 0x0200 /* negotiate request */
1626
-#define CIFS_OP_MASK 0x0380 /* mask request type */
1788
+#define CIFS_ECHO_OP 0x080 /* echo request */
1789
+#define CIFS_OBREAK_OP 0x0100 /* oplock break request */
1790
+#define CIFS_NEG_OP 0x0200 /* negotiate request */
1791
+#define CIFS_CP_CREATE_CLOSE_OP 0x0400 /* compound create+close request */
1792
+#define CIFS_OP_MASK 0x0780 /* mask request type */
16271793
16281794 #define CIFS_HAS_CREDITS 0x0400 /* already has credits */
16291795 #define CIFS_TRANSFORM_REQ 0x0800 /* transform request before sending */
1796
+#define CIFS_NO_SRV_RSP 0x1000 /* there is no server response */
16301797
16311798 /* Security Flags: indicate type of session setup needed */
16321799 #define CIFSSEC_MAY_SIGN 0x00001
....@@ -1695,6 +1862,8 @@
16951862 * GlobalMid_Lock protects:
16961863 * list operations on pending_mid_q and oplockQ
16971864 * updates to XID counters, multiplex id and SMB sequence numbers
1865
+ * list operations on global DnotifyReqList
1866
+ * updates to ses->status
16981867 * tcp_ses_lock protects:
16991868 * list operations on tcp and SMB session lists
17001869 * tcon->open_file_lock protects the list of open files hanging off the tcon
....@@ -1732,7 +1901,8 @@
17321901 /*
17331902 * This lock protects the cifs_tcp_ses_list, the list of smb sessions per
17341903 * tcp session, and the list of tcon's per smb session. It also protects
1735
- * the reference counters for the server, smb session, and tcon. Finally,
1904
+ * the reference counters for the server, smb session, and tcon. It also
1905
+ * protects some fields in the TCP_Server_Info struct such as dstaddr. Finally,
17361906 * changes to the tcon->tidStatus should be done while holding this lock.
17371907 * generally the locks should be taken in order tcp_ses_lock before
17381908 * tcon->open_file_lock and that before file->file_info_lock since the
....@@ -1769,6 +1939,7 @@
17691939 #ifdef CONFIG_CIFS_STATS2
17701940 GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
17711941 GLOBAL_EXTERN atomic_t totSmBufAllocCount;
1942
+extern unsigned int slow_rsp_threshold; /* number of secs before logging */
17721943 #endif
17731944 GLOBAL_EXTERN atomic_t smBufAllocCount;
17741945 GLOBAL_EXTERN atomic_t midCount;
....@@ -1779,6 +1950,8 @@
17791950 extern unsigned int global_secflags; /* if on, session setup sent
17801951 with more secure ntlmssp2 challenge/resp */
17811952 extern unsigned int sign_CIFS_PDUs; /* enable smb packet signing */
1953
+extern bool enable_gcm_256; /* allow optional negotiate of strongest signing (aes-gcm-256) */
1954
+extern bool require_gcm_256; /* require use of strongest signing (aes-gcm-256) */
17821955 extern bool linuxExtEnabled;/*enable Linux/Unix CIFS extensions*/
17831956 extern unsigned int CIFSMaxBufSize; /* max size not including hdr */
17841957 extern unsigned int cifs_min_rcv; /* min size of big ntwrk buf pool */
....@@ -1786,7 +1959,6 @@
17861959 extern unsigned int cifs_max_pending; /* MAX requests at once to server*/
17871960 extern bool disable_legacy_dialects; /* forbid vers=1.0 and vers=2.0 mounts */
17881961
1789
-#ifdef CONFIG_CIFS_ACL
17901962 GLOBAL_EXTERN struct rb_root uidtree;
17911963 GLOBAL_EXTERN struct rb_root gidtree;
17921964 GLOBAL_EXTERN spinlock_t siduidlock;
....@@ -1795,13 +1967,14 @@
17951967 GLOBAL_EXTERN struct rb_root sidgidtree;
17961968 GLOBAL_EXTERN spinlock_t uidsidlock;
17971969 GLOBAL_EXTERN spinlock_t gidsidlock;
1798
-#endif /* CONFIG_CIFS_ACL */
17991970
18001971 void cifs_oplock_break(struct work_struct *work);
18011972 void cifs_queue_oplock_break(struct cifsFileInfo *cfile);
18021973
18031974 extern const struct slow_work_ops cifs_oplock_break_ops;
18041975 extern struct workqueue_struct *cifsiod_wq;
1976
+extern struct workqueue_struct *decrypt_wq;
1977
+extern struct workqueue_struct *fileinfo_put_wq;
18051978 extern struct workqueue_struct *cifsoplockd_wq;
18061979 extern __u32 cifs_lock_secret;
18071980
....@@ -1809,11 +1982,13 @@
18091982
18101983 /* Operations for different SMB versions */
18111984 #define SMB1_VERSION_STRING "1.0"
1985
+#define SMB20_VERSION_STRING "2.0"
1986
+#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
18121987 extern struct smb_version_operations smb1_operations;
18131988 extern struct smb_version_values smb1_values;
1814
-#define SMB20_VERSION_STRING "2.0"
18151989 extern struct smb_version_operations smb20_operations;
18161990 extern struct smb_version_values smb20_values;
1991
+#endif /* CIFS_ALLOW_INSECURE_LEGACY */
18171992 #define SMB21_VERSION_STRING "2.1"
18181993 extern struct smb_version_operations smb21_operations;
18191994 extern struct smb_version_values smb21_values;
....@@ -1825,10 +2000,50 @@
18252000 extern struct smb_version_operations smb30_operations;
18262001 extern struct smb_version_values smb30_values;
18272002 #define SMB302_VERSION_STRING "3.02"
2003
+#define ALT_SMB302_VERSION_STRING "3.0.2"
18282004 /*extern struct smb_version_operations smb302_operations;*/ /* not needed yet */
18292005 extern struct smb_version_values smb302_values;
18302006 #define SMB311_VERSION_STRING "3.1.1"
18312007 #define ALT_SMB311_VERSION_STRING "3.11"
18322008 extern struct smb_version_operations smb311_operations;
18332009 extern struct smb_version_values smb311_values;
2010
+
2011
+static inline char *get_security_type_str(enum securityEnum sectype)
2012
+{
2013
+ switch (sectype) {
2014
+ case RawNTLMSSP:
2015
+ return "RawNTLMSSP";
2016
+ case Kerberos:
2017
+ return "Kerberos";
2018
+ case NTLMv2:
2019
+ return "NTLMv2";
2020
+ case NTLM:
2021
+ return "NTLM";
2022
+ case LANMAN:
2023
+ return "LANMAN";
2024
+ default:
2025
+ return "Unknown";
2026
+ }
2027
+}
2028
+
2029
+static inline bool is_smb1_server(struct TCP_Server_Info *server)
2030
+{
2031
+ return strcmp(server->vals->version_string, SMB1_VERSION_STRING) == 0;
2032
+}
2033
+
2034
+static inline bool is_tcon_dfs(struct cifs_tcon *tcon)
2035
+{
2036
+ /*
2037
+ * For SMB1, see MS-CIFS 2.4.55 SMB_COM_TREE_CONNECT_ANDX (0x75) and MS-CIFS 3.3.4.4 DFS
2038
+ * Subsystem Notifies That a Share Is a DFS Share.
2039
+ *
2040
+ * For SMB2+, see MS-SMB2 2.2.10 SMB2 TREE_CONNECT Response and MS-SMB2 3.3.4.14 Server
2041
+ * Application Updates a Share.
2042
+ */
2043
+ if (!tcon || !tcon->ses || !tcon->ses->server)
2044
+ return false;
2045
+ return is_smb1_server(tcon->ses->server) ? tcon->Flags & SMB_SHARE_IS_IN_DFS :
2046
+ tcon->share_flags & (SHI1005_FLAGS_DFS | SHI1005_FLAGS_DFS_ROOT);
2047
+}
2048
+
18342049 #endif /* _CIFS_GLOB_H */