1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
In detail, on 2.4 we used force_delete() to make sure inode were not cached,
and we then close the host file when the inode is cleared; when porting to 2.6
the "force_delete" thing was dropped, and this patch adds a fix for this
(by setting drop_inode = generic_delete_inode).
Search for drop_inode in the 2.6 Documentation/filesystems/vfs.txt for info about this.
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade_spam@yahoo.it>
---
uml-linux-2.6.7-paolo/fs/hostfs/hostfs_kern.c | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletion(-)
diff -puN fs/hostfs/hostfs_kern.c~HostFs-2.6-fd_leak fs/hostfs/hostfs_kern.c
--- uml-linux-2.6.7/fs/hostfs/hostfs_kern.c~HostFs-2.6-fd_leak 2004-06-29 21:03:01.138464296 +0200
+++ uml-linux-2.6.7-paolo/fs/hostfs/hostfs_kern.c 2004-06-29 21:03:01.141463840 +0200
@@ -284,13 +284,25 @@ static struct inode *hostfs_alloc_inode(
return(&hi->vfs_inode);
}
+static void hostfs_delete_inode(struct inode *inode)
+{
+ if(HOSTFS_I(inode)->fd != -1) {
+ close_file(&HOSTFS_I(inode)->fd);
+ printk("Closing host fd in .delete_inode\n");
+ HOSTFS_I(inode)->fd = -1;
+ }
+ clear_inode(inode);
+}
+
static void hostfs_destroy_inode(struct inode *inode)
{
if(HOSTFS_I(inode)->host_filename)
kfree(HOSTFS_I(inode)->host_filename);
- if(HOSTFS_I(inode)->fd != -1)
+ if(HOSTFS_I(inode)->fd != -1) {
close_file(&HOSTFS_I(inode)->fd);
+ printk("Closing host fd in .destroy_inode\n");
+ }
kfree(HOSTFS_I(inode));
}
@@ -302,6 +314,8 @@ static void hostfs_read_inode(struct ino
static struct super_operations hostfs_sbops = {
.alloc_inode = hostfs_alloc_inode,
+ .drop_inode = generic_delete_inode,
+ .delete_inode = hostfs_delete_inode,
.destroy_inode = hostfs_destroy_inode,
.read_inode = hostfs_read_inode,
.statfs = hostfs_statfs,
_
|