Discussion:
[-v3 PATCH 0/3] Persistent device name using alias
Nao Nishijima
2011-08-25 09:03:59 UTC
Permalink
Hi,

This patch series provide an "alias" of the disk into kernel messages.

A raw device name of a disk does not always point a same disk at each boot-up
time. Therefore, users have to use persistent device names, which udev creates
to always access the same disk. However, kernel messages still display the raw
device names.

My proposal is that users can use and see persistent device names which were
assigned by themselves because users expect same name to point same disk
anytime.

Why need to modify kernel messages?
- We can see mapping of device names and persistent device names in udev log.
If those logs output to syslog, we can search persistent device name from
device name, but it can cause a large amount of syslog output.

- If we can use the persistent device names and can always see the same name on
the kernel log, we don't need to pay additional cost for searching and picking
a correct pair of device name and persistent device name from udev log.

- Kernel messages are output to serial console when kenel crashes, it's so hard
to convert a device name to the alias.

Of course, I am going to modify the commands using device name so that users
can use an alias of the disk.

Changes in v3:
- "alias_name" was changed to "alias"
- The function to notify the partitions of uevent was deleted


How to use:
1. Build and install the kernel with this series, and reboot with the kernel.

2. Check device names.

[localhost]# cat /proc/partitions
major minor #blocks name

8 0 12582912 sda
8 1 12582878 sda1
8 0 8388608 sdb
8 1 512000 sdb1
8 2 7875584 sdb2


3. Make a script of get alias

[localhost]# vi /lib/udev/get_alias
#!/bin/sh -e
DEVNAME=`echo $1 | sed -e 's/[0-9]//g'`
echo "ALIAS=`cat /sys/block/$DEVNAME/alias`"
exit 0

And you should set an execute bit,
[localhost]# chmod +x /lib/udev/get_alias

4. Check disk's id
Here is an example to get the serial id and the path of the device.
Some devices have not the serial id. Therefore, to identify a device,
users need to get the path of the device.

[localhost]# udevadm info --query=property --path=/sys/block/sda \
| grep ID_SERIAL=
ID_SERIAL=0QEMU_QEMU_HARDDISK_drive-scsi0-0-1

or you can also use the path of the device

[localhost]# udevadm info --query=property --path=/sys/block/sr0 \
| grep ID_PATH=
ID_PATH=pci-0000:00:01.1-scsi-1:0:0:0


5. Write udev rules as follows
(The user assigns "foo" to sda and "bar" to sr0)
We use ENV{ID_SERIAL} or ENV{ID_PATH} (get by 3) to identify a disk.
And to assign automatically an "alias", we use ATTR key.
If ENV{ALIAS} is empty, we use to get an "alias" by get_alias script.

[localhost]# vi /etc/udev/rules.d/70-persistent-alias.rules
SUBSYSTEM!="block", GOTO="end"
ATTR{alias}!="", GOTO="symlink"

# write alias for sdX
KERNEL=="sd*[!0-9]", ACTION=="add", ATTR{alias}="foo", \
ENV{ID_SERIAL}=="0QEMU_QEMU_HARDDISK_drive-scsi0-0-1"

# write alias for srX
KERNEL=="sr[0-9]", ACTION=="add", ATTR{alias}="bar", \
ENV{ID_PATH}=="pci-0000:00:01.1-scsi-1:0:0:0"

LABEL="symlink"

# make symlink
ENV{DEVTYPE}=="disk|partition", ENV{ALIAS}=="", \
IMPORT{program}="/lib/udev/get_alias %k"
ENV{DEVTYPE}=="disk", ENV{ALIAS}=="?*", SYMLINK+="disk/by-alias/$env{ALIAS}"
ENV{DEVTYPE}=="partition", ENV{ALIAS}=="?*", \
SYMLINK+="disk/by-alias/$env{ALIAS}%n"

LABEL="end"


6. reboot
After reboot, we can see aliases in kernel messages.

