mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 11:41:38 -04:00
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: Mateusz Guzik <[email protected]> Signed-off-by: Al Viro <[email protected]>
This commit is contained in:
parent
5297908270
commit
c02b1a9b41
2 changed files with 7 additions and 8 deletions
11
fs/file.c
11
fs/file.c
|
|
@ -592,13 +592,16 @@ void __fd_install(struct files_struct *files, unsigned int fd,
|
|||
{
|
||||
struct fdtable *fdt;
|
||||
|
||||
might_sleep();
|
||||
rcu_read_lock_sched();
|
||||
|
||||
while (unlikely(files->resize_in_progress)) {
|
||||
if (unlikely(files->resize_in_progress)) {
|
||||
rcu_read_unlock_sched();
|
||||
wait_event(files->resize_wait, !files->resize_in_progress);
|
||||
rcu_read_lock_sched();
|
||||
spin_lock(&files->file_lock);
|
||||
fdt = files_fdtable(files);
|
||||
BUG_ON(fdt->fd[fd] != NULL);
|
||||
rcu_assign_pointer(fdt->fd[fd], file);
|
||||
spin_unlock(&files->file_lock);
|
||||
return;
|
||||
}
|
||||
/* coupled with smp_wmb() in expand_fdtable() */
|
||||
smp_rmb();
|
||||
|
|
|
|||
Loading…
Reference in a new issue