Skip to contentSkip to conversation

Fix samba bug #8914

PATCH In review Gregor Beck 4 participants 21 messages Nov 21, 2013 – Nov 22, 2013 10 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix samba bug #8914

Hi,

NetApp sends brocken packages in response to trans2_query_path_info with info level smb_file_all_info as reported at:
https://bugzilla.samba.org/show_bug.cgi?id=8914

The attached patch for cifs 2.01 works around the problem by retrying the operation with info levels basic and standard which yield the same information.

Thanks
Gregor

Signature · 4 lines
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:[email protected]
Quoted 1 line

From 7b44faa24e0fc447bd76c5b97389538189f17667 Mon Sep 17 00:00:00 2001

From: Gregor Beck <[email protected]>
Date: Thu, 17 Oct 2013 13:47:15 +0200
Subject: [PATCH 1/9] add struct FILE_STANDARD_INFO

---
 cifspdu.h |   10 ++++++++++
 1 file changed, 10 insertions(+)
cifspdu.h +10 -0
index 11ca24a..89aa1f2 100644
@@ -2233,6 +2233,16 @@ typedef struct { /* data block encoding of response to level 263 QPathInfo */
 	char FileName[1];
 } __attribute__((packed)) FILE_ALL_INFO;	/* level 0x107 QPathInfo */
 
+typedef struct {
+	__le64 AllocationSize;
+	__le64 EndOfFile;	/* size ie offset to first free byte in file */
+	__le32 NumberOfLinks;	/* hard links */
+	__u8 DeletePending;
+	__u8 Directory;
+	__u16 Pad;
+} __attribute__((packed)) FILE_STANDARD_INFO;	/* level 0x102 QPathInfo */
+
+
 /* defines for enumerating possible values of the Unix type field below */
 #define UNIX_FILE      0
 #define UNIX_DIR       1
Signature · 1 line
1.7.9.5
Quoted 1 line

From f82cb72e295b3bdc9c08444124681695d6b7ca07 Mon Sep 17 00:00:00 2001

From: Gregor Beck <[email protected]>
Date: Mon, 21 Oct 2013 16:24:01 +0200
Subject: [PATCH 2/9] refactor CIFSSMBQPathInfo()

---
 cifssmb.c |   59 ++++++++++++++++++++++++++++++++---------------------------
 1 file changed, 32 insertions(+), 27 deletions(-)
cifssmb.c +32 -27

93 lines not on this page · raw message

Signature · 1 line
1.7.9.5
Quoted 1 line

From e7479e89fdea3e61ef6607762e8400ed2377d68d Mon Sep 17 00:00:00 2001

From: Gregor Beck <[email protected]>
Date: Mon, 21 Oct 2013 16:28:49 +0200
Subject: [PATCH 3/9] add function CIFSSMBQPathInfoBasic()

---
 cifsproto.h |    3 +++
 cifssmb.c   |   11 +++++++++++
 2 files changed, 14 insertions(+)
cifsproto.h +3 -0
index b29a012..ea25d0d 100644
@@ -240,6 +240,9 @@ extern int CIFSSMBQPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
 			    const char *search_Name, FILE_ALL_INFO *data,
 			    int legacy /* whether to use old info level */,
 			    const struct nls_table *nls_codepage, int remap);
+extern int CIFSSMBQPathInfoBasic(const unsigned int xid, struct cifs_tcon *tcon,
+				 const char *search_name, FILE_BASIC_INFO *data,
+				 const struct nls_table *nls_codepage, int remap);
 extern int SMBQueryInformation(const unsigned int xid, struct cifs_tcon *tcon,
 			       const char *search_name, FILE_ALL_INFO *data,
 			       const struct nls_table *nls_codepage, int remap);
cifssmb.c +11 -0
index 7b055fe..d8189b5 100644
@@ -4065,6 +4065,17 @@ CIFSSMBQPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
 }
 
 int
+CIFSSMBQPathInfoBasic(const unsigned int xid, struct cifs_tcon *tcon,
+		      const char *search_name, FILE_BASIC_INFO *data,
+		      const struct nls_table *nls_codepage, int remap)
+{
+	return CIFSSMBQPathInfoImpl(xid, tcon, search_name,
+				    data, sizeof(FILE_BASIC_INFO),
+				    SMB_QUERY_FILE_BASIC_INFO, 40 /*???*/,
+				    nls_codepage, remap);
+}
+
+int
 CIFSSMBUnixQFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
 		 u16 netfid, FILE_UNIX_BASIC_INFO *pFindData)
 {
Signature · 1 line
1.7.9.5
Quoted 1 line

From 3ccd459f7d365b22510b4461f6a671f850722791 Mon Sep 17 00:00:00 2001

From: Gregor Beck <[email protected]>
Date: Mon, 21 Oct 2013 16:33:31 +0200
Subject: [PATCH 4/9] add function CIFSSMBQPathInfoStandard()

---
 cifsproto.h |    3 +++
 cifssmb.c   |   11 +++++++++++
 2 files changed, 14 insertions(+)
cifsproto.h +3 -0
index ea25d0d..d015336 100644
@@ -243,6 +243,9 @@ extern int CIFSSMBQPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
 extern int CIFSSMBQPathInfoBasic(const unsigned int xid, struct cifs_tcon *tcon,
 				 const char *search_name, FILE_BASIC_INFO *data,
 				 const struct nls_table *nls_codepage, int remap);
+extern int CIFSSMBQPathInfoStandard(const unsigned int xid, struct cifs_tcon *tcon,
+				    const char *search_name, FILE_STANDARD_INFO *data,
+				    const struct nls_table *nls_codepage, int remap);
 extern int SMBQueryInformation(const unsigned int xid, struct cifs_tcon *tcon,
 			       const char *search_name, FILE_ALL_INFO *data,
 			       const struct nls_table *nls_codepage, int remap);
cifssmb.c +11 -0
index d8189b5..38be854 100644
@@ -4076,6 +4076,17 @@ CIFSSMBQPathInfoBasic(const unsigned int xid, struct cifs_tcon *tcon,
 }
 
 int
+CIFSSMBQPathInfoStandard(const unsigned int xid, struct cifs_tcon *tcon,
+			 const char *search_name, FILE_STANDARD_INFO *data,
+			 const struct nls_table *nls_codepage, int remap)
+{
+	return CIFSSMBQPathInfoImpl(xid, tcon, search_name,
+				    data, sizeof(FILE_STANDARD_INFO),
+				    SMB_QUERY_FILE_STANDARD_INFO, 24 /*???*/,
+				    nls_codepage, remap);
+}
+
+int
 CIFSSMBUnixQFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
 		 u16 netfid, FILE_UNIX_BASIC_INFO *pFindData)
 {
Signature · 1 line
1.7.9.5
Quoted 1 line

From 69fca242cbd396f2446e74413ff8906a04ad56d7 Mon Sep 17 00:00:00 2001

From: Gregor Beck <[email protected]>
Date: Mon, 21 Oct 2013 17:02:52 +0200
Subject: [PATCH 5/9] fallback to CIFSSMBQPathInfoBasic() in
cifs_is_path_accessible()

---
 smb1ops.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
smb1ops.c +8 -5
index 6094397..635b1e5 100644
@@ -513,20 +513,23 @@ cifs_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
 {
 	int rc;
 	FILE_ALL_INFO *file_info;
+	const int remap = cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR;
 
 	file_info = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL);
 	if (file_info == NULL)
 		return -ENOMEM;
 
 	rc = CIFSSMBQPathInfo(xid, tcon, full_path, file_info,
-			      0 /* not legacy */, cifs_sb->local_nls,
-			      cifs_sb->mnt_cifs_flags &
-				CIFS_MOUNT_MAP_SPECIAL_CHR);
+			      0 /* not legacy */, cifs_sb->local_nls, remap);
+	if (rc == -EIO) {
+		rc = CIFSSMBQPathInfoBasic(xid, tcon, full_path,
+					   (FILE_BASIC_INFO*)file_info,
+					   cifs_sb->local_nls, remap);
+	}
 
 	if (rc == -EOPNOTSUPP || rc == -EINVAL)
 		rc = SMBQueryInformation(xid, tcon, full_path, file_info,
-				cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
-				  CIFS_MOUNT_MAP_SPECIAL_CHR);
+					 cifs_sb->local_nls, remap);
 	kfree(file_info);
 	return rc;
 }
