mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Will Drewry <wad@chromium.org>
To: dm-devel@redhat.com
Cc: Randy Dunlap <rdunlap@xenotime.net>, Ingo Molnar <mingo@elte.hu>,
	Len Brown <len.brown@intel.com>, Neil Brown <neilb@suse.de>,
	Alasdair G Kergon <agk@redhat.com>,
	Greg Kroah-Hartman <gregkh@suse.de>,
	Mike Snitzer <snitzer@redhat.com>,
	Kiyoshi Ueda <k-ueda@ct.jp.nec.com>,
	"Jun'ichi Nomura" <j-nomura@ce.jp.nec.com>,
	Mikulas Patocka <mpatocka@redhat.com>,
	Nikanth Karthikesan <knikanth@suse.de>,
	Sam Ravnborg <sam@ravnborg.org>, Michal Marek <mmarek@suse.cz>,
	Tejun Heo <tj@kernel.org>, Jan Blunck <jblunck@suse.de>,
	Vegard Nossum <vegard.nossum@gmail.com>,
	Kay Sievers <kay.sievers@vrfy.org>,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-raid@vger.kernel.org, Will Drewry <wad@chromium.org>
Subject: [PATCH v4 2/3] dm: export a table+mapped device to the ioctl interface
Date: Mon,  7 Jun 2010 22:25:23 -0500	[thread overview]
Message-ID: <1275967524-24166-2-git-send-email-wad@chromium.org> (raw)
In-Reply-To: <1274294304-30606-1-git-send-email-wad@chromium.org>

If a mapped device and table is configured without traversing
the dm-ioctl interface (dm-fs-style), then it will not be bound
to a name or uuid.  This means that it will be inaccessible for
userspace management and udev will be unhappy with the lack of
a name or uuid.

The function added in this change performs the required association
to transition to being managed by the ioctl interface.

v4: same as v3 but keeping bundled

Signed-off-by: Will Drewry <wad@chromium.org>
---
 drivers/md/dm-ioctl.c         |   38 ++++++++++++++++++++++++++++++++++++++
 include/linux/device-mapper.h |    6 ++++++
 2 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index dfde391..8c73b20 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -1604,6 +1604,44 @@ void dm_interface_exit(void)
 }
 
 /**
+ * dm_ioctl_export - Permanently export a mapped device via the ioctl interface
+ * @md: Pointer to mapped_device
+ * @name: Buffer (size DM_NAME_LEN) for name
+ * @uuid: Buffer (size DM_UUID_LEN) for uuid or NULL if not desired
+ */
+int dm_ioctl_export(struct mapped_device *md, const char *name, const char *uuid)
+{
+	int r = 0;
+	struct hash_cell *hc;
+
+	if (!md) {
+		r = -ENXIO;
+		goto out;
+	}
+
+	/* The name and uuid can only be set once. */
+	mutex_lock(&dm_hash_cells_mutex);
+	hc = dm_get_mdptr(md);
+	mutex_unlock(&dm_hash_cells_mutex);
+	if (hc) {
+		DMERR("%s: already exported", dm_device_name(md));
+		r = -ENXIO;
+		goto out;
+	}
+
+	r = dm_hash_insert(name, uuid, md);
+	if (r) {
+		DMERR("%s: could not bind to '%s'", dm_device_name(md), name);
+		goto out;
+	}
+
+	/* Let udev know we've changed. */
+	dm_kobject_uevent(md, KOBJ_CHANGE, dm_get_event_nr(md));
+out:
+	return r;
+}
+
+/**
  * dm_copy_name_and_uuid - Copy mapped device name & uuid into supplied buffers
  * @md: Pointer to mapped_device
  * @name: Buffer (size DM_NAME_LEN) for name
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
index 1381cd9..0792cf3 100644
--- a/include/linux/device-mapper.h
+++ b/include/linux/device-mapper.h
@@ -215,6 +215,12 @@ void dm_set_mdptr(struct mapped_device *md, void *ptr);
 void *dm_get_mdptr(struct mapped_device *md);
 
 /*
+ * Export the device via the ioctl interface (uses mdptr).
+ */
+int dm_ioctl_export(struct mapped_device *md, const char *name,
+		    const char *uuid);
+
+/*
  * A device can still be used while suspended, but I/O is deferred.
  */
 int dm_suspend(struct mapped_device *md, unsigned suspend_flags);
-- 
1.7.0.4


  parent reply	other threads:[~2010-06-08  3:26 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-19 18:38 [PATCH v3 1/3] dm: allow a dm-fs-style device to be shared via dm-ioctl Will Drewry
2010-05-19 18:38 ` [PATCH v3 2/3] init: boot to device-mapper targets without an initr* Will Drewry
2010-05-19 18:38 ` [PATCH v3 3/3] dm: lookup devices by path with name_to_dev_t Will Drewry
2010-05-24 11:38   ` [dm-devel] " Alasdair G Kergon
2010-05-24 11:57   ` Alasdair G Kergon
2010-05-24 14:44     ` Will Drewry
2010-05-24 15:07       ` Alasdair G Kergon
2010-05-24 16:35         ` Will Drewry
2010-05-24 23:35           ` Mike Snitzer
2010-05-24 23:55             ` Mike Snitzer
2010-05-25 15:58               ` Will Drewry
2010-05-24 16:33 ` [PATCH 1/2] dm: ensure dm_table_complete() completes a table for use Will Drewry
2010-05-24 16:33 ` [PATCH 2/2] dm: export a table+mapped device to the ioctl interface Will Drewry
2010-06-08  3:25 ` [PATCH v4 1/3] dm: ensure dm_table_complete() completes a table for use Will Drewry
2010-06-08  3:25 ` Will Drewry [this message]
2010-06-08  3:25 ` [PATCH v4 3/3] init: add support to directly boot to a mapped device Will Drewry

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=1275967524-24166-2-git-send-email-wad@chromium.org \
    --to=wad@chromium.org \
    --cc=agk@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=gregkh@suse.de \
    --cc=j-nomura@ce.jp.nec.com \
    --cc=jblunck@suse.de \
    --cc=k-ueda@ct.jp.nec.com \
    --cc=kay.sievers@vrfy.org \
    --cc=knikanth@suse.de \
    --cc=len.brown@intel.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mmarek@suse.cz \
    --cc=mpatocka@redhat.com \
    --cc=neilb@suse.de \
    --cc=rdunlap@xenotime.net \
    --cc=sam@ravnborg.org \
    --cc=snitzer@redhat.com \
    --cc=tj@kernel.org \
    --cc=vegard.nossum@gmail.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

all inboxes | Powered by JetHome®