public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Jun'ichi Nomura" <j-nomura@ce.jp.nec.com>
To: Neil Brown <neilb@suse.de>, Alasdair Kergon <agk@redhat.com>,
	Lars Marowsky-Bree <lmb@suse.de>
Cc: device-mapper development <dm-devel@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 2/3] sysfs representation of stacked devices (dm)
Date: Fri, 17 Feb 2006 13:03:55 -0500	[thread overview]
Message-ID: <43F6100B.4000001@ce.jp.nec.com> (raw)
In-Reply-To: <43F60F31.1030507@ce.jp.nec.com>

[-- Attachment #1: Type: text/plain, Size: 129 bytes --]

This patch modifies dm driver to create symlinks to/from
underlying devices.

-- 
Jun'ichi Nomura, NEC Solutions (America), Inc.

[-- Attachment #2: stacked-device-representation-in-sysfs-1-dm.patch --]
[-- Type: text/x-patch, Size: 2812 bytes --]

Exporting stacked device relationship to sysfs (dm)

Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>

--- linux-2.6.15.orig/drivers/md/dm.c	2006-01-02 22:21:10.000000000 -0500
+++ linux-2.6.15/drivers/md/dm.c	2006-02-14 12:18:13.000000000 -0500
@@ -853,6 +853,7 @@ static int __bind(struct mapped_device *
 
 	dm_table_get(t);
 	dm_table_event_callback(t, event_callback, md);
+	dm_link_device(md, t);
 
 	write_lock(&md->map_lock);
 	md->map = t;
@@ -873,6 +874,7 @@ static void __unbind(struct mapped_devic
 	write_lock(&md->map_lock);
 	md->map = NULL;
 	write_unlock(&md->map_lock);
+	dm_unlink_device(md, map);
 	dm_table_put(map);
 }
 
--- linux-2.6.15.orig/drivers/md/dm.h	2006-01-02 22:21:10.000000000 -0500
+++ linux-2.6.15/drivers/md/dm.h	2006-02-14 12:21:10.000000000 -0500
@@ -94,6 +94,12 @@ int dm_wait_event(struct mapped_device *
 struct gendisk *dm_disk(struct mapped_device *md);
 int dm_suspended(struct mapped_device *md);
 
+/*
+ * kobject linking functions
+ */
+int dm_link_device(struct mapped_device *md, struct dm_table *t);
+int dm_unlink_device(struct mapped_device *md, struct dm_table *t);
+
 /*-----------------------------------------------------------------
  * Functions for manipulating a table.  Tables are also reference
  * counted.
--- linux-2.6.15.orig/drivers/md/dm-table.c	2006-01-02 22:21:10.000000000 -0500
+++ linux-2.6.15/drivers/md/dm-table.c	2006-02-16 23:25:49.000000000 -0500
@@ -53,6 +53,9 @@ struct dm_table {
 	/* events get handed up using this callback */
 	void (*event_fn)(void *);
 	void *event_context;
+
+	/* sysfs deptree */
+	struct kobject slave_dir;
 };
 
 /*
@@ -945,6 +948,43 @@ int dm_table_flush_all(struct dm_table *
 	return ret;
 }
 
+/* create sysfs symlinks between mapped device and underlying devices */
+int dm_link_device(struct mapped_device *md, struct dm_table *t)
+{
+	struct list_head *d, *devices;
+	struct kobject *md_kobj;
+
+	md_kobj = &dm_disk(md)->kobj;
+	stackdev_init(&t->slave_dir, md_kobj);
+
+	devices = dm_table_get_devices(t);
+	for (d = devices->next; d != devices; d = d->next) {
+		struct dm_dev *dd = list_entry(d, struct dm_dev, list);
+		stackdev_link(dd->bdev, &t->slave_dir, md_kobj);
+	}
+
+	return 0;
+}
+
+/* remove sysfs symlinks between mapped device and underlying devices */
+int dm_unlink_device(struct mapped_device *md, struct dm_table *t)
+{
+	struct list_head *d, *devices;
+	struct kobject *md_kobj;
+
+	md_kobj = &dm_disk(md)->kobj;
+
+	devices = dm_table_get_devices(t);
+	for (d = devices->next; d != devices; d = d->next) {
+		struct dm_dev *dd = list_entry(d, struct dm_dev, list);
+		stackdev_unlink(dd->bdev, &t->slave_dir, md_kobj);
+	}
+
+	stackdev_clear(&t->slave_dir);
+
+	return 0;
+}
+
 EXPORT_SYMBOL(dm_vcalloc);
 EXPORT_SYMBOL(dm_get_device);
 EXPORT_SYMBOL(dm_put_device);

  parent reply	other threads:[~2006-02-17 18:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-17 18:00 [PATCH 0/3] sysfs representation of stacked devices (dm/md) Jun'ichi Nomura
2006-02-17 18:01 ` [PATCH 1/3] sysfs representation of stacked devices (dm/md common) Jun'ichi Nomura
2006-02-17 18:44   ` Alasdair G Kergon
2006-02-18  1:03     ` Jun'ichi Nomura
2006-02-18 19:50       ` Alasdair G Kergon
2006-02-21 15:33         ` Jun'ichi Nomura
2006-02-21 15:52           ` Alasdair G Kergon
2006-02-17 18:03 ` Jun'ichi Nomura [this message]
2006-02-17 18:05 ` [PATCH 3/3] sysfs representation of stacked devices (md) Jun'ichi Nomura
2006-02-17 19:42 ` [PATCH 0/3] sysfs representation of stacked devices (dm/md) Alasdair G Kergon
2006-02-18  1:21   ` Jun'ichi Nomura
2006-02-18 19:53     ` Alasdair G Kergon
2006-02-21 15:34       ` Jun'ichi Nomura
2006-02-18  6:06   ` Kyle Moffett
2006-02-19 22:04 ` Neil Brown

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=43F6100B.4000001@ce.jp.nec.com \
    --to=j-nomura@ce.jp.nec.com \
    --cc=agk@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lmb@suse.de \
    --cc=neilb@suse.de \
    /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