Skip to contentSkip to conversation

SCSI: userspace cannot use scsi_command_size_tbl, COMMAND_SIZE and scsi_device_type

PATCH In review Jaswinder Singh Rajput 5 participants 12 messages Jun 27, 2009 – Jul 2, 2009 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 SCSI: userspace cannot use scsi_command_size_tbl, COMMAND_SIZE and scsi_device_type

userspace cannot use scsi_command_size_tbl, COMMAND_SIZE and scsi_device_type defined in kernel

fix the following 'make headers_check' warnings:

usr/include/scsi/scsi.h:159: userspace cannot call function or variable defined in the kernel usr/include/scsi/scsi.h:285: userspace cannot call function or variable defined in the kernel

---
 include/scsi/scsi.h |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)
include/scsi/scsi.h +7 -6
index 084478e..7ba5acf 100644
@@ -156,9 +156,6 @@ scsi_varlen_cdb_length(const void *hdr)
 	return ((struct scsi_varlen_cdb_hdr *)hdr)->additional_cdb_length + 8;
 }
 
-extern const unsigned char scsi_command_size_tbl[8];
-#define COMMAND_SIZE(opcode) scsi_command_size_tbl[((opcode) >> 5) & 7]
-
 static inline unsigned
 scsi_command_size(const unsigned char *cmnd)
 {
@@ -166,6 +163,13 @@ scsi_command_size(const unsigned char *cmnd)
 		scsi_varlen_cdb_length(cmnd) : COMMAND_SIZE(cmnd[0]);
 }
 
+#ifdef __KERNEL__
+extern const unsigned char scsi_command_size_tbl[8];
+#define COMMAND_SIZE(opcode) scsi_command_size_tbl[((opcode) >> 5) & 7]
+
+/* Returns a human-readable name for the device */
+extern const char * scsi_device_type(unsigned type);
+#endif
 /*
  *  SCSI Architecture Model (SAM) Status codes. Taken from SAM-3 draft
  *  T10/1561-D Revision 4 Draft dated 7th November 2002.
@@ -281,9 +285,6 @@ enum scsi_protocol {
 	SCSI_PROTOCOL_UNSPEC = 0xf, /* No specific protocol */
 };
 
-/* Returns a human-readable name for the device */
-extern const char * scsi_device_type(unsigned type);
-
 /*
  * standard mode-select header prepended to all mode-select commands
  */
Signature · 1 line
1.6.0.6
maintainer
#1 lore raw

All SCSI patches should be cc'd to the SCSI list

Quoted 28 lines · Jaswinder Singh Rajput

userspace cannot use scsi_command_size_tbl, COMMAND_SIZE and scsi_device_type defined in kernel

fix the following 'make headers_check' warnings:

usr/include/scsi/scsi.h:159: userspace cannot call function or variable defined in the kernel usr/include/scsi/scsi.h:285: userspace cannot call function or variable defined in the kernel

---
 include/scsi/scsi.h |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)
include/scsi/scsi.h +0 -3
index 084478e..7ba5acf 100644
@@ -156,9 +156,6 @@ scsi_varlen_cdb_length(const void *hdr)
 	return ((struct scsi_varlen_cdb_hdr *)hdr)->additional_cdb_length + 8;
 }
 
