Add -f flag (force) when changing node parameters that are defined as ATTR_DEFERRED.
When using this flag, changing of ATTR_DEFERRED parameter while in active session can take place. The change itself will take effect only in the next session. A warning message is displayed. Signed-off-by: Doron Shoham <[EMAIL PROTECTED]> --- usr/idbm.c | 7 ++++++- usr/iscsiadm.c | 50 ++++++++++++++++++++++++++++++-------------------- 2 files changed, 36 insertions(+), 21 deletions(-) diff --git a/usr/idbm.c b/usr/idbm.c index c77042a..35390b3 100644 --- a/usr/idbm.c +++ b/usr/idbm.c @@ -593,10 +593,15 @@ static int idbm_verify_param(recinfo_t *info, char *name, int is_active) else if (info[i].can_modify == ATTR_DEFERRED) { if (is_active == 0) return 0; - else { + else if (is_active == 1) { log_error("Cannot modify %s. Please logout before modifing it", name); return EINVAL; } + else if (is_active == 2) { + log_warning("Modify %s while in active session. \ + \n\t Changes will take effect only in the next login", name); + return 0; + } } else if (info[i].can_modify == ATTR_IMMUTABLE) { log_error("Cannot modify %s. This value is immutable " diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c index 847393d..a79c7e9 100644 --- a/usr/iscsiadm.c +++ b/usr/iscsiadm.c @@ -85,9 +85,10 @@ static struct option const long_options[] = {"show", no_argument, NULL, 'S'}, {"version", no_argument, NULL, 'V'}, {"help", no_argument, NULL, 'h'}, + {"force", no_argument, NULL, 'f'}, {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 = "RlVhfm:p:P:T:H:I:U:k:L:d:r:n:v:o:sSt:u"; static void usage(int status) { @@ -1757,7 +1758,7 @@ static void catch_sigint( int signo ) { } /* TODO: merge iter helpers and clean them up, so we can use them here */ -static int exec_iface_op(idbm_t *db, int op, int do_show, int info_level, +static int exec_iface_op(idbm_t *db, int op, int do_show, int do_force, int info_level, struct iface_rec *iface, char *name, char *value) { struct db_set_param set_param; @@ -1873,11 +1874,14 @@ delete_fail: set_param.value = value; /* pass rec's iface because it has the db values */ - if (check_for_session_through_iface(rec)) - set_param.connected = 1; - else + if (check_for_session_through_iface(rec)) { + if (do_force == 1) + set_param.connected = 2; + else + set_param.connected = 1; + } else set_param.connected = 0; - + rc = iface_conf_update(db, &set_param, &rec->iface); if (rc) goto update_fail; @@ -1917,7 +1921,7 @@ update_fail: /* TODO cleanup arguments */ static int exec_node_op(idbm_t *db, int op, int do_login, int do_logout, - int do_show, int do_rescan, int do_stats, + int do_show, int do_rescan, int do_stats, int do_force, int info_level, struct node_rec *rec, char *name, char *value) { @@ -2011,12 +2015,15 @@ static int exec_node_op(idbm_t *db, int op, int do_login, int do_logout, set_param.db = db; set_param.name = name; set_param.value = value; - if (check_for_session_through_iface(rec)) - set_param.connected = 1; - else + if (check_for_session_through_iface(rec)) { + if (do_force == 1) + set_param.connected = 2; + else + set_param.connected = 1; + } else set_param.connected = 0; - if (for_each_rec(db, rec, &set_param, idbm_node_set_param)) + if (for_each_rec(db, rec, &set_param, idbm_node_set_param)) rc = -1; goto out; } else if (op == OP_DELETE) { @@ -2153,7 +2160,7 @@ main(int argc, char **argv) { char *ip = NULL, *name = NULL, *value = NULL; char *targetname = NULL, *group_session_mgmt_mode = NULL; - int ch, longindex, mode=-1, port=-1, do_login=0, do_rescan=0; + int ch, longindex, mode=-1, port=-1, do_login=0, do_rescan=0, do_force=0; 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; @@ -2274,6 +2281,9 @@ main(int argc, char **argv) list_add_tail(&iface->list, &ifaces); num_ifaces++; break; + case 'f': + do_force = 1; + break; case 'V': printf("%s version %s\n", program_name, ISCSI_VERSION_STR); @@ -2319,7 +2329,7 @@ main(int argc, char **argv) switch (mode) { case MODE_IFACE: - if ((rc = verify_mode_params(argc, argv, "IdnvmPo", 0))) { + if ((rc = verify_mode_params(argc, argv, "IdnvmPof", 0))) { log_error("iface mode: option '-%c' is not " "allowed/supported", rc); rc = -1; @@ -2334,8 +2344,8 @@ main(int argc, char **argv) "interface. Using the first one " "%s.", iface->name); } - rc = exec_iface_op(db, op, do_show, info_level, iface, - name, value); + rc = exec_iface_op(db, op, do_show, do_force, info_level, + iface, name, value); break; case MODE_DISCOVERY: if ((rc = verify_mode_params(argc, argv, "IPdmtplo", 0))) { @@ -2442,7 +2452,7 @@ main(int argc, char **argv) } break; case MODE_NODE: - if ((rc = verify_mode_params(argc, argv, "RsPIdmlSonvupTUL", + if ((rc = verify_mode_params(argc, argv, "RsPIdmlSonvupTULf", 0))) { log_error("node mode: option '-%c' is not " "allowed/supported", rc); @@ -2479,8 +2489,8 @@ main(int argc, char **argv) } rc = exec_node_op(db, op, do_login, do_logout, do_show, - do_rescan, do_stats, info_level, rec, - name, value); + do_rescan, do_stats, do_force, info_level, + rec, name, value); break; case MODE_SESSION: if ((rc = verify_mode_params(argc, argv, @@ -2535,7 +2545,7 @@ main(int argc, char **argv) /* drop down to node ops */ rc = exec_node_op(db, op, do_login, do_logout, do_show, - do_rescan, do_stats, info_level, + do_rescan, do_stats, do_force, info_level, rec, name, value); free_info: free(info); @@ -2543,7 +2553,7 @@ free_info: } else { if (do_logout || do_rescan || do_stats) { rc = exec_node_op(db, op, do_login, do_logout, - do_show, do_rescan, do_stats, + do_show, do_rescan, do_stats, do_force, info_level, NULL, name, value); goto out; } -- 1.5.3.6 --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/open-iscsi -~----------~----~----~----~------~----~------~--~---