From: Joe Thornber <thornber@redhat.com>
To: device-mapper development <dm-devel@redhat.com>,
Joe Thornber <ejt@redhat.com>, Mike Snitzer <snitzer@redhat.com>
Subject: Re: [patch] dm cache: fix up IS_ERR vs NULL confusion
Date: Wed, 28 Jan 2015 12:11:28 +0000 [thread overview]
Message-ID: <20150128121127.GB21433@debian> (raw)
In-Reply-To: <20150128105311.GA21433@debian>
Here's my take. You were destroying the metadata object with the
mutex still held, which I'd been trying to avoid.
commit ea87d6105c1b13c13ece0fc8d9add09c78b1aa4c
Author: Joe Thornber <ejt@redhat.com>
Date: Wed Jan 28 12:07:46 2015 +0000
dm-cache: fixup evil err ptrs that were ommitted from earlier patch.
diff --git a/drivers/md/dm-cache-metadata.c b/drivers/md/dm-cache-metadata.c
index 8876250..b6dc968 100644
--- a/drivers/md/dm-cache-metadata.c
+++ b/drivers/md/dm-cache-metadata.c
@@ -683,7 +683,7 @@ static struct dm_cache_metadata *metadata_open(struct block_device *bdev,
cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
if (!cmd) {
DMERR("could not allocate metadata struct");
- return NULL;
+ return ERR_PTR(-ENOMEM);
}
atomic_set(&cmd->ref_count, 1);
@@ -745,7 +745,7 @@ static struct dm_cache_metadata *lookup_or_open(struct block_device *bdev,
return cmd;
cmd = metadata_open(bdev, data_block_size, may_format_device, policy_hint_size);
- if (cmd) {
+ if (!IS_ERR(cmd)) {
mutex_lock(&table_lock);
cmd2 = lookup(bdev);
if (cmd2) {
@@ -779,9 +779,9 @@ struct dm_cache_metadata *dm_cache_metadata_open(struct block_device *bdev,
size_t policy_hint_size)
{
struct dm_cache_metadata *cmd = lookup_or_open(bdev, data_block_size, may_format_device, policy_hint_size);
- if (cmd && !same_params(cmd, data_block_size)) {
+ if (!IS_ERR(cmd) && !same_params(cmd, data_block_size)) {
dm_cache_metadata_close(cmd);
- return NULL;
+ return ERR_PTR(-EINVAL);
}
return cmd;
prev parent reply other threads:[~2015-01-28 12:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-28 6:46 [patch] dm cache: fix up IS_ERR vs NULL confusion Dan Carpenter
2015-01-28 10:53 ` Joe Thornber
2015-01-28 12:11 ` Joe Thornber [this message]
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=20150128121127.GB21433@debian \
--to=thornber@redhat.com \
--cc=dm-devel@redhat.com \
--cc=ejt@redhat.com \
--cc=snitzer@redhat.com \
/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