- Rewrite SysV initscripts, fixes rh 441290, 246960, 282001, 436175, 430791
- Add patch to make iscsiadm complain and exit when run as user instead of hang spinning for the database lock - Add patch to make iscsiadm start iscsid when needed (rh 436175 related) - Don't start iscsi service when network not yet up (in case of using NM) add NM dispatcher script to start iscsi service once network is up
This commit is contained in:
parent
a4c8b301eb
commit
4cc2dba7fe
15
04-iscsi
Executable file
15
04-iscsi
Executable file
@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
export LC_ALL=C
|
||||
|
||||
if [ "$2" = "down" ]; then
|
||||
/sbin/ip route ls | grep -q ^default || {
|
||||
[ -f /var/lock/subsys/iscsi ] && /etc/rc.d/init.d/iscsi stop
|
||||
}
|
||||
fi
|
||||
|
||||
if [ "$2" = "up" ]; then
|
||||
/sbin/ip -o route show dev "$1" | grep -q '^default' && {
|
||||
/sbin/chkconfig iscsi && /etc/rc.d/init.d/iscsi start
|
||||
}
|
||||
fi
|
@ -1,18 +0,0 @@
|
||||
diff -up open-iscsi-2.0-870-rc1/usr/idbm.c~ open-iscsi-2.0-870-rc1/usr/idbm.c
|
||||
--- open-iscsi-2.0-870-rc1/usr/idbm.c~ 2008-09-29 13:01:48.000000000 +0200
|
||||
+++ open-iscsi-2.0-870-rc1/usr/idbm.c 2008-09-29 13:01:48.000000000 +0200
|
||||
@@ -849,6 +849,14 @@ int idbm_lock(void)
|
||||
ret = link(LOCK_FILE, LOCK_WRITE_FILE);
|
||||
if (ret == 0)
|
||||
break;
|
||||
+
|
||||
+ if (errno != EEXIST) {
|
||||
+ log_error("Could not lock discovery DB: %s: %s",
|
||||
+ LOCK_WRITE_FILE, strerror(errno));
|
||||
+ log_error("Maybe you are not root?");
|
||||
+ exit(-1);
|
||||
+ } else if (i == 0)
|
||||
+ log_warning("Waiting for discovery DB lock");
|
||||
|
||||
usleep(10000);
|
||||
}
|
32
iscsi-initiator-utils-only-root-use.patch
Normal file
32
iscsi-initiator-utils-only-root-use.patch
Normal file
@ -0,0 +1,32 @@
|
||||
diff -up open-iscsi-2.0-870-rc1/usr/idbm.c.error open-iscsi-2.0-870-rc1/usr/idbm.c
|
||||
--- open-iscsi-2.0-870-rc1/usr/idbm.c.error 2008-09-30 10:09:40.000000000 +0200
|
||||
+++ open-iscsi-2.0-870-rc1/usr/idbm.c 2008-09-30 10:20:43.000000000 +0200
|
||||
@@ -850,6 +850,12 @@ int idbm_lock(void)
|
||||
if (ret == 0)
|
||||
break;
|
||||
|
||||
+ if (errno != EEXIST) {
|
||||
+ log_error("Could not lock discovery DB: %s: %s",
|
||||
+ LOCK_WRITE_FILE, strerror(errno));
|
||||
+ exit(-1);
|
||||
+ }
|
||||
+
|
||||
usleep(10000);
|
||||
}
|
||||
|
||||
diff -up open-iscsi-2.0-870-rc1/usr/iscsiadm.c.error open-iscsi-2.0-870-rc1/usr/iscsiadm.c
|
||||
--- open-iscsi-2.0-870-rc1/usr/iscsiadm.c.error 2008-09-30 10:20:15.000000000 +0200
|
||||
+++ open-iscsi-2.0-870-rc1/usr/iscsiadm.c 2008-09-30 10:20:15.000000000 +0200
|
||||
@@ -2141,6 +2141,12 @@ main(int argc, char **argv)
|
||||
if (mode < 0)
|
||||
usage(0);
|
||||
|
||||
+ if (getuid()) {
|
||||
+ log_error("must be run as root");
|
||||
+ rc = -1;
|
||||
+ goto free_ifaces;
|
||||
+ }
|
||||
+
|
||||
if (mode == MODE_FW) {
|
||||
if ((rc = verify_mode_params(argc, argv, "ml", 0))) {
|
||||
log_error("fw mode: option '-%c' is not "
|
202
iscsi-initiator-utils-start-iscsid.patch
Normal file
202
iscsi-initiator-utils-start-iscsid.patch
Normal file
@ -0,0 +1,202 @@
|
||||
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, 1);
|
||||
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 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);
|
Loading…
Reference in New Issue
Block a user