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>
This commit is contained in:
Родитель
0ee9608c89
Коммит
86108c2e34
|
@ -47,9 +47,6 @@ int __fscache_register_netfs(struct fscache_netfs *netfs)
|
||||||
netfs->primary_index->netfs_data = netfs;
|
netfs->primary_index->netfs_data = netfs;
|
||||||
netfs->primary_index->flags = 1 << FSCACHE_COOKIE_ENABLED;
|
netfs->primary_index->flags = 1 << FSCACHE_COOKIE_ENABLED;
|
||||||
|
|
||||||
atomic_inc(&netfs->primary_index->parent->usage);
|
|
||||||
atomic_inc(&netfs->primary_index->parent->n_children);
|
|
||||||
|
|
||||||
spin_lock_init(&netfs->primary_index->lock);
|
spin_lock_init(&netfs->primary_index->lock);
|
||||||
INIT_HLIST_HEAD(&netfs->primary_index->backing_objects);
|
INIT_HLIST_HEAD(&netfs->primary_index->backing_objects);
|
||||||
|
|
||||||
|
@ -62,6 +59,9 @@ int __fscache_register_netfs(struct fscache_netfs *netfs)
|
||||||
goto already_registered;
|
goto already_registered;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
atomic_inc(&netfs->primary_index->parent->usage);
|
||||||
|
atomic_inc(&netfs->primary_index->parent->n_children);
|
||||||
|
|
||||||
list_add(&netfs->link, &fscache_netfs_list);
|
list_add(&netfs->link, &fscache_netfs_list);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
|
@ -71,8 +71,7 @@ already_registered:
|
||||||
up_write(&fscache_addremove_sem);
|
up_write(&fscache_addremove_sem);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
netfs->primary_index->parent = NULL;
|
kmem_cache_free(fscache_cookie_jar, netfs->primary_index);
|
||||||
__fscache_cookie_put(netfs->primary_index);
|
|
||||||
netfs->primary_index = NULL;
|
netfs->primary_index = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче