]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - repair/threads.c
libxfs: refactor manage_zones()
[thirdparty/xfsprogs-dev.git] / repair / threads.c
1 // SPDX-License-Identifier: GPL-2.0
2
3 #include "libxfs.h"
4 #include <pthread.h>
5 #include <signal.h>
6 #include "threads.h"
7 #include "err_protos.h"
8 #include "protos.h"
9 #include "globals.h"
10
11 void
12 thread_init(void)
13 {
14 sigset_t blocked;
15
16 /*
17 * block delivery of progress report signal to all threads
18 */
19 sigemptyset(&blocked);
20 sigaddset(&blocked, SIGHUP);
21 sigaddset(&blocked, SIGALRM);
22 pthread_sigmask(SIG_BLOCK, &blocked, NULL);
23 }
24
25
26 void
27 create_work_queue(
28 struct workqueue *wq,
29 struct xfs_mount *mp,
30 unsigned int nworkers)
31 {
32 int err;
33
34 err = workqueue_create(wq, mp, nworkers);
35 if (err)
36 do_error(_("cannot create worker threads, error = [%d] %s\n"),
37 err, strerror(err));
38 }
39
40 void
41 queue_work(
42 struct workqueue *wq,
43 workqueue_func_t func,
44 xfs_agnumber_t agno,
45 void *arg)
46 {
47 int err;
48
49 err = workqueue_add(wq, func, agno, arg);
50 if (err)
51 do_error(_("cannot allocate worker item, error = [%d] %s\n"),
52 err, strerror(err));
53 }
54
55 void
56 destroy_work_queue(
57 struct workqueue *wq)
58 {
59 workqueue_destroy(wq);
60 }