[stgt] RFC [patch] README.passthrough v1 (2nd send)

FUJITA Tomonori fujita.tomonori at lab.ntt.co.jp
Fri Aug 20 04:22:18 CEST 2010


On Thu, 19 Aug 2010 12:51:54 -0700
"Nicholas A. Bellinger" <nab at linux-iscsi.org> wrote:

> > # ls -l /dev/bsg/
> > total 0
> > crw-rw---- 1 root root 253,  0 2010-08-15 13:15 0:0:0:0
> > crw-rw---- 1 root root 253,  1 2010-08-15 13:15 2:0:0:0
> > crw-rw---- 1 root root 253, 10 2010-08-17 12:02 3:0:0:0
> > crw-rw---- 1 root root 253,  2 2010-08-17 12:02 3:0:1:0
> > crw-rw---- 1 root root 253,  7 2010-08-17 12:02 3:0:10:0
> > crw-rw---- 1 root root 253,  8 2010-08-17 12:02 3:0:11:0
> > crw-rw---- 1 root root 253,  9 2010-08-17 12:02 3:0:12:0
> > crw-rw---- 1 root root 253,  3 2010-08-17 12:02 3:0:2:0
> > crw-rw---- 1 root root 253,  4 2010-08-17 12:02 3:0:3:0
> > crw-rw---- 1 root root 253,  5 2010-08-17 12:02 3:0:4:0
> > crw-rw---- 1 root root 253, 11 2010-08-17 12:02 3:0:8:0
> > crw-rw---- 1 root root 253,  6 2010-08-17 12:02 3:0:9:0
> > 
> > # tgtadm --op new --mode target --tid 1 -T iqn.2010-08.com.nbusyd:mh
> > # tgtadm --op new --mode logicalunit --tid 1 --lun 1 --bstype=bsg
> > --device-type=pt -b /dev/bsg/3:0:1:0
> > tgtadm: invalid request
> > 
> > All the syslog shows is:
> > tgtd: bs_sg_open(361) Not recognized /dev/bsg/3:0:1:0 as an SG device
> > 
> 
> Hmmmmm, so it appears that usr/bs_sg.c:chk_sg_device() is failing to
> pick up the BSG device nodes here:
> 
>         /* Check for SG_IO major first.. */
>         if (major(st.st_rdev) == SCSI_GENERIC_MAJOR)
>                 return 0;
> 
>         /* This is not yet defined in include/linux/major.h.. */
>         if (major(st.st_rdev) == 254)
>                 return 1;
> 
>         return -1;
> }
> 
> So it looks like the failure is attributed to my hardcoding of major 254
> in the original STGT/BSG patch (note the comment above the conditional
> check).  Here is a quick fix:
> 
> diff --git a/usr/bs_sg.c b/usr/bs_sg.c
> index cda5cd2..a369570 100644
> --- a/usr/bs_sg.c
> +++ b/usr/bs_sg.c
> @@ -289,7 +289,7 @@ static int chk_sg_device(char *path)
>                 return 0;
>  
>         /* This is not yet defined in include/linux/major.h.. */
> -       if (major(st.st_rdev) == 254)
> +       if ((major(st.st_rdev) == 254) || (major(st.st_rdev) == 253))
>                 return 1;
>  
>         return -1;

Well, seems that nobody uses the bsg support except for you. :)

The above patch is still wrong.

bsg major number can be anything. So you need to get it from
/proc/devices.

Or you can also get it from /sys/class/bsg/, which is created by
kernel so available on any distributions.

You can steal the bsg device handling code from sg3-utils. Maybe
someone could create something like libbsg.so
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list