| From 79433b8432a256a02d8d42b59745c95b35d69cf8 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 5417515c41119..9abc697b208b7 100644 | |
| --- a/include/linux/fs.h | |
| +++ b/include/linux/fs.h | |
| @@ -782,6 +782,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); | |
| @@ -792,6 +797,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 | |