diff options
author | Vadim Lobanov <vlobanov@speakeasy.net> | 2006-12-10 05:21:17 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.osdl.org> | 2006-12-10 12:57:22 -0500 |
commit | 4fd45812cbe875a620c86a096a5d46c742694b7e (patch) | |
tree | 8d2c99caa718da6cda87229076adf708494ff251 /kernel | |
parent | bbea9f69668a3d0cf9feba15a724cd02896f8675 (diff) |
[PATCH] fdtable: Remove the free_files field
An fdtable can either be embedded inside a files_struct or standalone (after
being expanded). When an fdtable is being discarded after all RCU references
to it have expired, we must either free it directly, in the standalone case,
or free the files_struct it is contained within, in the embedded case.
Currently the free_files field controls this behavior, but we can get rid of
it entirely, as all the necessary information is already recorded. We can
distinguish embedded and standalone fdtables using max_fds, and if it is
embedded we can divine the relevant files_struct using container_of().
Signed-off-by: Vadim Lobanov <vlobanov@speakeasy.net>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Dipankar Sarma <dipankar@in.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/exit.c | 6 | ||||
-rw-r--r-- | kernel/fork.c | 1 |
2 files changed, 2 insertions, 5 deletions
diff --git a/kernel/exit.c b/kernel/exit.c index 5f77e76b4f97..122fadb972fc 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -466,11 +466,9 @@ void fastcall put_files_struct(struct files_struct *files) | |||
466 | * you can free files immediately. | 466 | * you can free files immediately. |
467 | */ | 467 | */ |
468 | fdt = files_fdtable(files); | 468 | fdt = files_fdtable(files); |
469 | if (fdt == &files->fdtab) | 469 | if (fdt != &files->fdtab) |
470 | fdt->free_files = files; | ||
471 | else | ||
472 | kmem_cache_free(files_cachep, files); | 470 | kmem_cache_free(files_cachep, files); |
473 | free_fdtable(fdt); | 471 | call_rcu(&fdt->rcu, free_fdtable_rcu); |
474 | } | 472 | } |
475 | } | 473 | } |
476 | 474 | ||
diff --git a/kernel/fork.c b/kernel/fork.c index aba595424f78..d16c566eb645 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -645,7 +645,6 @@ static struct files_struct *alloc_files(void) | |||
645 | fdt->open_fds = (fd_set *)&newf->open_fds_init; | 645 | fdt->open_fds = (fd_set *)&newf->open_fds_init; |
646 | fdt->fd = &newf->fd_array[0]; | 646 | fdt->fd = &newf->fd_array[0]; |
647 | INIT_RCU_HEAD(&fdt->rcu); | 647 | INIT_RCU_HEAD(&fdt->rcu); |
648 | fdt->free_files = NULL; | ||
649 | fdt->next = NULL; | 648 | fdt->next = NULL; |
650 | rcu_assign_pointer(newf->fdt, fdt); | 649 | rcu_assign_pointer(newf->fdt, fdt); |
651 | out: | 650 | out: |