Skip to contentSkip to conversation

fdtable: Provide free_fdtable() wrapper.

PATCH New Vadim Lobanov 1 participant 1 message Dec 20, 2006 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fdtable: Provide free_fdtable() wrapper.

Hi,

Christoph Hellwig has expressed concerns that the recent fdtable changes expose the details of the RCU methodology used to release no-longer-used fdtable structures to the rest of the kernel. The trivial patch below addresses these concerns by introducing the appropriate free_fdtable() calls, which simply wrap the release RCU usage. Since free_fdtable() is a one-liner, it makes sense to promote it to an inline helper.

Please apply.

fs/file.c +1 -1
diff -pru old/fs/file.c new/fs/file.c
@@ -206,7 +206,7 @@ static int expand_fdtable(struct files_s
 		copy_fdtable(new_fdt, cur_fdt);
 		rcu_assign_pointer(files->fdt, new_fdt);
 		if (cur_fdt->max_fds > NR_OPEN_DEFAULT)
-			call_rcu(&cur_fdt->rcu, free_fdtable_rcu);
+			free_fdtable(cur_fdt);
 	} else {
 		/* Somebody else expanded, so undo our attempt */
 		free_fdarr(new_fdt);
include/linux/file.h +5 -0
diff -pru old/include/linux/file.h new/include/linux/file.h
@@ -80,6 +80,11 @@ extern int expand_files(struct files_str
 extern void free_fdtable_rcu(struct rcu_head *rcu);
 extern void __init files_defer_init(void);
 
+static inline void free_fdtable(struct fdtable *fdt)
+{
+	call_rcu(&fdt->rcu, free_fdtable_rcu);
+}
+
 static inline struct file * fcheck_files(struct files_struct *files, unsigned int fd)
 {
 	struct file * file = NULL;
kernel/exit.c +1 -1
diff -pru old/kernel/exit.c new/kernel/exit.c
@@ -466,7 +466,7 @@ void fastcall put_files_struct(struct fi
 		fdt = files_fdtable(files);
 		if (fdt != &files->fdtab)
 			kmem_cache_free(files_cachep, files);
-		call_rcu(&fdt->rcu, free_fdtable_rcu);
+		free_fdtable(fdt);
 	}
 }