iscsi-initiator-utils/iscsi-initiator-utils-start-iscsid.patch
Hans de Goede a8ea6d9b12 - Add force-start iscsid initscript option and use that in "patch to make
iscsiadm start iscsid when needed" so that iscsid will actual be
    started even if there are no iscsi disks configured yet (rh 470437)
- Do not start iscsid when not running when iscsiadm -k 0 gets executed (rh
    470438)
2008-11-08 12:44:13 +00:00

203 lines
6.9 KiB
Diff

diff -up open-iscsi-2.0-870-rc1/usr/discovery.c.start-iscsid open-iscsi-2.0-870-rc1/usr/discovery.c
--- open-iscsi-2.0-870-rc1/usr/discovery.c.start-iscsid 2008-07-01 03:14:03.000000000 +0200
+++ open-iscsi-2.0-870-rc1/usr/discovery.c 2008-09-30 10:41:57.000000000 +0200
@@ -87,7 +87,7 @@ int discovery_offload_sendtargets(int ho
* and get back the results. We should do this since it would
* allows us to then process the results like software iscsi.
*/
- rc = do_iscsid(&req, &rsp);
+ rc = do_iscsid(&req, &rsp, 1);
if (rc) {
log_error("Could not offload sendtargets to %s.\n",
drec->address);
@@ -521,7 +521,7 @@ static int request_initiator_name(void)
memset(&req, 0, sizeof(req));
req.command = MGMT_IPC_CONFIG_INAME;
- rc = do_iscsid(&req, &rsp);
+ rc = do_iscsid(&req, &rsp, 1);
if (rc)
return EIO;
@@ -531,7 +531,7 @@ static int request_initiator_name(void)
memset(&req, 0, sizeof(req));
req.command = MGMT_IPC_CONFIG_IALIAS;
- rc = do_iscsid(&req, &rsp);
+ rc = do_iscsid(&req, &rsp, 0);
if (rc)
/* alias is optional so return ok */
return 0;
diff -up open-iscsi-2.0-870-rc1/usr/iscsiadm.c.start-iscsid open-iscsi-2.0-870-rc1/usr/iscsiadm.c
--- open-iscsi-2.0-870-rc1/usr/iscsiadm.c.start-iscsid 2008-09-30 10:41:57.000000000 +0200
+++ open-iscsi-2.0-870-rc1/usr/iscsiadm.c 2008-09-30 10:41:57.000000000 +0200
@@ -191,7 +191,7 @@ static void kill_iscsid(int priority)
memset(&req, 0, sizeof(req));
req.command = MGMT_IPC_IMMEDIATE_STOP;
- rc = do_iscsid(&req, &rsp);
+ rc = do_iscsid(&req, &rsp, 0);
if (rc) {
iscsid_handle_error(rc);
log_error("Could not stop iscsid. Trying sending iscsid "
@@ -823,7 +823,7 @@ static char *get_config_file(void)
memset(&req, 0, sizeof(req));
req.command = MGMT_IPC_CONFIG_FILE;
- rc = do_iscsid(&req, &rsp);
+ rc = do_iscsid(&req, &rsp, 1);
if (rc)
return NULL;
@@ -883,7 +883,7 @@ static int print_iscsi_state(int sid)
req.command = MGMT_IPC_SESSION_INFO;
req.u.session.sid = sid;
- err = do_iscsid(&req, &rsp);
+ err = do_iscsid(&req, &rsp, 1);
/*
* for drivers like qla4xxx, iscsid does not display
* anything here since it does not know about it.
@@ -1151,7 +1151,7 @@ session_stats(void *data, struct session
req.command = MGMT_IPC_SESSION_STATS;
req.u.session.sid = info->sid;
- rc = do_iscsid(&req, &rsp);
+ rc = do_iscsid(&req, &rsp, 1);
if (rc)
return EIO;
@@ -1617,7 +1617,7 @@ static int isns_dev_attr_query(discovery
memset(&req, 0, sizeof(iscsiadm_req_t));
req.command = MGMT_IPC_ISNS_DEV_ATTR_QUERY;
- err = do_iscsid(&req, &rsp);
+ err = do_iscsid(&req, &rsp, 1);
if (err) {
iscsid_handle_error(err);
return EIO;
diff -up open-iscsi-2.0-870-rc1/usr/iscsid.c.start-iscsid open-iscsi-2.0-870-rc1/usr/iscsid.c
--- open-iscsi-2.0-870-rc1/usr/iscsid.c.start-iscsid 2008-07-01 03:14:03.000000000 +0200
+++ open-iscsi-2.0-870-rc1/usr/iscsid.c 2008-09-30 10:41:57.000000000 +0200
@@ -252,7 +252,7 @@ static int sync_session(void *data, stru
req.u.session.sid = info->sid;
memcpy(&req.u.session.rec, &rec, sizeof(node_rec_t));
- do_iscsid(&req, &rsp);
+ do_iscsid(&req, &rsp, 0);
return 0;
}
diff -up open-iscsi-2.0-870-rc1/usr/iscsistart.c.start-iscsid open-iscsi-2.0-870-rc1/usr/iscsistart.c
--- open-iscsi-2.0-870-rc1/usr/iscsistart.c.start-iscsid 2008-07-01 03:14:03.000000000 +0200
+++ open-iscsi-2.0-870-rc1/usr/iscsistart.c 2008-09-30 10:41:57.000000000 +0200
@@ -112,7 +112,7 @@ static int stop_event_loop(void)
memset(&req, 0, sizeof(req));
req.command = MGMT_IPC_IMMEDIATE_STOP;
- rc = do_iscsid(&req, &rsp);
+ rc = do_iscsid(&req, &rsp, 0);
if (rc) {
iscsid_handle_error(rc);
log_error("Could not stop event_loop\n");
@@ -142,7 +142,7 @@ static int setup_session(void)
memset(&req, 0, sizeof(req));
req.command = MGMT_IPC_SESSION_LOGIN;
memcpy(&req.u.session.rec, &config_rec, sizeof(node_rec_t));
- rc = do_iscsid(&req, &rsp);
+ rc = do_iscsid(&req, &rsp, 0);
if (rc)
iscsid_handle_error(rc);
diff -up open-iscsi-2.0-870-rc1/usr/util.c.start-iscsid open-iscsi-2.0-870-rc1/usr/util.c
--- open-iscsi-2.0-870-rc1/usr/util.c.start-iscsid 2008-07-01 03:14:03.000000000 +0200
+++ open-iscsi-2.0-870-rc1/usr/util.c 2008-09-30 11:25:38.000000000 +0200
@@ -120,7 +120,7 @@ int increase_max_files(void)
#define MAXSLEEP 128
-static mgmt_ipc_err_e iscsid_connect(int *fd)
+static mgmt_ipc_err_e iscsid_connect(int *fd, int iscsid_start)
{
int nsec;
struct sockaddr_un addr;
@@ -145,8 +145,12 @@ static mgmt_ipc_err_e iscsid_connect(int
/* If iscsid isn't there, there's no sense
* in retrying. */
- if (errno == ECONNREFUSED)
- break;
+ if (errno == ECONNREFUSED) {
+ if (iscsid_start && nsec == 1)
+ system("/etc/rc.d/init.d/iscsid force-start");
+ else
+ break;
+ }
/*
* Delay before trying again
@@ -158,11 +162,11 @@ static mgmt_ipc_err_e iscsid_connect(int
return MGMT_IPC_ERR_ISCSID_COMM_ERR;
}
-mgmt_ipc_err_e iscsid_request(int *fd, iscsiadm_req_t *req)
+mgmt_ipc_err_e iscsid_request(int *fd, iscsiadm_req_t *req, int start_iscsid)
{
int err;
- err = iscsid_connect(fd);
+ err = iscsid_connect(fd, start_iscsid);
if (err)
return err;
@@ -192,12 +196,13 @@ mgmt_ipc_err_e iscsid_response(int fd, i
return iscsi_err;
}
-mgmt_ipc_err_e do_iscsid(iscsiadm_req_t *req, iscsiadm_rsp_t *rsp)
+mgmt_ipc_err_e do_iscsid(iscsiadm_req_t *req, iscsiadm_rsp_t *rsp,
+ int start_iscsid)
{
int fd;
mgmt_ipc_err_e err;
- err = iscsid_request(&fd, req);
+ err = iscsid_request(&fd, req, start_iscsid);
if (err)
return err;
@@ -220,7 +225,7 @@ int iscsid_req_by_rec_async(iscsiadm_cmd
req.command = cmd;
memcpy(&req.u.session.rec, rec, sizeof(node_rec_t));
- return iscsid_request(fd, &req);
+ return iscsid_request(fd, &req, 1);
}
int iscsid_req_by_rec(iscsiadm_cmd_e cmd, node_rec_t *rec)
@@ -241,7 +246,7 @@ int iscsid_req_by_sid_async(iscsiadm_cmd
req.command = cmd;
req.u.session.sid = sid;
- return iscsid_request(fd, &req);
+ return iscsid_request(fd, &req, 1);
}
int iscsid_req_by_sid(iscsiadm_cmd_e cmd, int sid)
diff -up open-iscsi-2.0-870-rc1/usr/util.h.start-iscsid open-iscsi-2.0-870-rc1/usr/util.h
--- open-iscsi-2.0-870-rc1/usr/util.h.start-iscsid 2008-07-01 03:14:03.000000000 +0200
+++ open-iscsi-2.0-870-rc1/usr/util.h 2008-09-30 10:41:57.000000000 +0200
@@ -13,9 +13,10 @@ extern int oom_adjust(void);
extern void daemon_init(void);
extern int increase_max_files(void);
-extern int do_iscsid(struct iscsiadm_req *req, struct iscsiadm_rsp *rsp);
+extern int do_iscsid(struct iscsiadm_req *req, struct iscsiadm_rsp *rsp,
+ int iscsid_start);
extern void iscsid_handle_error(int err);
-extern int iscsid_request(int *fd, struct iscsiadm_req *req);
+extern int iscsid_request(int *fd, struct iscsiadm_req *req, int iscsid_start);
extern int iscsid_response(int fd, int cmd, struct iscsiadm_rsp *rsp);
extern int iscsid_req_wait(int cmd, int fd);
extern int iscsid_req_by_rec_async(int cmd, struct node_rec *rec, int *fd);