Commit c02b1a9b authored by Mateusz Guzik's avatar Mateusz Guzik Committed by Al Viro
Browse files

vfs: grab the lock instead of blocking in __fd_install during resizing

Explicit locking in the fallback case provides a safe state of the
table. Getting rid of blocking semantics makes __fd_install usable
again in non-sleepable contexts, which easies backporting efforts.

There is a side effect of slightly nicer assembly for the common case
as might_sleep can now be removed.
Signed-off-by: default avatarMateusz Guzik <>
Signed-off-by: default avatarAl Viro <>
parent 52979082
......@@ -501,10 +501,6 @@ in your dentry operations instead.
is non-NULL. Note that link body isn't available anymore, so if you need it,
store it as cookie.
__fd_install() & fd_install() can now sleep. Callers should not
hold a spinlock or other resources that do not allow a schedule.
any symlink that might use page_follow_link_light/page_put_link() must
have inode_nohighmem(inode) called before anything might start playing with
......@@ -592,13 +592,16 @@ void __fd_install(struct files_struct *files, unsigned int fd,
struct fdtable *fdt;
while (unlikely(files->resize_in_progress)) {
if (unlikely(files->resize_in_progress)) {
wait_event(files->resize_wait, !files->resize_in_progress);
fdt = files_fdtable(files);
BUG_ON(fdt->fd[fd] != NULL);
rcu_assign_pointer(fdt->fd[fd], file);
/* coupled with smp_wmb() in expand_fdtable() */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment