From: David Howells <dhowells@redhat.com>
To: viro@ZenIV.linux.org.uk
Cc: Kinglong Mee <kinglongmee@gmail.com>,
linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org,
dhowells@redhat.com, linux-cachefs@redhat.com,
linux-fsdevel@vger.kernel.org
Subject: [PATCH 1/4] FS-Cache: Increase reference of parent after registering, netfs success
Date: Wed, 04 Nov 2015 15:20:15 +0000 [thread overview]
Message-ID: <20151104152015.2987.68616.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <20151104152005.2987.46683.stgit@warthog.procyon.org.uk>
From: Kinglong Mee <kinglongmee@gmail.com>
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>
Signed-off-by: David Howells <dhowells@redhat.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 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)
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;
}
next prev parent reply other threads:[~2015-11-04 15:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-04 15:20 [PATCH 0/4] FS-Cache: Miscellaneous fixes David Howells
2015-11-04 15:20 ` David Howells [this message]
2015-11-04 15:20 ` [PATCH 2/4] FS-Cache: Don't override netfs's primary_index if registering failed David Howells
2015-11-04 15:20 ` [PATCH 3/4] cachefiles: perform test on s_blocksize when opening cache file David Howells
2015-11-04 15:20 ` [PATCH 4/4] FS-Cache: Handle a write to the page immediately beyond the EOF marker David Howells
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151104152015.2987.68616.stgit@warthog.procyon.org.uk \
--to=dhowells@redhat.com \
--cc=kinglongmee@gmail.com \
--cc=linux-cachefs@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox