mirror of
https://github.com/torvalds/linux.git
synced 2026-05-27 08:33:17 +02:00
Merge patch series "include/linux/fs.h: add inode_lock_killable()"
Try and make a few filesystem operations killable on the VFS inode->i_mutex level. * patches from https://lore.kernel.org/20250513150327.1373061-1-max.kellermann@ionos.com: fs/read_write: make default_llseek() killable fs/open: make do_truncate() killable fs/open: make chmod_common() and chown_common() killable include/linux/fs.h: add inode_lock_killable() Link: https://lore.kernel.org/20250513150327.1373061-1-max.kellermann@ionos.com Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
commit
4fae90d04a
14
fs/open.c
14
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);
|
||||
|
|
@ -635,7 +638,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 +655,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 +775,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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user