-extern const unsigned char scsi_command_size_tbl[8];
-#define COMMAND_SIZE(opcode) scsi_command_size_tbl[((opcode) >> 5) & 7]
-
 static inline unsigned
 scsi_command_size(const unsigned char *cmnd)
 {

include/scsi/scsi.h scsi_command_size(const unsigned char *cmnd) · line 163

Quoted 1 line
include/scsi/scsi.h +0 -0
@@ -166,6 +163,13 @@ scsi_command_size(const unsigned char *cmnd)
 		scsi_varlen_cdb_length(cmnd) : COMMAND_SIZE(cmnd[0]);

Even a simple eyeball inspection of this patch shows that the removal of COMMAND_SIZE above causes this inline function to fail to compile.

If you can't be bothered even to read your own patches or at the very least compile test them, what makes you think I should bother reading anything you send in?

James

#2 lore raw
Quoted 36 lines · James Bottomley

All SCSI patches should be cc'd to the SCSI list

Quoted 28 lines · Jaswinder Singh Rajput

userspace cannot use scsi_command_size_tbl, COMMAND_SIZE and scsi_device_type defined in kernel

fix the following 'make headers_check' warnings:

usr/include/scsi/scsi.h:159: userspace cannot call function or variable defined in the kernel usr/include/scsi/scsi.h:285: userspace cannot call function or variable defined in the kernel

---
 include/scsi/scsi.h |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)
include/scsi/scsi.h +0 -3
index 084478e..7ba5acf 100644
@@ -156,9 +156,6 @@ scsi_varlen_cdb_length(const void *hdr)
 	return ((struct scsi_varlen_cdb_hdr *)hdr)->additional_cdb_length + 8;
 }
 
-extern const unsigned char scsi_command_size_tbl[8];
-#define COMMAND_SIZE(opcode) scsi_command_size_tbl[((opcode) >> 5) & 7]
-
 static inline unsigned
 scsi_command_size(const unsigned char *cmnd)
 {

include/scsi/scsi.h scsi_command_size(const unsigned char *cmnd) · line 163

Quoted 1 line
include/scsi/scsi.h +0 -0
@@ -166,6 +163,13 @@ scsi_command_size(const unsigned char *cmnd)
 		scsi_varlen_cdb_length(cmnd) : COMMAND_SIZE(cmnd[0]);

Even a simple eyeball inspection of this patch shows that the removal of COMMAND_SIZE above causes this inline function to fail to compile.

Quoted 4 lines

If you can't be bothered even to read your own patches or at the very least compile test them, what makes you think I should bother reading anything you send in?

oops I am sorry, actually it should be RFC I want to check whether I need to cover more member under __KERNEL__

[RFC][PATCH] SCSI: userspace cannot use scsi_command_size_tbl, scsi_device_type and friends

userspace cannot use scsi_command_size_tbl and scsi_device_type defined in kernel as well as its friends :

- SCSI_MAX_VARLEN_CDB_SIZE
- COMMAND_SIZE
- struct scsi_varlen_cdb_hdr
- scsi_varlen_cdb_length()
- scsi_command_size()

fix the following 'make headers_check' warnings:

usr/include/scsi/scsi.h:159: userspace cannot call function or variable defined in the kernel usr/include/scsi/scsi.h:285: userspace cannot call function or variable defined in the kernel

---
 include/scsi/scsi.h |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
include/scsi/scsi.h +4 -3
index 084478e..5ac0157 100644
@@ -134,6 +134,7 @@ struct scsi_cmnd;
 #define	ATA_16		      0x85	/* 16-byte pass-thru */
 #define	ATA_12		      0xa1	/* 12-byte pass-thru */
 
+#ifdef __KERNEL__
 /*
  *	SCSI command lengths
  */
@@ -166,6 +167,9 @@ scsi_command_size(const unsigned char *cmnd)
 		scsi_varlen_cdb_length(cmnd) : COMMAND_SIZE(cmnd[0]);
 }
 
+/* Returns a human-readable name for the device */
+extern const char * scsi_device_type(unsigned type);
+#endif
 /*
  *  SCSI Architecture Model (SAM) Status codes. Taken from SAM-3 draft
  *  T10/1561-D Revision 4 Draft dated 7th November 2002.
@@ -281,9 +285,6 @@ enum scsi_protocol {
 	SCSI_PROTOCOL_UNSPEC = 0xf, /* No specific protocol */
 };
 
-/* Returns a human-readable name for the device */
-extern const char * scsi_device_type(unsigned type);
-
 /*
  * standard mode-select header prepended to all mode-select commands
  */