Signature · 1 line
1.7.9.5
Quoted 1 line

From c36dda3c9901daa0f7ff4fa920a4ee19246a0e55 Mon Sep 17 00:00:00 2001

From: Gregor Beck <[email protected]>
Date: Tue, 22 Oct 2013 09:52:59 +0200
Subject: [PATCH 6/9] fallback to CIFSSMBQPathInfoBasic()/Standard() in
cifs_is_path_accessible()

---
 smb1ops.c |   20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
smb1ops.c +15 -5
index 635b1e5..a12e370 100644
@@ -540,11 +540,23 @@ cifs_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
 		     FILE_ALL_INFO *data, bool *adjustTZ)
 {
 	int rc;
+	const int remap = cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR;
 
 	/* could do find first instead but this returns more info */
 	rc = CIFSSMBQPathInfo(xid, tcon, full_path, data, 0 /* not legacy */,
-			      cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
-						CIFS_MOUNT_MAP_SPECIAL_CHR);
+			      cifs_sb->local_nls, remap);
+
+	if (rc == -EIO) {
+		rc = CIFSSMBQPathInfoBasic(xid, tcon, full_path,
+					   (FILE_BASIC_INFO*)data,
+					   cifs_sb->local_nls, remap);
+		if (!rc) {
+			rc = CIFSSMBQPathInfoStandard(xid, tcon, full_path,
+						      (void*)data + sizeof(FILE_BASIC_INFO),
+						      cifs_sb->local_nls, remap);
+		}
+	}
+
 	/*
 	 * BB optimize code so we do not make the above call when server claims
 	 * no NT SMB support and the above call failed at least once - set flag
@@ -552,9 +564,7 @@ cifs_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
 	 */
 	if ((rc == -EOPNOTSUPP) || (rc == -EINVAL)) {
 		rc = SMBQueryInformation(xid, tcon, full_path, data,
-					 cifs_sb->local_nls,
-					 cifs_sb->mnt_cifs_flags &
-						CIFS_MOUNT_MAP_SPECIAL_CHR);
+					 cifs_sb->local_nls, remap);
 		*adjustTZ = true;
 	}
 	return rc;
Signature · 1 line
1.7.9.5
Quoted 1 line

From f53227ee3349f91412de23f9db49da251679e043 Mon Sep 17 00:00:00 2001

From: Gregor Beck <[email protected]>
Date: Tue, 22 Oct 2013 10:01:40 +0200
Subject: [PATCH 7/9] fix some cFYI in cifssmb.c

---
 cifssmb.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
