Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  *   Copyright (C) International Business Machines Corp., 2000-2001
0004  *   Portions Copyright (C) Christoph Hellwig, 2001-2002
0005  */
0006 #ifndef _H_JFS_LOCK
0007 #define _H_JFS_LOCK
0008 
0009 #include <linux/spinlock.h>
0010 #include <linux/mutex.h>
0011 #include <linux/sched.h>
0012 
0013 /*
0014  *  jfs_lock.h
0015  */
0016 
0017 /*
0018  * Conditional sleep where condition is protected by spinlock
0019  *
0020  * lock_cmd and unlock_cmd take and release the spinlock
0021  */
0022 #define __SLEEP_COND(wq, cond, lock_cmd, unlock_cmd)    \
0023 do {                            \
0024     DECLARE_WAITQUEUE(__wait, current);     \
0025                             \
0026     add_wait_queue(&wq, &__wait);           \
0027     for (;;) {                  \
0028         set_current_state(TASK_UNINTERRUPTIBLE);\
0029         if (cond)               \
0030             break;              \
0031         unlock_cmd;             \
0032         io_schedule();              \
0033         lock_cmd;               \
0034     }                       \
0035     __set_current_state(TASK_RUNNING);          \
0036     remove_wait_queue(&wq, &__wait);        \
0037 } while (0)
0038 
0039 #endif              /* _H_JFS_LOCK */