Commit | Line | Data |
---|---|---|
1a59d1b8 | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
1da177e4 | 2 | /* |
63f83c9f DK |
3 | * Copyright (C) International Business Machines Corp., 2000-2001 |
4 | * Portions Copyright (C) Christoph Hellwig, 2001-2002 | |
1da177e4 LT |
5 | */ |
6 | #ifndef _H_JFS_LOCK | |
7 | #define _H_JFS_LOCK | |
8 | ||
9 | #include <linux/spinlock.h> | |
1de87444 | 10 | #include <linux/mutex.h> |
1da177e4 LT |
11 | #include <linux/sched.h> |
12 | ||
13 | /* | |
14 | * jfs_lock.h | |
15 | */ | |
16 | ||
17 | /* | |
18 | * Conditional sleep where condition is protected by spinlock | |
19 | * | |
20 | * lock_cmd and unlock_cmd take and release the spinlock | |
21 | */ | |
22 | #define __SLEEP_COND(wq, cond, lock_cmd, unlock_cmd) \ | |
23 | do { \ | |
24 | DECLARE_WAITQUEUE(__wait, current); \ | |
25 | \ | |
26 | add_wait_queue(&wq, &__wait); \ | |
27 | for (;;) { \ | |
28 | set_current_state(TASK_UNINTERRUPTIBLE);\ | |
29 | if (cond) \ | |
30 | break; \ | |
31 | unlock_cmd; \ | |
4aa0d230 | 32 | io_schedule(); \ |
1da177e4 LT |
33 | lock_cmd; \ |
34 | } \ | |
3cbb1c8e | 35 | __set_current_state(TASK_RUNNING); \ |
1da177e4 LT |
36 | remove_wait_queue(&wq, &__wait); \ |
37 | } while (0) | |
38 | ||
39 | #endif /* _H_JFS_LOCK */ |