cifssmb.c +3 -3
index 38be854..5d10afc 100644
@@ -3935,7 +3935,7 @@ QFileInfoRetry:
 	rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
 			 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
 	if (rc) {
-		cifs_dbg(FYI, "Send error in QPathInfo = %d\n", rc);
+		cifs_dbg(FYI, "Send error in QFileInfo = %d", rc);
 	} else {		/* decode response */
 		rc = validate_t2((struct smb_t2_rsp *)pSMBr);
 
@@ -4131,7 +4131,7 @@ UnixQFileInfoRetry:
 	rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
 			 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
 	if (rc) {
-		cifs_dbg(FYI, "Send error in QPathInfo = %d\n", rc);
+		cifs_dbg(FYI, "Send error in UnixQFileInfo = %d", rc);
 	} else {		/* decode response */
 		rc = validate_t2((struct smb_t2_rsp *)pSMBr);
 
@@ -4215,7 +4215,7 @@ UnixQPathInfoRetry:
 	rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
 			 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
 	if (rc) {
-		cifs_dbg(FYI, "Send error in QPathInfo = %d\n", rc);
+		cifs_dbg(FYI, "Send error in UnixQPathInfo = %d", rc);
 	} else {		/* decode response */
 		rc = validate_t2((struct smb_t2_rsp *)pSMBr);
 
Signature · 1 line
1.7.9.5
Quoted 1 line

From f13f9d5ca298da2d6f40059a6169fb8504427e0b Mon Sep 17 00:00:00 2001

From: Gregor Beck <[email protected]>
Date: Tue, 22 Oct 2013 11:02:57 +0200
Subject: [PATCH 8/9] cFYI

---
 smb1ops.c |    2 ++
 1 file changed, 2 insertions(+)
smb1ops.c +2 -0
index a12e370..11daa28 100644
@@ -522,6 +522,7 @@ cifs_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
 	rc = CIFSSMBQPathInfo(xid, tcon, full_path, file_info,
 			      0 /* not legacy */, cifs_sb->local_nls, remap);
 	if (rc == -EIO) {
+		cifs_dbg(FYI, "is_path_accessible: FALLBACK");
 		rc = CIFSSMBQPathInfoBasic(xid, tcon, full_path,
 					   (FILE_BASIC_INFO*)file_info,
 					   cifs_sb->local_nls, remap);
@@ -547,6 +548,7 @@ cifs_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
 			      cifs_sb->local_nls, remap);
 
 	if (rc == -EIO) {
+		cifs_dbg(FYI, "cifs_query_path_info: FALLBACK");
 		rc = CIFSSMBQPathInfoBasic(xid, tcon, full_path,
 					   (FILE_BASIC_INFO*)data,
 					   cifs_sb->local_nls, remap);
Signature · 1 line
1.7.9.5
Quoted 1 line

From 95a15de52fff01fc0875dfa246842b06698525c5 Mon Sep 17 00:00:00 2001

From: Gregor Beck <[email protected]>
Date: Wed, 30 Oct 2013 14:14:52 +0100
Subject: [PATCH 9/9] cache we have broken_qpath_info per tcon

---
 cifsglob.h |    1 +
 smb1ops.c  |   26 ++++++++++++++++++--------
 2 files changed, 19 insertions(+), 8 deletions(-)
cifsglob.h +1 -0
index 52ca861..d3adde7 100644
@@ -818,6 +818,7 @@ struct cifs_tcon {
 	bool local_lease:1; /* check leases (only) on local system not remote */
 	bool broken_posix_open; /* e.g. Samba server versions < 3.3.2, 3.2.9 */
 	bool need_reconnect:1; /* connection reset, tid now invalid */
+	bool broken_qpath_info:1;
 #ifdef CONFIG_CIFS_SMB2
 	bool print:1;		/* set if connection to printer share */
 	bool bad_network_name:1; /* set if ret status STATUS_BAD_NETWORK_NAME */
smb1ops.c +18 -8
index 11daa28..e3798a4 100644
@@ -511,7 +511,7 @@ static int
 cifs_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
 			struct cifs_sb_info *cifs_sb, const char *full_path)
 {
-	int rc;
+	int rc= -EIO;
 	FILE_ALL_INFO *file_info;
 	const int remap = cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR;
 
@@ -519,13 +519,18 @@ cifs_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
 	if (file_info == NULL)
 		return -ENOMEM;
 
-	rc = CIFSSMBQPathInfo(xid, tcon, full_path, file_info,
-			      0 /* not legacy */, cifs_sb->local_nls, remap);
+	if (!tcon->broken_qpath_info) {
+		rc = CIFSSMBQPathInfo(xid, tcon, full_path, file_info,
+				      0, cifs_sb->local_nls, remap);
+	}
 	if (rc == -EIO) {
-		cifs_dbg(FYI, "is_path_accessible: FALLBACK");
 		rc = CIFSSMBQPathInfoBasic(xid, tcon, full_path,
 					   (FILE_BASIC_INFO*)file_info,
 					   cifs_sb->local_nls, remap);
+		cifs_dbg(FYI, "is_path_accessible: FALLBACK returns %d", rc);
+		if (!rc) {
+			tcon->broken_qpath_info = true;
+		}
 	}
 
 	if (rc == -EOPNOTSUPP || rc == -EINVAL)
@@ -540,15 +545,16 @@ cifs_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
 		     struct cifs_sb_info *cifs_sb, const char *full_path,
 		     FILE_ALL_INFO *data, bool *adjustTZ)
 {
-	int rc;
+	int rc = -EIO;
 	const int remap = cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR;
 
 	/* could do find first instead but this returns more info */
-	rc = CIFSSMBQPathInfo(xid, tcon, full_path, data, 0 /* not legacy */,
-			      cifs_sb->local_nls, remap);
+	if (!tcon->broken_qpath_info) {
+		rc = CIFSSMBQPathInfo(xid, tcon, full_path, data, 0,
+				      cifs_sb->local_nls, remap);
+	}
 
 	if (rc == -EIO) {
-		cifs_dbg(FYI, "cifs_query_path_info: FALLBACK");
 		rc = CIFSSMBQPathInfoBasic(xid, tcon, full_path,
 					   (FILE_BASIC_INFO*)data,
 					   cifs_sb->local_nls, remap);
@@ -557,6 +563,10 @@ cifs_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
 						      (void*)data + sizeof(FILE_BASIC_INFO),
 						      cifs_sb->local_nls, remap);
 		}
+		cifs_dbg(FYI, "cifs_query_path_info: FALLBACK returns %d", rc);
+		if (!rc) {
+			tcon->broken_qpath_info = true;
+		}
 	}
 
 	/*
Signature · 1 line
1.7.9.5

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 6 lines · On Thu, 21 Nov 2013 12:51:43 +0100 Gregor Beck…

Hi,

NetApp sends brocken packages in response to trans2_query_path_info with info level smb_file_all_info as reported at:
https://bugzilla.samba.org/show_bug.cgi?id=8914

Quoted 7 lines

The attached patch for cifs 2.01 works around the problem by retrying the operation with info levels basic and standard which yield the same information.

Thanks
Gregor

Could you repost these in the standard way?

One patch per email

Also, inlined in the email instead of as attachments, but we can work with it if you need to send them as attachments. git-send-email is a good tool for this, btw...

Signature · 1 line
Jeff Layton <[email protected]>

A message that is not in the archive (sent off-list or not yet received): 1385116018-14068-1-git-send-email-gbeck-3ekOc4rQMZmzQB+pC5nmwQ@public.gmane.org

#5 lore raw

PATCH 1/9 add struct FILE_STANDARD_INFO

---
 cifspdu.h |   10 ++++++++++
 1 file changed, 10 insertions(+)
cifspdu.h +10 -0
index 11ca24a..89aa1f2 100644
@@ -2233,6 +2233,16 @@ typedef struct { /* data block encoding of response to level 263 QPathInfo */
 	char FileName[1];
 } __attribute__((packed)) FILE_ALL_INFO;	/* level 0x107 QPathInfo */
 
+typedef struct {
+	__le64 AllocationSize;
+	__le64 EndOfFile;	/* size ie offset to first free byte in file */
+	__le32 NumberOfLinks;	/* hard links */
+	__u8 DeletePending;
+	__u8 Directory;
+	__u16 Pad;
+} __attribute__((packed)) FILE_STANDARD_INFO;	/* level 0x102 QPathInfo */
+
+
 /* defines for enumerating possible values of the Unix type field below */
 #define UNIX_FILE      0
 #define UNIX_DIR       1
Signature · 1 line
1.7.9.5

A message that is not in the archive (sent off-list or not yet received): 1385116018-14068-2-git-send-email-gbeck-3ekOc4rQMZmzQB+pC5nmwQ@public.gmane.org

Acked-by
#7 lore raw

Re: [PATCH 1/9] add struct FILE_STANDARD_INFO

Quoted 15 lines · On Fri, 22 Nov 2013 11:26:50 +0100 Gregor Beck…
---
 cifspdu.h |   10 ++++++++++
 1 file changed, 10 insertions(+)
cifspdu.h +3 -0
index 11ca24a..89aa1f2 100644
@@ -2233,6 +2233,16 @@ typedef struct { /* data block encoding of response to level 263 QPathInfo */
 	char FileName[1];
 } __attribute__((packed)) FILE_ALL_INFO;	/* level 0x107 QPathInfo */
 
+typedef struct {
+	__le64 AllocationSize;
+	__le64 EndOfFile;	/* size ie offset to first free byte in file */

cifspdu.h typedef struct { /* data block encoding of response to level 263 QPathInfo */ · line 2248

Quoted 10 lines
cifspdu.h +7 -0
+	__le32 NumberOfLinks;	/* hard links */
+	__u8 DeletePending;
+	__u8 Directory;
+	__u16 Pad;
+} __attribute__((packed)) FILE_STANDARD_INFO;	/* level 0x102 QPathInfo */
+
+
 /* defines for enumerating possible values of the Unix type field below */
 #define UNIX_FILE      0
 #define UNIX_DIR       1

Looks correct...

#8 lore raw

PATCH 2/9 refactor CIFSSMBQPathInfo()

In reply to a message not in the archive
---
 cifssmb.c |   59 ++++++++++++++++++++++++++++++++---------------------------
 1 file changed, 32 insertions(+), 27 deletions(-)
cifssmb.c +32 -27
index a89c4cb..7b055fe 100644
@@ -3958,13 +3958,13 @@ QFileInfoRetry:
 	return rc;
 }
 
-int
-CIFSSMBQPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
-		 const char *search_name, FILE_ALL_INFO *data,
-		 int legacy /* old style infolevel */,
-		 const struct nls_table *nls_codepage, int remap)
+static int
+CIFSSMBQPathInfoImpl(const unsigned int xid, struct cifs_tcon *tcon,
+		     const char *search_name,
+		     void *data, int size,
+		     __u16 level, __u16 bcc,
+		     const struct nls_table *nls_codepage, int remap)
 {
-	/* level 263 SMB_QUERY_FILE_ALL_INFO */
 	TRANSACTION2_QPI_REQ *pSMB = NULL;
 	TRANSACTION2_QPI_RSP *pSMBr = NULL;
 	int rc = 0;
@@ -3972,7 +3972,7 @@ CIFSSMBQPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
 	int name_len;
 	__u16 params, byte_count;
 
-	/* cifs_dbg(FYI, "In QPathInfo path %s\n", search_name); */
+	cifs_dbg(FYI, "In QPathInfo level %u path %s", level, search_name);
 QPathInfoRetry:
 	rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB,
 		      (void **) &pSMBr);
@@ -4011,10 +4011,7 @@ QPathInfoRetry:
 	byte_count = params + 1 /* pad */ ;
 	pSMB->TotalParameterCount = cpu_to_le16(params);
 	pSMB->ParameterCount = pSMB->TotalParameterCount;
-	if (legacy)
-		pSMB->InformationLevel = cpu_to_le16(SMB_INFO_STANDARD);
-	else
-		pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_ALL_INFO);
+	pSMB->InformationLevel = level;
 	pSMB->Reserved4 = 0;
 	inc_rfc1001_len(pSMB, byte_count);
 	pSMB->ByteCount = cpu_to_le16(byte_count);
@@ -4028,25 +4025,10 @@ QPathInfoRetry:
 
 		if (rc) /* BB add auto retry on EOPNOTSUPP? */
 			rc = -EIO;
-		else if (!legacy && get_bcc(&pSMBr->hdr) < 40)
+		else if (get_bcc(&pSMBr->hdr) < bcc)
 			rc = -EIO;	/* bad smb */
-		else if (legacy && get_bcc(&pSMBr->hdr) < 24)
-			rc = -EIO;  /* 24 or 26 expected but we do not read
-					last field */
 		else if (data) {
-			int size;
 			__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
-
-			/*
-			 * On legacy responses we do not read the last field,
-			 * EAsize, fortunately since it varies by subdialect and
-			 * also note it differs on Set vs Get, ie two bytes or 4
-			 * bytes depending but we don't care here.
-			 */
-			if (legacy)
-				size = sizeof(FILE_INFO_STANDARD);
-			else
-				size = sizeof(FILE_ALL_INFO);
 			memcpy((char *) data, (char *) &pSMBr->hdr.Protocol +
 			       data_offset, size);
 		} else
@@ -4060,6 +4042,29 @@ QPathInfoRetry:
 }
 
 int
+CIFSSMBQPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
+		 const char *search_name, FILE_ALL_INFO *data,
+		 int legacy /* old style infolevel */,
+		 const struct nls_table *nls_codepage, int remap)
+{
+	if (legacy) {
+		/* 24 or 26 expected but on legacy responses we do not read the
+		   last field, EAsize, fortunately since it varies by subdialect
+		   and also note it differs on Set vs. Get, ie two bytes or 4
+		   bytes depending but we don't care here */
+		return CIFSSMBQPathInfoImpl(xid, tcon, search_name,
+					    data, sizeof(FILE_INFO_STANDARD),
+					    SMB_INFO_STANDARD, 24,
+					    nls_codepage, remap);
+	} else {
+		return CIFSSMBQPathInfoImpl(xid, tcon, search_name,
+					    data, sizeof(FILE_ALL_INFO),
+					    SMB_QUERY_FILE_ALL_INFO, 40,
+					    nls_codepage, remap);
+	}
+}
+
+int
 CIFSSMBUnixQFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
 		 u16 netfid, FILE_UNIX_BASIC_INFO *pFindData)
 {
Signature · 1 line
1.7.9.5

A message that is not in the archive (sent off-list or not yet received): 1385116018-14068-3-git-send-email-gbeck-3ekOc4rQMZmzQB+pC5nmwQ@public.gmane.org

#10 lore raw

Re: [PATCH 2/9] refactor CIFSSMBQPathInfo()

Quoted 38 lines · On Fri, 22 Nov 2013 11:26:51 +0100 Gregor Beck…
---
 cifssmb.c |   59 ++++++++++++++++++++++++++++++++---------------------------
 1 file changed, 32 insertions(+), 27 deletions(-)
cifssmb.c +7 -7
index a89c4cb..7b055fe 100644
@@ -3958,13 +3958,13 @@ QFileInfoRetry:
 	return rc;
 }
 
-int
-CIFSSMBQPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
-		 const char *search_name, FILE_ALL_INFO *data,
-		 int legacy /* old style infolevel */,
-		 const struct nls_table *nls_codepage, int remap)
+static int
+CIFSSMBQPathInfoImpl(const unsigned int xid, struct cifs_tcon *tcon,
+		     const char *search_name,
+		     void *data, int size,
+		     __u16 level, __u16 bcc,
+		     const struct nls_table *nls_codepage, int remap)
 {
-	/* level 263 SMB_QUERY_FILE_ALL_INFO */
 	TRANSACTION2_QPI_REQ *pSMB = NULL;
 	TRANSACTION2_QPI_RSP *pSMBr = NULL;
 	int rc = 0;
@@ -3972,7 +3972,7 @@ CIFSSMBQPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
 	int name_len;
 	__u16 params, byte_count;
 
-	/* cifs_dbg(FYI, "In QPathInfo path %s\n", search_name); */
+	cifs_dbg(FYI, "In QPathInfo level %u path %s", level, search_name);
 QPathInfoRetry:
 	rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB,
 		      (void **) &pSMBr);

cifssmb.c QPathInfoRetry: · line 4014

Quoted 8 lines
cifssmb.c +1 -4
@@ -4011,10 +4011,7 @@ QPathInfoRetry:
 	byte_count = params + 1 /* pad */ ;
 	pSMB->TotalParameterCount = cpu_to_le16(params);
 	pSMB->ParameterCount = pSMB->TotalParameterCount;
-	if (legacy)
-		pSMB->InformationLevel = cpu_to_le16(SMB_INFO_STANDARD);
-	else
-		pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_ALL_INFO);
+	pSMB->InformationLevel = level;

should be "cpu_to_le16(level)"

Quoted 34 lines
cifssmb.c +1 -16
 	pSMB->Reserved4 = 0;
 	inc_rfc1001_len(pSMB, byte_count);
 	pSMB->ByteCount = cpu_to_le16(byte_count);
@@ -4028,25 +4025,10 @@ QPathInfoRetry:
 
 		if (rc) /* BB add auto retry on EOPNOTSUPP? */
 			rc = -EIO;
-		else if (!legacy && get_bcc(&pSMBr->hdr) < 40)
+		else if (get_bcc(&pSMBr->hdr) < bcc)
 			rc = -EIO;	/* bad smb */
-		else if (legacy && get_bcc(&pSMBr->hdr) < 24)
-			rc = -EIO;  /* 24 or 26 expected but we do not read
-					last field */
 		else if (data) {
-			int size;
 			__u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
-
-			/*
-			 * On legacy responses we do not read the last field,
-			 * EAsize, fortunately since it varies by subdialect and
-			 * also note it differs on Set vs Get, ie two bytes or 4
-			 * bytes depending but we don't care here.
-			 */
-			if (legacy)
-				size = sizeof(FILE_INFO_STANDARD);
-			else
-				size = sizeof(FILE_ALL_INFO);
 			memcpy((char *) data, (char *) &pSMBr->hdr.Protocol +
 			       data_offset, size);
 		} else
@@ -4060,6 +4042,29 @@ QPathInfoRetry:
 }
 
 int

cifssmb.c QPathInfoRetry: · line 4054

