* [PATCH] fscache: put reference of parent's usage and n_children
@ 2015-04-10 13:01 Kinglong Mee
[not found] ` <5527C9A0.6030502-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 10+ messages in thread
From: Kinglong Mee @ 2015-04-10 13:01 UTC (permalink / raw)
To: David Howells
Cc: linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
kinglongmee-Re5JQEeQqe8AvxtiuMwx3w
If netfs exist, fscache must put the reference of parent's
usage and n_children, otherwise, never be decreased.
Signed-off-by: Kinglong Mee <kinglongmee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
fs/fscache/netfs.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/fscache/netfs.c b/fs/fscache/netfs.c
index 6d941f5..b16afba 100644
--- a/fs/fscache/netfs.c
+++ b/fs/fscache/netfs.c
@@ -71,8 +71,7 @@ already_registered:
up_write(&fscache_addremove_sem);
if (ret < 0) {
- netfs->primary_index->parent = NULL;
- __fscache_cookie_put(netfs->primary_index);
+ fscache_relinquish_cookie(netfs->primary_index, 0);
netfs->primary_index = NULL;
}
--
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] 10+ messages in thread
* Re: [PATCH] fscache: put reference of parent's usage and n_children
[not found] ` <5527C9A0.6030502-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2015-04-13 11:33 ` David Howells
2015-04-13 12:23 ` Kinglong Mee
[not found] ` <552BB530.50405-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 2 replies; 10+ messages in thread
From: David Howells @ 2015-04-13 11:33 UTC (permalink / raw)
To: Kinglong Mee
Cc: dhowells-H+wXaHxf7aLQT0dZR+AlfA,
linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Kinglong Mee <kinglongmee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> If netfs exist, fscache must put the reference of parent's
> usage and n_children, otherwise, never be decreased.
Good catch. Though it might be preferable to only increment the counters if
the list_add() is done.
David
--
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 [flat|nested] 10+ messages in thread
* Re: [PATCH] fscache: put reference of parent's usage and n_children
2015-04-13 11:33 ` David Howells
@ 2015-04-13 12:23 ` Kinglong Mee
[not found] ` <552BB530.50405-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
1 sibling, 0 replies; 10+ messages in thread
From: Kinglong Mee @ 2015-04-13 12:23 UTC (permalink / raw)
To: David Howells; +Cc: linux-fsdevel, linux-nfs@vger.kernel.org
On 4/13/2015 7:33 PM, David Howells wrote:
> Kinglong Mee <kinglongmee@gmail.com> wrote:
>
>> If netfs exist, fscache must put the reference of parent's
>> usage and n_children, otherwise, never be decreased.
>
> Good catch. Though it might be preferable to only increment the counters if
> the list_add() is done.
Thanks for your comments, that's great.
I will update and resend those two patch.
Thanks,
Kinglong Mee
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] fscache: put reference of parent's usage and n_children
[not found] ` <552BB530.50405-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2015-04-13 12:44 ` David Howells
[not found] ` <32264.1428929064-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: David Howells @ 2015-04-13 12:44 UTC (permalink / raw)
To: Kinglong Mee
Cc: dhowells-H+wXaHxf7aLQT0dZR+AlfA,
linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Kinglong Mee <kinglongmee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > Good catch. Though it might be preferable to only increment the counters if
> > the list_add() is done.
>
> Thanks for your comments, that's great.
> I will update and resend those two patch.
In fact, kmem_cache_free() can be called instead of
fscache_relinquish_cookie() in that case.
David
--
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 [flat|nested] 10+ messages in thread
* [PATCH v2 1/2] FSCACHE: Increase reference of parent after registering netfs success
[not found] ` <32264.1428929064-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
@ 2015-04-13 13:01 ` Kinglong Mee
0 siblings, 0 replies; 10+ messages in thread
From: Kinglong Mee @ 2015-04-13 13:01 UTC (permalink / raw)
To: David Howells
Cc: linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
kinglongmee-Re5JQEeQqe8AvxtiuMwx3w
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
Signed-off-by: Kinglong Mee <kinglongmee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
fs/fscache/netfs.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/fs/fscache/netfs.c b/fs/fscache/netfs.c
index 6d941f5..bea1f2e 100644
--- a/fs/fscache/netfs.c
+++ b/fs/fscache/netfs.c
@@ -43,13 +43,9 @@ int __fscache_register_netfs(struct fscache_netfs *netfs)
atomic_set(&netfs->primary_index->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;
- atomic_inc(&netfs->primary_index->parent->usage);
- atomic_inc(&netfs->primary_index->parent->n_children);
-
spin_lock_init(&netfs->primary_index->lock);
INIT_HLIST_HEAD(&netfs->primary_index->backing_objects);
@@ -62,6 +58,10 @@ int __fscache_register_netfs(struct fscache_netfs *netfs)
goto already_registered;
}
+ netfs->primary_index->parent = &fscache_fsdef_index;
+ atomic_inc(&netfs->primary_index->parent->usage);
+ atomic_inc(&netfs->primary_index->parent->n_children);
+
list_add(&netfs->link, &fscache_netfs_list);
ret = 0;
@@ -71,8 +71,7 @@ already_registered:
up_write(&fscache_addremove_sem);
if (ret < 0) {
- netfs->primary_index->parent = NULL;
- __fscache_cookie_put(netfs->primary_index);
+ kmem_cache_free(fscache_cookie_jar, netfs->primary_index);
netfs->primary_index = NULL;
}
--
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] 10+ messages in thread
* [PATCH v2 2/2] FSCACHE: Don't override netfs's primary_index if registering failed
2015-04-13 12:44 ` David Howells
[not found] ` <32264.1428929064-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
@ 2015-04-13 13:01 ` Kinglong Mee
[not found] ` <552BBE2E.5050903-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2 siblings, 0 replies; 10+ messages in thread
From: Kinglong Mee @ 2015-04-13 13:01 UTC (permalink / raw)
To: David Howells; +Cc: linux-fsdevel, linux-nfs@vger.kernel.org, kinglongmee
Only override netfs->primary_index when registering success.
v2: according to the change of 1/2
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
---
fs/fscache/netfs.c | 35 +++++++++++++++++------------------
1 file changed, 17 insertions(+), 18 deletions(-)
diff --git a/fs/fscache/netfs.c b/fs/fscache/netfs.c
index bea1f2e..166fdc3 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,25 +30,24 @@ 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->netfs_data = netfs;
- netfs->primary_index->flags = 1 << FSCACHE_COOKIE_ENABLED;
+ cookie->def = &fscache_fsdef_netfs_def;
+ cookie->netfs_data = netfs;
+ cookie->flags = 1 << FSCACHE_COOKIE_ENABLED;
- 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);
@@ -58,10 +58,11 @@ int __fscache_register_netfs(struct fscache_netfs *netfs)
goto already_registered;
}
- netfs->primary_index->parent = &fscache_fsdef_index;
- atomic_inc(&netfs->primary_index->parent->usage);
- atomic_inc(&netfs->primary_index->parent->n_children);
+ cookie->parent = &fscache_fsdef_index;
+ atomic_inc(&cookie->parent->usage);
+ atomic_inc(&cookie->parent->n_children);
+ netfs->primary_index = cookie;
list_add(&netfs->link, &fscache_netfs_list);
ret = 0;
@@ -70,10 +71,8 @@ int __fscache_register_netfs(struct fscache_netfs *netfs)
already_registered:
up_write(&fscache_addremove_sem);
- if (ret < 0) {
- kmem_cache_free(fscache_cookie_jar, netfs->primary_index);
- netfs->primary_index = NULL;
- }
+ if (ret < 0)
+ kmem_cache_free(fscache_cookie_jar, cookie);
_leave(" = %d", ret);
return ret;
--
2.3.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/2] FSCACHE: Increase reference of parent after registering netfs success
[not found] ` <552BBE2E.5050903-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2015-04-13 13:12 ` David Howells
2015-04-13 13:35 ` [PATCH v3 1/2] FSCACHE: Increase reference of parent after registering, " Kinglong Mee
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: David Howells @ 2015-04-13 13:12 UTC (permalink / raw)
To: Kinglong Mee
Cc: dhowells-H+wXaHxf7aLQT0dZR+AlfA,
linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Kinglong Mee <kinglongmee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> - netfs->primary_index->parent = &fscache_fsdef_index;
fscache_fsdef_index is a static variable so leave this where it is.
David
--
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 [flat|nested] 10+ messages in thread
* [PATCH v3 1/2] FSCACHE: Increase reference of parent after registering, netfs success
2015-04-13 13:12 ` [PATCH v2 1/2] FSCACHE: Increase reference of parent after registering netfs success David Howells
@ 2015-04-13 13:35 ` Kinglong Mee
2015-04-13 13:35 ` [PATCH v3 2/2] FSCACHE: Don't override netfs's primary_index if registering failed Kinglong Mee
2015-04-14 9:34 ` [PATCH v3 1/2] FSCACHE: Increase reference of parent after registering, netfs success David Howells
2 siblings, 0 replies; 10+ messages in thread
From: Kinglong Mee @ 2015-04-13 13:35 UTC (permalink / raw)
To: David Howells; +Cc: linux-fsdevel, linux-nfs@vger.kernel.org
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;"
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
---
fs/fscache/netfs.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/fs/fscache/netfs.c b/fs/fscache/netfs.c
index 6d941f5..458cc96 100644
--- a/fs/fscache/netfs.c
+++ b/fs/fscache/netfs.c
@@ -47,9 +47,6 @@ int __fscache_register_netfs(struct fscache_netfs *netfs)
netfs->primary_index->netfs_data = netfs;
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);
INIT_HLIST_HEAD(&netfs->primary_index->backing_objects);
@@ -62,6 +59,9 @@ int __fscache_register_netfs(struct fscache_netfs *netfs)
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);
ret = 0;
@@ -71,8 +71,7 @@ already_registered:
up_write(&fscache_addremove_sem);
if (ret < 0) {
- netfs->primary_index->parent = NULL;
- __fscache_cookie_put(netfs->primary_index);
+ kmem_cache_free(fscache_cookie_jar, netfs->primary_index);
netfs->primary_index = NULL;
}
--
2.3.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 2/2] FSCACHE: Don't override netfs's primary_index if registering failed
2015-04-13 13:12 ` [PATCH v2 1/2] FSCACHE: Increase reference of parent after registering netfs success David Howells
2015-04-13 13:35 ` [PATCH v3 1/2] FSCACHE: Increase reference of parent after registering, " Kinglong Mee
@ 2015-04-13 13:35 ` Kinglong Mee
2015-04-14 9:34 ` [PATCH v3 1/2] FSCACHE: Increase reference of parent after registering, netfs success David Howells
2 siblings, 0 replies; 10+ messages in thread
From: Kinglong Mee @ 2015-04-13 13:35 UTC (permalink / raw)
To: David Howells; +Cc: linux-fsdevel, linux-nfs@vger.kernel.org
Only override netfs->primary_index when registering success.
v2,v3: according to the change of [PATH 1/2]
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
---
fs/fscache/netfs.c | 35 +++++++++++++++++------------------
1 file changed, 17 insertions(+), 18 deletions(-)
diff --git a/fs/fscache/netfs.c b/fs/fscache/netfs.c
index 458cc96..9b28649 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,26 +30,25 @@ 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;
- 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);
@@ -59,9 +59,10 @@ int __fscache_register_netfs(struct fscache_netfs *netfs)
goto already_registered;
}
- 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);
+ netfs->primary_index = cookie;
list_add(&netfs->link, &fscache_netfs_list);
ret = 0;
@@ -70,10 +71,8 @@ int __fscache_register_netfs(struct fscache_netfs *netfs)
already_registered:
up_write(&fscache_addremove_sem);
- if (ret < 0) {
- kmem_cache_free(fscache_cookie_jar, netfs->primary_index);
- netfs->primary_index = NULL;
- }
+ if (ret < 0)
+ kmem_cache_free(fscache_cookie_jar, cookie);
_leave(" = %d", ret);
return ret;
--
2.3.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v3 1/2] FSCACHE: Increase reference of parent after registering, netfs success
2015-04-13 13:12 ` [PATCH v2 1/2] FSCACHE: Increase reference of parent after registering netfs success David Howells
2015-04-13 13:35 ` [PATCH v3 1/2] FSCACHE: Increase reference of parent after registering, " Kinglong Mee
2015-04-13 13:35 ` [PATCH v3 2/2] FSCACHE: Don't override netfs's primary_index if registering failed Kinglong Mee
@ 2015-04-14 9:34 ` David Howells
2 siblings, 0 replies; 10+ messages in thread
From: David Howells @ 2015-04-14 9:34 UTC (permalink / raw)
To: Kinglong Mee; +Cc: dhowells, linux-fsdevel, linux-nfs@vger.kernel.org
Applied here:
http://git.kernel.org/cgit/linux/kernel/git/dhowells/linux-fs.git/log/?h=fscache
David
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2015-04-14 9:34 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-10 13:01 [PATCH] fscache: put reference of parent's usage and n_children Kinglong Mee
[not found] ` <5527C9A0.6030502-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-04-13 11:33 ` David Howells
2015-04-13 12:23 ` Kinglong Mee
[not found] ` <552BB530.50405-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-04-13 12:44 ` David Howells
[not found] ` <32264.1428929064-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
2015-04-13 13:01 ` [PATCH v2 1/2] FSCACHE: Increase reference of parent after registering netfs success Kinglong Mee
2015-04-13 13:01 ` [PATCH v2 2/2] FSCACHE: Don't override netfs's primary_index if registering failed Kinglong Mee
[not found] ` <552BBE2E.5050903-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-04-13 13:12 ` [PATCH v2 1/2] FSCACHE: Increase reference of parent after registering netfs success David Howells
2015-04-13 13:35 ` [PATCH v3 1/2] FSCACHE: Increase reference of parent after registering, " Kinglong Mee
2015-04-13 13:35 ` [PATCH v3 2/2] FSCACHE: Don't override netfs's primary_index if registering failed Kinglong Mee
2015-04-14 9:34 ` [PATCH v3 1/2] FSCACHE: Increase reference of parent after registering, netfs success 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).