From: Sachin Prabhu <sprabhu@redhat.com>
Subject: Fix regression which breaks DFS mounting
Patch-mainline: Queued in Steve French for-next
Git-repo: git://git.samba.org/sfrench/cifs-2.6.git
Git-commit: 8d3ba6b7bbc3734969613908e688750e338a8006
References: bsc#799133

Patch a6b5058 results in -EREMOTE returned by is_path_accessible() in
cifs_mount() to be ignored which breaks DFS mounting.

Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
Reviewed-by: Aurelien Aptel <aaptel@suse.com>
CC: Stable <stable@vger.kernel.org>
Signed-off-by: Steve French <smfrench@gmail.com>

--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -3209,13 +3209,15 @@ remote_path_check:
 			goto mount_fail_check;
 		}
 
-		rc = cifs_are_all_path_components_accessible(xid, tcon, cifs_sb,
-							     full_path);
-		if (rc != 0) {
-			cifswarn("cannot query dirs between root and final path, "
-				 "enabling CIFS_MOUNT_USE_PREFIX_PATH\n");
-			cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_USE_PREFIX_PATH;
-			rc = 0;
+		if (rc != -EREMOTE) {
+			rc = cifs_are_all_path_components_accessible(xid, tcon, cifs_sb,
+								     full_path);
+			if (rc != 0) {
+				cifswarn("cannot query dirs between root and final path, "
+					 "enabling CIFS_MOUNT_USE_PREFIX_PATH\n");
+				cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_USE_PREFIX_PATH;
+				rc = 0;
+			}
 		}
 		kfree(full_path);
 	}
