]>
Commit | Line | Data |
---|---|---|
959ef981 DC |
1 | // SPDX-License-Identifier: GPL-2.0 |
2 | ||
6b803e5a | 3 | #include "libxfs.h" |
2556c98b BN |
4 | #include <pthread.h> |
5 | #include <signal.h> | |
3b6ac903 MV |
6 | #include "threads.h" |
7 | #include "err_protos.h" | |
8 | #include "protos.h" | |
2556c98b | 9 | #include "globals.h" |
3b6ac903 | 10 | |
3b6ac903 MV |
11 | void |
12 | thread_init(void) | |
13 | { | |
3b6ac903 MV |
14 | sigset_t blocked; |
15 | ||
3b6ac903 MV |
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); | |
3b6ac903 MV |
23 | } |
24 | ||
2556c98b BN |
25 | |
26 | void | |
27 | create_work_queue( | |
62843f36 DW |
28 | struct workqueue *wq, |
29 | struct xfs_mount *mp, | |
30 | unsigned int nworkers) | |
3b6ac903 | 31 | { |
2556c98b | 32 | int err; |
3b6ac903 | 33 | |
baed134d | 34 | err = -workqueue_create(wq, mp, nworkers); |
62843f36 DW |
35 | if (err) |
36 | do_error(_("cannot create worker threads, error = [%d] %s\n"), | |
2556c98b | 37 | err, strerror(err)); |
3b6ac903 MV |
38 | } |
39 | ||
2556c98b BN |
40 | void |
41 | queue_work( | |
62843f36 DW |
42 | struct workqueue *wq, |
43 | workqueue_func_t func, | |
44 | xfs_agnumber_t agno, | |
45 | void *arg) | |
3b6ac903 | 46 | { |
62843f36 | 47 | int err; |
3b6ac903 | 48 | |
baed134d | 49 | err = -workqueue_add(wq, func, agno, arg); |
62843f36 | 50 | if (err) |
2556c98b | 51 | do_error(_("cannot allocate worker item, error = [%d] %s\n"), |
62843f36 | 52 | err, strerror(err)); |
3b6ac903 MV |
53 | } |
54 | ||
55 | void | |
2556c98b | 56 | destroy_work_queue( |
62843f36 | 57 | struct workqueue *wq) |
3b6ac903 | 58 | { |
71296cf8 DW |
59 | int err; |
60 | ||
baed134d | 61 | err = -workqueue_terminate(wq); |
71296cf8 DW |
62 | if (err) |
63 | do_error(_("cannot terminate worker item, error = [%d] %s\n"), | |
64 | err, strerror(err)); | |
62843f36 | 65 | workqueue_destroy(wq); |
3b6ac903 | 66 | } |