Quoted 10 lines
cifssmb.c +10 -0
+CIFSSMBQPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
+		 const char *search_name, FILE_ALL_INFO *data,
+		 int legacy /* old style infolevel */,
+		 const struct nls_table *nls_codepage, int remap)
+{
+	if (legacy) {
+		/* 24 or 26 expected but on legacy responses we do not read the
+		   last field, EAsize, fortunately since it varies by subdialect
+		   and also note it differs on Set vs. Get, ie two bytes or 4
+		   bytes depending but we don't care here */

nit: The above comment should be in kernel standard format (like the one is
that you removed).

cifssmb.c QPathInfoRetry: · line 4063

Quoted 9 lines
cifssmb.c +9 -0
+		return CIFSSMBQPathInfoImpl(xid, tcon, search_name,
+					    data, sizeof(FILE_INFO_STANDARD),
+					    SMB_INFO_STANDARD, 24,
+					    nls_codepage, remap);
+	} else {
+		return CIFSSMBQPathInfoImpl(xid, tcon, search_name,
+					    data, sizeof(FILE_ALL_INFO),
+					    SMB_QUERY_FILE_ALL_INFO, 40,
+					    nls_codepage, remap);

Avoid using "naked" numbers like you are with the bcc values above. At the very least if you do use them, please add comments to explain why they are what they are.

Yes, it's true that the existing code does that but it's nasty, and the time to clean it up is while you're in there.

cifssmb.c QPathInfoRetry: · line 4070

Quoted 7 lines
cifssmb.c +4 -0
+	}
+}
+
+int
 CIFSSMBUnixQFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
 		 u16 netfid, FILE_UNIX_BASIC_INFO *pFindData)
 {

Other than the above, this looks like a reasonable cleanup.

Signature · 1 line
Jeff Layton <[email protected]>
#11 lore raw

PATCH 3/9 add function CIFSSMBQPathInfoBasic()

In reply to a message not in the archive
---
 cifsproto.h |    3 +++
 cifssmb.c   |   11 +++++++++++
 2 files changed, 14 insertions(+)
cifsproto.h +3 -0
index b29a012..ea25d0d 100644
@@ -240,6 +240,9 @@ extern int CIFSSMBQPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
 			    const char *search_Name, FILE_ALL_INFO *data,
 			    int legacy /* whether to use old info level */,
 			    const struct nls_table *nls_codepage, int remap);
+extern int CIFSSMBQPathInfoBasic(const unsigned int xid, struct cifs_tcon *tcon,
+				 const char *search_name, FILE_BASIC_INFO *data,
+				 const struct nls_table *nls_codepage, int remap);
 extern int SMBQueryInformation(const unsigned int xid, struct cifs_tcon *tcon,
 			       const char *search_name, FILE_ALL_INFO *data,
 			       const struct nls_table *nls_codepage, int remap);
cifssmb.c +11 -0
index 7b055fe..d8189b5 100644
@@ -4065,6 +4065,17 @@ CIFSSMBQPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
 }
 
 int
+CIFSSMBQPathInfoBasic(const unsigned int xid, struct cifs_tcon *tcon,
+		      const char *search_name, FILE_BASIC_INFO *data,
+		      const struct nls_table *nls_codepage, int remap)
+{
+	return CIFSSMBQPathInfoImpl(xid, tcon, search_name,
+				    data, sizeof(FILE_BASIC_INFO),
+				    SMB_QUERY_FILE_BASIC_INFO, 40 /*???*/,
+				    nls_codepage, remap);
+}
+
+int
 CIFSSMBUnixQFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
 		 u16 netfid, FILE_UNIX_BASIC_INFO *pFindData)
 {
Signature · 1 line
1.7.9.5
#12 lore raw

PATCH 4/9 add function CIFSSMBQPathInfoStandard()

In reply to a message not in the archive
---
 cifsproto.h |    3 +++
 cifssmb.c   |   11 +++++++++++
 2 files changed, 14 insertions(+)
cifsproto.h +3 -0
index ea25d0d..d015336 100644
@@ -243,6 +243,9 @@ extern int CIFSSMBQPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
 extern int CIFSSMBQPathInfoBasic(const unsigned int xid, struct cifs_tcon *tcon,
 				 const char *search_name, FILE_BASIC_INFO *data,
 				 const struct nls_table *nls_codepage, int remap);
+extern int CIFSSMBQPathInfoStandard(const unsigned int xid, struct cifs_tcon *tcon,
+				    const char *search_name, FILE_STANDARD_INFO *data,
+				    const struct nls_table *nls_codepage, int remap);
 extern int SMBQueryInformation(const unsigned int xid, struct cifs_tcon *tcon,
 			       const char *search_name, FILE_ALL_INFO *data,
 			       const struct nls_table *nls_codepage, int remap);
cifssmb.c +11 -0
index d8189b5..38be854 100644
@@ -4076,6 +4076,17 @@ CIFSSMBQPathInfoBasic(const unsigned int xid, struct cifs_tcon *tcon,
 }
 
 int
+CIFSSMBQPathInfoStandard(const unsigned int xid, struct cifs_tcon *tcon,
+			 const char *search_name, FILE_STANDARD_INFO *data,
+			 const struct nls_table *nls_codepage, int remap)
+{
+	return CIFSSMBQPathInfoImpl(xid, tcon, search_name,
+				    data, sizeof(FILE_STANDARD_INFO),
+				    SMB_QUERY_FILE_STANDARD_INFO, 24 /*???*/,
+				    nls_codepage, remap);
+}
+
+int
 CIFSSMBUnixQFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
 		 u16 netfid, FILE_UNIX_BASIC_INFO *pFindData)
 {
Signature · 1 line
1.7.9.5
#13 lore raw

PATCH 5/9 fallback to CIFSSMBQPathInfoBasic() in cifs_is_path_accessible()

In reply to a message not in the archive
---
 smb1ops.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
smb1ops.c +8 -5
index 6094397..635b1e5 100644
@@ -513,20 +513,23 @@ cifs_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
 {
 	int rc;
 	FILE_ALL_INFO *file_info;
+	const int remap = cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR;
 
 	file_info = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL);
 	if (file_info == NULL)
 		return -ENOMEM;
 
 	rc = CIFSSMBQPathInfo(xid, tcon, full_path, file_info,
-			      0 /* not legacy */, cifs_sb->local_nls,
-			      cifs_sb->mnt_cifs_flags &
-				CIFS_MOUNT_MAP_SPECIAL_CHR);
+			      0 /* not legacy */, cifs_sb->local_nls, remap);
+	if (rc == -EIO) {
+		rc = CIFSSMBQPathInfoBasic(xid, tcon, full_path,
+					   (FILE_BASIC_INFO*)file_info,
+					   cifs_sb->local_nls, remap);
+	}
 
 	if (rc == -EOPNOTSUPP || rc == -EINVAL)
 		rc = SMBQueryInformation(xid, tcon, full_path, file_info,
-				cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
-				  CIFS_MOUNT_MAP_SPECIAL_CHR);
+					 cifs_sb->local_nls, remap);
 	kfree(file_info);
 	return rc;
 }
Signature · 1 line
1.7.9.5

A message that is not in the archive (sent off-list or not yet received): 1385116018-14068-6-git-send-email-gbeck-3ekOc4rQMZmzQB+pC5nmwQ@public.gmane.org

#15 lore raw

Re: [PATCH 5/9] fallback to CIFSSMBQPathInfoBasic() in cifs_is_path_accessible()

Quoted 9 lines · On Fri, 22 Nov 2013 11:26:54 +0100 Gregor Beck…
---
 smb1ops.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
smb1ops.c +0 -0
index 6094397..635b1e5 100644

smb1ops.c cifs_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon, · line 517

