On 10/02/2009 02:33 AM, Hannes Reinecke wrote:
> I would go with this option for a start. We really should aim for
> making iscsiadm to be as flexible as possible, up to the point where
> iscsid.conf really just sets some sensible defaults; everything else
> should be tweaked via calls to iscsiadm.
>
> And I doubt the change in the default behaviour is really noticeable;
> any user seriously using CHAP with different values will benefit from
> this.
>
> Patch is actually quite simple :-)
>
> --- a/usr/iscsiadm.c
> +++ b/usr/iscsiadm.c
> @@ -2211,12 +2211,12 @@ main(int argc, char **argv)
>                                  rc = -1;
>                                  goto out;
>                          }
> -
> -                       memset(&drec, 0, sizeof(discovery_rec_t));

The patch does not apply. Upstream does not have this memset. The 
attached which should fix that and also changes the docs to relfect that 
passing op=update during discovery would update the node records and the 
discovery one. With your patch it will only update the node records.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To post to this group, send email to open-iscsi@googlegroups.com
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/open-iscsi
-~----------~----~----~----~------~----~------~--~---

diff --git a/README b/README
index 1f1d9fc..43a4569 100644
--- a/README
+++ b/README
@@ -186,11 +186,15 @@ Usage: iscsiadm [OPTION]
                           perform [type] discovery for target portal with
                           ip-address [ip] and port [port].
 
-                         By default this command will 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 command line.
+                         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,
+                         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
+                         command line.
 
                          [op] can be passed in multiple times to this
                          command, and it will alter the DB manipulation.
@@ -200,8 +204,8 @@ Usage: iscsiadm [OPTION]
                          not yet have records in the db.
 
                          If [op] is passed in and the value is
-                         "update", iscsiadm will update records using info
-                         from iscsi.conf and the command line for portals
+                         "update", iscsiadm will update node records using
+                         info from iscsi.conf and the command line for portals
                          that are returned during discovery and have
                          a record in the db.
 
diff --git a/doc/iscsiadm.8 b/doc/iscsiadm.8
index 8599efa..8131054 100644
--- a/doc/iscsiadm.8
+++ b/doc/iscsiadm.8
@@ -134,9 +134,9 @@ record.
 .IP
 \fInew\fR creates a new database record for a given \fIportal\fR (IP address 
and port number). In discovery mode, iscsiadm will create new records for 
portals returned by the target.
 .IP
-\fIdelete\fR deletes a specified \fIrecid\fR. In discovery node, iscsiadm will 
delete records for portals that are no longer returned.
+\fIdelete\fR deletes a specified \fIrecid\fR. In discovery node, if iscsiadm 
is performing discovery it will delete records for portals that are no longer 
returned.
 .IP
-\fIupdate\fR will update the \fIrecid\fR with \fIname\fR to the specified 
\fIvalue\fR. In discovery node the \fIrecid\fR, \fIname\fR  and \fIvalue\fR 
arguments are not needed. The update operation will operate on the portals 
returned by the target, and will update the record with info from the config 
file and command line.
+\fIupdate\fR will update the \fIrecid\fR with \fIname\fR to the specified 
\fIvalue\fR. In discovery node, if iscsiadm is performing discovery the 
\fIrecid\fR, \fIname\fR  and \fIvalue\fR arguments are not needed. The update 
operation will operate on the portals returned by the target, and will update 
the node records with info from the config file and command line.
 .IP
 \fIshow\fR is the default behaviour for node, discovery and iface mode. It is
 also used when there are no commands passed into session mode and a running
diff --git a/usr/idbm.c b/usr/idbm.c
index ca5479e..5d1611e 100644
--- a/usr/idbm.c
+++ b/usr/idbm.c
@@ -1519,17 +1519,15 @@ free_portal:
        return rc;
 }
 
-int
-idbm_add_discovery(discovery_rec_t *newrec, int overwrite)
+int idbm_add_discovery(discovery_rec_t *newrec)
 {
        discovery_rec_t rec;
        int rc;
 
        if (!idbm_discovery_read(&rec, newrec->address,
                                newrec->port)) {
-               if (!overwrite)
-                       return 0;
-               log_debug(7, "overwriting existing record");
+               log_debug(7, "disc rec already exists");
+               return 0;
        } else
                log_debug(7, "adding new DB record");
 
diff --git a/usr/idbm.h b/usr/idbm.h
index 0609c47..8fdd863 100644
--- a/usr/idbm.h
+++ b/usr/idbm.h
@@ -130,7 +130,7 @@ extern int idbm_bind_ifaces_to_nodes(idbm_disc_nodes_fn 
*disc_node_fn,
 extern int idbm_add_nodes(node_rec_t *newrec,
                          discovery_rec_t *drec, struct list_head *ifaces,
                          int overwrite);
-extern int idbm_add_discovery(discovery_rec_t *newrec, int overwrite);
+extern int idbm_add_discovery(discovery_rec_t *newrec);
 extern void idbm_sendtargets_defaults(struct iscsi_sendtargets_config *cfg);
 extern void idbm_slp_defaults(struct iscsi_slp_config *cfg);
 extern int idbm_discovery_read(discovery_rec_t *rec, char *addr,
diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
index c9f9a88..d4f7925 100644
--- a/usr/iscsiadm.c
+++ b/usr/iscsiadm.c
@@ -1183,7 +1183,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
         */
-       rc = idbm_add_discovery(drec, op & OP_UPDATE);
+       rc = idbm_add_discovery(drec);
        if (rc) {
                log_error("Could not add new discovery record.");
                return rc;
@@ -1927,9 +1927,11 @@ main(int argc, char **argv)
                                goto out;
                        }
 
-                       idbm_sendtargets_defaults(&drec.u.sendtargets);
-                       strlcpy(drec.address, ip, sizeof(drec.address));
-                       drec.port = port;
+                       if (idbm_discovery_read(&drec, ip, 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)) {
@@ -2002,7 +2004,8 @@ main(int argc, char **argv)
                                        }
                                        set_param.name = name;
                                        set_param.value = value;
-                                       if 
(idbm_discovery_set_param(&set_param, &drec))
+                                       if (idbm_discovery_set_param(&set_param,
+                                                                    &drec))
                                                rc = -1;
                                } else {
                                        log_error("operation is not 
supported.");

Reply via email to