summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README41
-rw-r--r--doc/iscsiadm.811
-rw-r--r--usr/idbm.c2
-rw-r--r--usr/iscsiadm.c35
4 files changed, 64 insertions, 25 deletions
diff --git a/README b/README
index eadb385..074fb56 100644
--- a/README
+++ b/README
@@ -185,11 +185,12 @@ Usage: iscsiadm [OPTION]
perform [type] discovery for target portal with
ip-address [ip] and port [port].
- By default this command will searh for a discovery
- record for ip:port, and if found will use the
- record's settings for discovery. If a record does
- not exist iscsiadm will create one. It will then
- remove records for portals no longer returned. And,
+ This command will not use the discovery record
+ settings. It will use the iscsid.conf discovery
+ settings and it will overwrite the discovery
+ record with iscsid.conf discovery settings if it
+ exists. By default, it will then remove records for
+ portals no longer returned. And,
if a portal is returned by the target, then the
discovery command will create a new record or modify
an existing one with values from iscsi.conf and the
@@ -224,7 +225,7 @@ Usage: iscsiadm [OPTION]
Multiple ifaces can be passed in during discovery.
-m discovery --print=[N] display all discovery records from internal
persistent discovery database.
- -m discovery --interface --portal=[ip:port] --print=[N] --login
+ -m discovery --interface --portal=[ip:port] --print=[N] --discover
perform discovery based on portal in database. See
above for info in the interface argument.
@@ -234,6 +235,17 @@ Usage: iscsiadm [OPTION]
1 = The tree style with the inteface info is used.
If print is not used the old flay style is used.
+ -m discovery --interface --portal=[ip:port] --print=[N] --login
+ perform discovery based on portal in database, and
+ log into portals found during discovery. See
+ above for info in the interface argument.
+
+ For the above commands "print" is optional. If
+ used, N can be 0 or 1.
+ 0 = The old flat style of output is used.
+ 1 = The tree style with the inteface info is used.
+
+ If print is not used the old flay style is used.
-m discovery --portal=[ip:port] --op=[op] [--name=[name] --value=[value]]
perform specific DB operation [op] for specific
discovery portal. It could be one of:
@@ -617,6 +629,23 @@ To now log into targets it is the same as with sofware iscsi. See section
the record info in the card's FLASH or the node DB, so you must
rerun discovery every time the driver is reloaded.
+ - SendTargets iSCSI Discovery using the default driver and interface and
+ using the discovery settings for the discovery record with the
+ ID [192.168.1.1:3260].
+
+ ./iscsiadm -m discovery -p 192.168.1.1:3260 --discover
+
+ This will search /etc/iscsi/send_targets for a record with the
+ ID [192.168.1.1:3260]. If found it will perform discovery using
+ the settings stored in the record. For the ifaces,
+ This will first search /etc/iscsi/ifaces for interfaces
+ using software iscsi. If any are found then nodes found during
+ discovery will be setup so that they can logged in through
+ those interfaces.
+
+ This command also accepts the -o new, delete and update settings
+ like above.
+
Node mode. In node mode you can specify which records you want to log
into by specifying the targetname, ip address, port or interface
(if specifying the interface it must already be setup in the node db).
diff --git a/doc/iscsiadm.8 b/doc/iscsiadm.8
index b2bad47..c46cd59 100644
--- a/doc/iscsiadm.8
+++ b/doc/iscsiadm.8
@@ -2,8 +2,9 @@
.SH NAME
iscsiadm \- open-iscsi administration utility
.SH SYNOPSIS
-\fBiscsiadm\fR \-m discovery [ \-hV ] [ \-d debug_level ] [ \-P printlevel ] [ \-I iface \-t type \-p ip:port [ \-l ] ] |
-[ \-o operation ] [ \-n name ] [ \-v value ]
+\fBiscsiadm\fR \-m discovery [ \-hV ] [ \-d debug_level ] [ \-P printlevel ] [ \-I iface \-t type \-p ip:port [ \-l ] ] | [ [ -p ip:port ] \
+[ \-o operation ] [ \-n name ] [ \-v value ] [ \-l | \-D ] ]
+
\fBiscsiadm\fR \-m node [ \-hV ] [ \-d debug_level ] [ \-P printlevel ] [ \-L all,manual,automatic ] [ \-U all,manual,automatic ] [ \-S ] [ [ \-T targetname \-p ip:port \-I iface ] [ \-l | \-u | \-R | \-s] ]
[ [ \-o operation ] [ \-n name ] [ \-v value ] [ \-p ip:port ] ]
@@ -92,6 +93,12 @@ is an error while iscsid is not running, the system may not be able to recover.
This command and iscsid's SIGTERM handling are experimental.
.TP
+\fB\-l\fR, \fB\-\-discover\fR
+Discover targets using discovery record info.
+.IP
+This option is only valid for SendTargets discovery mode.
+
+.TP
\fB\-l\fR, \fB\-\-login\fR
For node and fw mode, login to a specified record. For discovery mode, login to
all discovered targets.
diff --git a/usr/idbm.c b/usr/idbm.c
index 1428365..d83e9dc 100644
--- a/usr/idbm.c
+++ b/usr/idbm.c
@@ -1523,7 +1523,7 @@ int idbm_add_discovery(discovery_rec_t *newrec)
if (!idbm_discovery_read(&rec, newrec->address,
newrec->port)) {
log_debug(7, "disc rec already exists");
- return 0;
+ /* fall through */
} else
log_debug(7, "adding new DB record");
diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
index 3fb45cc..9258000 100644
--- a/usr/iscsiadm.c
+++ b/usr/iscsiadm.c
@@ -85,6 +85,7 @@ static struct option const long_options[] =
{"sid", required_argument, NULL, 'r'},
{"rescan", no_argument, NULL, 'R'},
{"print", required_argument, NULL, 'P'},
+ {"discover", no_argument, NULL, 'D'},
{"login", no_argument, NULL, 'l'},
{"loginall", required_argument, NULL, 'L'},
{"logout", no_argument, NULL, 'u'},
@@ -97,7 +98,7 @@ static struct option const long_options[] =
{"help", no_argument, NULL, 'h'},
{NULL, 0, NULL, 0},
};
-static char *short_options = "RlVhm:p:P:T:H:I:U:k:L:d:r:n:v:o:sSt:u";
+static char *short_options = "RlDVhm:p:P:T:H:I:U:k:L:d:r:n:v:o:sSt:u";
static void usage(int status)
{
@@ -106,8 +107,8 @@ static void usage(int status)
program_name);
else {
printf("\
-iscsiadm -m discovery [ -hV ] [ -d debug_level ] [-P printlevel] [ -t type -p ip:port -I ifaceN ... [ -l ] ] | [ -p ip:port ] \
-[ -o operation ] [ -n name ] [ -v value ]\n\
+iscsiadm -m discovery [ -hV ] [ -d debug_level ] [-P printlevel] [ -t type -p ip:port -I ifaceN ... [ -l ] ] | [ [ -p ip:port ] \
+[ -o operation ] [ -n name ] [ -v value ] [ -l | -D ] ] \n\
iscsiadm -m node [ -hV ] [ -d debug_level ] [ -P printlevel ] [ -L all,manual,automatic ] [ -U all,manual,automatic ] [ -S ] [ [ -T targetname -p ip:port -I ifaceN ] [ -l | -u | -R | -s] ] \
[ [ -o operation ] [ -n name ] [ -v value ] ]\n\
iscsiadm -m session [ -hV ] [ -d debug_level ] [ -P printlevel] [ -r sessionid | sysfsdir [ -R | -u | -s ] [ -o operation ] [ -n name ] [ -v value ] ]\n\
@@ -892,7 +893,7 @@ exec_disc_op_on_recs(discovery_rec_t *drec, struct list_head *rec_list,
static int
do_software_sendtargets(discovery_rec_t *drec, struct list_head *ifaces,
- int info_level, int do_login, int op)
+ int info_level, int do_login, int op, int sync_drec)
{
struct list_head rec_list;
struct node_rec *rec, *tmp;
@@ -912,7 +913,7 @@ do_software_sendtargets(discovery_rec_t *drec, struct list_head *ifaces,
* DB lined up, but for now just put all the targets found from
* a discovery portal in one place
*/
- if (!(op & OP_NONPERSISTENT)) {
+ if ((!(op & OP_NONPERSISTENT)) && sync_drec) {
rc = idbm_add_discovery(drec);
if (rc) {
log_error("Could not add new discovery record.");
@@ -939,7 +940,7 @@ do_software_sendtargets(discovery_rec_t *drec, struct list_head *ifaces,
static int
do_sendtargets(discovery_rec_t *drec, struct list_head *ifaces,
- int info_level, int do_login, int op)
+ int info_level, int do_login, int op, int sync_drec)
{
struct iface_rec *tmp, *iface;
int rc, host_no;
@@ -995,7 +996,7 @@ do_sendtargets(discovery_rec_t *drec, struct list_head *ifaces,
sw_st:
return do_software_sendtargets(drec, ifaces, info_level, do_login,
- op);
+ op, sync_drec);
}
static int do_isns(discovery_rec_t *drec, struct list_head *ifaces,
@@ -1473,6 +1474,7 @@ main(int argc, char **argv)
int rc=0, sid=-1, op=OP_NOOP, type=-1, do_logout=0, do_stats=0;
int do_login_all=0, do_logout_all=0, info_level=-1, num_ifaces = 0;
int tpgt = PORTAL_GROUP_TAG_UNKNOWN, killiscsid=-1, do_show=0;
+ int do_discover = 0;
struct sigaction sa_old;
struct sigaction sa_new;
discovery_rec_t drec;
@@ -1555,6 +1557,9 @@ main(int argc, char **argv)
case 'P':
info_level = atoi(optarg);
break;
+ case 'D':
+ do_discover = 1;
+ break;
case 'l':
do_login = 1;
break;
@@ -1682,7 +1687,7 @@ main(int argc, char **argv)
name, value);
break;
case MODE_DISCOVERY:
- if ((rc = verify_mode_params(argc, argv, "SIPdmntplov", 0))) {
+ if ((rc = verify_mode_params(argc, argv, "DSIPdmntplov", 0))) {
log_error("discovery mode: option '-%c' is not "
"allowed/supported", rc);
rc = -1;
@@ -1700,14 +1705,12 @@ main(int argc, char **argv)
goto out;
}
- if (idbm_discovery_read(&drec, ip, port)) {
- idbm_sendtargets_defaults(&drec.u.sendtargets);
- strlcpy(drec.address, ip, sizeof(drec.address));
- drec.port = port;
- }
+ idbm_sendtargets_defaults(&drec.u.sendtargets);
+ strlcpy(drec.address, ip, sizeof(drec.address));
+ drec.port = port;
if (do_sendtargets(&drec, &ifaces, info_level,
- do_login, op)) {
+ do_login, op, 1)) {
rc = -1;
goto out;
}
@@ -1750,11 +1753,11 @@ main(int argc, char **argv)
rc = -1;
goto out;
}
- if (do_login &&
+ if ((do_discover || do_login) &&
drec.type == DISCOVERY_TYPE_SENDTARGETS) {
do_sendtargets(&drec, &ifaces,
info_level, do_login,
- op);
+ op, 0);
} else if (do_login &&
drec.type == DISCOVERY_TYPE_SLP) {
log_error("SLP discovery is not fully "