blob: f2ad944f0854c5eb93e98b542f7e0949b4b02a18 [file]
From 4b818a90e636721b37ff059754c7f51c7f60e095 Mon Sep 17 00:00:00 2001
From: Sasha Levin <sashal@kernel.org>
Date: Tue, 13 May 2025 17:03:24 +0200
Subject: include/linux/fs.h: add inode_lock_killable()
From: Max Kellermann <max.kellermann@ionos.com>
[ Upstream commit d8c5507cd140d9471472ece673e70250b957c595 ]
Prepare for making inode operations killable while they're waiting for
the lock.
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
Link: https://lore.kernel.org/20250513150327.1373061-1-max.kellermann@ionos.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
Stable-dep-of: 7a5783cfac71 ("fs: reject negative offsets for SEEK_DATA and SEEK_HOLE in default_llseek()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
include/linux/fs.h | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index a6845fdc73cf9..fe4bcaefff094 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -795,6 +795,11 @@ static inline void inode_lock(struct inode *inode)
down_write(&inode->i_rwsem);
}
+static inline __must_check int inode_lock_killable(struct inode *inode)
+{
+ return down_write_killable(&inode->i_rwsem);
+}
+
static inline void inode_unlock(struct inode *inode)
{
up_write(&inode->i_rwsem);
@@ -805,6 +810,11 @@ static inline void inode_lock_shared(struct inode *inode)
down_read(&inode->i_rwsem);
}
+static inline __must_check int inode_lock_shared_killable(struct inode *inode)
+{
+ return down_read_killable(&inode->i_rwsem);
+}
+
static inline void inode_unlock_shared(struct inode *inode)
{
up_read(&inode->i_rwsem);
--
2.53.0