Permalink
Browse files

Initial import of a working iSCSI initiator, which uses reFUSE and

libpuffs.

With a round of applause to Antti Kantee for helping out with puffs
debugging, and a huge thank you to Greg Oster, who has fixed numerous
bugs over the last week (unfortunately, the bugs are all mine), and
provided enthusiasm and drive.

Right now, the initiator is fulling working for only a single target,
and should be considered to be in a state of flux.  Having said that,
Greg completed a run of build.sh with the storage on the iSCSI target,
and found times to be within 0.5% of direct attached storage.  Cache
effects apply.

The initiator should be portable to everything that uses the FUSE
interface. That's right - a portable iSCSI initiator.

Storage (LUNs exported by the target) is, at the present time,
presented as a regular file called "storage". This will likely
change in the future.

% priv obj/iscsifs -u agc inspiron1300 /mnt &
[1] 13158
inspiron1300.wherever.co.uk: 10.4.0.42:3260,1 iqn.1994-04.org.netbsd.iscsi-target:target0
inspiron1300.wherever.co.uk: 10.4.0.42:3260,1 iqn.1994-04.org.netbsd.iscsi-target:target1

% ls -al /mnt/inspiron1300.wherever.co.uk/target0/
total 576
drwxr-xr-x  2 agc  agc        512 Nov  8 21:07 .
drwxr-xr-x  2 agc  agc        512 Nov  8 21:07 ..
lrw-r--r--  1 agc  agc         44 Nov  8 21:07 hostname -> inspiron1300.wherever.co.uk
lrw-r--r--  1 agc  agc          9 Nov  8 21:07 ip -> 10.4.0.42
lrw-r--r--  1 agc  agc         16 Nov  8 21:07 product -> NetBSD iSCSI
-rw-r--r--  1 agc  agc  104857088 Nov  8 21:07 storage
lrw-r--r--  1 agc  agc         43 Nov  8 21:07 targetname -> iqn.1994-04.org.netbsd.iscsi-target:target0
lrw-r--r--  1 agc  agc          8 Nov  8 21:07 vendor -> NetBSD
lrw-r--r--  1 agc  agc          4 Nov  8 21:07 version -> 0

FFS needs a block device, and so vnconfig can be used to sit on top of
the regular file.

% mount -vv | grep iscsifs
/dev/puffs on /mnt type puffs|refuse:iscsifs (nosuid, nodev, fsid: 0xcb04/0x6acb, reads: sync 0 async 0, writes: sync 0 async 0)
% priv vnconfig vnd0 /mnt/inspiron1300.wherever.co.uk/target0/storage
% priv mount /dev/vnd0a /iscsi
% df
Filesystem   1K-blocks       Used      Avail %Cap Mounted on
/dev/dk0      28101396   21491182    5205146  80% /
kernfs               1          1          0 100% /kern
procfs               4          4          0 100% /proc
ptyfs                1          1          0 100% /dev/pts
/dev/puffs           0          0          0 100% /mnt
/dev/vnd0a       99214       8209      86045   8% /iscsi
% mount -vv | grep iscsi
/dev/puffs on /mnt type puffs|refuse:iscsifs (nosuid, nodev, fsid: 0xcb04/0x6acb, reads: sync 0 async 0, writes: sync 0 async 0)
/dev/vnd0a on /iscsi type ffs (local, fsid: 0xe00/0x78b, reads: sync 1 async 0, writes: sync 2 async 0)
  • Loading branch information...