[localhost]# ls -l /dev/disk/by-alias/
total 0
lrwxrwxrwx. 1 root root 9 Jul 1 21:21 bar -> ../../sr0
lrwxrwxrwx. 1 root root 9 Jul 1 21:21 foo -> ../../sda
lrwxrwxrwx. 1 root root 10 Jul 1 21:21 foo1 -> ../../sda1

[localhost]# dmesg
...
sd 2:0:1:0: [sda] Attached SCSI disk
alias: assigned foo to sda
sd 2:0:1:0: [foo] Send: 0xffff88007a82cd00
sd 2:0:1:0: [foo] CDB: Write(10): 2a 00 01 58 0c 8a 00 00 08 00
buffer = 0xffff88007a82c500, bufflen = 4096, queuecommand 0xffffffffa00277fd
leaving scsi_dispatch_cmnd()
sd 2:0:1:0: [foo] Done: 0xffff88007a82cd00 SUCCESS
sd 2:0:1:0: [foo] Result: hostbyte=DID_OK driverbyte=DRIVER_OK
sd 2:0:1:0: [foo] CDB: Write(10): 2a 00 01 58 0c 8a 00 00 08 00
...

When a new device is added, the udev appends a new rule manually.
In the future, it is appended automatically, as like NIC.

Best Regards,

---

Joe Perches (1):
sd: modify printk for alias name

Nao Nishijima (2):
sd: [cleanup] Use sd_printk() instead of printk()
block: add a new attribute "alias" in gendisk


Documentation/ABI/testing/sysfs-block | 13 ++++++
block/genhd.c | 71 +++++++++++++++++++++++++++++++++
drivers/scsi/scsi_lib.c | 26 ++++++++++++
drivers/scsi/sd.c | 30 +++++++++++++-
drivers/scsi/sd.h | 8 +---
include/linux/genhd.h | 4 ++
include/scsi/scsi_device.h | 8 +---
7 files changed, 147 insertions(+), 13 deletions(-)


--
Nao Nishijima (***@hitachi.com)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Nao Nishijima
2011-08-25 09:04:06 UTC
Permalink
This patch allows the user to set an "alias" of the disk via sysfs interface.

This patch only adds a new attribute "alias" in gendisk structure.
To show the alias instead of the device name in kernel messages,
we need to revise printk messages and use alias_name() in them.

Example:
(current) printk("disk name is %s\n", disk->disk_name);
(new) printk("disk name is %s\n", alias_name(disk));

Users can use alphabets, numbers, '-' and '_' in "alias" attribute. A disk can
have an "alias" which length is up to 255 bytes. This attribute is write-once.

Suggested-by: James Bottomley <***@HansenPartnership.com>
Suggested-by: Jon Masters <***@redhat.com>
Signed-off-by: Nao Nishijima <***@hitachi.com>
---

Documentation/ABI/testing/sysfs-block | 13 ++++++
block/genhd.c | 71 +++++++++++++++++++++++++++++++++
include/linux/genhd.h | 4 ++
3 files changed, 88 insertions(+), 0 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-block b/Documentation/ABI/testing/sysfs-block
index c1eb41c..2b5d561 100644
--- a/Documentation/ABI/testing/sysfs-block
+++ b/Documentation/ABI/testing/sysfs-block
@@ -206,3 +206,16 @@ Description:
when a discarded area is read the discard_zeroes_data
parameter will be set to one. Otherwise it will be 0 and
the result of reading a discarded area is undefined.
+What: /sys/block/<disk>/alias
+Date: Aug 2011
+Contact: Nao Nishijima <***@hitachi.com>
+Description:
+ A raw device name of a disk does not always point a same disk
+ each boot-up time. Therefore, users have to use persistent
+ device names, which udev creates when the kernel finds a disk,
+ instead of raw device name. However, kernel doesn't show those
+ persistent names on its messages (e.g. dmesg).
+ This file can store an alias of the disk and it would be
+ appeared in kernel messages if it is set. A disk can have an
+ alias which length is up to 255bytes. Users can use alphabets,
+ numbers, "-" and "_" in alias name. This file is writeonce.
diff --git a/block/genhd.c b/block/genhd.c
index e2f6790..94855a9 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -19,6 +19,7 @@
#include <linux/mutex.h>
#include <linux/idr.h>
#include <linux/log2.h>
+#include <linux/ctype.h>

