[sheepdog] [PATCH stable-0.7 1/2] sheep: prevent starvation of "node kill" requests

Hitoshi Mitake mitake.hitoshi at lab.ntt.co.jp
Thu Mar 6 07:15:18 CET 2014


Under heavy load, sheep process continues to execute event_loop()
even if admins execute "dog node kill" because
sys->nr_outstanding_reqs rarely reaches 0. In our case, actual
exit of sheep process took about from 10 min to 1 hour to complete.

This patch prevents the starvation of the stop requests by
unregistering events of listening fds. By unregistering, sheep can
stop generating new requests.

Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix at gmail.com>

Conflicts:
	sheep/ops.c
	sheep/request.c

Conflicts were resolved by Hitoshi Mitake.
Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
 sheep/ops.c        |    3 +++
 sheep/request.c    |   23 +++++++++++++++++++++++
 sheep/sheep_priv.h |    1 +
 3 files changed, 27 insertions(+)

diff --git a/sheep/ops.c b/sheep/ops.c
index 5af516d..5afabf5 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -287,6 +287,8 @@ static int cluster_shutdown(const struct sd_req *req, struct sd_rsp *rsp,
 			    void *data)
 {
 	sys->cinfo.status = SD_STATUS_SHUTDOWN;
+	unregister_listening_fds();
+
 	return SD_RES_SUCCESS;
 }
 
@@ -837,6 +839,7 @@ static int local_kill_node(const struct sd_req *req, struct sd_rsp *rsp,
 			   void *data)
 {
 	sys->cinfo.status = SD_STATUS_KILLED;
+	unregister_listening_fds();
 
 	return SD_RES_SUCCESS;
 }
diff --git a/sheep/request.c b/sheep/request.c
index 87286b0..39e0d9e 100644
--- a/sheep/request.c
+++ b/sheep/request.c
@@ -810,11 +810,34 @@ static void listen_handler(int listen_fd, int events, void *data)
 	sd_debug("accepted a new connection: %d", fd);
 }
 
+static LIST_HEAD(listening_fd_list);
+
+struct listening_fd {
+	int fd;
+	struct list_head list;
+};
+
 static int create_listen_port_fn(int fd, void *data)
 {
+	struct listening_fd *new_fd;
+
+	new_fd = xzalloc(sizeof(*new_fd));
+	new_fd->fd = fd;
+	list_add_tail(&new_fd->list, &listening_fd_list);
+
 	return register_event(fd, listen_handler, data);
 }
 
+void unregister_listening_fds(void)
+{
+	struct listening_fd *fd;
+
+	list_for_each_entry(fd, &listening_fd_list, list) {
+		sd_debug("unregistering fd: %d", fd->fd);
+		unregister_event(fd->fd);
+	}
+}
+
 int create_listen_port(char *bindaddr, int port)
 {
 	static bool is_inet_socket = true;
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 19db37e..0ff288c 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -265,6 +265,7 @@ static inline bool is_aligned_to_pagesize(void *p)
 
 int create_listen_port(char *bindaddr, int port);
 int init_unix_domain_socket(const char *dir);
+void unregister_listening_fds(void);
 
 int init_store_driver(bool is_gateway);
 int init_global_pathnames(const char *d, char *);
-- 
1.7.10.4




More information about the sheepdog mailing list