VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   32 Branches   54 Tags
author: Mateusz Guzik <mguzik@redhat.com> 2017-10-03 12:58:15 +0200 committer: Al Viro <viro@zeniv.linux.org.uk> 2017-11-05 18:58:07 -0500 commit: c02b1a9b41c2e728289f96850580a3651e0a8b5f parent: 5297908270549b734c7c2556745e2385b6d4941d
Commit Summary:
vfs: grab the lock instead of blocking in __fd_install during resizing
Diffstat:
1 file changed, 7 insertions, 4 deletions
diff --git a/fs/file.c b/fs/file.c
index 9d047bd046b0..4115503bb575 100644
--- a/fs/file.c
+++ b/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();