Quoted 5 lines
smb1ops.c +1 -0
@@ -513,20 +513,23 @@ cifs_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
 {
 	int rc;
 	FILE_ALL_INFO *file_info;
+	const int remap = cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR;
 

So many of the arguments to these functions always come from the cifs_sb. Would it be reasonable to simply pass a cifs_sb pointer down to these functions and cut out some of the argument bloat?

Quoted 13 lines
smb1ops.c +5 -3
 	file_info = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL);
 	if (file_info == NULL)
 		return -ENOMEM;
 
 	rc = CIFSSMBQPathInfo(xid, tcon, full_path, file_info,
-			      0 /* not legacy */, cifs_sb->local_nls,
-			      cifs_sb->mnt_cifs_flags &
-				CIFS_MOUNT_MAP_SPECIAL_CHR);
+			      0 /* not legacy */, cifs_sb->local_nls, remap);
+	if (rc == -EIO) {
+		rc = CIFSSMBQPathInfoBasic(xid, tcon, full_path,
+					   (FILE_BASIC_INFO*)file_info,
+					   cifs_sb->local_nls, remap);

smb1ops.c cifs_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon, · line 535

Quoted 10 lines
smb1ops.c +2 -2
+	}
 
 	if (rc == -EOPNOTSUPP || rc == -EINVAL)
 		rc = SMBQueryInformation(xid, tcon, full_path, file_info,
-				cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
-				  CIFS_MOUNT_MAP_SPECIAL_CHR);
+					 cifs_sb->local_nls, remap);
 	kfree(file_info);
 	return rc;
 }

-EIO can happen for a lot of different reasons, but there's little harm in retrying with a more basic call in this function. In fact, it might make more sense to just always use CIFSSMBQPathInfoBasic here since we don't actually do anything with the returned info.

Signature · 1 line
Jeff Layton <[email protected]>
#16 lore raw

Re: [PATCH 5/9] fallback to CIFSSMBQPathInfoBasic() in cifs_is_path_accessible()

In reply to a message not in the archive

Please provide a helper that encapsulates the calls for the different info levels, and then formats them into a in-kernel sanitized structure instead of casting around the on the wire structures, similar to how the directory code translates that various info levels in a cifs_dirent structure.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#18 lore raw

Re: [PATCH 5/9] fallback to CIFSSMBQPathInfoBasic() in cifs_is_path_accessible()

Quoted 6 lines · On Fri, 22 Nov 2013 06:35:46 -0800 Christoph Hellwig…

Please provide a helper that encapsulates the calls for the different info levels, and then formats them into a in-kernel sanitized structure instead of casting around the on the wire structures, similar to how the directory code translates that various info levels in a cifs_dirent structure.

Agreed. What we really need to do is to have these functions pass around the container we already have for this: a struct cifs_fattr rather than FILE_ALL_INFO. It's really an API abortion that even the SMB2 calls have to pass around an SMB1 on-the-wire data structure.

Gregor, it would be best to do a patchset to fix that mess first and then layer these changes on top of it.

Signature · 1 line
Jeff Layton <[email protected]>
#19 lore raw

PATCH 6/9 fallback to CIFSSMBQPathInfoBasic()/Standard() in cifs_is_path_accessible()

In reply to a message not in the archive
---
 smb1ops.c |   20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
smb1ops.c +15 -5
index 635b1e5..a12e370 100644
@@ -540,11 +540,23 @@ cifs_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
 		     FILE_ALL_INFO *data, bool *adjustTZ)
 {
 	int rc;
+	const int remap = cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR;
 
 	/* could do find first instead but this returns more info */
 	rc = CIFSSMBQPathInfo(xid, tcon, full_path, data, 0 /* not legacy */,
-			      cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
-						CIFS_MOUNT_MAP_SPECIAL_CHR);
+			      cifs_sb->local_nls, remap);
+
+	if (rc == -EIO) {
+		rc = CIFSSMBQPathInfoBasic(xid, tcon, full_path,
+					   (FILE_BASIC_INFO*)data,
+					   cifs_sb->local_nls, remap);
+		if (!rc) {
+			rc = CIFSSMBQPathInfoStandard(xid, tcon, full_path,
+						      (void*)data + sizeof(FILE_BASIC_INFO),
+						      cifs_sb->local_nls, remap);
+		}
+	}
+
 	/*
 	 * BB optimize code so we do not make the above call when server claims
 	 * no NT SMB support and the above call failed at least once - set flag
@@ -552,9 +564,7 @@ cifs_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
 	 */
 	if ((rc == -EOPNOTSUPP) || (rc == -EINVAL)) {
 		rc = SMBQueryInformation(xid, tcon, full_path, data,
-					 cifs_sb->local_nls,
-					 cifs_sb->mnt_cifs_flags &
-						CIFS_MOUNT_MAP_SPECIAL_CHR);
+					 cifs_sb->local_nls, remap);
 		*adjustTZ = true;
 	}
 	return rc;
Signature · 1 line
1.7.9.5

A message that is not in the archive (sent off-list or not yet received): 1385116018-14068-7-git-send-email-gbeck-3ekOc4rQMZmzQB+pC5nmwQ@public.gmane.org

#21 lore raw

Re: [PATCH 6/9] fallback to CIFSSMBQPathInfoBasic()/Standard() in cifs_is_path_accessible()

On Fri, 22 Nov 2013 11:26:55 +0100
Gregor Beck <[email protected]> wrote:

Some explanation of the rationale for this might be nice.

Quoted 21 lines
---
 smb1ops.c |   20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
smb1ops.c +4 -2
index 635b1e5..a12e370 100644
@@ -540,11 +540,23 @@ cifs_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
 		     FILE_ALL_INFO *data, bool *adjustTZ)
 {
 	int rc;
+	const int remap = cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR;
 
 	/* could do find first instead but this returns more info */
 	rc = CIFSSMBQPathInfo(xid, tcon, full_path, data, 0 /* not legacy */,
-			      cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
-						CIFS_MOUNT_MAP_SPECIAL_CHR);
+			      cifs_sb->local_nls, remap);
+
+	if (rc == -EIO) {

smb1ops.c cifs_query_path_info(const unsigned int xid, struct cifs_tcon *tcon, · line 559

Quoted 10 lines
smb1ops.c +10 -0
+		rc = CIFSSMBQPathInfoBasic(xid, tcon, full_path,
+					   (FILE_BASIC_INFO*)data,
+					   cifs_sb->local_nls, remap);
+		if (!rc) {
+			rc = CIFSSMBQPathInfoStandard(xid, tcon, full_path,
+						      (void*)data + sizeof(FILE_BASIC_INFO),
+						      cifs_sb->local_nls, remap);
+		}
+	}
+

I don't get the above. Why do the Basic call at all if you're just going to overwrite the returned info with the standard one when it succeeds?

Quoted 14 lines
smb1ops.c +1 -3
 	/*
 	 * BB optimize code so we do not make the above call when server claims
 	 * no NT SMB support and the above call failed at least once - set flag
@@ -552,9 +564,7 @@ cifs_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
 	 */
 	if ((rc == -EOPNOTSUPP) || (rc == -EINVAL)) {
 		rc = SMBQueryInformation(xid, tcon, full_path, data,
-					 cifs_sb->local_nls,
-					 cifs_sb->mnt_cifs_flags &
-						CIFS_MOUNT_MAP_SPECIAL_CHR);
+					 cifs_sb->local_nls, remap);
 		*adjustTZ = true;
 	}
 	return rc;
Signature · 1 line
Jeff Layton <[email protected]>
#22 lore raw

PATCH 7/9 fix some cFYI in cifssmb.c

In reply to a message not in the archive
---
 cifssmb.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
