From: Coly Li <colyli@suse.de>
To: linux-bcache@vger.kernel.org
Cc: Coly Li <colyli@suse.de>, Jan Kara <jack@suse.cz>,
Christoph Hellwig <hch@infradead.org>
Subject: [PATCH] bcache: remove problematic code block from register_bcache()
Date: Tue, 5 Sep 2017 15:10:49 +0800 [thread overview]
Message-ID: <20170905071049.20273-1-colyli@suse.de> (raw)
There is a leak of bdev reference in register_bcache(), and Jan Kara
posted a patch to fix it. Discussion happened on bcache mailing list,
Christoph Hellwig pointed out that whole chunk of code where the bdev
reference leak lied was problematic,
"adding a lookup_bdev and resulting mess just for a
slightly different error message is just insane"
This patch jsut removes whole chunk of the problematic code, of cause
the leak of bdev reference is removed too.
Signed-off-by: Coly Li <colyli@suse.de>
Cc: Jan Kara <jack@suse.cz>
Cc: Christoph Hellwig <hch@infradead.org>
---
drivers/md/bcache/super.c | 14 +-------------
1 file changed, 1 insertion(+), 13 deletions(-)
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 8352fad765f6..85262f2628fb 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -1955,20 +1955,8 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
bdev = blkdev_get_by_path(strim(path),
FMODE_READ|FMODE_WRITE|FMODE_EXCL,
sb);
- if (IS_ERR(bdev)) {
- if (bdev == ERR_PTR(-EBUSY)) {
- bdev = lookup_bdev(strim(path));
- mutex_lock(&bch_register_lock);
- if (!IS_ERR(bdev) && bch_is_open(bdev))
- err = "device already registered";
- else
- err = "device busy";
- mutex_unlock(&bch_register_lock);
- if (attr == &ksysfs_register_quiet)
- goto out;
- }
+ if (IS_ERR(bdev))
goto err;
- }
err = "failed to set blocksize";
if (set_blocksize(bdev, 4096))
--
2.13.5
next reply other threads:[~2017-09-05 7:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-05 7:10 Coly Li [this message]
2017-09-05 8:03 ` [PATCH] bcache: remove problematic code block from register_bcache() Coly Li
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=20170905071049.20273-1-colyli@suse.de \
--to=colyli@suse.de \
--cc=hch@infradead.org \
--cc=jack@suse.cz \
--cc=linux-bcache@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox