blob: feb37dd9debf6fece91dd9101e1d8ac348f01184 [file] [log] [blame]
Thomas Gleixner1a59d1b82019-05-27 08:55:05 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
Dave Kleikamp63f83c92006-10-02 09:55:27 -05003 * Copyright (C) International Business Machines Corp., 2000-2001
4 * Portions Copyright (C) Christoph Hellwig, 2001-2002
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 */
6#ifndef _H_JFS_LOCK
7#define _H_JFS_LOCK
8
9#include <linux/spinlock.h>
Ingo Molnar1de87442006-01-24 15:22:50 -060010#include <linux/mutex.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#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) \
23do { \
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; \
Dave Kleikamp4aa0d232007-01-17 21:18:35 -060032 io_schedule(); \
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 lock_cmd; \
34 } \
Milind Arun Choudhary3cbb1c82007-04-26 07:30:29 -050035 __set_current_state(TASK_RUNNING); \
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 remove_wait_queue(&wq, &__wait); \
37} while (0)
38
39#endif /* _H_JFS_LOCK */