All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org, cachefs@lists.infradead.org
Subject: [PATCH] Release CacheFS search records lest they return to haunt us
Date: Thu, 30 Sep 2004 12:16:07 +0100	[thread overview]
Message-ID: <26133.1096542967@redhat.com> (raw)


The attached patch causes CacheFS to free cached search records when it
destroys a cookie. These were coming back to haunt us because the list isn't
re-initialised when the cookie is re-allocated (the slab allocator func
initialises it in the first place).

Signed-Off-By: David Howells <dhowells@redhat.com>
---

 interface.c |   34 ++++++++++++++++++++++++++--------
 1 files changed, 26 insertions(+), 8 deletions(-)


--- linux-2.6.9-rc2-mm4/fs/cachefs/interface.c	2004-09-27 11:23:55.000000000 +0100
+++ linux-2.6.9-rc2-mm4-afskey/fs/cachefs/interface.c	2004-09-29 20:06:25.416144902 +0100
@@ -114,7 +114,8 @@
 	up_write(&cachefs_addremove_sem);
 
 	if (ret < 0) {
-		kmem_cache_free(cachefs_cookie_jar, netfs->primary_index);
+		netfs->primary_index->iparent = NULL;
+		__cachefs_cookie_put(netfs->primary_index);
 		netfs->primary_index = NULL;
 	}
 
@@ -275,8 +276,9 @@
 	struct cachefs_search_result *srch;
 	struct cachefs_cookie *cookie, *xcookie = NULL;
 
-	_enter("{ino=%lu cnt=%u}",
-	       inode->vfs_inode.i_ino, atomic_read(&inode->vfs_inode.i_count));
+	_enter("{ino=%lu cnt=%u ck=%p}",
+	       inode->vfs_inode.i_ino, atomic_read(&inode->vfs_inode.i_count),
+	       inode->cookie);
 
 	/* first of all we have to break the links between the inode and the
 	 * cookie
@@ -305,9 +307,11 @@
 		 * cookie's list */
 		list_for_each_entry(srch, &cookie->search_results, link) {
 			if (srch->super == inode->vfs_inode.i_sb->s_fs_info)
-				break;
+				goto found_record;
 		}
+		BUG();
 
+	found_record:
 		list_del(&srch->link);
 		dbgfree(srch);
 		kfree(srch);
@@ -773,9 +777,8 @@
  error:
 	printk("CacheFS: error from cache fs: %d\n", ret);
 	if (cookie) {
-		kmem_cache_free(cachefs_cookie_jar, cookie);
+		__cachefs_cookie_put(cookie);
 		cookie = CACHEFS_NEGATIVE_COOKIE;
-		atomic_dec(&iparent->usage);
 		atomic_dec(&iparent->children);
 	}
 
@@ -800,7 +803,8 @@
 {
 	struct cachefs_inode *inode;
 
-	_enter("{%s},%d",
+	_enter("%p{%s},%d",
+	       cookie,
 	       cookie && cookie->idef ? (char *) cookie->idef->name : "<file>",
 	       retire);
 
@@ -955,11 +959,25 @@
  */
 static void __cachefs_cookie_put(struct cachefs_cookie *cookie)
 {
-	_enter("");
+	struct cachefs_search_result *srch;
+
+	_enter("%p", cookie);
 
 	if (cookie->iparent)
 		cachefs_cookie_put(cookie->iparent);
 
+	/* dispose of any cached search results */
+	while (!list_empty(&cookie->search_results)) {
+		srch = list_entry(cookie->search_results.next,
+				  struct cachefs_search_result,
+				  link);
+
+		list_del(&srch->link);
+		kfree(srch);
+	}
+
+	BUG_ON(!list_empty(&cookie->search_results));
+	BUG_ON(!list_empty(&cookie->backing_inodes));
 	kmem_cache_free(cachefs_cookie_jar, cookie);
 
 	_leave("");

                 reply	other threads:[~2004-09-30 11:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=26133.1096542967@redhat.com \
    --to=dhowells@redhat.com \
    --cc=akpm@osdl.org \
    --cc=cachefs@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.