diff options
| author | Tejun Heo <[email protected]> | 2022-08-28 05:04:35 +0000 |
|---|---|---|
| committer | Greg Kroah-Hartman <[email protected]> | 2022-09-01 16:08:44 +0000 |
| commit | bdb2fd7fc56e197a63c0b0e7e07d25d5e20e7c72 (patch) | |
| tree | a01241b3c7ee54a7ea3f534f432d283bae452740 /fs/kernfs/kernfs-internal.h | |
| parent | kernfs: Refactor kernfs_get_open_node() (diff) | |
| download | kernel-bdb2fd7fc56e197a63c0b0e7e07d25d5e20e7c72.tar.gz kernel-bdb2fd7fc56e197a63c0b0e7e07d25d5e20e7c72.zip | |
kernfs: Skip kernfs_drain_open_files() more aggressively
Track the number of mmapped files and files that need to be released and
skip kernfs_drain_open_file() if both are zero, which are the precise
conditions which require draining open_files. The early exit test is
factored into kernfs_should_drain_open_files() which is now tested by
kernfs_drain_open_files()'s caller - kernfs_drain().
This isn't a meaningful optimization on its own but will enable future
stand-alone kernfs_deactivate() implementation.
v2: Chengming noticed that on->nr_to_release was leaking after ->open()
failure. Fix it by telling kernfs_unlink_open_file() that it's called
from the ->open() fail path and should dec the counter. Use kzalloc() to
allocate kernfs_open_node so that the tracking fields are correctly
initialized.
Cc: Chengming Zhou <[email protected]>
Tested-by: Chengming Zhou <[email protected]>
Reviewed-by: Chengming Zhou <[email protected]>
Signed-off-by: Tejun Heo <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Diffstat (limited to 'fs/kernfs/kernfs-internal.h')
| -rw-r--r-- | fs/kernfs/kernfs-internal.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/kernfs/kernfs-internal.h b/fs/kernfs/kernfs-internal.h index 3ae214d02d44..fc5821effd97 100644 --- a/fs/kernfs/kernfs-internal.h +++ b/fs/kernfs/kernfs-internal.h @@ -157,6 +157,7 @@ struct kernfs_node *kernfs_new_node(struct kernfs_node *parent, */ extern const struct file_operations kernfs_file_fops; +bool kernfs_should_drain_open_files(struct kernfs_node *kn); void kernfs_drain_open_files(struct kernfs_node *kn); /* |