Signature · 1 line
1.6.0.6
#3 lore raw
Quoted 3 lines · Jaswinder Singh Rajput
Quoted 3 lines · Jaswinder Singh Rajput
Quoted 2 lines

userspace cannot use scsi_command_size_tbl, COMMAND_SIZE and scsi_device_type defined in kernel

When did we start exporting include/scsi to userspace? I thought glibc had its own separate definitions.

Signature · 4 lines
Matthew Wilcox				Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."
#4 lore raw
Quoted 8 lines · Matthew Wilcox
Quoted 3 lines · Jaswinder Singh Rajput
Quoted 3 lines · Jaswinder Singh Rajput
Quoted 2 lines

userspace cannot use scsi_command_size_tbl, COMMAND_SIZE and scsi_device_type defined in kernel

When did we start exporting include/scsi to userspace? I thought glibc had its own separate definitions.

commit 9e4f5e29610162fd426366f3b29e3cc6e575b858

Author: James Smart <[email protected]>
Date:   Thu Mar 26 13:33:19 2009 -0400

[SCSI] FC Pass Thru support

--
JSR

maintainer
#5 lore raw
Quoted 10 lines · Jaswinder Singh Rajput
Quoted 8 lines · Matthew Wilcox
Quoted 3 lines · Jaswinder Singh Rajput
Quoted 3 lines · Jaswinder Singh Rajput
Quoted 2 lines

userspace cannot use scsi_command_size_tbl, COMMAND_SIZE and scsi_device_type defined in kernel

When did we start exporting include/scsi to userspace? I thought glibc had its own separate definitions.

Quoted 5 lines

commit 9e4f5e29610162fd426366f3b29e3cc6e575b858

Author: James Smart <[email protected]>
Date:   Thu Mar 26 13:33:19 2009 -0400

[SCSI] FC Pass Thru support

That's what you get from a simplistic view.

If you look at the full history, scsi.h and sg.h were exported in 2006 by the initial commit by David Woodhouse

commit 8555255f0b426858d8648c6206b70eb906cf4ec7

Author: David Woodhouse <[email protected]>
Date:   Sun Jun 18 12:14:01 2006 +0100

Add generic Kbuild files for 'make headers_install'

They were unexported again a year later, apparently on grounds of clashing with /usr/include/scsi from glibc:

commit e629a7ddc0188e1bb9e956e698a9bd00c19c9854

Author: Olaf Hering <[email protected]>
Date:   Tue Oct 16 23:27:01 2007 -0700

do not export /usr/include/scsi in make headers_install

So perhaps the meta question is how are we supposed to resolve this? Glibc ceded it's copy of /usr/include/linux to the kernel headers package, so it looks to be an oversight that it still retains /usr/include/scsi (there's nothing extra in there in glibc beyond what SCSI exports).

James

#6 lore raw
Quoted 35 lines · James Bottomley
Quoted 5 lines · Jaswinder Singh Rajput
Quoted 4 lines · Matthew Wilcox
Quoted 3 lines · Jaswinder Singh Rajput
Quoted 3 lines · Jaswinder Singh Rajput
Quoted 2 lines

userspace cannot use scsi_command_size_tbl, COMMAND_SIZE and scsi_device_type defined in kernel

Quoted 8 lines
Quoted 3 lines

When did we start exporting include/scsi to userspace? I thought glibc had its own separate definitions.

commit 9e4f5e29610162fd426366f3b29e3cc6e575b858

Author: James Smart <[email protected]>
Date:   Thu Mar 26 13:33:19 2009 -0400

[SCSI] FC Pass Thru support

That's what you get from a simplistic view.

If you look at the full history, scsi.h and sg.h were exported in 2006 by the initial commit by David Woodhouse

commit 8555255f0b426858d8648c6206b70eb906cf4ec7

Author: David Woodhouse <[email protected]>
Date:   Sun Jun 18 12:14:01 2006 +0100

Add generic Kbuild files for 'make headers_install'

They were unexported again a year later, apparently on grounds of clashing with /usr/include/scsi from glibc:

commit e629a7ddc0188e1bb9e956e698a9bd00c19c9854

Author: Olaf Hering <[email protected]>
Date:   Tue Oct 16 23:27:01 2007 -0700

do not export /usr/include/scsi in make headers_install

Quoted 9 lines

So perhaps the meta question is how are we supposed to resolve this? Glibc ceded it's copy of /usr/include/linux to the kernel headers package, so it looks to be an oversight that it still retains /usr/include/scsi (there's nothing extra in there in glibc beyond what SCSI exports).

James

Right! so a good strategy might be to first fix up the header for proper user-mode consumption. And then just let glibc eventually drop their scsi.h header once enough complains register.

Though out of courtesy someone might send a patch to the glibc maintainers to remove that header. Andrew do you have any passed experience with this project?

I agree that Kernel should get back control of this header.

Boaz

#7 lore raw
In reply to Jaswinder Singh Rajput
Quoted 56 lines · Jaswinder Singh Rajput
Quoted 36 lines · James Bottomley

All SCSI patches should be cc'd to the SCSI list

Quoted 28 lines · Jaswinder Singh Rajput

userspace cannot use scsi_command_size_tbl, COMMAND_SIZE and scsi_device_type defined in kernel

fix the following 'make headers_check' warnings:

usr/include/scsi/scsi.h:159: userspace cannot call function or variable defined in the kernel usr/include/scsi/scsi.h:285: userspace cannot call function or variable defined in the kernel

---
 include/scsi/scsi.h |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)
include/scsi/scsi.h +0 -3
index 084478e..7ba5acf 100644
@@ -156,9 +156,6 @@ scsi_varlen_cdb_length(const void *hdr)
 	return ((struct scsi_varlen_cdb_hdr *)hdr)->additional_cdb_length + 8;
 }
 
