All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jun'ichi Nomura" <j-nomura@ce.jp.nec.com>
To: Alasdair G Kergon <agk@redhat.com>
Cc: device-mapper development <dm-devel@redhat.com>,
	Lars Marowsky-Bree <lmb@suse.de>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] sysfs representation of stacked devices (dm/md common)
Date: Fri, 17 Feb 2006 20:03:48 -0500	[thread overview]
Message-ID: <43F67274.80509@ce.jp.nec.com> (raw)
In-Reply-To: <20060217184435.GM12169@agk.surrey.redhat.com>

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

Hi Alasdair,

Thank you for the comments.

Alasdair G Kergon wrote:
> Make sure you test this properly under low memory situations.

OK.

> dm_swap_table() mustn't block waiting for memory to become
> free (except in a controlled way e.g. with a mempool, but
> it would need more than that here).
> 
> Here, dm_swap_table() leads to kmalloc() getting called
> in sysfs_add_link().

I moved the sysfs_add_link() to the last part of dm_resume().
Directory creation/deletion are also moved in the alloc_dev/
free_dev function as kobject_register/unregister may allocate
memory.
I didn't change the part of removing symlink as it doesn't
allocate memory.

Do you think this is an acceptable approach?

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

[-- Attachment #2: stacked-device-representation-in-sysfs-2-dm.patch --]
[-- Type: text/x-patch, Size: 2539 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-17 16:27:38.000000000 -0500
@@ -98,6 +98,12 @@ struct mapped_device {
 	 */
 	struct super_block *frozen_sb;
 	struct block_device *frozen_bdev;
+
+	/*
+	 * sysfs deptree
+	 */
+	int sysfs_linked;
+	struct kobject slave_dir;
 };
 
 #define MIN_IOS 256
@@ -791,6 +797,7 @@ static struct mapped_device *alloc_dev(u
 	md->disk->private_data = md;
 	sprintf(md->disk->disk_name, "dm-%d", minor);
 	add_disk(md->disk);
+	stackdev_init(&md->slave_dir, &md->disk->kobj);
 
 	atomic_set(&md->pending, 0);
 	init_waitqueue_head(&md->wait);
@@ -815,6 +822,7 @@ static void free_dev(struct mapped_devic
 	free_minor(md->disk->first_minor);
 	mempool_destroy(md->tio_pool);
 	mempool_destroy(md->io_pool);
+	stackdev_clear(&md->slave_dir);
 	del_gendisk(md->disk);
 	put_disk(md->disk);
 	blk_put_queue(md->queue);
@@ -841,6 +849,42 @@ static void __set_size(struct mapped_dev
 	up(&md->frozen_bdev->bd_inode->i_sem);
 }
 
+/* create sysfs symlinks between mapped device and underlying devices */
+static int __link_device(struct mapped_device *md, struct dm_table *t)
+{
+	struct list_head *d, *devices;
+
+	if (md->sysfs_linked)
+		return 0;
+
+	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, &md->slave_dir, &md->disk->kobj);
+	}
+
+	md->sysfs_linked = 1;
+	return 0;
+}
+
+/* remove sysfs symlinks between mapped device and underlying devices */
+static int __unlink_device(struct mapped_device *md, struct dm_table *t)
+{
+	struct list_head *d, *devices;
+
+	if (!md->sysfs_linked)
+		return 0;
+
+	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, &md->slave_dir, &md->disk->kobj);
+	}
+
+	md->sysfs_linked = 0;
+	return 0;
+}
+
 static int __bind(struct mapped_device *md, struct dm_table *t)
 {
 	request_queue_t *q = md->queue;
@@ -873,6 +917,7 @@ static void __unbind(struct mapped_devic
 	write_lock(&md->map_lock);
 	md->map = NULL;
 	write_unlock(&md->map_lock);
+	__unlink_device(md, map);
 	dm_table_put(map);
 }
 
@@ -1139,6 +1184,8 @@ int dm_resume(struct mapped_device *md)
 
 	dm_table_unplug_all(map);
 
+	__link_device(md, map);
+
 	r = 0;
 
 out:

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



WARNING: multiple messages have this Message-ID (diff)
From: "Jun'ichi Nomura" <j-nomura@ce.jp.nec.com>
To: Alasdair G Kergon <agk@redhat.com>
Cc: Neil Brown <neilb@suse.de>, Lars Marowsky-Bree <lmb@suse.de>,
	device-mapper development <dm-devel@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] sysfs representation of stacked devices (dm/md common)
Date: Fri, 17 Feb 2006 20:03:48 -0500	[thread overview]
Message-ID: <43F67274.80509@ce.jp.nec.com> (raw)
In-Reply-To: <20060217184435.GM12169@agk.surrey.redhat.com>

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

Hi Alasdair,

Thank you for the comments.

Alasdair G Kergon wrote:
> Make sure you test this properly under low memory situations.

OK.

> dm_swap_table() mustn't block waiting for memory to become
> free (except in a controlled way e.g. with a mempool, but
> it would need more than that here).
> 
> Here, dm_swap_table() leads to kmalloc() getting called
> in sysfs_add_link().