#include "blk.h"

@@ -909,6 +910,74 @@ static int __init genhd_device_init(void)

subsys_initcall(genhd_device_init);

+static ssize_t alias_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct gendisk *disk = dev_to_disk(dev);
+ ssize_t ret = 0;
+
+ if (disk->alias)
+ ret = snprintf(buf, ALIAS_LEN, "%s\n", disk->alias);
+ return ret;
+}
+
+static ssize_t alias_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct gendisk *disk = dev_to_disk(dev);
+ char *alias;
+ char *envp[] = { NULL, NULL };
+ unsigned char c;
+ int i;
+ ssize_t ret = count;
+
+ if (!count)
+ return -EINVAL;
+
+ if (count >= ALIAS_LEN) {
+ printk(KERN_ERR "alias: alias is too long\n");
+ return -EINVAL;
+ }
+
+ /* Validation check */
+ for (i = 0; i < count; i++) {
+ c = buf[i];
+ if (i == count - 1 && c == '\n')
+ break;
+ if (!isalnum(c) && c != '_' && c != '-') {
+ printk(KERN_ERR "alias: invalid alias\n");
+ return -EINVAL;
+ }
+ }
+
+ if (disk->alias) {
+ printk(KERN_INFO "alias: %s is already assigned (%s)\n",
+ disk->disk_name, disk->alias);
+ return -EINVAL;
+ }
+
+ alias = kasprintf(GFP_KERNEL, "%s", buf);
+ if (!alias)
+ return -ENOMEM;
+
+ if (alias[count - 1] == '\n')
+ alias[count - 1] = '\0';
+
+ envp[0] = kasprintf(GFP_KERNEL, "ALIAS=%s", alias);
+ if (!envp[0]) {
+ kfree(alias);
+ return -ENOMEM;
+ }
+
+ disk->alias = alias;
+ printk(KERN_INFO "alias: assigned %s to %s\n", alias, disk->disk_name);
+
+ kobject_uevent_env(&dev->kobj, KOBJ_ADD, envp);
+
+ kfree(envp[0]);
+ return ret;
+}
+
static ssize_t disk_range_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
@@ -968,6 +1037,7 @@ static ssize_t disk_discard_alignment_show(struct device *dev,
return sprintf(buf, "%d\n", queue_discard_alignment(disk->queue));
}

+static DEVICE_ATTR(alias, S_IRUGO|S_IWUSR, alias_show, alias_store);
static DEVICE_ATTR(range, S_IRUGO, disk_range_show, NULL);
static DEVICE_ATTR(ext_range, S_IRUGO, disk_ext_range_show, NULL);
static DEVICE_ATTR(removable, S_IRUGO, disk_removable_show, NULL);
@@ -990,6 +1060,7 @@ static struct device_attribute dev_attr_fail_timeout =
#endif

static struct attribute *disk_attrs[] = {
+ &dev_attr_alias.attr,
&dev_attr_range.attr,
&dev_attr_ext_range.attr,
&dev_attr_removable.attr,
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 02fa469..6957350 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -21,6 +21,8 @@
#define dev_to_part(device) container_of((device), struct hd_struct, __dev)
#define disk_to_dev(disk) (&(disk)->part0.__dev)
#define part_to_dev(part) (&((part)->__dev))
+#define alias_name(disk) ((disk)->alias ? (disk)->alias : \
+ (disk)->disk_name)

extern struct device_type part_type;
extern struct kobject *block_depr;
@@ -58,6 +60,7 @@ enum {

#define DISK_MAX_PARTS 256
#define DISK_NAME_LEN 32
+#define ALIAS_LEN 256

#include <linux/major.h>
#include <linux/device.h>
@@ -162,6 +165,7 @@ struct gendisk {
* disks that can't be partitioned. */

char disk_name[DISK_NAME_LEN]; /* name of major driver */
+ char *alias; /* alias name of disk */
char *(*devnode)(struct gendisk *gd, mode_t *mode);

unsigned int events; /* supported events */
Nao Nishijima
2011-08-25 09:04:24 UTC
Permalink
From: Joe Perches <***@perches.com>

Reduce size of code and text of scmd_printk and sd_printk
macros by converting to the macros to functions and using
vsprintf extension %pV. This moves the code out-of-line
and centralizes the code used to emit additional arguments.

Save ~32KB of space in an x86 allyesconfig.

$ size drivers/scsi/built-in.o*
text data bss dec hex filename
5860439 135396 1393024 7388859 70bebb drivers/scsi/built-in.o.new
5882368 135396 1395848 7413612 711f6c drivers/scsi/built-in.o.old
5887100 135396 1397264 7419760 713770 drivers/scsi/built-in.o.with_patch_1_and_2

Signed-off-by: Joe Perches <***@perches.com>
Reviewed-by: Nao Nishijima <***@hitachi.com>
---

drivers/scsi/scsi_lib.c | 26 ++++++++++++++++++++++++++
drivers/scsi/sd.c | 23 +++++++++++++++++++++++
drivers/scsi/sd.h | 8 +++-----
include/scsi/scsi_device.h | 8 +++-----
4 files changed, 55 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index fc3f168..63579d4 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2574,3 +2574,29 @@ void scsi_kunmap_atomic_sg(void *virt)
kunmap_atomic(virt, KM_BIO_SRC_IRQ);
}
EXPORT_SYMBOL(scsi_kunmap_atomic_sg);
+
+/* Logging utilities */
+
+int scmd_printk(const char *prefix, const struct scsi_cmnd *scmd,
+ const char *format, ...)
+{
+ struct va_format vaf;
+ va_list args;
+ int r;
+
+ va_start(args, format);
+
+ vaf.fmt = format;
+ vaf.va = &args;
+
+ if (scmd->request->rq_disk)
+ r = sdev_printk(prefix, scmd->device, "[%s] %pV",
+ alias_name(scmd->request->rq_disk), &vaf);
+ else
+ r = sdev_printk(prefix, scmd->device, "%pV", &vaf);
+
+ va_end(args);
+
+ return r;
+}
+EXPORT_SYMBOL(scmd_printk);
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index a7942e5..7824f7a 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2889,3 +2889,26 @@ static void sd_print_result(struct scsi_disk *sdkp, int result)
scsi_show_result(result);
}

+int sd_printk(const char *prefix, const struct scsi_disk *sdsk,
+ const char *format, ...)
+{
+ struct va_format vaf;
+ va_list args;
+ int r;
+
+ va_start(args, format);
+
+ vaf.fmt = format;
+ vaf.va = &args;
+
+ if (sdsk->disk)
+ r = sdev_printk(prefix, sdsk->device, "[%s] %pV",
+ alias_name(sdsk->disk), &vaf);
+ else
+ r = sdev_printk(prefix, sdsk->device, "%pV", &vaf);
+
+ va_end(args);
+
+ return r;
+}
+EXPORT_SYMBOL(sd_printk);
diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h
index 6ad798b..46aa748 100644
--- a/drivers/scsi/sd.h
+++ b/drivers/scsi/sd.h
@@ -88,11 +88,9 @@ static inline struct scsi_disk *scsi_disk(struct gendisk *disk)
return container_of(disk->private_data, struct scsi_disk, driver);
}