-extern const unsigned char scsi_command_size_tbl[8];
-#define COMMAND_SIZE(opcode) scsi_command_size_tbl[((opcode) >> 5) & 7]
-
 static inline unsigned
 scsi_command_size(const unsigned char *cmnd)
 {

include/scsi/scsi.h scsi_command_size(const unsigned char *cmnd) · line 163

Quoted 1 line
include/scsi/scsi.h +0 -0
@@ -166,6 +163,13 @@ scsi_command_size(const unsigned char *cmnd)
 		scsi_varlen_cdb_length(cmnd) : COMMAND_SIZE(cmnd[0]);

Even a simple eyeball inspection of this patch shows that the removal of COMMAND_SIZE above causes this inline function to fail to compile.

Quoted 4 lines

If you can't be bothered even to read your own patches or at the very least compile test them, what makes you think I should bother reading anything you send in?

oops I am sorry, actually it should be RFC I want to check whether I need to cover more member under __KERNEL__

[RFC][PATCH] SCSI: userspace cannot use scsi_command_size_tbl, scsi_device_type and friends

userspace cannot use scsi_command_size_tbl and scsi_device_type defined in kernel as well as its friends :

- SCSI_MAX_VARLEN_CDB_SIZE
- COMMAND_SIZE
- struct scsi_varlen_cdb_hdr
- scsi_varlen_cdb_length()
- scsi_command_size()

Quoted 6 lines

fix the following 'make headers_check' warnings:

usr/include/scsi/scsi.h:159: userspace cannot call function or variable defined in the kernel usr/include/scsi/scsi.h:285: userspace cannot call function or variable defined in the kernel

What is the status of this patch.

Thanks,
--
JSR

#8 lore raw
In reply to Jaswinder Singh Rajput
Quoted 9 lines · Jaswinder Singh Rajput

userspace cannot use scsi_command_size_tbl, COMMAND_SIZE and scsi_device_type defined in kernel

fix the following 'make headers_check' warnings:

usr/include/scsi/scsi.h:159: userspace cannot call function or variable defined in the kernel usr/include/scsi/scsi.h:285: userspace cannot call function or variable defined in the kernel

include/scsi/scsi.h was always provided by glibc and was never exported from Kernel. It was only recently added to include/scsi/Kbuild. (In this merge window, was never released) (see: [9e4f5e29] [SCSI] FC Pass Thru support)

Two questions.
1. Are we sure this will work. Is the Header fully compatible with glibc's header.
2. What will this do to distor's package managers having the same file in two packages? Don't we need a followup patch sent to glibc to remove that Header from there?

James Smart
What is the new definitions needed in user-mode in scsi.h that is not available in glibc's
supplied header?

(For reference see this patch from 2007: [e629a7dd] do not export /usr/include/scsi in make headers_install)

Boaz

#9 lore raw

Sorry folks -- the nuance of the clibrary having it's own version of a kernel header for distros was completely unknown to me.

Christoph mentioned this to me last week, with the recommendation to back out the patch and move the other headers that were exprted into include/linux - thus nothing in include/scsi gets export. No Problem. and I'll do so shortly.

How does a lowly contributor track these kind of nuances ?

-- james s

Quoted 29 lines · Boaz Harrosh
Quoted 10 lines · Jaswinder Singh Rajput

userspace cannot use scsi_command_size_tbl, COMMAND_SIZE and scsi_device_type defined in kernel

fix the following 'make headers_check' warnings:

usr/include/scsi/scsi.h:159: userspace cannot call function or variable defined in the kernel usr/include/scsi/scsi.h:285: userspace cannot call function or variable defined in the kernel

include/scsi/scsi.h was always provided by glibc and was never exported from Kernel. It was only recently added to include/scsi/Kbuild. (In this merge window, was never released) (see: [9e4f5e29] [SCSI] FC Pass Thru support)

Two questions. 1. Are we sure this will work. Is the Header fully compatible with glibc's header.
2. What will this do to distor's package managers having the same file in two packages? Don't we need a followup patch sent to glibc to remove that Header from there?

James Smart
What is the new definitions needed in user-mode in scsi.h that is not available in glibc's
supplied header?

(For reference see this patch from 2007: [e629a7dd] do not export /usr/include/scsi in make headers_install)

Boaz

maintainer
#10 lore raw
Quoted 7 lines · James Smart

Sorry folks -- the nuance of the clibrary having it's own version of a kernel header for distros was completely unknown to me.

Christoph mentioned this to me last week, with the recommendation to back out the patch and move the other headers that were exprted into include/linux - thus nothing in include/scsi gets export. No Problem. and I'll do so shortly.

Actually, I'm not sure that's the best way forwards ... the idea of include/scsi is to group all the SCSI headers together; having to put them in include/linux if they need to be exported defeats that purpose slightly.

I think the first point of business might be to find out why (or even if) glibc still wants its own SCSI headers. After all, we now have quite an anomaly: if you use the old SG_IO ioctl, glibc supplies the header in include/scsi/sg.h; if you use the new bsg SG_IO then we supply it in include/linux/bsg.h

Quoted 1 line

How does a lowly contributor track these kind of nuances ?

If the creator of the kernel header exports missed this problem for a year, I think it's safe to assume you don't lose brownie points for not spotting it either.

James

#11 lore raw
In reply to James Smart
Quoted 12 lines · James Smart

Sorry folks -- the nuance of the clibrary having it's own version of a kernel header for distros was completely unknown to me.

Christoph mentioned this to me last week, with the recommendation to back out the patch and move the other headers that were exprted into include/linux - thus nothing in include/scsi gets export. No Problem. and I'll do so shortly.

How does a lowly contributor track these kind of nuances ?

-- james s

Don't give up so fast. Please.
Kernel should reclaim back control of it's own headers. /usr/include/scsi is Kernel territory from the start. This is just a plain historical mistake that glibc had to duplicate all these Kernel headers.

Please lets start with scsi.h and then advance slowly to more Headers like sg.h

Andrew, please help.

Thanks
Boaz