]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blame - fs/aufs/wkq.h
UBUNTU: SAUCE: Update aufs to 5.4.3 20200302
[mirror_ubuntu-focal-kernel.git] / fs / aufs / wkq.h
CommitLineData
a3a49a17
SF
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
e4a3f096 3 * Copyright (C) 2005-2020 Junjiro R. Okajima
a3a49a17
SF
4 *
5 * This program, aufs is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/*
20 * workqueue for asynchronous/super-io operations
21 * todo: try new credentials management scheme
22 */
23
24#ifndef __AUFS_WKQ_H__
25#define __AUFS_WKQ_H__
26
27#ifdef __KERNEL__
28
29#include <linux/wait.h>
30
31struct super_block;
32
33/* ---------------------------------------------------------------------- */
34
35/*
36 * in the next operation, wait for the 'nowait' tasks in system-wide workqueue
37 */
38struct au_nowait_tasks {
39 atomic_t nw_len;
40 wait_queue_head_t nw_wq;
41};
42
43/* ---------------------------------------------------------------------- */
44
45typedef void (*au_wkq_func_t)(void *args);
46
47/* wkq flags */
48#define AuWkq_WAIT 1
49#define AuWkq_NEST (1 << 1)
50#define au_ftest_wkq(flags, name) ((flags) & AuWkq_##name)
51#define au_fset_wkq(flags, name) \
52 do { (flags) |= AuWkq_##name; } while (0)
53#define au_fclr_wkq(flags, name) \
54 do { (flags) &= ~AuWkq_##name; } while (0)
55
56/* wkq.c */
57int au_wkq_do_wait(unsigned int flags, au_wkq_func_t func, void *args);
58int au_wkq_nowait(au_wkq_func_t func, void *args, struct super_block *sb,
59 unsigned int flags);
60void au_nwt_init(struct au_nowait_tasks *nwt);
61int __init au_wkq_init(void);
62void au_wkq_fin(void);
63
64/* ---------------------------------------------------------------------- */
65
66static inline int au_wkq_test(void)
67{
68 return current->flags & PF_WQ_WORKER;
69}
70
71static inline int au_wkq_wait(au_wkq_func_t func, void *args)
72{
73 return au_wkq_do_wait(AuWkq_WAIT, func, args);
74}
75
76static inline void au_nwt_done(struct au_nowait_tasks *nwt)
77{
78 if (atomic_dec_and_test(&nwt->nw_len))
79 wake_up_all(&nwt->nw_wq);
80}
81
82static inline int au_nwt_flush(struct au_nowait_tasks *nwt)
83{
84 wait_event(nwt->nw_wq, !atomic_read(&nwt->nw_len));
85 return 0;
86}
87
88#endif /* __KERNEL__ */
89#endif /* __AUFS_WKQ_H__ */