mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 2/7] revoke: add f_light flag for struct file
@ 2007-03-09  8:14 Pekka J Enberg
  2007-03-09 10:08 ` Eric Dumazet
  0 siblings, 1 reply; 11+ messages in thread
From: Pekka J Enberg @ 2007-03-09  8:14 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, hch, alan, serue

From: Pekka Enberg <penberg@cs.helsinki.fi>

This adds a f_light flag to struct file to indicate that the file was
looked up with fget_light().  Needed by revoke to ensure we don't
close a file pointer while someone is using it without actually
holding a reference.

These bits were taken from the forced unmount patches by Tigran
Aivazian.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
---
 fs/file_table.c      |    1 +
 include/linux/file.h |   14 ++++++++++++++
 include/linux/fs.h   |    2 ++
 3 files changed, 17 insertions(+)

Index: uml-2.6/fs/file_table.c
===================================================================
--- uml-2.6.orig/fs/file_table.c	2007-03-08 10:24:24.000000000 +0200
+++ uml-2.6/fs/file_table.c	2007-03-08 10:24:31.000000000 +0200
@@ -219,6 +219,7 @@
 	*fput_needed = 0;
 	if (likely((atomic_read(&files->count) == 1))) {
 		file = fcheck_files(files, fd);
+		set_f_light(file);
 	} else {
 		rcu_read_lock();
 		file = fcheck_files(files, fd);
Index: uml-2.6/include/linux/file.h
===================================================================
--- uml-2.6.orig/include/linux/file.h	2007-03-08 10:24:24.000000000 +0200
+++ uml-2.6/include/linux/file.h	2007-03-08 10:24:31.000000000 +0200
@@ -6,6 +6,7 @@
 #define __LINUX_FILE_H
 
 #include <asm/atomic.h>
+#include <linux/fs.h>
 #include <linux/posix_types.h>
 #include <linux/compiler.h>
 #include <linux/spinlock.h>
@@ -62,10 +63,23 @@
 extern void FASTCALL(__fput(struct file *));
 extern void FASTCALL(fput(struct file *));
 
+static inline void clear_f_light(struct file *file)
+{
+	file->f_light = 0;
+}
+
+static inline void set_f_light(struct file *file)
+{
+	if (file)
+		file->f_light = 1;
+}
+
 static inline void fput_light(struct file *file, int fput_needed)
 {
 	if (unlikely(fput_needed))
 		fput(file);
+	else
+		clear_f_light(file);
 }
 
 extern struct file * FASTCALL(fget(unsigned int fd));
Index: uml-2.6/include/linux/fs.h
===================================================================
--- uml-2.6.orig/include/linux/fs.h	2007-03-08 10:24:24.000000000 +0200
+++ uml-2.6/include/linux/fs.h	2007-03-08 10:24:31.000000000 +0200
@@ -739,6 +739,8 @@
 	struct list_head	f_ep_links;
 	spinlock_t		f_ep_lock;
 #endif /* #ifdef CONFIG_EPOLL */
+	/* This instance is being used without holding a reference. */
+	int			f_light;
 	struct address_space	*f_mapping;
 };
 extern spinlock_t files_lock;

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2007-03-09 17:47 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-09  8:14 [PATCH 2/7] revoke: add f_light flag for struct file Pekka J Enberg
2007-03-09 10:08 ` Eric Dumazet
2007-03-09 10:43   ` Pekka Enberg
2007-03-09 11:13     ` Eric Dumazet
2007-03-09 11:52       ` Pekka Enberg
2007-03-09 11:58         ` Pekka Enberg
2007-03-09 14:12           ` Alan Cox
2007-03-09 13:13             ` Pekka J Enberg
2007-03-09 16:11       ` Benjamin LaHaise
2007-03-09 17:02         ` Pekka Enberg
2007-03-09 17:47         ` Eric Dumazet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®