summaryrefslogtreecommitdiff
path: root/include/linux/filelock.h
diff options
context:
space:
mode:
authorJeff Layton <jlayton@kernel.org>2024-02-01 02:01:45 +0300
committerChristian Brauner <brauner@kernel.org>2024-02-05 15:11:35 +0300
commit75cabec0111b7ccb140d917cc9c481e845cc3498 (patch)
treebdb05f83be056d66d4be6c680aec3c7351e94298 /include/linux/filelock.h
parent6021d62c677f12f2f975bb1bf2389730e1d9f746 (diff)
downloadlinux-75cabec0111b7ccb140d917cc9c481e845cc3498.tar.xz
filelock: add some new helper functions
In later patches we're going to embed some common fields into a new structure inside struct file_lock. Smooth the transition by adding some new helper functions, and converting the core file locking code to use them. Signed-off-by: Jeff Layton <jlayton@kernel.org> Link: https://lore.kernel.org/r/20240131-flsplit-v3-4-c6129007ee8d@kernel.org Reviewed-by: NeilBrown <neilb@suse.de> Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'include/linux/filelock.h')
-rw-r--r--include/linux/filelock.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/include/linux/filelock.h b/include/linux/filelock.h
index 085ff6ba0653..a3cb59b7922a 100644
--- a/include/linux/filelock.h
+++ b/include/linux/filelock.h
@@ -147,6 +147,29 @@ int fcntl_setlk64(unsigned int, struct file *, unsigned int,
int fcntl_setlease(unsigned int fd, struct file *filp, int arg);
int fcntl_getlease(struct file *filp);
+static inline bool lock_is_unlock(struct file_lock *fl)
+{
+ return fl->fl_type == F_UNLCK;
+}
+
+static inline bool lock_is_read(struct file_lock *fl)
+{
+ return fl->fl_type == F_RDLCK;
+}
+
+static inline bool lock_is_write(struct file_lock *fl)
+{
+ return fl->fl_type == F_WRLCK;
+}
+
+static inline void locks_wake_up(struct file_lock *fl)
+{
+ wake_up(&fl->fl_wait);
+}
+
+/* for walking lists of file_locks linked by fl_list */
+#define for_each_file_lock(_fl, _head) list_for_each_entry(_fl, _head, fl_list)
+
/* fs/locks.c */
void locks_free_lock_context(struct inode *inode);
void locks_free_lock(struct file_lock *fl);
@@ -223,6 +246,27 @@ static inline int fcntl_getlease(struct file *filp)
return F_UNLCK;
}
+static inline bool lock_is_unlock(struct file_lock *fl)
+{
+ return false;
+}
+
+static inline bool lock_is_read(struct file_lock *fl)
+{
+ return false;
+}
+
+static inline bool lock_is_write(struct file_lock *fl)
+{
+ return false;
+}
+
+static inline void locks_wake_up(struct file_lock *fl)
+{
+}
+
+#define for_each_file_lock(_fl, _head) while(false)
+
static inline void
locks_free_lock_context(struct inode *inode)
{