diff options
author | Kinglong Mee <kinglongmee@gmail.com> | 2015-11-04 10:20:15 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-11-11 02:06:53 -0500 |
commit | 86108c2e34a26e4bec3c6ddb23390bf8cedcf391 (patch) | |
tree | 6c9dc0e43e804fa041a2e0d5c20e70678d3f898d | |
parent | 0ee9608c89e81a1ccee52ecb58a7ff040e2522d9 (diff) |
FS-Cache: Increase reference of parent after registering, netfs success
If netfs exist, fscache should not increase the reference of parent's
usage and n_children, otherwise, never be decreased.
v2: thanks David's suggest,
move increasing reference of parent if success
use kmem_cache_free() freeing primary_index directly
v3: don't move "netfs->primary_index->parent = &fscache_fsdef_index;"
Cc: stable@vger.kernel.org # v2.6.30+
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/fscache/netfs.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/fs/fscache/netfs.c b/fs/fscache/netfs.c index 6d941f56faf4..458cc968d9a0 100644 --- a/fs/fscache/netfs.c +++ b/fs/fscache/netfs.c | |||
@@ -47,9 +47,6 @@ int __fscache_register_netfs(struct fscache_netfs *netfs) | |||
47 | netfs->primary_index->netfs_data = netfs; | 47 | netfs->primary_index->netfs_data = netfs; |
48 | netfs->primary_index->flags = 1 << FSCACHE_COOKIE_ENABLED; | 48 | netfs->primary_index->flags = 1 << FSCACHE_COOKIE_ENABLED; |
49 | 49 | ||
50 | atomic_inc(&netfs->primary_index->parent->usage); | ||
51 | atomic_inc(&netfs->primary_index->parent->n_children); | ||
52 | |||
53 | spin_lock_init(&netfs->primary_index->lock); | 50 | spin_lock_init(&netfs->primary_index->lock); |
54 | INIT_HLIST_HEAD(&netfs->primary_index->backing_objects); | 51 | INIT_HLIST_HEAD(&netfs->primary_index->backing_objects); |
55 | 52 | ||
@@ -62,6 +59,9 @@ int __fscache_register_netfs(struct fscache_netfs *netfs) | |||
62 | goto already_registered; | 59 | goto already_registered; |
63 | } | 60 | } |
64 | 61 | ||
62 | atomic_inc(&netfs->primary_index->parent->usage); | ||
63 | atomic_inc(&netfs->primary_index->parent->n_children); | ||
64 | |||
65 | list_add(&netfs->link, &fscache_netfs_list); | 65 | list_add(&netfs->link, &fscache_netfs_list); |
66 | ret = 0; | 66 | ret = 0; |
67 | 67 | ||
@@ -71,8 +71,7 @@ already_registered: | |||
71 | up_write(&fscache_addremove_sem); | 71 | up_write(&fscache_addremove_sem); |
72 | 72 | ||
73 | if (ret < 0) { | 73 | if (ret < 0) { |
74 | netfs->primary_index->parent = NULL; | 74 | kmem_cache_free(fscache_cookie_jar, netfs->primary_index); |
75 | __fscache_cookie_put(netfs->primary_index); | ||
76 | netfs->primary_index = NULL; | 75 | netfs->primary_index = NULL; |
77 | } | 76 | } |
78 | 77 | ||