* [PATCH v2 1/4] include/linux/fs.h: add inode_lock_killable()
@ 2025-05-13 15:03 Max Kellermann
2025-05-13 15:03 ` [PATCH v2 2/4] fs/open: make chmod_common() and chown_common() killable Max Kellermann
` (4 more replies)
0 siblings, 5 replies; 9+ messages in thread
From: Max Kellermann @ 2025-05-13 15:03 UTC (permalink / raw)
To: viro, brauner, jack, linux-fsdevel, linux-kernel; +Cc: Max Kellermann
Prepare for making inode operations killable while they're waiting for
the lock.
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
---
include/linux/fs.h | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 016b0fe1536e..5e4ac873228d 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -867,6 +867,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);
@@ -877,6 +882,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.47.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 2/4] fs/open: make chmod_common() and chown_common() killable
2025-05-13 15:03 [PATCH v2 1/4] include/linux/fs.h: add inode_lock_killable() Max Kellermann
@ 2025-05-13 15:03 ` Max Kellermann
2025-05-15 11:28 ` Jan Kara
2025-05-13 15:03 ` [PATCH v2 3/4] fs/open: make do_truncate() killable Max Kellermann
` (3 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Max Kellermann @ 2025-05-13 15:03 UTC (permalink / raw)
To: viro, brauner, jack, linux-fsdevel, linux-kernel; +Cc: Max Kellermann
Allows killing processes that are waiting for the inode lock.
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
---
v2: split into separate patches
This part was reviewed by Christian Brauner here:
https://lore.kernel.org/linux-fsdevel/20250512-unrat-kapital-2122d3777c5d@brauner/
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
---
fs/open.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/fs/open.c b/fs/open.c
index a9063cca9911..d2f2df52c458 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -635,7 +635,9 @@ int chmod_common(const struct path *path, umode_t mode)
if (error)
return error;
retry_deleg:
- inode_lock(inode);
+ error = inode_lock_killable(inode);
+ if (error)
+ goto out_mnt_unlock;
error = security_path_chmod(path, mode);
if (error)
goto out_unlock;
@@ -650,6 +652,7 @@ int chmod_common(const struct path *path, umode_t mode)
if (!error)
goto retry_deleg;
}
+out_mnt_unlock:
mnt_drop_write(path->mnt);
return error;
}
@@ -769,7 +772,9 @@ int chown_common(const struct path *path, uid_t user, gid_t group)
return -EINVAL;
if ((group != (gid_t)-1) && !setattr_vfsgid(&newattrs, gid))
return -EINVAL;
- inode_lock(inode);
+ error = inode_lock_killable(inode);
+ if (error)
+ return error;
if (!S_ISDIR(inode->i_mode))
newattrs.ia_valid |= ATTR_KILL_SUID | ATTR_KILL_PRIV |
setattr_should_drop_sgid(idmap, inode);
--
2.47.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 3/4] fs/open: make do_truncate() killable
2025-05-13 15:03 [PATCH v2 1/4] include/linux/fs.h: add inode_lock_killable() Max Kellermann
2025-05-13 15:03 ` [PATCH v2 2/4] fs/open: make chmod_common() and chown_common() killable Max Kellermann
@ 2025-05-13 15:03 ` Max Kellermann
2025-05-15 11:30 ` Jan Kara
2025-05-13 15:03 ` [PATCH v2 4/4] fs/read_write: make default_llseek() killable Max Kellermann
` (2 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Max Kellermann @ 2025-05-13 15:03 UTC (permalink / raw)
To: viro, brauner, jack, linux-fsdevel, linux-kernel; +Cc: Max Kellermann
Allows killing processes that are waiting for the inode lock.
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
---
v2: split into separate patches
Review here (though nothing about do_truncate()):
https://lore.kernel.org/linux-fsdevel/20250512-unrat-kapital-2122d3777c5d@brauner/
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
---
fs/open.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/fs/open.c b/fs/open.c
index d2f2df52c458..7828234a7caa 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -60,7 +60,10 @@ int do_truncate(struct mnt_idmap *idmap, struct dentry *dentry,
if (ret)
newattrs.ia_valid |= ret | ATTR_FORCE;
- inode_lock(dentry->d_inode);
+ ret = inode_lock_killable(dentry->d_inode);
+ if (ret)
+ return ret;
+
/* Note any delegations or leases have already been broken: */
ret = notify_change(idmap, dentry, &newattrs, NULL);
inode_unlock(dentry->d_inode);
--
2.47.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 4/4] fs/read_write: make default_llseek() killable
2025-05-13 15:03 [PATCH v2 1/4] include/linux/fs.h: add inode_lock_killable() Max Kellermann
2025-05-13 15:03 ` [PATCH v2 2/4] fs/open: make chmod_common() and chown_common() killable Max Kellermann
2025-05-13 15:03 ` [PATCH v2 3/4] fs/open: make do_truncate() killable Max Kellermann
@ 2025-05-13 15:03 ` Max Kellermann
2025-05-15 11:47 ` Jan Kara
2025-05-15 10:04 ` [PATCH v2 1/4] include/linux/fs.h: add inode_lock_killable() Christian Brauner
2025-05-15 11:28 ` Jan Kara
4 siblings, 1 reply; 9+ messages in thread
From: Max Kellermann @ 2025-05-13 15:03 UTC (permalink / raw)
To: viro, brauner, jack, linux-fsdevel, linux-kernel; +Cc: Max Kellermann
Allows killing processes that are waiting for the inode lock.
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
---
v2: split into separate patches
TODO: review whether all callers can handle EINTR; see
https://lore.kernel.org/linux-fsdevel/20250512-unrat-kapital-2122d3777c5d@brauner/
and
https://lore.kernel.org/linux-fsdevel/hzrj5b7x3rvtxt4qgjxdihhi5vjoc5gw3i35pbyopa7ccucizo@q5c42kjlkly3/
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
---
fs/read_write.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/read_write.c b/fs/read_write.c
index bb0ed26a0b3a..0ef70e128c4a 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -332,7 +332,9 @@ loff_t default_llseek(struct file *file, loff_t offset, int whence)
struct inode *inode = file_inode(file);
loff_t retval;
- inode_lock(inode);
+ retval = inode_lock_killable(inode);
+ if (retval)
+ return retval;
switch (whence) {
case SEEK_END:
offset += i_size_read(inode);
--
2.47.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/4] include/linux/fs.h: add inode_lock_killable()
2025-05-13 15:03 [PATCH v2 1/4] include/linux/fs.h: add inode_lock_killable() Max Kellermann
` (2 preceding siblings ...)
2025-05-13 15:03 ` [PATCH v2 4/4] fs/read_write: make default_llseek() killable Max Kellermann
@ 2025-05-15 10:04 ` Christian Brauner
2025-05-15 11:28 ` Jan Kara
4 siblings, 0 replies; 9+ messages in thread
From: Christian Brauner @ 2025-05-15 10:04 UTC (permalink / raw)
To: Max Kellermann; +Cc: Christian Brauner, viro, jack, linux-fsdevel, linux-kernel
On Tue, 13 May 2025 17:03:24 +0200, Max Kellermann wrote:
> Prepare for making inode operations killable while they're waiting for
> the lock.
>
>
Applied to the vfs-6.16.misc branch of the vfs/vfs.git tree.
Patches in the vfs-6.16.misc branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-6.16.misc
[1/4] include/linux/fs.h: add inode_lock_killable()
https://git.kernel.org/vfs/vfs/c/d8c5507cd140
[2/4] fs/open: make chmod_common() and chown_common() killable
https://git.kernel.org/vfs/vfs/c/28a3f6ab2fe0
[3/4] fs/open: make do_truncate() killable
https://git.kernel.org/vfs/vfs/c/d68687564280
[4/4] fs/read_write: make default_llseek() killable
https://git.kernel.org/vfs/vfs/c/2e1a8fbff51b
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/4] include/linux/fs.h: add inode_lock_killable()
2025-05-13 15:03 [PATCH v2 1/4] include/linux/fs.h: add inode_lock_killable() Max Kellermann
` (3 preceding siblings ...)
2025-05-15 10:04 ` [PATCH v2 1/4] include/linux/fs.h: add inode_lock_killable() Christian Brauner
@ 2025-05-15 11:28 ` Jan Kara
4 siblings, 0 replies; 9+ messages in thread
From: Jan Kara @ 2025-05-15 11:28 UTC (permalink / raw)
To: Max Kellermann; +Cc: viro, brauner, jack, linux-fsdevel, linux-kernel
On Tue 13-05-25 17:03:24, Max Kellermann wrote:
> Prepare for making inode operations killable while they're waiting for
> the lock.
>
> Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> include/linux/fs.h | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 016b0fe1536e..5e4ac873228d 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -867,6 +867,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);
> @@ -877,6 +882,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.47.2
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/4] fs/open: make chmod_common() and chown_common() killable
2025-05-13 15:03 ` [PATCH v2 2/4] fs/open: make chmod_common() and chown_common() killable Max Kellermann
@ 2025-05-15 11:28 ` Jan Kara
0 siblings, 0 replies; 9+ messages in thread
From: Jan Kara @ 2025-05-15 11:28 UTC (permalink / raw)
To: Max Kellermann; +Cc: viro, brauner, jack, linux-fsdevel, linux-kernel
On Tue 13-05-25 17:03:25, Max Kellermann wrote:
> Allows killing processes that are waiting for the inode lock.
>
> Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> v2: split into separate patches
>
> This part was reviewed by Christian Brauner here:
> https://lore.kernel.org/linux-fsdevel/20250512-unrat-kapital-2122d3777c5d@brauner/
>
> Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
> ---
> fs/open.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/fs/open.c b/fs/open.c
> index a9063cca9911..d2f2df52c458 100644
> --- a/fs/open.c
> +++ b/fs/open.c
> @@ -635,7 +635,9 @@ int chmod_common(const struct path *path, umode_t mode)
> if (error)
> return error;
> retry_deleg:
> - inode_lock(inode);
> + error = inode_lock_killable(inode);
> + if (error)
> + goto out_mnt_unlock;
> error = security_path_chmod(path, mode);
> if (error)
> goto out_unlock;
> @@ -650,6 +652,7 @@ int chmod_common(const struct path *path, umode_t mode)
> if (!error)
> goto retry_deleg;
> }
> +out_mnt_unlock:
> mnt_drop_write(path->mnt);
> return error;
> }
> @@ -769,7 +772,9 @@ int chown_common(const struct path *path, uid_t user, gid_t group)
> return -EINVAL;
> if ((group != (gid_t)-1) && !setattr_vfsgid(&newattrs, gid))
> return -EINVAL;
> - inode_lock(inode);
> + error = inode_lock_killable(inode);
> + if (error)
> + return error;
> if (!S_ISDIR(inode->i_mode))
> newattrs.ia_valid |= ATTR_KILL_SUID | ATTR_KILL_PRIV |
> setattr_should_drop_sgid(idmap, inode);
> --
> 2.47.2
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 3/4] fs/open: make do_truncate() killable
2025-05-13 15:03 ` [PATCH v2 3/4] fs/open: make do_truncate() killable Max Kellermann
@ 2025-05-15 11:30 ` Jan Kara
0 siblings, 0 replies; 9+ messages in thread
From: Jan Kara @ 2025-05-15 11:30 UTC (permalink / raw)
To: Max Kellermann; +Cc: viro, brauner, jack, linux-fsdevel, linux-kernel
On Tue 13-05-25 17:03:26, Max Kellermann wrote:
> Allows killing processes that are waiting for the inode lock.
>
> Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> v2: split into separate patches
>
> Review here (though nothing about do_truncate()):
> https://lore.kernel.org/linux-fsdevel/20250512-unrat-kapital-2122d3777c5d@brauner/
>
> Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
> ---
> fs/open.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/fs/open.c b/fs/open.c
> index d2f2df52c458..7828234a7caa 100644
> --- a/fs/open.c
> +++ b/fs/open.c
> @@ -60,7 +60,10 @@ int do_truncate(struct mnt_idmap *idmap, struct dentry *dentry,
> if (ret)
> newattrs.ia_valid |= ret | ATTR_FORCE;
>
> - inode_lock(dentry->d_inode);
> + ret = inode_lock_killable(dentry->d_inode);
> + if (ret)
> + return ret;
> +
> /* Note any delegations or leases have already been broken: */
> ret = notify_change(idmap, dentry, &newattrs, NULL);
> inode_unlock(dentry->d_inode);
> --
> 2.47.2
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 4/4] fs/read_write: make default_llseek() killable
2025-05-13 15:03 ` [PATCH v2 4/4] fs/read_write: make default_llseek() killable Max Kellermann
@ 2025-05-15 11:47 ` Jan Kara
0 siblings, 0 replies; 9+ messages in thread
From: Jan Kara @ 2025-05-15 11:47 UTC (permalink / raw)
To: Max Kellermann; +Cc: viro, brauner, jack, linux-fsdevel, linux-kernel
On Tue 13-05-25 17:03:27, Max Kellermann wrote:
> Allows killing processes that are waiting for the inode lock.
>
> Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
> v2: split into separate patches
>
> TODO: review whether all callers can handle EINTR; see
I did a quick audit and everything seems OK AFAICT.
Honza
> https://lore.kernel.org/linux-fsdevel/20250512-unrat-kapital-2122d3777c5d@brauner/
> and
> https://lore.kernel.org/linux-fsdevel/hzrj5b7x3rvtxt4qgjxdihhi5vjoc5gw3i35pbyopa7ccucizo@q5c42kjlkly3/
>
> Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
> ---
> fs/read_write.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/read_write.c b/fs/read_write.c
> index bb0ed26a0b3a..0ef70e128c4a 100644
> --- a/fs/read_write.c
> +++ b/fs/read_write.c
> @@ -332,7 +332,9 @@ loff_t default_llseek(struct file *file, loff_t offset, int whence)
> struct inode *inode = file_inode(file);
> loff_t retval;
>
> - inode_lock(inode);
> + retval = inode_lock_killable(inode);
> + if (retval)
> + return retval;
> switch (whence) {
> case SEEK_END:
> offset += i_size_read(inode);
> --
> 2.47.2
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-05-15 11:47 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-13 15:03 [PATCH v2 1/4] include/linux/fs.h: add inode_lock_killable() Max Kellermann
2025-05-13 15:03 ` [PATCH v2 2/4] fs/open: make chmod_common() and chown_common() killable Max Kellermann
2025-05-15 11:28 ` Jan Kara
2025-05-13 15:03 ` [PATCH v2 3/4] fs/open: make do_truncate() killable Max Kellermann
2025-05-15 11:30 ` Jan Kara
2025-05-13 15:03 ` [PATCH v2 4/4] fs/read_write: make default_llseek() killable Max Kellermann
2025-05-15 11:47 ` Jan Kara
2025-05-15 10:04 ` [PATCH v2 1/4] include/linux/fs.h: add inode_lock_killable() Christian Brauner
2025-05-15 11:28 ` Jan Kara
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).