* [PATCH] fscache: Don't override netfs->primary_index if register failed
@ 2015-04-10 13:46 Kinglong Mee
2015-04-13 11:36 ` David Howells
0 siblings, 1 reply; 2+ messages in thread
From: Kinglong Mee @ 2015-04-10 13:46 UTC (permalink / raw)
To: David Howells
Cc: linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
kinglongmee-Re5JQEeQqe8AvxtiuMwx3w
Only override netfs->primary_index when registering success.
Note: this patch is made with,
"[PATCH] fscache: put reference of parent's usage and n_children"
Signed-off-by: Kinglong Mee <kinglongmee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
fs/fscache/netfs.c | 36 +++++++++++++++++-------------------
1 file changed, 17 insertions(+), 19 deletions(-)
diff --git a/fs/fscache/netfs.c b/fs/fscache/netfs.c
index b16afba..b935250 100644
--- a/fs/fscache/netfs.c
+++ b/fs/fscache/netfs.c
@@ -22,6 +22,7 @@ static LIST_HEAD(fscache_netfs_list);
int __fscache_register_netfs(struct fscache_netfs *netfs)
{
struct fscache_netfs *ptr;
+ struct fscache_cookie *cookie;
int ret;
_enter("{%s}", netfs->name);
@@ -29,29 +30,28 @@ int __fscache_register_netfs(struct fscache_netfs *netfs)
INIT_LIST_HEAD(&netfs->link);
/* allocate a cookie for the primary index */
- netfs->primary_index =
- kmem_cache_zalloc(fscache_cookie_jar, GFP_KERNEL);
+ cookie = kmem_cache_zalloc(fscache_cookie_jar, GFP_KERNEL);
- if (!netfs->primary_index) {
+ if (!cookie) {
_leave(" = -ENOMEM");
return -ENOMEM;
}
/* initialise the primary index cookie */
- atomic_set(&netfs->primary_index->usage, 1);
- atomic_set(&netfs->primary_index->n_children, 0);
- atomic_set(&netfs->primary_index->n_active, 1);
+ atomic_set(&cookie->usage, 1);
+ atomic_set(&cookie->n_children, 0);
+ atomic_set(&cookie->n_active, 1);
- netfs->primary_index->def = &fscache_fsdef_netfs_def;
- netfs->primary_index->parent = &fscache_fsdef_index;
- netfs->primary_index->netfs_data = netfs;
- netfs->primary_index->flags = 1 << FSCACHE_COOKIE_ENABLED;
+ cookie->def = &fscache_fsdef_netfs_def;
+ cookie->parent = &fscache_fsdef_index;
+ cookie->netfs_data = netfs;
+ cookie->flags = 1 << FSCACHE_COOKIE_ENABLED;
- atomic_inc(&netfs->primary_index->parent->usage);
- atomic_inc(&netfs->primary_index->parent->n_children);
+ atomic_inc(&cookie->parent->usage);
+ atomic_inc(&cookie->parent->n_children);
- spin_lock_init(&netfs->primary_index->lock);
- INIT_HLIST_HEAD(&netfs->primary_index->backing_objects);
+ spin_lock_init(&cookie->lock);
+ INIT_HLIST_HEAD(&cookie->backing_objects);
/* check the netfs type is not already present */
down_write(&fscache_addremove_sem);
@@ -62,6 +62,7 @@ int __fscache_register_netfs(struct fscache_netfs *netfs)
goto already_registered;
}
+ netfs->primary_index = cookie;
list_add(&netfs->link, &fscache_netfs_list);
ret = 0;
@@ -69,11 +70,8 @@ int __fscache_register_netfs(struct fscache_netfs *netfs)
already_registered:
up_write(&fscache_addremove_sem);
-
- if (ret < 0) {
- fscache_relinquish_cookie(netfs->primary_index, 0);
- netfs->primary_index = NULL;
- }
+ if (ret < 0)
+ fscache_relinquish_cookie(cookie, 0);
_leave(" = %d", ret);
return ret;
--
2.3.5
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] fscache: Don't override netfs->primary_index if register failed
2015-04-10 13:46 [PATCH] fscache: Don't override netfs->primary_index if register failed Kinglong Mee
@ 2015-04-13 11:36 ` David Howells
0 siblings, 0 replies; 2+ messages in thread
From: David Howells @ 2015-04-13 11:36 UTC (permalink / raw)
To: Kinglong Mee; +Cc: dhowells, linux-fsdevel, linux-nfs@vger.kernel.org
Kinglong Mee <kinglongmee@gmail.com> wrote:
> Only override netfs->primary_index when registering success.
It shouldn't matter since the fscache_netfs struct being registered should not
be active when __fscache_register_netfs() is called upon it. It does,
however, make things a bit more readable, so I'll take it.
David
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-04-13 11:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-10 13:46 [PATCH] fscache: Don't override netfs->primary_index if register failed Kinglong Mee
2015-04-13 11:36 ` David Howells
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).