Skip to content

Commit

Permalink
Fourth (b) official iSCSI support commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Dec 14, 2011
1 parent a38718a commit b54231d
Show file tree
Hide file tree
Showing 19 changed files with 1,159 additions and 97 deletions.
212 changes: 175 additions & 37 deletions cmd/zfs/zfs_main.c

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions include/libzfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ enum {
EZFS_DIFF, /* general failure of zfs diff */
EZFS_DIFFDATA, /* bad zfs diff data */
EZFS_POOLREADONLY, /* pool is in read-only mode */
EZFS_UNSHAREISCSIFAILED,/* failed to unshare over iSCSI */
EZFS_SHAREISCSIFAILED, /* failed to share over iSCSI */
EZFS_UNKNOWN
};

Expand Down Expand Up @@ -523,6 +525,7 @@ typedef struct get_all_cb {
zfs_handle_t **cb_handles;
size_t cb_alloc;
size_t cb_used;
uint_t cb_types;
boolean_t cb_verbose;
int (*cb_getone)(zfs_handle_t *, void *);
} get_all_cb_t;
Expand Down Expand Up @@ -660,13 +663,17 @@ extern int zfs_unshare(zfs_handle_t *);
*/
extern boolean_t zfs_is_shared_nfs(zfs_handle_t *, char **);
extern boolean_t zfs_is_shared_smb(zfs_handle_t *, char **);
extern boolean_t zfs_is_shared_iscsi(zfs_handle_t *, char **);
extern int zfs_share_nfs(zfs_handle_t *);
extern int zfs_share_smb(zfs_handle_t *);
extern int zfs_share_iscsi(zfs_handle_t *);
extern int zfs_shareall(zfs_handle_t *);
extern int zfs_unshare_nfs(zfs_handle_t *, const char *);
extern int zfs_unshare_smb(zfs_handle_t *, const char *);
extern int zfs_unshare_iscsi(zfs_handle_t *, const char *);
extern int zfs_unshareall_nfs(zfs_handle_t *);
extern int zfs_unshareall_smb(zfs_handle_t *);
extern int zfs_unshareall_iscsi(zfs_handle_t *);
extern int zfs_unshareall_bypath(zfs_handle_t *, const char *);
extern int zfs_unshareall(zfs_handle_t *);
extern int zfs_deleg_share_nfs(libzfs_handle_t *, char *, char *, char *,
Expand Down
6 changes: 4 additions & 2 deletions include/libzfs_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ struct zpool_handle {
typedef enum {
PROTO_NFS = 0,
PROTO_SMB = 1,
PROTO_END = 2
PROTO_ISCSI = 2,
PROTO_END = 3
} zfs_share_proto_t;

/*
Expand All @@ -132,7 +133,8 @@ typedef enum {
typedef enum {
SHARED_NOT_SHARED = 0x0,
SHARED_NFS = 0x2,
SHARED_SMB = 0x4
SHARED_SMB = 0x4,
SHARED_ISCSI = 0x8
} zfs_share_type_t;

int zfs_error(libzfs_handle_t *, int, const char *);
Expand Down
5 changes: 4 additions & 1 deletion include/sys/fs/zfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ typedef enum {
ZFS_PROP_MLSLABEL,
ZFS_PROP_SYNC,
ZFS_PROP_REFRATIO,
ZFS_PROP_SHAREISCSI,
ZFS_NUM_PROPS
} zfs_prop_t;

Expand Down Expand Up @@ -287,7 +288,9 @@ typedef enum zfs_share_op {
ZFS_SHARE_NFS = 0,
ZFS_UNSHARE_NFS = 1,
ZFS_SHARE_SMB = 2,
ZFS_UNSHARE_SMB = 3
ZFS_UNSHARE_SMB = 3,
ZFS_SHARE_ISCSI = 4,
ZFS_UNSHARE_ISCSI = 5
} zfs_share_op_t;

typedef enum zfs_smb_acl_op {
Expand Down
1 change: 1 addition & 0 deletions lib/libshare/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
iscsi_test
11 changes: 9 additions & 2 deletions lib/libshare/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ lib_LTLIBRARIES = libshare.la

libshare_la_SOURCES = \
$(top_srcdir)/lib/libshare/libshare.c \
$(top_srcdir)/lib/libshare/nfs.c \
$(top_srcdir)/lib/libshare/libshare_impl.h \
$(top_srcdir)/lib/libshare/nfs.h
$(top_srcdir)/lib/libshare/nfs.c \
$(top_srcdir)/lib/libshare/nfs.h \
$(top_srcdir)/lib/libshare/iscsi.c \
$(top_srcdir)/lib/libshare/iscsi.h

libshare_la_LDFLAGS = -version-info 1:0:0

iscsi_test_SOURCES = \
$(top_srcdir)/lib/libshare/iscsi_test.c \
$(top_srcdir)/lib/libshare/iscsi.c \
$(top_srcdir)/lib/libshare/iscsi.h
45 changes: 39 additions & 6 deletions lib/libshare/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ am__base_list = \
am__installdirs = "$(DESTDIR)$(libdir)"
LTLIBRARIES = $(lib_LTLIBRARIES)
libshare_la_LIBADD =
am_libshare_la_OBJECTS = libshare.lo nfs.lo
am_libshare_la_OBJECTS = libshare.lo nfs.lo iscsi.lo
libshare_la_OBJECTS = $(am_libshare_la_OBJECTS)
AM_V_lt = $(am__v_lt_$(V))
am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
Expand Down Expand Up @@ -147,8 +147,8 @@ am__v_CCLD_0 = @echo " CCLD " $@;
AM_V_GEN = $(am__v_GEN_$(V))
am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
am__v_GEN_0 = @echo " GEN " $@;
SOURCES = $(libshare_la_SOURCES)
DIST_SOURCES = $(libshare_la_SOURCES)
SOURCES = $(libshare_la_SOURCES) $(iscsi_test_SOURCES)
DIST_SOURCES = $(libshare_la_SOURCES) $(iscsi_test_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
Expand Down Expand Up @@ -333,11 +333,30 @@ AM_CFLAGS = -Wall -Wstrict-prototypes -fno-strict-aliasing \
lib_LTLIBRARIES = libshare.la
libshare_la_SOURCES = \
$(top_srcdir)/lib/libshare/libshare.c \
$(top_srcdir)/lib/libshare/nfs.c \
$(top_srcdir)/lib/libshare/libshare_impl.h \
$(top_srcdir)/lib/libshare/nfs.h
$(top_srcdir)/lib/libshare/nfs.c \
$(top_srcdir)/lib/libshare/nfs.h \
$(top_srcdir)/lib/libshare/iscsi.c \
$(top_srcdir)/lib/libshare/iscsi.h

libshare_la_LDFLAGS = -version-info 1:0:0

iscsi_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(LDFLAGS) -o $@
am_iscsi_test_OBJECTS = $(libshare_la_OBJECTS) iscsi_test.o
iscsi_test_OBJECTS = $(am_iscsi_test_OBJECTS)
iscsi_test_SOURCES = \
$(top_srcdir)/lib/libshare/iscsi_test.c \
$(top_srcdir)/lib/libshare/iscsi.c \
$(top_srcdir)/lib/libshare/iscsi.h
iscsi_test_DEPENDENCIES = \
$(lib_LTLIBRARIES) \
$(top_builddir)/lib/libzfs/libzfs.la
iscsi_test_LDADD = \
$(lib_LTLIBRARIES) \
$(top_builddir)/lib/libzfs/libzfs.la

all: all-am

.SUFFIXES:
Expand Down Expand Up @@ -406,14 +425,19 @@ clean-libLTLIBRARIES:
libshare.la: $(libshare_la_OBJECTS) $(libshare_la_DEPENDENCIES)
$(AM_V_CCLD)$(libshare_la_LINK) -rpath $(libdir) $(libshare_la_OBJECTS) $(libshare_la_LIBADD) $(LIBS)

iscsi_test$(EXEEXT): $(iscsi_test_OBJECTS) $(iscsi_test_DEPENDENCIES)
@rm -f iscsi_test$(EXEEXT)
$(AM_V_CCLD)$(iscsi_test_LINK) $(iscsi_test_LDADD) iscsi_test.$(OBJEXT)

mostlyclean-compile:
-rm -f *.$(OBJEXT)
-rm -f *.$(OBJEXT) iscsi_test$(EXEEXT)

distclean-compile:
-rm -f *.tab.c

@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libshare.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfs.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iscsi.Plo@am__quote@

.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
Expand Down Expand Up @@ -455,6 +479,15 @@ nfs.lo: $(top_srcdir)/lib/libshare/nfs.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nfs.lo `test -f '$(top_srcdir)/lib/libshare/nfs.c' || echo '$(srcdir)/'`$(top_srcdir)/lib/libshare/nfs.c

iscsi.lo: $(top_srcdir)/lib/libshare/iscsi.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT iscsi.lo -MD -MP -MF $(DEPDIR)/iscsi.Tpo -c -o iscsi.lo `test -f '$(top_srcdir)/lib/libshare/iscsi.c' || echo '$(srcdir)/'`$(top_srcdir)/lib/libshare/iscsi.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/iscsi.Tpo $(DEPDIR)/iscsi.Plo
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_srcdir)/lib/libshare/iscsi.c' object='iscsi.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o iscsi.lo `test -f '$(top_srcdir)/lib/libshare/iscsi.c' || echo '$(srcdir)/'`$(top_srcdir)/lib/libshare/iscsi.c


mostlyclean-libtool:
-rm -f *.lo

Expand Down
13 changes: 13 additions & 0 deletions lib/libshare/README_iscsi.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
This is iSCSI support for the IET iSCSI targets.

It will call ietmadm to both add or remove a iSCSI
target from the call to 'zfs share':

zfs create -V tank/test
zfs set shareiscsi=on tank/test
zfs share tank/test

PS. The domainname needs to be set in /proc/sys/kernel/domainname
for the driver to work out the iqn correctly. You can either
set it by echo'ing the domain name to the file, OR set it
using sysctl.
Loading

0 comments on commit b54231d

Please sign in to comment.