1 parent 5f599b9 commit 7df20b2acf08af33e5b475a91987e81b0ed55741 agc committed Nov 8, 2007
@@ -0,0 +1,14 @@
+# $NetBSD: Makefile,v 1.1.1.1 2007/11/08 23:12:03 agc Exp $
+
+.include <bsd.own.mk>
+
+PROG=iscsifs
+SRCS=iscsifs.c virtdir.c initiator.c
+LDADD+= -lrefuse -liscsi
+CPPFLAGS+= -g -I${.CURDIR}/../virtdir -I${NETBSDSRCDIR}/dist/iscsi/include
+MAN=iscsifs.8
+WARNS=4
+
+.PATH: ${.CURDIR}/../virtdir ${NETBSDSRCDIR}/dist/iscsi/src
+
+.include <bsd.prog.mk>
@@ -0,0 +1,133 @@
+.\"
+.\" Copyright © 2007 Alistair Crooks. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. The name of the author may not be used to endorse or promote
+.\" products derived from this software without specific prior written
+.\" permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+.\" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+.\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd September 20, 2007
+.Dt ISCSIFS 8
+.Os
+.Sh NAME
+.Nm iscsifs
+.Nd refuse-based iSCSI initiator
+.Sh SYNOPSIS
+.Nm
+.Op Fl 46bcfvV
+.Op Fl a Ar authentication-type
+.Op Fl d Ar digest-type
+.Op Fl h Ar target-hostname
+.Op Fl p Ar target-port-number
+.Op Fl t Ar target-number
+.Op Fl u Ar username
+.Ar mount_point
+.Sh DESCRIPTION
+The
+.Nm
+utility can be used to access an iSCSI target, such as
+.Xr iscsi-target 8 ,
+to access block storage which has been exported.
+The
+.Nm
+utility makes use of the
+.Xr virtdir 3
+virtual directory routines.
+Information pertaining to the target is displayed underneath
+the mount point, along with the device corresponding
+to the storage which the target exports.
+.Pp
+The various arguments are as follows:
+.Bl -tag -width Ds
+.It Fl 4
+Use an IPv4 connection to the target
+.It Fl 6
+Use an IPv6 connection to the target
+.It Fl a Ar authentication-type
+Use the specified authentication type when communicating with the target.
+The possible values are chap, kerberos, srp or none.
+The default value is none.
+.It Fl b
+Show the storage as a block device
+.It Fl c
+Show the storage as a character device
+.It Fl d Ar digest-type
+Use the specified digest type when communicating with the target.
+The possible values are header, data, both, all or none.
+The default value is none.
+.It Fl f
+Show the storage as a regular file
+.It Fl h Ar hostname
+Connect to the iSCSI target running on the host specified as the argument.
+.It Fl p Ar port-number
+Connect to the iSCSI target running on the port specified as the argument.
+The default value is 3260.
+.It Fl t Ar target
+Connect to the number of the iSCSI target running as the argument.
+.It Fl u Ar username
+Use the specified user's credentials when logging in to the iSCSI target.
+There is no default.
+.It Fl v
+Be verbose in operation
+.It Fl V
+Print out the version number and then exit.
+.El
+.Pp
+The
+.Xr refuse 3
+library is used to provide the file system features.
+.Pp
+The mandatory parameter is
+the local mount
+point.
+.Pp
+This iSCSI initiator presents a view of the targets underneath the
+mount point.
+Firstly, it creates a directory tree with the hostname of the target,
+and, in that directory, a virtual directory is created for each
+target name exported by the iSCSI target program.
+Within that virtual target directory, symbolic links exist for
+the hostname (for convenience),
+a textual representation of the IP address,
+the iSCSI target product name,
+the iSCSI target IQN,
+the iSCSI target vendor and version number.
+One other directory entry is presented in the virtual target
+directory, relating to the storage presented by the iSCSI target.
+This can be in the form of a regular file, which is also the
+default, a block device or a character device.
+.Sh SEE ALSO
+.Xr librefuse 3 ,
+.Xr puffs 3 ,
+.Xr virtdir 3 ,
+.Xr iscsi-target 8 .
+.Sh HISTORY
+The
+.Nm
+utility first appeared in
+.Nx 5.0 .
+.Sh AUTHORS
+The
+.Nm
+utility was written by
+.An Alistair Crooks
+.Aq agc@NetBSD.org .
Oops, something went wrong.

0 comments on commit 7df20b2

Please sign in to comment.