I moved the sysfs_add_link() to the last part of dm_resume().
Directory creation/deletion are also moved in the alloc_dev/
free_dev function as kobject_register/unregister may allocate
memory.
I didn't change the part of removing symlink as it doesn't
allocate memory.

Do you think this is an acceptable approach?

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

[-- Attachment #2: stacked-device-representation-in-sysfs-2-dm.patch --]
[-- Type: text/x-patch, Size: 2539 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-17 16:27:38.000000000 -0500
@@ -98,6 +98,12 @@ struct mapped_device {
 	 */
 	struct super_block *frozen_sb;
 	struct block_device *frozen_bdev;
+
+	/*
+	 * sysfs deptree
+	 */
+	int sysfs_linked;
+	struct kobject slave_dir;
 };
 
 #define MIN_IOS 256
@@ -791,6 +797,7 @@ static struct mapped_device *alloc_dev(u
 	md->disk->private_data = md;
 	sprintf(md->disk->disk_name, "dm-%d", minor);
 	add_disk(md->disk);
+	stackdev_init(&md->slave_dir, &md->disk->kobj);
 
 	atomic_set(&md->pending, 0);
 	init_waitqueue_head(&md->wait);
@@ -815,6 +822,7 @@ static void free_dev(struct mapped_devic
 	free_minor(md->disk->first_minor);
 	mempool_destroy(md->tio_pool);
 	mempool_destroy(md->io_pool);
+	stackdev_clear(&md->slave_dir);
 	del_gendisk(md->disk);
 	put_disk(md->disk);
 	blk_put_queue(md->queue);
@@ -841,6 +849,42 @@ static void __set_size(struct mapped_dev
 	up(&md->frozen_bdev->bd_inode->i_sem);
 }
 
+/* create sysfs symlinks between mapped device and underlying devices */
+static int __link_device(struct mapped_device *md, struct dm_table *t)
+{
+	struct list_head *d, *devices;
+
+	if (md->sysfs_linked)
+		return 0;
+
+	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, &md->slave_dir, &md->disk->kobj);
+	}
+
+	md->sysfs_linked = 1;
+	return 0;
+}
+
+/* remove sysfs symlinks between mapped device and underlying devices */
+static int __unlink_device(struct mapped_device *md, struct dm_table *t)
+{
+	struct list_head *d, *devices;
+
+	if (!md->sysfs_linked)
+		return 0;
+
+	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, &md->slave_dir, &md->disk->kobj);
+	}
+
+	md->sysfs_linked = 0;
+	return 0;
+}
+
 static int __bind(struct mapped_device *md, struct dm_table *t)
 {
 	request_queue_t *q = md->queue;
@@ -873,6 +917,7 @@ static void __unbind(struct mapped_devic
 	write_lock(&md->map_lock);
 	md->map = NULL;
 	write_unlock(&md->map_lock);
+	__unlink_device(md, map);
 	dm_table_put(map);
 }
 
@@ -1139,6 +1184,8 @@ int dm_resume(struct mapped_device *md)
 
 	dm_table_unplug_all(map);
 
+	__link_device(md, map);
+
 	r = 0;
 
 out:

  reply	other threads:[~2006-02-18  1:03 UTC|newest]

Thread overview: 28+ 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:01   ` Jun'ichi Nomura
2006-02-17 18:44   ` Alasdair G Kergon
2006-02-17 18:44     ` Alasdair G Kergon
2006-02-18  1:03     ` Jun'ichi Nomura [this message]
2006-02-18  1:03       ` Jun'ichi Nomura
2006-02-18 19:50       ` Alasdair G Kergon
2006-02-18 19:50         ` Alasdair G Kergon
2006-02-21 15:33         ` Jun'ichi Nomura
2006-02-21 15:33           ` Jun'ichi Nomura
2006-02-21 15:52           ` Alasdair G Kergon
2006-02-21 15:52             ` Alasdair G Kergon
2006-02-17 18:03 ` [PATCH 2/3] sysfs representation of stacked devices (dm) Jun'ichi Nomura
2006-02-17 18:03   ` Jun'ichi Nomura
2006-02-17 18:05 ` [PATCH 3/3] sysfs representation of stacked devices (md) Jun'ichi Nomura
2006-02-17 18:05   ` Jun'ichi Nomura
2006-02-17 19:42 ` [PATCH 0/3] sysfs representation of stacked devices (dm/md) Alasdair G Kergon
2006-02-17 19:42   ` Alasdair G Kergon
2006-02-18  1:21   ` Jun'ichi Nomura
2006-02-18  1:21     ` Jun'ichi Nomura
2006-02-18 19:53     ` Alasdair G Kergon
2006-02-18 19:53       ` Alasdair G Kergon
2006-02-21 15:34       ` Jun'ichi Nomura
2006-02-21 15:34         ` Jun'ichi Nomura
2006-02-18  6:06   ` Kyle Moffett
2006-02-19 22:04 ` Neil Brown
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=43F67274.80509@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 \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.