cifssmb.c +3 -3
index 38be854..5d10afc 100644
@@ -3935,7 +3935,7 @@ QFileInfoRetry:
 	rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
 			 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
 	if (rc) {
-		cifs_dbg(FYI, "Send error in QPathInfo = %d\n", rc);
+		cifs_dbg(FYI, "Send error in QFileInfo = %d", rc);
 	} else {		/* decode response */
 		rc = validate_t2((struct smb_t2_rsp *)pSMBr);
 
@@ -4131,7 +4131,7 @@ UnixQFileInfoRetry:
 	rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
 			 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
 	if (rc) {
-		cifs_dbg(FYI, "Send error in QPathInfo = %d\n", rc);
+		cifs_dbg(FYI, "Send error in UnixQFileInfo = %d", rc);
 	} else {		/* decode response */
 		rc = validate_t2((struct smb_t2_rsp *)pSMBr);
 
@@ -4215,7 +4215,7 @@ UnixQPathInfoRetry:
 	rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
 			 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
 	if (rc) {
-		cifs_dbg(FYI, "Send error in QPathInfo = %d\n", rc);
+		cifs_dbg(FYI, "Send error in UnixQPathInfo = %d", rc);
 	} else {		/* decode response */
 		rc = validate_t2((struct smb_t2_rsp *)pSMBr);
 
Signature · 1 line
1.7.9.5

A message that is not in the archive (sent off-list or not yet received): 1385116018-14068-8-git-send-email-gbeck-3ekOc4rQMZmzQB+pC5nmwQ@public.gmane.org

Reviewed-by
#24 lore raw

Re: [PATCH 7/9] fix some cFYI in cifssmb.c

Quoted 27 lines · On Fri, 22 Nov 2013 11:26:56 +0100 Gregor Beck…
---
 cifssmb.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
cifssmb.c +2 -2
index 38be854..5d10afc 100644
@@ -3935,7 +3935,7 @@ QFileInfoRetry:
 	rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
 			 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
 	if (rc) {
-		cifs_dbg(FYI, "Send error in QPathInfo = %d\n", rc);
+		cifs_dbg(FYI, "Send error in QFileInfo = %d", rc);
 	} else {		/* decode response */
 		rc = validate_t2((struct smb_t2_rsp *)pSMBr);
 
@@ -4131,7 +4131,7 @@ UnixQFileInfoRetry:
 	rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
 			 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
 	if (rc) {
-		cifs_dbg(FYI, "Send error in QPathInfo = %d\n", rc);
+		cifs_dbg(FYI, "Send error in UnixQFileInfo = %d", rc);
 	} else {		/* decode response */
 		rc = validate_t2((struct smb_t2_rsp *)pSMBr);
 

cifssmb.c UnixQPathInfoRetry: · line 4221

Quoted 8 lines
cifssmb.c +1 -1
@@ -4215,7 +4215,7 @@ UnixQPathInfoRetry:
 	rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
 			 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
 	if (rc) {
-		cifs_dbg(FYI, "Send error in QPathInfo = %d\n", rc);
+		cifs_dbg(FYI, "Send error in UnixQPathInfo = %d", rc);
 	} else {		/* decode response */
 		rc = validate_t2((struct smb_t2_rsp *)pSMBr);
 

Nice fix. I'd go ahead and ask Steve to merge this independently of the others...

#25 lore raw

PATCH 8/9 cFYI

In reply to a message not in the archive
---
 smb1ops.c |    2 ++
 1 file changed, 2 insertions(+)
smb1ops.c +2 -0
index a12e370..11daa28 100644
@@ -522,6 +522,7 @@ cifs_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
 	rc = CIFSSMBQPathInfo(xid, tcon, full_path, file_info,
 			      0 /* not legacy */, cifs_sb->local_nls, remap);
 	if (rc == -EIO) {
+		cifs_dbg(FYI, "is_path_accessible: FALLBACK");
 		rc = CIFSSMBQPathInfoBasic(xid, tcon, full_path,
 					   (FILE_BASIC_INFO*)file_info,
 					   cifs_sb->local_nls, remap);
@@ -547,6 +548,7 @@ cifs_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
 			      cifs_sb->local_nls, remap);
 
 	if (rc == -EIO) {
+		cifs_dbg(FYI, "cifs_query_path_info: FALLBACK");
 		rc = CIFSSMBQPathInfoBasic(xid, tcon, full_path,
 					   (FILE_BASIC_INFO*)data,
 					   cifs_sb->local_nls, remap);
Signature · 1 line
1.7.9.5

A message that is not in the archive (sent off-list or not yet received): 1385116018-14068-9-git-send-email-gbeck-3ekOc4rQMZmzQB+pC5nmwQ@public.gmane.org

#27 lore raw

Re: [PATCH 8/9] cFYI

On Fri, 22 Nov 2013 11:26:57 +0100
Gregor Beck <[email protected]> wrote:

The subject on this patch needs more elaboration. "cFYI" doesn't tell me much when I'm looking at this patch in a year or two.

Quoted 24 lines
---
 smb1ops.c |    2 ++
 1 file changed, 2 insertions(+)
smb1ops.c +2 -0
index a12e370..11daa28 100644
@@ -522,6 +522,7 @@ cifs_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
 	rc = CIFSSMBQPathInfo(xid, tcon, full_path, file_info,
 			      0 /* not legacy */, cifs_sb->local_nls, remap);
 	if (rc == -EIO) {
+		cifs_dbg(FYI, "is_path_accessible: FALLBACK");
 		rc = CIFSSMBQPathInfoBasic(xid, tcon, full_path,
 					   (FILE_BASIC_INFO*)file_info,
 					   cifs_sb->local_nls, remap);
@@ -547,6 +548,7 @@ cifs_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
 			      cifs_sb->local_nls, remap);
 
 	if (rc == -EIO) {
+		cifs_dbg(FYI, "cifs_query_path_info: FALLBACK");
 		rc = CIFSSMBQPathInfoBasic(xid, tcon, full_path,
 					   (FILE_BASIC_INFO*)data,
 					   cifs_sb->local_nls, remap);
Signature · 1 line
Jeff Layton <[email protected]>
#28 lore raw

PATCH 9/9 cache we have broken_qpath_info per tcon

In reply to a message not in the archive
---
 cifsglob.h |    1 +
 smb1ops.c  |   26 ++++++++++++++++++--------
 2 files changed, 19 insertions(+), 8 deletions(-)
cifsglob.h +1 -0
index 52ca861..d3adde7 100644
@@ -818,6 +818,7 @@ struct cifs_tcon {
 	bool local_lease:1; /* check leases (only) on local system not remote */
 	bool broken_posix_open; /* e.g. Samba server versions < 3.3.2, 3.2.9 */
 	bool need_reconnect:1; /* connection reset, tid now invalid */
+	bool broken_qpath_info:1;
 #ifdef CONFIG_CIFS_SMB2
 	bool print:1;		/* set if connection to printer share */
 	bool bad_network_name:1; /* set if ret status STATUS_BAD_NETWORK_NAME */
smb1ops.c +18 -8
index 11daa28..e3798a4 100644
@@ -511,7 +511,7 @@ static int
 cifs_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
 			struct cifs_sb_info *cifs_sb, const char *full_path)
 {
-	int rc;
+	int rc= -EIO;
 	FILE_ALL_INFO *file_info;
 	const int remap = cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR;
 
@@ -519,13 +519,18 @@ cifs_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
 	if (file_info == NULL)
 		return -ENOMEM;
 
-	rc = CIFSSMBQPathInfo(xid, tcon, full_path, file_info,
-			      0 /* not legacy */, cifs_sb->local_nls, remap);
+	if (!tcon->broken_qpath_info) {
+		rc = CIFSSMBQPathInfo(xid, tcon, full_path, file_info,
+				      0, cifs_sb->local_nls, remap);
+	}
 	if (rc == -EIO) {
-		cifs_dbg(FYI, "is_path_accessible: FALLBACK");
 		rc = CIFSSMBQPathInfoBasic(xid, tcon, full_path,
 					   (FILE_BASIC_INFO*)file_info,
 					   cifs_sb->local_nls, remap);
+		cifs_dbg(FYI, "is_path_accessible: FALLBACK returns %d", rc);
+		if (!rc) {
+			tcon->broken_qpath_info = true;
+		}
 	}
 
 	if (rc == -EOPNOTSUPP || rc == -EINVAL)
@@ -540,15 +545,16 @@ cifs_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
 		     struct cifs_sb_info *cifs_sb, const char *full_path,
 		     FILE_ALL_INFO *data, bool *adjustTZ)
 {
-	int rc;
+	int rc = -EIO;
 	const int remap = cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR;
 
 	/* could do find first instead but this returns more info */
-	rc = CIFSSMBQPathInfo(xid, tcon, full_path, data, 0 /* not legacy */,
-			      cifs_sb->local_nls, remap);
+	if (!tcon->broken_qpath_info) {
+		rc = CIFSSMBQPathInfo(xid, tcon, full_path, data, 0,
+				      cifs_sb->local_nls, remap);
+	}
 
 	if (rc == -EIO) {
-		cifs_dbg(FYI, "cifs_query_path_info: FALLBACK");
 		rc = CIFSSMBQPathInfoBasic(xid, tcon, full_path,
 					   (FILE_BASIC_INFO*)data,
 					   cifs_sb->local_nls, remap);
@@ -557,6 +563,10 @@ cifs_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
 						      (void*)data + sizeof(FILE_BASIC_INFO),
 						      cifs_sb->local_nls, remap);
 		}
+		cifs_dbg(FYI, "cifs_query_path_info: FALLBACK returns %d", rc);
+		if (!rc) {
+			tcon->broken_qpath_info = true;
+		}
 	}
 
 	/*
Signature · 1 line
1.7.9.5

A message that is not in the archive (sent off-list or not yet received): 1385116018-14068-10-git-send-email-gbeck-3ekOc4rQMZmzQB+pC5nmwQ@public.gmane.org

#30 lore raw

Re: [PATCH 9/9] cache we have broken_qpath_info per tcon

Quoted 74 lines · On Fri, 22 Nov 2013 11:26:58 +0100 Gregor Beck…
---
 cifsglob.h |    1 +
 smb1ops.c  |   26 ++++++++++++++++++--------
 2 files changed, 19 insertions(+), 8 deletions(-)
cifsglob.h +1 -0
index 52ca861..d3adde7 100644
@@ -818,6 +818,7 @@ struct cifs_tcon {
 	bool local_lease:1; /* check leases (only) on local system not remote */
 	bool broken_posix_open; /* e.g. Samba server versions < 3.3.2, 3.2.9 */
 	bool need_reconnect:1; /* connection reset, tid now invalid */
+	bool broken_qpath_info:1;
 #ifdef CONFIG_CIFS_SMB2
 	bool print:1;		/* set if connection to printer share */
 	bool bad_network_name:1; /* set if ret status STATUS_BAD_NETWORK_NAME */
smb1ops.c +14 -8
index 11daa28..e3798a4 100644
@@ -511,7 +511,7 @@ static int
 cifs_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
 			struct cifs_sb_info *cifs_sb, const char *full_path)
 {
-	int rc;
+	int rc= -EIO;
 	FILE_ALL_INFO *file_info;
 	const int remap = cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR;
 
@@ -519,13 +519,18 @@ cifs_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
 	if (file_info == NULL)
 		return -ENOMEM;
 
-	rc = CIFSSMBQPathInfo(xid, tcon, full_path, file_info,
-			      0 /* not legacy */, cifs_sb->local_nls, remap);
+	if (!tcon->broken_qpath_info) {
+		rc = CIFSSMBQPathInfo(xid, tcon, full_path, file_info,
+				      0, cifs_sb->local_nls, remap);
+	}
 	if (rc == -EIO) {
-		cifs_dbg(FYI, "is_path_accessible: FALLBACK");
 		rc = CIFSSMBQPathInfoBasic(xid, tcon, full_path,
 					   (FILE_BASIC_INFO*)file_info,
 					   cifs_sb->local_nls, remap);
+		cifs_dbg(FYI, "is_path_accessible: FALLBACK returns %d", rc);
+		if (!rc) {
+			tcon->broken_qpath_info = true;
+		}
 	}
 
 	if (rc == -EOPNOTSUPP || rc == -EINVAL)
@@ -540,15 +545,16 @@ cifs_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
 		     struct cifs_sb_info *cifs_sb, const char *full_path,
 		     FILE_ALL_INFO *data, bool *adjustTZ)
 {
-	int rc;
+	int rc = -EIO;
 	const int remap = cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR;
 
 	/* could do find first instead but this returns more info */
-	rc = CIFSSMBQPathInfo(xid, tcon, full_path, data, 0 /* not legacy */,
-			      cifs_sb->local_nls, remap);
+	if (!tcon->broken_qpath_info) {
+		rc = CIFSSMBQPathInfo(xid, tcon, full_path, data, 0,
+				      cifs_sb->local_nls, remap);
+	}
 
 	if (rc == -EIO) {
-		cifs_dbg(FYI, "cifs_query_path_info: FALLBACK");
 		rc = CIFSSMBQPathInfoBasic(xid, tcon, full_path,
 					   (FILE_BASIC_INFO*)data,
 					   cifs_sb->local_nls, remap);

smb1ops.c cifs_query_path_info(const unsigned int xid, struct cifs_tcon *tcon, · line 569

Quoted 7 lines
smb1ops.c +4 -0
@@ -557,6 +563,10 @@ cifs_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
 						      (void*)data + sizeof(FILE_BASIC_INFO),
 						      cifs_sb->local_nls, remap);
 		}
+		cifs_dbg(FYI, "cifs_query_path_info: FALLBACK returns %d", rc);
+		if (!rc) {
+			tcon->broken_qpath_info = true;
+		}

I have a bit of a problem with the above...

Trying to change behavior automatically like this is fraught with peril and cifs.ko is already a horrid mess of this sort of thing. It's bad enough that we have some existing fallbacks for -EOPNOTSUPP and -EINVAL, but those errors are a bit more informative so we can rationalize them a bit. Also we don't mark the server as broken based on those errors (though maybe there's an argument to be made for doing that).

Now however, you're adding one for -EIO. That error tends to be what we get when an NT error code can't easily be translated to a POSIX error. So now you might end up falling back and marking this server with broken_qpath_info when the server might actually support those infolevels just fine, but you hit some strange transient error.

I think it would be best to respin this set and add a new vers= value (e.g. 1.0basic or something) that users can mount with to enable this behavior. That way instead of bloating out the already horribly bloated standard 1.0 codepaths, you could add a new set of smb_version ops and have that enable the use of the more basic infolevels.

Yes, it means that users might have to read the manpage to figure this out, but I think trying to do this automatically will prove quite problematic.

Signature · 1 line
Jeff Layton <[email protected]>