-#define sd_printk(prefix, sdsk, fmt, a...) \
- (sdsk)->disk ? \
- sdev_printk(prefix, (sdsk)->device, "[%s] " fmt, \
- (sdsk)->disk->disk_name, ##a) : \
- sdev_printk(prefix, (sdsk)->device, fmt, ##a)
+extern __attribute__((format (printf, 3, 4)))
+int sd_printk(const char *prefix, const struct scsi_disk *sdsk,
+ const char *format, ...);

/*
* A DIF-capable target device can be formatted with different
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index d371c3c..2632502 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -216,11 +216,9 @@ struct scsi_dh_data {
#define sdev_printk(prefix, sdev, fmt, a...) \
dev_printk(prefix, &(sdev)->sdev_gendev, fmt, ##a)

-#define scmd_printk(prefix, scmd, fmt, a...) \
- (scmd)->request->rq_disk ? \
- sdev_printk(prefix, (scmd)->device, "[%s] " fmt, \
- (scmd)->request->rq_disk->disk_name, ##a) : \
- sdev_printk(prefix, (scmd)->device, fmt, ##a)
+extern __attribute__((format (printf, 3, 4)))
+int scmd_printk(const char *prefix, const struct scsi_cmnd *scmd,
+ const char *format, ...);

enum scsi_target_state {
STARGET_CREATED = 1,

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Nao Nishijima
2011-08-25 09:04:14 UTC
Permalink
sd_ioctl() still use printk() for log output.
It should use sd_printk() instead of printk(), as well as other sd_*.

All SCSI messages should output via s*_printk() instead of printk().

Signed-off-by: Nao Nishijima <***@hitachi.com>
---

drivers/scsi/sd.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 953773c..a7942e5 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1066,12 +1066,13 @@ static int sd_ioctl(struct block_device *bdev, fmode_t mode,
unsigned int cmd, unsigned long arg)
{
struct gendisk *disk = bdev->bd_disk;
- struct scsi_device *sdp = scsi_disk(disk)->device;
+ struct scsi_disk *sdkp = scsi_disk(disk);
+ struct scsi_device *sdp = sdkp->device;
void __user *p = (void __user *)arg;
int error;

- SCSI_LOG_IOCTL(1, printk("sd_ioctl: disk=%s, cmd=0x%x\n",
- disk->disk_name, cmd));
+ SCSI_LOG_IOCTL(1, sd_printk(KERN_INFO, sdkp, "sd_ioctl: disk=%s, "
+ "cmd=0x%x\n", disk->disk_name, cmd));

/*
* If we are in the middle of error recovery, don't let anyone
Tejun Heo
2011-08-25 10:16:02 UTC
Permalink
Hello,
Post by Nao Nishijima
This patch series provide an "alias" of the disk into kernel messages.
A raw device name of a disk does not always point a same disk at each boot-up
time. Therefore, users have to use persistent device names, which udev creates
to always access the same disk. However, kernel messages still display the raw
device names.
My proposal is that users can use and see persistent device names which were
assigned by themselves because users expect same name to point same disk
anytime.
Why need to modify kernel messages?
- We can see mapping of device names and persistent device names in udev log.
If those logs output to syslog, we can search persistent device name from
device name, but it can cause a large amount of syslog output.
- If we can use the persistent device names and can always see the same name on
the kernel log, we don't need to pay additional cost for searching and picking
a correct pair of device name and persistent device name from udev log.
- Kernel messages are output to serial console when kenel crashes, it's so hard
to convert a device name to the alias.
Just some general comments. This may already be a horse which is
beaten to death but anyways...

I'm not really convinced this is something we need. What we're
missing is structured error reporting which can be understood,
processed, presented and reacted by programs implementing system
management policies. Such facility would be useful in general but for
block devices I think it's a must that we're sorely missing.

Free format kernel message is a very undiscoverable way of
communicating these information. For developing and debugging, it's
fine. It's easy, flexible and you don't really have to think too much
about what should be presented how. For anything else, it's basically
horrible.

I don't really see what the point of this feature is. For developing
and debugging, pretty names might be nice but almost completely
unnecessary. For anything else, this falls way too short and can be
easily replaced by some smart scripting from userland. After all,
matching different device names is the least of the worries when
trying to use kernel log for general management and post-processing w/
good amount of heuristics is necessary to be useful anyway.

So, FWIW, I object.

Thank you.
--
tejun
Kay Sievers
2011-08-28 18:07:09 UTC
Permalink
Hmm... I don't follow. =C2=A0Why wouldn't it be able to? =C2=A0All=
the
informations are in the log. =C2=A0It is messy but it's there. =C2=
=A0If you want
In many cases, the script is able to convert the name. However there=
is
the special case that the logs do not exist in memory and disk due t=
o
the crash except console.
Sorry but I still don't get it. =C2=A0If you can extract the log, the
information is there and w/ remote logging (be it via serial or
network), the information always has to be there. =C2=A0Are you talki=
ng
about the case where somehow only the video console somehow succeeds
to print out oops? =C2=A0I don't think that's a common case as serial=
(also
on IPMI) tends to be pretty robust, often more robust than vide
output, and even when such case occurs, the only thing you want is
mapping kernel device name to more recognizable information, which
isn't difficult at all. =C2=A0If you wanna do it in a really simple m=
anner,
just save udisks --dump output after boot and each hotplug event and
write a simple script to search it.
more structured information, u{dev|disks} already maintain device
libarary - what maps to what, connected how with what attributes a=
nd
so on. =C2=A0Sending them off to the log machine as device hotplug=
events
occur and consulting it when post-processing log message would wor=
k
fine. =C2=A0All you need is just some python scripting. =C2=A0I do=
n't really see
much point in messing with device names directly. =C2=A0The only t=
hing is
that the raw log would be prettier. =C2=A0I don't think that is us=
eful
enough to justify changing kernel device names.
A kernel device names (e.g. sda) is not useful information because i=
t
doesn't always point the same disk at each boot-up time.
Eh? =C2=A0What difference does that make? =C2=A0Just make the target =
machines
send up-to-date disk config info to the log server.
An alias is just an option and provides the ability to give all
kernel devices a "preferred name".
By default, dev_printk's will show a kernel device name. They show a=
n
alias only when the user assigns a "preferred name" to an alias.
Even if the persistend device name is used, the device names in logs=
are
different from the name that the users are using. So, an alias helps=
the
user identify the disk.
Yes, I do understand what it's doing and can see there can be cases i=
t
can be somewhat useful but I still think it's too adhoc an approach
which doesn't really justify itself. =C2=A0It just does too little to=
solve
the actual problem and even that 'little' part isn't very trivial - i=
t
adds whole lot of policy decisions to make and I'm pretty sure it wil=
l
cause good amount of havoc w/ all the system tools which currently
don't expect block device names to change to some admin determined
free format string on the fly.
My take on this in short again:
The very same thing that needs to store the 'pretty name' in the
kernel here, can instead just log that name along with the kernel name
to /dev/kmsg. It ends up in the kernel log buffer and is the marker to
safely match all later log entries.

This can be done today, even on many years old distros, with a single
udev rule and a tiny program. It needs no kernel or tool changes and
gives almost all the benefits of the 'pretty name' infrastructure.

Kay
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" i=
n
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Bernd Schubert
2011-08-30 21:53:44 UTC
Permalink
Post by Kay Sievers
Hmm... I don't follow. Why wouldn't it be able to? All the
informations are in the log. It is messy but it's there. If you want
In many cases, the script is able to convert the name. However there is
the special case that the logs do not exist in memory and disk due to
the crash except console.
Sorry but I still don't get it. If you can extract the log, the
information is there and w/ remote logging (be it via serial or
network), the information always has to be there. Are you talking
about the case where somehow only the video console somehow succeeds
to print out oops? I don't think that's a common case as serial (also
on IPMI) tends to be pretty robust, often more robust than vide
output, and even when such case occurs, the only thing you want is
mapping kernel device name to more recognizable information, which
isn't difficult at all. If you wanna do it in a really simple manner,
just save udisks --dump output after boot and each hotplug event and
write a simple script to search it.
more structured information, u{dev|disks} already maintain device
libarary - what maps to what, connected how with what attributes and
so on. Sending them off to the log machine as device hotplug events
occur and consulting it when post-processing log message would work
fine. All you need is just some python scripting. I don't really see
much point in messing with device names directly. The only thing is
that the raw log would be prettier. I don't think that is useful
enough to justify changing kernel device names.
A kernel device names (e.g. sda) is not useful information because it
doesn't always point the same disk at each boot-up time.
Eh? What difference does that make? Just make the target machines
send up-to-date disk config info to the log server.
An alias is just an option and provides the ability to give all
kernel devices a "preferred name".
By default, dev_printk's will show a kernel device name. They show an
alias only when the user assigns a "preferred name" to an alias.
Even if the persistend device name is used, the device names in logs are
different from the name that the users are using. So, an alias helps the
user identify the disk.
Yes, I do understand what it's doing and can see there can be cases it
can be somewhat useful but I still think it's too adhoc an approach
which doesn't really justify itself. It just does too little to solve
the actual problem and even that 'little' part isn't very trivial - it
adds whole lot of policy decisions to make and I'm pretty sure it will
cause good amount of havoc w/ all the system tools which currently
don't expect block device names to change to some admin determined
free format string on the fly.
The very same thing that needs to store the 'pretty name' in the
kernel here, can instead just log that name along with the kernel name
to /dev/kmsg. It ends up in the kernel log buffer and is the marker to
safely match all later log entries.
This can be done today, even on many years old distros, with a single
udev rule and a tiny program. It needs no kernel or tool changes and
gives almost all the benefits of the 'pretty name' infrastructure.
Could you please explain exactly how? Simply replace sd{X} by the
preferred name in /dev/kmsg? How do make make sure you do not replace
something that is not supposed to be replaced? I think unless you plan
to modify existing kernel device message you cannot, as sd{X} is too
general.
And how does /dev/kmsg solve the serial console problem?

However, I think a real technical issue with any udev device name rules
remains - it often does not work well with multipath devices. Alua
partly solves that problem, but only if there is a direct connection to
each of the alua controllers. But if there is a switch in between, there
are often several devices with the same alua score. And the situation is
even worse with multipath hardware that does not know alua at all.
So for many multipath devices it probably would not make sense to set
alias names. But especially on those system you often would like to have
suitable alias names, as it gets a bit chaotic without (I had to deal
with 30 or even 60 devices x 8 paths in the past...).

Cheers,
Bernd
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
V***@vt.edu
2011-08-30 20:02:17 UTC
Permalink
A kernel device names (e.g. sda) is not useful information because it
doesn't always point the same disk at each boot-up time.
If this is important to you, can't you use a udev rule, similar to what most
distros already stick in 70-persistent-net.rules and 70-persistent-cd.rules?

(Yes, this *does* involve finding a UUID or label or something on the disk
that you can identify as "same entity as last time".
Nao Nishijima
2011-09-02 12:51:54 UTC
Permalink
Hi Valdis,
=20
A kernel device names (e.g. sda) is not useful information because i=
t
doesn't always point the same disk at each boot-up time.
=20
If this is important to you, can't you use a udev rule, similar to wh=
at most
distros already stick in 70-persistent-net.rules and 70-persistent-cd=
=2Erules?
=20
(Yes, this *does* involve finding a UUID or label or something on th=
e disk
that you can identify as "same entity as last time".
As you said, it is able to identify a disk at the expense of checking
cost. However to introduce "alias" is an advantage of reducing both the
cost and the risk of miss-communication, and it can easily identify it.

And also, currently, kernel log and command output do not accord with
the device name which a user uses (e.g. by-id, by-uuid). I would try to
solve those mismatches using "alias". In other words, I'd like to
introduce aliases for integrating the name of devices to control and re=
cord.

Of course I will modify commands using a device name to use a persisten=
t
device names.


Best regards,

--=20
Nao NISHIJIMA
Software Platform Research Dept. Linux Technology Center
Hitachi, Ltd., YOKOHAMA Research Laboratory
Email=EF=BC=9A ***@hitachi.com

Continue reading on narkive:
Loading...