aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2013-06-25 02:32:17 -0400
committerSteve French <smfrench@gmail.com>2013-06-26 18:31:41 -0400
commit2a2c41c07c710f2c1afe3748bdde40db9ea9d9e6 (patch)
treeb3aefdf4ddae055c48e56f0f75a8fbdeb8847dcf /fs/cifs
parent4a72dafa19ba77a2fb77ae676f8e3a0d6077c37c (diff)
revalidate directories instiantiated via FIND_* in order to handle DFS referrals
We've had a long-standing problem with DFS referral points. CIFS servers generally try to make them look like directories in FIND_FIRST/NEXT responses. When you go to try to do a FIND_FIRST on them though, the server will then (correctly) return STATUS_PATH_NOT_COVERED. Mostly this manifests as spurious EREMOTE errors back to userland. This patch attempts to fix this by marking directories that are discovered via FIND_FIRST/NEXT for revaldiation. When the lookup code runs across them again, we'll reissue a QPathInfo against them and that will make it chase the referral properly. There is some performance penalty involved here and no I haven't measured it -- it'll be highly dependent upon the workload and contents of the mounted share. To try and mitigate that though, the code only marks the inode for revalidation when it's possible to run across a DFS referral. i.e.: when the kernel has DFS support built in and the share is "in DFS" [At the Microsoft plugfest we noted that usually the DFS links had the REPARSE attribute tag enabled - DFS junctions are reparse points after all - so I just added a check for that flag too so the performance impact should be smaller - Steve] Signed-off-by: Jeff Layton <jlayton@redhat.com> Reviewed-by: Sachin Prabhu <sprabhu@redhat.com> Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs')
-rw-r--r--fs/cifs/readdir.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 770d5a9781c1..94d620198209 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -126,6 +126,22 @@ out:
126 dput(dentry); 126 dput(dentry);
127} 127}
128 128
129/*
130 * Is it possible that this directory might turn out to be a DFS referral
131 * once we go to try and use it?
132 */
133static bool
134cifs_dfs_is_possible(struct cifs_sb_info *cifs_sb)
135{
136#ifdef CONFIG_CIFS_DFS_UPCALL
137 struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
138
139 if (tcon->Flags & SMB_SHARE_IS_IN_DFS)
140 return true;
141#endif
142 return false;
143}
144
129static void 145static void
130cifs_fill_common_info(struct cifs_fattr *fattr, struct cifs_sb_info *cifs_sb) 146cifs_fill_common_info(struct cifs_fattr *fattr, struct cifs_sb_info *cifs_sb)
131{ 147{
@@ -135,6 +151,19 @@ cifs_fill_common_info(struct cifs_fattr *fattr, struct cifs_sb_info *cifs_sb)
135 if (fattr->cf_cifsattrs & ATTR_DIRECTORY) { 151 if (fattr->cf_cifsattrs & ATTR_DIRECTORY) {
136 fattr->cf_mode = S_IFDIR | cifs_sb->mnt_dir_mode; 152 fattr->cf_mode = S_IFDIR | cifs_sb->mnt_dir_mode;
137 fattr->cf_dtype = DT_DIR; 153 fattr->cf_dtype = DT_DIR;
154 /*
155 * Windows CIFS servers generally make DFS referrals look
156 * like directories in FIND_* responses with the reparse
157 * attribute flag also set (since DFS junctions are
158 * reparse points). We must revalidate at least these
159 * directory inodes before trying to use them (if
160 * they are DFS we will get PATH_NOT_COVERED back
161 * when queried directly and can then try to connect
162 * to the DFS target)
163 */
164 if (cifs_dfs_is_possible(cifs_sb) &&
165 (fattr->cf_cifsattrs & ATTR_REPARSE))
166 fattr->cf_flags |= CIFS_FATTR_NEED_REVAL;
138 } else { 167 } else {
139 fattr->cf_mode = S_IFREG | cifs_sb->mnt_file_mode; 168 fattr->cf_mode = S_IFREG | cifs_sb->mnt_file_mode;
140 fattr->cf_dtype = DT_REG; 169 fattr->cf_dtype = DT_REG;