From: David Howells <dhowells@redhat.com>
To: akpm@osdl.org, torvalds@osdl.org, steved@redhat.com
Cc: linux-kernel@vger.kernel.org, linux-cachefs@redhat.com
Subject: [PATCH] FS-Cache: Fix bug in error handling
Date: Tue, 12 Apr 2005 15:04:51 +0100 [thread overview]
Message-ID: <3919.1113314691@redhat.com> (raw)
The attached patch fixes a bug in the in __fscache_acquire_cookie()'s error
handling and tidies the code up a bit.
What was happening was the dead cookie was being released in the bit governed
by the error: label, and then an attempt was made to release the cookie's
semaphore when that fell through into the done: bit.
Signed-Off-By: David Howells <dhowells@redhat.com>
---
warthog>diffstat -p1 fscache-nullptr-fix-2612rc2mm1.diff
fs/fscache/cookie.c | 49 ++++++++++++++++++++++++++-----------------------
1 files changed, 26 insertions(+), 23 deletions(-)
diff -uNr linux-2.6.12-rc2-mm1/fs/fscache/cookie.c linux-2.6.12-rc2-mm1-cachefs/fs/fscache/cookie.c
--- linux-2.6.12-rc2-mm1/fs/fscache/cookie.c 2005-04-06 13:48:23.000000000 +0100
+++ linux-2.6.12-rc2-mm1-cachefs/fs/fscache/cookie.c 2005-04-06 18:28:47.000000000 +0100
@@ -743,7 +743,7 @@
if (list_empty(&fscache_cache_list)) {
up_read(&fscache_addremove_sem);
- _leave(" [no caches]");
+ _leave(" = %p [no caches]", cookie);
return cookie;
}
@@ -765,38 +765,41 @@
}
}
- /* if the object is a cookie then we need do nothing more here - we
+ /* if the object is an index then we need do nothing more here - we
* create indexes on disc when we need them as an index may exist in
* multiple caches */
- if (cookie->idef)
- goto done;
+ if (!cookie->idef) {
+ /* the object is a file - we need to select a cache in which to
+ * store it */
+ cache = fscache_select_cache_for_file();
+ if (!cache)
+ goto no_cache; /* couldn't decide on a cache */
+
+ /* create a file index entry on disc, along with all the
+ * indexes required to find it again later */
+ ret = fscache_instantiate_object(cookie, cache);
+ if (ret < 0)
+ goto error;
+ }
- /* the object is a file - we need to select a cache in which to store
- * it */
- ret = -ENOMEDIUM;
- cache = fscache_select_cache_for_file();
- if (!cache)
- goto error; /* couldn't decide on a cache */
-
- /* create a file index entry on disc, along with all the indexes
- * required to find it again later */
- ret = fscache_instantiate_object(cookie, cache);
- if (ret == 0)
- goto done;
+ up_write(&cookie->sem);
+out:
+ up_read(&fscache_addremove_sem);
+ _leave(" = %p", cookie);
+ return cookie;
- error:
- printk("FS-Cache: error from cache fs: %d\n", ret);
+no_cache:
+ ret = -ENOMEDIUM;
+error:
+ printk("FS-Cache: error from cache: %d\n", ret);
if (cookie) {
+ up_write(&cookie->sem);
__fscache_cookie_put(cookie);
cookie = FSCACHE_NEGATIVE_COOKIE;
atomic_dec(&iparent->children);
}
- done:
- up_write(&cookie->sem);
- up_read(&fscache_addremove_sem);
- _leave(" = %p", cookie);
- return cookie;
+ goto out;
} /* end __fscache_acquire_cookie() */
reply other threads:[~2005-04-12 14:12 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=3919.1113314691@redhat.com \
--to=dhowells@redhat.com \
--cc=akpm@osdl.org \
--cc=linux-cachefs@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=steved@redhat.com \
--cc=torvalds@osdl.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox