From: Tejun Heo <tj@kernel.org>
To: Jens Axboe <axboe@kernel.dk>, Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Cc: Milan Broz <mbroz@redhat.com>,
Valdis.Kletnieks@vt.edu, Alexander Viro <viro@zeniv.linux.org.uk>,
Neil Brown <neilb@suse.de>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-raid@vger.kernel.org,
device-mapper development <dm-devel@redhat.com>,
Kay Sievers <kay.sievers@vrfy.org>
Subject: [PATCH] block: restore multiple bd_link_disk_holder() support
Date: Thu, 13 Jan 2011 18:21:33 +0100 [thread overview]
Message-ID: <20110113172133.GE14096@htj.dyndns.org> (raw)
In-Reply-To: <4D2E6129.8000700@ce.jp.nec.com>
Commit e09b457b (block: simplify holder symlink handling) incorrectly
assumed that there is only one holder at maximum. dm may use multiple
holders. Remove the single holder assumption and automatic removal of
the link. Let the callers explicitly remove them. This change makes
it even more alien from the rest of the block layer.
While at it, note that this facility should not be used by anyone else
than the current ones. Sysfs symlinks shouldn't be abused like this
and the whole thing doesn't belong in the block layer at all.
Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Milan Broz <mbroz@redhat.com>
Cc: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Cc: Neil Brown <neilb@suse.de>
Cc: linux-raid@vger.kernel.org
Cc: Kay Sievers <kay.sievers@vrfy.org>
---
Milan, Jun, can you guys please verify this works correctly for the
multi holder dm case? Thank you.
drivers/md/dm-table.c | 1 +
drivers/md/md.c | 1 +
fs/block_dev.c | 28 +++++++++++++++-------------
include/linux/fs.h | 9 ++++++---
4 files changed, 23 insertions(+), 16 deletions(-)
Index: work/include/linux/fs.h
===================================================================
--- work.orig/include/linux/fs.h
+++ work/include/linux/fs.h
@@ -663,9 +663,6 @@ struct block_device {
void * bd_holder;
int bd_holders;
bool bd_write_holder;
-#ifdef CONFIG_SYSFS
- struct gendisk * bd_holder_disk; /* for sysfs slave linkng */
-#endif
struct block_device * bd_contains;
unsigned bd_block_size;
struct hd_struct * bd_part;
@@ -2045,12 +2042,18 @@ extern struct block_device *blkdev_get_b
extern int blkdev_put(struct block_device *bdev, fmode_t mode);
#ifdef CONFIG_SYSFS
extern int bd_link_disk_holder(struct block_device *bdev, struct gendisk *disk);
+extern void bd_unlink_disk_holder(struct block_device *bdev,
+ struct gendisk *disk);
#else
static inline int bd_link_disk_holder(struct block_device *bdev,
struct gendisk *disk)
{
return 0;
}
+static inline void bd_unlink_disk_holder(struct block_device *bdev,
+ struct gendisk *disk)
+{
+}
#endif
#endif
Index: work/drivers/md/dm-table.c
===================================================================
--- work.orig/drivers/md/dm-table.c
+++ work/drivers/md/dm-table.c
@@ -347,6 +347,7 @@ static void close_dev(struct dm_dev_inte
if (!d->dm_dev.bdev)
return;
+ bd_unlink_disk_holder(d->dm_dev.bdev, dm_disk(md));
blkdev_put(d->dm_dev.bdev, d->dm_dev.mode | FMODE_EXCL);
d->dm_dev.bdev = NULL;
}
Index: work/drivers/md/md.c
===================================================================
--- work.orig/drivers/md/md.c
+++ work/drivers/md/md.c
@@ -1907,6 +1907,7 @@ static void unbind_rdev_from_array(mdk_r
MD_BUG();
return;
}
+ bd_unlink_disk_holder(rdev->bdev, rdev->mddev->gendisk);
list_del_rcu(&rdev->same_set);
printk(KERN_INFO "md: unbind<%s>\n", bdevname(rdev->bdev,b));
rdev->mddev = NULL;
Index: work/fs/block_dev.c
===================================================================
--- work.orig/fs/block_dev.c
+++ work/fs/block_dev.c
@@ -788,6 +788,8 @@ static void del_symlink(struct kobject *
* @bdev: the claimed slave bdev
* @disk: the holding disk
*
+ * DON'T USE THIS UNLESS YOU'RE ALREADY USING IT.
+ *
* This functions creates the following sysfs symlinks.
*
* - from "slaves" directory of the holder @disk to the claimed @bdev
@@ -815,7 +817,7 @@ int bd_link_disk_holder(struct block_dev
mutex_lock(&bdev->bd_mutex);
- WARN_ON_ONCE(!bdev->bd_holder || bdev->bd_holder_disk);
+ WARN_ON_ONCE(!bdev->bd_holder);
/* FIXME: remove the following once add_disk() handles errors */
if (WARN_ON(!disk->slave_dir || !bdev->bd_part->holder_dir))
@@ -831,27 +833,28 @@ int bd_link_disk_holder(struct block_dev
goto out_unlock;
}
- bdev->bd_holder_disk = disk;
out_unlock:
mutex_unlock(&bdev->bd_mutex);
return ret;
}
EXPORT_SYMBOL_GPL(bd_link_disk_holder);
-static void bd_unlink_disk_holder(struct block_device *bdev)
+/**
+ * bd_unlink_disk_holder - destroy symlinks created by bd_link_disk_holder()
+ * @bdev: the calimed slave bdev
+ * @disk: the holding disk
+ *
+ * DON'T USE THIS UNLESS YOU'RE ALREADY USING IT.
+ *
+ * CONTEXT:
+ * Might sleep.
+ */
+void bd_unlink_disk_holder(struct block_device *bdev, struct gendisk *disk)
{
- struct gendisk *disk = bdev->bd_holder_disk;
-
- bdev->bd_holder_disk = NULL;
- if (!disk)
- return;
-
del_symlink(disk->slave_dir, &part_to_dev(bdev->bd_part)->kobj);
del_symlink(bdev->bd_part->holder_dir, &disk_to_dev(disk)->kobj);
}
-#else
-static inline void bd_unlink_disk_holder(struct block_device *bdev)
-{ }
+EXPORT_SYMBOL_GPL(bd_unlink_disk_holder);
#endif
/**
@@ -1374,7 +1377,6 @@ int blkdev_put(struct block_device *bdev
* unblock evpoll if it was a write holder.
*/
if (bdev_free) {
- bd_unlink_disk_holder(bdev);
if (bdev->bd_write_holder) {
disk_unblock_events(bdev->bd_disk);
bdev->bd_write_holder = false;
next prev parent reply other threads:[~2011-01-13 17:21 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-12 17:34 linux-next - WARNING: at fs/block_dev.c:824 bd_link_disk_holder+0x92/0x1ac() Valdis.Kletnieks
2011-01-13 0:23 ` Milan Broz
2011-01-13 2:19 ` Jun'ichi Nomura
2011-01-13 11:06 ` Tejun Heo
2011-01-13 11:26 ` [dm-devel] " Milan Broz
2011-01-13 12:27 ` Karel Zak
2011-01-13 13:12 ` Tejun Heo
2011-01-13 13:26 ` Karel Zak
2011-01-13 13:37 ` Tejun Heo
2011-01-13 13:52 ` Tejun Heo
2011-01-13 13:58 ` Milan Broz
2011-01-13 14:11 ` Tejun Heo
2011-01-13 14:25 ` Milan Broz
2011-01-13 14:30 ` Tejun Heo
2011-01-13 14:43 ` Kay Sievers
2011-01-13 15:03 ` Milan Broz
2011-01-14 7:38 ` Jun'ichi Nomura
2011-01-13 15:59 ` Karel Zak
2011-01-13 16:10 ` [dm-devel] " Kay Sievers
2011-01-14 15:07 ` Karel Zak
2011-01-14 15:23 ` Kay Sievers
2011-01-13 14:45 ` Theodore Tso
2011-01-13 20:18 ` NeilBrown
2011-01-13 20:41 ` Ted Ts'o
2011-01-14 16:20 ` Tejun Heo
[not found] ` <20110114162022.GC978@htj.dyndns.org>
2011-01-14 17:59 ` Ted Ts'o
2011-01-14 18:23 ` Tejun Heo
2011-01-13 14:49 ` Milan Broz
2011-01-14 16:35 ` Tejun Heo
2011-01-13 17:21 ` Tejun Heo [this message]
2011-01-13 18:42 ` [PATCH] block: restore multiple bd_link_disk_holder() support Milan Broz
2011-01-14 7:31 ` Jun'ichi Nomura
2011-01-14 16:10 ` [PATCH UPDATED] " Tejun Heo
2011-01-14 21:09 ` Milan Broz
2011-01-17 0:18 ` Jun'ichi Nomura
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=20110113172133.GE14096@htj.dyndns.org \
--to=tj@kernel.org \
--cc=Valdis.Kletnieks@vt.edu \
--cc=axboe@kernel.dk \
--cc=dm-devel@redhat.com \
--cc=j-nomura@ce.jp.nec.com \
--cc=kay.sievers@vrfy.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=mbroz@redhat.com \
--cc=neilb@suse.de \
--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;
as well as URLs for NNTP newsgroup(s).