aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2013-10-25 05:43:47 -0400
committerTakashi Iwai <tiwai@suse.de>2013-10-25 05:43:47 -0400
commit6913a9dbf18f08e3577695032da15812bda92b66 (patch)
tree05ca8620b11f2898022a7fd8a00f1f8566161428 /fs/cifs
parent7342017f4a0f129d277f78b8761f2732661ba30a (diff)
parent9645083ca5ef365b7b750cf219bb20b61bb925f8 (diff)
Merge tag 'asoc-v3.13' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-next
ASoC: Updates for v3.13 - Further work on the dmaengine helpers, including support for configuring the parameters for DMA by reading the capabilities of the DMA controller which removes some guesswork and magic numbers fromm drivers. - A refresh of the documentation. - Conversions of many drivers to direct regmap API usage in order to allow the ASoC level register I/O code to be removed, this will hopefully be completed by v3.14. - Support for using async register I/O in DAPM, reducing the time taken to implement power transitions on systems that support it.
Diffstat (limited to 'fs/cifs')
-rw-r--r--fs/cifs/cifsfs.c6
-rw-r--r--fs/cifs/cifsfs.h2
-rw-r--r--fs/cifs/cifsglob.h5
-rw-r--r--fs/cifs/cifspdu.h52
-rw-r--r--fs/cifs/cifssmb.c41
-rw-r--r--fs/cifs/file.c8
-rw-r--r--fs/cifs/fscache.c7
-rw-r--r--fs/cifs/fscache.h13
-rw-r--r--fs/cifs/inode.c45
-rw-r--r--fs/cifs/netmisc.c4
-rw-r--r--fs/cifs/readdir.c3
-rw-r--r--fs/cifs/sess.c88
-rw-r--r--fs/cifs/smb2pdu.c6
-rw-r--r--fs/cifs/smbfsctl.h14
-rw-r--r--fs/cifs/transport.c9
15 files changed, 167 insertions, 136 deletions
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index a16b4e58bcc6..77fc5e181077 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -120,14 +120,16 @@ cifs_read_super(struct super_block *sb)
120{ 120{
121 struct inode *inode; 121 struct inode *inode;
122 struct cifs_sb_info *cifs_sb; 122 struct cifs_sb_info *cifs_sb;
123 struct cifs_tcon *tcon;
123 int rc = 0; 124 int rc = 0;
124 125
125 cifs_sb = CIFS_SB(sb); 126 cifs_sb = CIFS_SB(sb);
127 tcon = cifs_sb_master_tcon(cifs_sb);
126 128
127 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIXACL) 129 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIXACL)
128 sb->s_flags |= MS_POSIXACL; 130 sb->s_flags |= MS_POSIXACL;
129 131
130 if (cifs_sb_master_tcon(cifs_sb)->ses->capabilities & CAP_LARGE_FILES) 132 if (tcon->ses->capabilities & tcon->ses->server->vals->cap_large_files)
131 sb->s_maxbytes = MAX_LFS_FILESIZE; 133 sb->s_maxbytes = MAX_LFS_FILESIZE;
132 else 134 else
133 sb->s_maxbytes = MAX_NON_LFS; 135 sb->s_maxbytes = MAX_NON_LFS;
@@ -147,7 +149,7 @@ cifs_read_super(struct super_block *sb)
147 goto out_no_root; 149 goto out_no_root;
148 } 150 }
149 151
150 if (cifs_sb_master_tcon(cifs_sb)->nocase) 152 if (tcon->nocase)
151 sb->s_d_op = &cifs_ci_dentry_ops; 153 sb->s_d_op = &cifs_ci_dentry_ops;
152 else 154 else
153 sb->s_d_op = &cifs_dentry_ops; 155 sb->s_d_op = &cifs_dentry_ops;
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h
index ea723a5e8226..6d0b07217ac9 100644
--- a/fs/cifs/cifsfs.h
+++ b/fs/cifs/cifsfs.h
@@ -132,5 +132,5 @@ extern long cifs_ioctl(struct file *filep, unsigned int cmd, unsigned long arg);
132extern const struct export_operations cifs_export_ops; 132extern const struct export_operations cifs_export_ops;
133#endif /* CONFIG_CIFS_NFSD_EXPORT */ 133#endif /* CONFIG_CIFS_NFSD_EXPORT */
134 134
135#define CIFS_VERSION "2.01" 135#define CIFS_VERSION "2.02"
136#endif /* _CIFSFS_H */ 136#endif /* _CIFSFS_H */
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index cfa14c80ef3b..52b6f6c26bfc 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -547,9 +547,6 @@ struct TCP_Server_Info {
547 unsigned int max_rw; /* maxRw specifies the maximum */ 547 unsigned int max_rw; /* maxRw specifies the maximum */
548 /* message size the server can send or receive for */ 548 /* message size the server can send or receive for */
549 /* SMB_COM_WRITE_RAW or SMB_COM_READ_RAW. */ 549 /* SMB_COM_WRITE_RAW or SMB_COM_READ_RAW. */
550 unsigned int max_vcs; /* maximum number of smb sessions, at least
551 those that can be specified uniquely with
552 vcnumbers */
553 unsigned int capabilities; /* selective disabling of caps by smb sess */ 550 unsigned int capabilities; /* selective disabling of caps by smb sess */
554 int timeAdj; /* Adjust for difference in server time zone in sec */ 551 int timeAdj; /* Adjust for difference in server time zone in sec */
555 __u64 CurrentMid; /* multiplex id - rotating counter */ 552 __u64 CurrentMid; /* multiplex id - rotating counter */
@@ -715,7 +712,6 @@ struct cifs_ses {
715 enum statusEnum status; 712 enum statusEnum status;
716 unsigned overrideSecFlg; /* if non-zero override global sec flags */ 713 unsigned overrideSecFlg; /* if non-zero override global sec flags */
717 __u16 ipc_tid; /* special tid for connection to IPC share */ 714 __u16 ipc_tid; /* special tid for connection to IPC share */
718 __u16 vcnum;
719 char *serverOS; /* name of operating system underlying server */ 715 char *serverOS; /* name of operating system underlying server */
720 char *serverNOS; /* name of network operating system of server */ 716 char *serverNOS; /* name of network operating system of server */
721 char *serverDomain; /* security realm of server */ 717 char *serverDomain; /* security realm of server */
@@ -1272,6 +1268,7 @@ struct dfs_info3_param {
1272#define CIFS_FATTR_DELETE_PENDING 0x2 1268#define CIFS_FATTR_DELETE_PENDING 0x2
1273#define CIFS_FATTR_NEED_REVAL 0x4 1269#define CIFS_FATTR_NEED_REVAL 0x4
1274#define CIFS_FATTR_INO_COLLISION 0x8 1270#define CIFS_FATTR_INO_COLLISION 0x8
1271#define CIFS_FATTR_UNKNOWN_NLINK 0x10
1275 1272
1276struct cifs_fattr { 1273struct cifs_fattr {
1277 u32 cf_flags; 1274 u32 cf_flags;
diff --git a/fs/cifs/cifspdu.h b/fs/cifs/cifspdu.h
index 948676db8e2e..08f9dfb1a894 100644
--- a/fs/cifs/cifspdu.h
+++ b/fs/cifs/cifspdu.h
@@ -1491,15 +1491,30 @@ struct file_notify_information {
1491 __u8 FileName[0]; 1491 __u8 FileName[0];
1492} __attribute__((packed)); 1492} __attribute__((packed));
1493 1493
1494struct reparse_data { 1494/* For IO_REPARSE_TAG_SYMLINK */
1495 __u32 ReparseTag; 1495struct reparse_symlink_data {
1496 __u16 ReparseDataLength; 1496 __le32 ReparseTag;
1497 __le16 ReparseDataLength;
1497 __u16 Reserved; 1498 __u16 Reserved;
1498 __u16 SubstituteNameOffset; 1499 __le16 SubstituteNameOffset;
1499 __u16 SubstituteNameLength; 1500 __le16 SubstituteNameLength;
1500 __u16 PrintNameOffset; 1501 __le16 PrintNameOffset;
1501 __u16 PrintNameLength; 1502 __le16 PrintNameLength;
1502 __u32 Flags; 1503 __le32 Flags;
1504 char PathBuffer[0];
1505} __attribute__((packed));
1506
1507/* For IO_REPARSE_TAG_NFS */
1508#define NFS_SPECFILE_LNK 0x00000000014B4E4C
1509#define NFS_SPECFILE_CHR 0x0000000000524843
1510#define NFS_SPECFILE_BLK 0x00000000004B4C42
1511#define NFS_SPECFILE_FIFO 0x000000004F464946
1512#define NFS_SPECFILE_SOCK 0x000000004B434F53
1513struct reparse_posix_data {
1514 __le32 ReparseTag;
1515 __le16 ReparseDataLength;
1516 __u16 Reserved;
1517 __le64 InodeType; /* LNK, FIFO, CHR etc. */
1503 char PathBuffer[0]; 1518 char PathBuffer[0];
1504} __attribute__((packed)); 1519} __attribute__((packed));
1505 1520
@@ -2652,26 +2667,7 @@ typedef struct file_xattr_info {
2652} __attribute__((packed)) FILE_XATTR_INFO; /* extended attribute info 2667} __attribute__((packed)) FILE_XATTR_INFO; /* extended attribute info
2653 level 0x205 */ 2668 level 0x205 */
2654 2669
2655 2670/* flags for lsattr and chflags commands removed arein uapi/linux/fs.h */
2656/* flags for chattr command */
2657#define EXT_SECURE_DELETE 0x00000001 /* EXT3_SECRM_FL */
2658#define EXT_ENABLE_UNDELETE 0x00000002 /* EXT3_UNRM_FL */
2659/* Reserved for compress file 0x4 */
2660#define EXT_SYNCHRONOUS 0x00000008 /* EXT3_SYNC_FL */
2661#define EXT_IMMUTABLE_FL 0x00000010 /* EXT3_IMMUTABLE_FL */
2662#define EXT_OPEN_APPEND_ONLY 0x00000020 /* EXT3_APPEND_FL */
2663#define EXT_DO_NOT_BACKUP 0x00000040 /* EXT3_NODUMP_FL */
2664#define EXT_NO_UPDATE_ATIME 0x00000080 /* EXT3_NOATIME_FL */
2665/* 0x100 through 0x800 reserved for compression flags and are GET-ONLY */
2666#define EXT_HASH_TREE_INDEXED_DIR 0x00001000 /* GET-ONLY EXT3_INDEX_FL */
2667/* 0x2000 reserved for IMAGIC_FL */
2668#define EXT_JOURNAL_THIS_FILE 0x00004000 /* GET-ONLY EXT3_JOURNAL_DATA_FL */
2669/* 0x8000 reserved for EXT3_NOTAIL_FL */
2670#define EXT_SYNCHRONOUS_DIR 0x00010000 /* EXT3_DIRSYNC_FL */
2671#define EXT_TOPDIR 0x00020000 /* EXT3_TOPDIR_FL */
2672
2673#define EXT_SET_MASK 0x000300FF
2674#define EXT_GET_MASK 0x0003DFFF
2675 2671
2676typedef struct file_chattr_info { 2672typedef struct file_chattr_info {
2677 __le64 mask; /* list of all possible attribute bits */ 2673 __le64 mask; /* list of all possible attribute bits */
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index a3d74fea1623..ccd31ab815d4 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -463,7 +463,6 @@ decode_lanman_negprot_rsp(struct TCP_Server_Info *server, NEGOTIATE_RSP *pSMBr)
463 cifs_max_pending); 463 cifs_max_pending);
464 set_credits(server, server->maxReq); 464 set_credits(server, server->maxReq);
465 server->maxBuf = le16_to_cpu(rsp->MaxBufSize); 465 server->maxBuf = le16_to_cpu(rsp->MaxBufSize);
466 server->max_vcs = le16_to_cpu(rsp->MaxNumberVcs);
467 /* even though we do not use raw we might as well set this 466 /* even though we do not use raw we might as well set this
468 accurately, in case we ever find a need for it */ 467 accurately, in case we ever find a need for it */
469 if ((le16_to_cpu(rsp->RawMode) & RAW_ENABLE) == RAW_ENABLE) { 468 if ((le16_to_cpu(rsp->RawMode) & RAW_ENABLE) == RAW_ENABLE) {
@@ -3089,7 +3088,8 @@ CIFSSMBQuerySymLink(const unsigned int xid, struct cifs_tcon *tcon,
3089 bool is_unicode; 3088 bool is_unicode;
3090 unsigned int sub_len; 3089 unsigned int sub_len;
3091 char *sub_start; 3090 char *sub_start;
3092 struct reparse_data *reparse_buf; 3091 struct reparse_symlink_data *reparse_buf;
3092 struct reparse_posix_data *posix_buf;
3093 __u32 data_offset, data_count; 3093 __u32 data_offset, data_count;
3094 char *end_of_smb; 3094 char *end_of_smb;
3095 3095
@@ -3138,20 +3138,47 @@ CIFSSMBQuerySymLink(const unsigned int xid, struct cifs_tcon *tcon,
3138 goto qreparse_out; 3138 goto qreparse_out;
3139 } 3139 }
3140 end_of_smb = 2 + get_bcc(&pSMBr->hdr) + (char *)&pSMBr->ByteCount; 3140 end_of_smb = 2 + get_bcc(&pSMBr->hdr) + (char *)&pSMBr->ByteCount;
3141 reparse_buf = (struct reparse_data *) 3141 reparse_buf = (struct reparse_symlink_data *)
3142 ((char *)&pSMBr->hdr.Protocol + data_offset); 3142 ((char *)&pSMBr->hdr.Protocol + data_offset);
3143 if ((char *)reparse_buf >= end_of_smb) { 3143 if ((char *)reparse_buf >= end_of_smb) {
3144 rc = -EIO; 3144 rc = -EIO;
3145 goto qreparse_out; 3145 goto qreparse_out;
3146 } 3146 }
3147 if ((reparse_buf->PathBuffer + reparse_buf->PrintNameOffset + 3147 if (reparse_buf->ReparseTag == cpu_to_le32(IO_REPARSE_TAG_NFS)) {
3148 reparse_buf->PrintNameLength) > end_of_smb) { 3148 cifs_dbg(FYI, "NFS style reparse tag\n");
3149 posix_buf = (struct reparse_posix_data *)reparse_buf;
3150
3151 if (posix_buf->InodeType != cpu_to_le64(NFS_SPECFILE_LNK)) {
3152 cifs_dbg(FYI, "unsupported file type 0x%llx\n",
3153 le64_to_cpu(posix_buf->InodeType));
3154 rc = -EOPNOTSUPP;
3155 goto qreparse_out;
3156 }
3157 is_unicode = true;
3158 sub_len = le16_to_cpu(reparse_buf->ReparseDataLength);
3159 if (posix_buf->PathBuffer + sub_len > end_of_smb) {
3160 cifs_dbg(FYI, "reparse buf beyond SMB\n");
3161 rc = -EIO;
3162 goto qreparse_out;
3163 }
3164 *symlinkinfo = cifs_strndup_from_utf16(posix_buf->PathBuffer,
3165 sub_len, is_unicode, nls_codepage);
3166 goto qreparse_out;
3167 } else if (reparse_buf->ReparseTag !=
3168 cpu_to_le32(IO_REPARSE_TAG_SYMLINK)) {
3169 rc = -EOPNOTSUPP;
3170 goto qreparse_out;
3171 }
3172
3173 /* Reparse tag is NTFS symlink */
3174 sub_start = le16_to_cpu(reparse_buf->SubstituteNameOffset) +
3175 reparse_buf->PathBuffer;
3176 sub_len = le16_to_cpu(reparse_buf->SubstituteNameLength);
3177 if (sub_start + sub_len > end_of_smb) {
3149 cifs_dbg(FYI, "reparse buf beyond SMB\n"); 3178 cifs_dbg(FYI, "reparse buf beyond SMB\n");
3150 rc = -EIO; 3179 rc = -EIO;
3151 goto qreparse_out; 3180 goto qreparse_out;
3152 } 3181 }
3153 sub_start = reparse_buf->SubstituteNameOffset + reparse_buf->PathBuffer;
3154 sub_len = reparse_buf->SubstituteNameLength;
3155 if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) 3182 if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE)
3156 is_unicode = true; 3183 is_unicode = true;
3157 else 3184 else
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index eb955b525e55..7ddddf2e2504 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -3254,6 +3254,9 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
3254 /* 3254 /*
3255 * Reads as many pages as possible from fscache. Returns -ENOBUFS 3255 * Reads as many pages as possible from fscache. Returns -ENOBUFS
3256 * immediately if the cookie is negative 3256 * immediately if the cookie is negative
3257 *
3258 * After this point, every page in the list might have PG_fscache set,
3259 * so we will need to clean that up off of every page we don't use.
3257 */ 3260 */
3258 rc = cifs_readpages_from_fscache(mapping->host, mapping, page_list, 3261 rc = cifs_readpages_from_fscache(mapping->host, mapping, page_list,
3259 &num_pages); 3262 &num_pages);
@@ -3376,6 +3379,11 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
3376 kref_put(&rdata->refcount, cifs_readdata_release); 3379 kref_put(&rdata->refcount, cifs_readdata_release);
3377 } 3380 }
3378 3381
3382 /* Any pages that have been shown to fscache but didn't get added to
3383 * the pagecache must be uncached before they get returned to the
3384 * allocator.
3385 */
3386 cifs_fscache_readpages_cancel(mapping->host, page_list);
3379 return rc; 3387 return rc;
3380} 3388}
3381 3389
diff --git a/fs/cifs/fscache.c b/fs/cifs/fscache.c
index 2f4bc5a58054..b3258f35e88a 100644
--- a/fs/cifs/fscache.c
+++ b/fs/cifs/fscache.c
@@ -223,6 +223,13 @@ void __cifs_readpage_to_fscache(struct inode *inode, struct page *page)
223 fscache_uncache_page(CIFS_I(inode)->fscache, page); 223 fscache_uncache_page(CIFS_I(inode)->fscache, page);
224} 224}
225 225
226void __cifs_fscache_readpages_cancel(struct inode *inode, struct list_head *pages)
227{
228 cifs_dbg(FYI, "%s: (fsc: %p, i: %p)\n",
229 __func__, CIFS_I(inode)->fscache, inode);
230 fscache_readpages_cancel(CIFS_I(inode)->fscache, pages);
231}
232
226void __cifs_fscache_invalidate_page(struct page *page, struct inode *inode) 233void __cifs_fscache_invalidate_page(struct page *page, struct inode *inode)
227{ 234{
228 struct cifsInodeInfo *cifsi = CIFS_I(inode); 235 struct cifsInodeInfo *cifsi = CIFS_I(inode);
diff --git a/fs/cifs/fscache.h b/fs/cifs/fscache.h
index 63539323e0b9..24794b6cd8ec 100644
--- a/fs/cifs/fscache.h
+++ b/fs/cifs/fscache.h
@@ -54,6 +54,7 @@ extern int __cifs_readpages_from_fscache(struct inode *,
54 struct address_space *, 54 struct address_space *,
55 struct list_head *, 55 struct list_head *,
56 unsigned *); 56 unsigned *);
57extern void __cifs_fscache_readpages_cancel(struct inode *, struct list_head *);
57 58
58extern void __cifs_readpage_to_fscache(struct inode *, struct page *); 59extern void __cifs_readpage_to_fscache(struct inode *, struct page *);
59 60
@@ -91,6 +92,13 @@ static inline void cifs_readpage_to_fscache(struct inode *inode,
91 __cifs_readpage_to_fscache(inode, page); 92 __cifs_readpage_to_fscache(inode, page);
92} 93}
93 94
95static inline void cifs_fscache_readpages_cancel(struct inode *inode,
96 struct list_head *pages)
97{
98 if (CIFS_I(inode)->fscache)
99 return __cifs_fscache_readpages_cancel(inode, pages);
100}
101
94#else /* CONFIG_CIFS_FSCACHE */ 102#else /* CONFIG_CIFS_FSCACHE */
95static inline int cifs_fscache_register(void) { return 0; } 103static inline int cifs_fscache_register(void) { return 0; }
96static inline void cifs_fscache_unregister(void) {} 104static inline void cifs_fscache_unregister(void) {}
@@ -131,6 +139,11 @@ static inline int cifs_readpages_from_fscache(struct inode *inode,
131static inline void cifs_readpage_to_fscache(struct inode *inode, 139static inline void cifs_readpage_to_fscache(struct inode *inode,
132 struct page *page) {} 140 struct page *page) {}
133 141
142static inline void cifs_fscache_readpages_cancel(struct inode *inode,
143 struct list_head *pages)
144{
145}
146
134#endif /* CONFIG_CIFS_FSCACHE */ 147#endif /* CONFIG_CIFS_FSCACHE */
135 148
136#endif /* _CIFS_FSCACHE_H */ 149#endif /* _CIFS_FSCACHE_H */
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index f9ff9c173f78..867b7cdc794a 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -120,6 +120,33 @@ cifs_revalidate_cache(struct inode *inode, struct cifs_fattr *fattr)
120 cifs_i->invalid_mapping = true; 120 cifs_i->invalid_mapping = true;
121} 121}
122 122
123/*
124 * copy nlink to the inode, unless it wasn't provided. Provide
125 * sane values if we don't have an existing one and none was provided
126 */
127static void
128cifs_nlink_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr)
129{
130 /*
131 * if we're in a situation where we can't trust what we
132 * got from the server (readdir, some non-unix cases)
133 * fake reasonable values
134 */
135 if (fattr->cf_flags & CIFS_FATTR_UNKNOWN_NLINK) {
136 /* only provide fake values on a new inode */
137 if (inode->i_state & I_NEW) {
138 if (fattr->cf_cifsattrs & ATTR_DIRECTORY)
139 set_nlink(inode, 2);
140 else
141 set_nlink(inode, 1);
142 }
143 return;
144 }
145
146 /* we trust the server, so update it */
147 set_nlink(inode, fattr->cf_nlink);
148}
149
123/* populate an inode with info from a cifs_fattr struct */ 150/* populate an inode with info from a cifs_fattr struct */
124void 151void
125cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr) 152cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr)
@@ -134,7 +161,7 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr)
134 inode->i_mtime = fattr->cf_mtime; 161 inode->i_mtime = fattr->cf_mtime;
135 inode->i_ctime = fattr->cf_ctime; 162 inode->i_ctime = fattr->cf_ctime;
136 inode->i_rdev = fattr->cf_rdev; 163 inode->i_rdev = fattr->cf_rdev;
137 set_nlink(inode, fattr->cf_nlink); 164 cifs_nlink_fattr_to_inode(inode, fattr);
138 inode->i_uid = fattr->cf_uid; 165 inode->i_uid = fattr->cf_uid;
139 inode->i_gid = fattr->cf_gid; 166 inode->i_gid = fattr->cf_gid;
140 167
@@ -541,6 +568,7 @@ cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info,
541 fattr->cf_bytes = le64_to_cpu(info->AllocationSize); 568 fattr->cf_bytes = le64_to_cpu(info->AllocationSize);
542 fattr->cf_createtime = le64_to_cpu(info->CreationTime); 569 fattr->cf_createtime = le64_to_cpu(info->CreationTime);
543 570
571 fattr->cf_nlink = le32_to_cpu(info->NumberOfLinks);
544 if (fattr->cf_cifsattrs & ATTR_DIRECTORY) { 572 if (fattr->cf_cifsattrs & ATTR_DIRECTORY) {
545 fattr->cf_mode = S_IFDIR | cifs_sb->mnt_dir_mode; 573 fattr->cf_mode = S_IFDIR | cifs_sb->mnt_dir_mode;
546 fattr->cf_dtype = DT_DIR; 574 fattr->cf_dtype = DT_DIR;
@@ -548,7 +576,8 @@ cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info,
548 * Server can return wrong NumberOfLinks value for directories 576 * Server can return wrong NumberOfLinks value for directories
549 * when Unix extensions are disabled - fake it. 577 * when Unix extensions are disabled - fake it.
550 */ 578 */
551 fattr->cf_nlink = 2; 579 if (!tcon->unix_ext)
580 fattr->cf_flags |= CIFS_FATTR_UNKNOWN_NLINK;
552 } else if (fattr->cf_cifsattrs & ATTR_REPARSE) { 581 } else if (fattr->cf_cifsattrs & ATTR_REPARSE) {
553 fattr->cf_mode = S_IFLNK; 582 fattr->cf_mode = S_IFLNK;
554 fattr->cf_dtype = DT_LNK; 583 fattr->cf_dtype = DT_LNK;
@@ -561,11 +590,15 @@ cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info,
561 if (fattr->cf_cifsattrs & ATTR_READONLY) 590 if (fattr->cf_cifsattrs & ATTR_READONLY)
562 fattr->cf_mode &= ~(S_IWUGO); 591 fattr->cf_mode &= ~(S_IWUGO);
563 592
564 fattr->cf_nlink = le32_to_cpu(info->NumberOfLinks); 593 /*
565 if (fattr->cf_nlink < 1) { 594 * Don't accept zero nlink from non-unix servers unless
566 cifs_dbg(1, "replacing bogus file nlink value %u\n", 595 * delete is pending. Instead mark it as unknown.
596 */
597 if ((fattr->cf_nlink < 1) && !tcon->unix_ext &&
598 !info->DeletePending) {
599 cifs_dbg(1, "bogus file nlink value %u\n",
567 fattr->cf_nlink); 600 fattr->cf_nlink);
568 fattr->cf_nlink = 1; 601 fattr->cf_flags |= CIFS_FATTR_UNKNOWN_NLINK;
569 } 602 }
570 } 603 }
571 604
diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c
index af847e1cf1c1..651a5279607b 100644
--- a/fs/cifs/netmisc.c
+++ b/fs/cifs/netmisc.c
@@ -780,7 +780,9 @@ static const struct {
780 ERRDOS, ERRnoaccess, 0xc0000290}, { 780 ERRDOS, ERRnoaccess, 0xc0000290}, {
781 ERRDOS, ERRbadfunc, 0xc000029c}, { 781 ERRDOS, ERRbadfunc, 0xc000029c}, {
782 ERRDOS, ERRsymlink, NT_STATUS_STOPPED_ON_SYMLINK}, { 782 ERRDOS, ERRsymlink, NT_STATUS_STOPPED_ON_SYMLINK}, {
783 ERRDOS, ERRinvlevel, 0x007c0001}, }; 783 ERRDOS, ERRinvlevel, 0x007c0001}, {
784 0, 0, 0 }
785};
784 786
785/***************************************************************************** 787/*****************************************************************************
786 Print an error message from the status code 788 Print an error message from the status code
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 42ef03be089f..53a75f3d0179 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -180,6 +180,9 @@ cifs_fill_common_info(struct cifs_fattr *fattr, struct cifs_sb_info *cifs_sb)
180 fattr->cf_dtype = DT_REG; 180 fattr->cf_dtype = DT_REG;
181 } 181 }
182 182
183 /* non-unix readdir doesn't provide nlink */
184 fattr->cf_flags |= CIFS_FATTR_UNKNOWN_NLINK;
185
183 if (fattr->cf_cifsattrs & ATTR_READONLY) 186 if (fattr->cf_cifsattrs & ATTR_READONLY)
184 fattr->cf_mode &= ~S_IWUGO; 187 fattr->cf_mode &= ~S_IWUGO;
185 188
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
index 5f99b7f19e78..e87387dbf39f 100644
--- a/fs/cifs/sess.c
+++ b/fs/cifs/sess.c
@@ -32,88 +32,6 @@
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include "cifs_spnego.h" 33#include "cifs_spnego.h"
34 34
35/*
36 * Checks if this is the first smb session to be reconnected after
37 * the socket has been reestablished (so we know whether to use vc 0).
38 * Called while holding the cifs_tcp_ses_lock, so do not block
39 */
40static bool is_first_ses_reconnect(struct cifs_ses *ses)
41{
42 struct list_head *tmp;
43 struct cifs_ses *tmp_ses;
44
45 list_for_each(tmp, &ses->server->smb_ses_list) {
46 tmp_ses = list_entry(tmp, struct cifs_ses,
47 smb_ses_list);
48 if (tmp_ses->need_reconnect == false)
49 return false;
50 }
51 /* could not find a session that was already connected,
52 this must be the first one we are reconnecting */
53 return true;
54}
55
56/*
57 * vc number 0 is treated specially by some servers, and should be the
58 * first one we request. After that we can use vcnumbers up to maxvcs,
59 * one for each smb session (some Windows versions set maxvcs incorrectly
60 * so maxvc=1 can be ignored). If we have too many vcs, we can reuse
61 * any vc but zero (some servers reset the connection on vcnum zero)
62 *
63 */
64static __le16 get_next_vcnum(struct cifs_ses *ses)
65{
66 __u16 vcnum = 0;
67 struct list_head *tmp;
68 struct cifs_ses *tmp_ses;
69 __u16 max_vcs = ses->server->max_vcs;
70 __u16 i;
71 int free_vc_found = 0;
72
73 /* Quoting the MS-SMB specification: "Windows-based SMB servers set this
74 field to one but do not enforce this limit, which allows an SMB client
75 to establish more virtual circuits than allowed by this value ... but
76 other server implementations can enforce this limit." */
77 if (max_vcs < 2)
78 max_vcs = 0xFFFF;
79
80 spin_lock(&cifs_tcp_ses_lock);
81 if ((ses->need_reconnect) && is_first_ses_reconnect(ses))
82 goto get_vc_num_exit; /* vcnum will be zero */
83 for (i = ses->server->srv_count - 1; i < max_vcs; i++) {
84 if (i == 0) /* this is the only connection, use vc 0 */
85 break;
86
87 free_vc_found = 1;
88
89 list_for_each(tmp, &ses->server->smb_ses_list) {
90 tmp_ses = list_entry(tmp, struct cifs_ses,
91 smb_ses_list);
92 if (tmp_ses->vcnum == i) {
93 free_vc_found = 0;
94 break; /* found duplicate, try next vcnum */
95 }
96 }
97 if (free_vc_found)
98 break; /* we found a vcnumber that will work - use it */
99 }
100
101 if (i == 0)
102 vcnum = 0; /* for most common case, ie if one smb session, use
103 vc zero. Also for case when no free vcnum, zero
104 is safest to send (some clients only send zero) */
105 else if (free_vc_found == 0)
106 vcnum = 1; /* we can not reuse vc=0 safely, since some servers
107 reset all uids on that, but 1 is ok. */
108 else
109 vcnum = i;
110 ses->vcnum = vcnum;
111get_vc_num_exit:
112 spin_unlock(&cifs_tcp_ses_lock);
113
114 return cpu_to_le16(vcnum);
115}
116
117static __u32 cifs_ssetup_hdr(struct cifs_ses *ses, SESSION_SETUP_ANDX *pSMB) 35static __u32 cifs_ssetup_hdr(struct cifs_ses *ses, SESSION_SETUP_ANDX *pSMB)
118{ 36{
119 __u32 capabilities = 0; 37 __u32 capabilities = 0;
@@ -128,7 +46,7 @@ static __u32 cifs_ssetup_hdr(struct cifs_ses *ses, SESSION_SETUP_ANDX *pSMB)
128 CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4, 46 CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4,
129 USHRT_MAX)); 47 USHRT_MAX));
130 pSMB->req.MaxMpxCount = cpu_to_le16(ses->server->maxReq); 48 pSMB->req.MaxMpxCount = cpu_to_le16(ses->server->maxReq);
131 pSMB->req.VcNumber = get_next_vcnum(ses); 49 pSMB->req.VcNumber = __constant_cpu_to_le16(1);
132 50
133 /* Now no need to set SMBFLG_CASELESS or obsolete CANONICAL PATH */ 51 /* Now no need to set SMBFLG_CASELESS or obsolete CANONICAL PATH */
134 52
@@ -582,9 +500,9 @@ select_sectype(struct TCP_Server_Info *server, enum securityEnum requested)
582 return NTLMv2; 500 return NTLMv2;
583 if (global_secflags & CIFSSEC_MAY_NTLM) 501 if (global_secflags & CIFSSEC_MAY_NTLM)
584 return NTLM; 502 return NTLM;
585 /* Fallthrough */
586 default: 503 default:
587 return Unspecified; 504 /* Fallthrough to attempt LANMAN authentication next */
505 break;
588 } 506 }
589 case CIFS_NEGFLAVOR_LANMAN: 507 case CIFS_NEGFLAVOR_LANMAN:
590 switch (requested) { 508 switch (requested) {
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index eba0efde66d7..edccb5252462 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -687,6 +687,10 @@ SMB2_logoff(const unsigned int xid, struct cifs_ses *ses)
687 else 687 else
688 return -EIO; 688 return -EIO;
689 689
690 /* no need to send SMB logoff if uid already closed due to reconnect */
691 if (ses->need_reconnect)
692 goto smb2_session_already_dead;
693
690 rc = small_smb2_init(SMB2_LOGOFF, NULL, (void **) &req); 694 rc = small_smb2_init(SMB2_LOGOFF, NULL, (void **) &req);
691 if (rc) 695 if (rc)
692 return rc; 696 return rc;
@@ -701,6 +705,8 @@ SMB2_logoff(const unsigned int xid, struct cifs_ses *ses)
701 * No tcon so can't do 705 * No tcon so can't do
702 * cifs_stats_inc(&tcon->stats.smb2_stats.smb2_com_fail[SMB2...]); 706 * cifs_stats_inc(&tcon->stats.smb2_stats.smb2_com_fail[SMB2...]);
703 */ 707 */
708
709smb2_session_already_dead:
704 return rc; 710 return rc;
705} 711}
706 712
diff --git a/fs/cifs/smbfsctl.h b/fs/cifs/smbfsctl.h
index d952ee48f4dc..a4b2391fe66e 100644
--- a/fs/cifs/smbfsctl.h
+++ b/fs/cifs/smbfsctl.h
@@ -97,9 +97,23 @@
97#define FSCTL_QUERY_NETWORK_INTERFACE_INFO 0x001401FC /* BB add struct */ 97#define FSCTL_QUERY_NETWORK_INTERFACE_INFO 0x001401FC /* BB add struct */
98#define FSCTL_SRV_READ_HASH 0x001441BB /* BB add struct */ 98#define FSCTL_SRV_READ_HASH 0x001441BB /* BB add struct */
99 99
100/* See FSCC 2.1.2.5 */
100#define IO_REPARSE_TAG_MOUNT_POINT 0xA0000003 101#define IO_REPARSE_TAG_MOUNT_POINT 0xA0000003
101#define IO_REPARSE_TAG_HSM 0xC0000004 102#define IO_REPARSE_TAG_HSM 0xC0000004
102#define IO_REPARSE_TAG_SIS 0x80000007 103#define IO_REPARSE_TAG_SIS 0x80000007
104#define IO_REPARSE_TAG_HSM2 0x80000006
105#define IO_REPARSE_TAG_DRIVER_EXTENDER 0x80000005
106/* Used by the DFS filter. See MS-DFSC */
107#define IO_REPARSE_TAG_DFS 0x8000000A
108/* Used by the DFS filter See MS-DFSC */
109#define IO_REPARSE_TAG_DFSR 0x80000012
110#define IO_REPARSE_TAG_FILTER_MANAGER 0x8000000B
111/* See section MS-FSCC 2.1.2.4 */
112#define IO_REPARSE_TAG_SYMLINK 0xA000000C
113#define IO_REPARSE_TAG_DEDUP 0x80000013
114#define IO_REPARSE_APPXSTREAM 0xC0000014
115/* NFS symlinks, Win 8/SMB3 and later */
116#define IO_REPARSE_TAG_NFS 0x80000014
103 117
104/* fsctl flags */ 118/* fsctl flags */
105/* If Flags is set to this value, the request is an FSCTL not ioctl request */ 119/* If Flags is set to this value, the request is an FSCTL not ioctl request */
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index 6fdcb1b4a106..800b938e4061 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -410,8 +410,13 @@ static int
410wait_for_free_request(struct TCP_Server_Info *server, const int timeout, 410wait_for_free_request(struct TCP_Server_Info *server, const int timeout,
411 const int optype) 411 const int optype)
412{ 412{
413 return wait_for_free_credits(server, timeout, 413 int *val;
414 server->ops->get_credits_field(server, optype)); 414
415 val = server->ops->get_credits_field(server, optype);
416 /* Since an echo is already inflight, no need to wait to send another */
417 if (*val <= 0 && optype == CIFS_ECHO_OP)
418 return -EAGAIN;
419 return wait_for_free_credits(server, timeout, val);
415} 420}
416 421
417static int allocate_mid(struct cifs_ses *ses, struct smb_hdr *in_buf, 422static int allocate_mid(struct cifs_ses *ses, struct smb_hdr *in_buf,