[sheepdog] [PATCH v3 1/2] lib: add an interface for registering workqueue for libsheepdog
Hitoshi Mitake
mitake.hitoshi at lab.ntt.co.jp
Wed Oct 22 03:29:58 CEST 2014
purge_directory() of libsheepdog can call bunch of unlink(2), so it
can cause long request blocking because sheep process calls the
function in its main thread. For avoiding such a problem, this patch
add a new interface for registering workqueue used in util.c of
libsheepdog and let sheep use it.
Cc: Philip Crotwell <crotwell at seis.sc.edu>
Cc: Masahiro Tsuji <tuji at atworks.co.jp>
Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
include/util.h | 3 +++
lib/util.c | 8 ++++++++
sheep/sheep.c | 7 +++++++
3 files changed, 18 insertions(+)
v2:
- use ordered workqueue
diff --git a/include/util.h b/include/util.h
index 69e114b..6a513e0 100644
--- a/include/util.h
+++ b/include/util.h
@@ -575,4 +575,7 @@ static inline uint64_t clock_get_time(void)
char *xstrdup(const char *s);
+struct work_queue;
+void register_util_wq(struct work_queue *wq);
+
#endif
diff --git a/lib/util.c b/lib/util.c
index 164f755..82cf28c 100644
--- a/lib/util.c
+++ b/lib/util.c
@@ -21,6 +21,14 @@
#include <fcntl.h>
#include "util.h"
+#include "work.h"
+
+static struct work_queue *util_wqueue;
+
+void register_util_wq(struct work_queue *wq)
+{
+ util_wqueue = wq;
+}
mode_t sd_def_dmode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP;
mode_t sd_def_fmode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;
diff --git a/sheep/sheep.c b/sheep/sheep.c
index 328a7fe..2e91d0f 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -439,6 +439,8 @@ static size_t get_nr_nodes(void)
static int create_work_queues(void)
{
+ struct work_queue *util_wq;
+
if (init_work_queue(get_nr_nodes))
return -1;
@@ -462,6 +464,11 @@ static int create_work_queues(void)
!sys->areq_wqueue)
return -1;
+ util_wq = create_ordered_work_queue("util");
+ if (!util_wq)
+ return -1;
+ register_util_wq(util_wq);
+
return 0;
}
--
1.8.3.2
More information about the sheepdog
mailing list