Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

block: Revert "[SCSI] genhd: add a new attribute "alias" in gendisk"

This reverts commit a72c5e5eb738033938ab30d6a634b74d1d060f10.

The commit introduced alias for block devices which is intended to be
used during logging although actual usage hasn't been committed yet.
This approach adds very limited benefit (raw log might be easier to
follow) which can be trivially implemented in userland but has a lot
of problems.

It is much worse than netif renames because it doesn't rename the
actual device but just adds conveninence name which isn't used
universally or enforced. Everything internal including device lookup
and sysfs still uses the internal name and nothing prevents two
devices from using conflicting alias - ie. sda can have sdb as its
alias.

This has been nacked by people working on device driver core, block
layer and kernel-userland interface and shouldn't have been
upstreamed. Revert it.

http://thread.gmane.org/gmane.linux.kernel/1155104
http://thread.gmane.org/gmane.linux.scsi/68632
http://thread.gmane.org/gmane.linux.scsi/69776

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Acked-by: Kay Sievers <kay.sievers@vrfy.org>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Nao Nishijima <nao.nishijima.xt@hitachi.com>
Cc: Alan Cox <alan@linux.intel.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Tejun Heo and committed by
Jens Axboe
d0985394 1ea6b8f4

-88
-13
Documentation/ABI/testing/sysfs-block
··· 206 206 when a discarded area is read the discard_zeroes_data 207 207 parameter will be set to one. Otherwise it will be 0 and 208 208 the result of reading a discarded area is undefined. 209 - What: /sys/block/<disk>/alias 210 - Date: Aug 2011 211 - Contact: Nao Nishijima <nao.nishijima.xt@hitachi.com> 212 - Description: 213 - A raw device name of a disk does not always point a same disk 214 - each boot-up time. Therefore, users have to use persistent 215 - device names, which udev creates when the kernel finds a disk, 216 - instead of raw device name. However, kernel doesn't show those 217 - persistent names on its messages (e.g. dmesg). 218 - This file can store an alias of the disk and it would be 219 - appeared in kernel messages if it is set. A disk can have an 220 - alias which length is up to 255bytes. Users can use alphabets, 221 - numbers, "-" and "_" in alias name. This file is writeonce.
-71
block/genhd.c
··· 19 19 #include <linux/mutex.h> 20 20 #include <linux/idr.h> 21 21 #include <linux/log2.h> 22 - #include <linux/ctype.h> 23 22 24 23 #include "blk.h" 25 24 ··· 915 916 916 917 subsys_initcall(genhd_device_init); 917 918 918 - static ssize_t alias_show(struct device *dev, 919 - struct device_attribute *attr, char *buf) 920 - { 921 - struct gendisk *disk = dev_to_disk(dev); 922 - ssize_t ret = 0; 923 - 924 - if (disk->alias) 925 - ret = snprintf(buf, ALIAS_LEN, "%s\n", disk->alias); 926 - return ret; 927 - } 928 - 929 - static ssize_t alias_store(struct device *dev, struct device_attribute *attr, 930 - const char *buf, size_t count) 931 - { 932 - struct gendisk *disk = dev_to_disk(dev); 933 - char *alias; 934 - char *envp[] = { NULL, NULL }; 935 - unsigned char c; 936 - int i; 937 - ssize_t ret = count; 938 - 939 - if (!count) 940 - return -EINVAL; 941 - 942 - if (count >= ALIAS_LEN) { 943 - printk(KERN_ERR "alias: alias is too long\n"); 944 - return -EINVAL; 945 - } 946 - 947 - /* Validation check */ 948 - for (i = 0; i < count; i++) { 949 - c = buf[i]; 950 - if (i == count - 1 && c == '\n') 951 - break; 952 - if (!isalnum(c) && c != '_' && c != '-') { 953 - printk(KERN_ERR "alias: invalid alias\n"); 954 - return -EINVAL; 955 - } 956 - } 957 - 958 - if (disk->alias) { 959 - printk(KERN_INFO "alias: %s is already assigned (%s)\n", 960 - disk->disk_name, disk->alias); 961 - return -EINVAL; 962 - } 963 - 964 - alias = kasprintf(GFP_KERNEL, "%s", buf); 965 - if (!alias) 966 - return -ENOMEM; 967 - 968 - if (alias[count - 1] == '\n') 969 - alias[count - 1] = '\0'; 970 - 971 - envp[0] = kasprintf(GFP_KERNEL, "ALIAS=%s", alias); 972 - if (!envp[0]) { 973 - kfree(alias); 974 - return -ENOMEM; 975 - } 976 - 977 - disk->alias = alias; 978 - printk(KERN_INFO "alias: assigned %s to %s\n", alias, disk->disk_name); 979 - 980 - kobject_uevent_env(&dev->kobj, KOBJ_ADD, envp); 981 - 982 - kfree(envp[0]); 983 - return ret; 984 - } 985 - 986 919 static ssize_t disk_range_show(struct device *dev, 987 920 struct device_attribute *attr, char *buf) 988 921 { ··· 974 1043 return sprintf(buf, "%d\n", queue_discard_alignment(disk->queue)); 975 1044 } 976 1045 977 - static DEVICE_ATTR(alias, S_IRUGO|S_IWUSR, alias_show, alias_store); 978 1046 static DEVICE_ATTR(range, S_IRUGO, disk_range_show, NULL); 979 1047 static DEVICE_ATTR(ext_range, S_IRUGO, disk_ext_range_show, NULL); 980 1048 static DEVICE_ATTR(removable, S_IRUGO, disk_removable_show, NULL); ··· 996 1066 #endif 997 1067 998 1068 static struct attribute *disk_attrs[] = { 999 - &dev_attr_alias.attr, 1000 1069 &dev_attr_range.attr, 1001 1070 &dev_attr_ext_range.attr, 1002 1071 &dev_attr_removable.attr,
-4
include/linux/genhd.h
··· 21 21 #define dev_to_part(device) container_of((device), struct hd_struct, __dev) 22 22 #define disk_to_dev(disk) (&(disk)->part0.__dev) 23 23 #define part_to_dev(part) (&((part)->__dev)) 24 - #define alias_name(disk) ((disk)->alias ? (disk)->alias : \ 25 - (disk)->disk_name) 26 24 27 25 extern struct device_type part_type; 28 26 extern struct kobject *block_depr; ··· 58 60 59 61 #define DISK_MAX_PARTS 256 60 62 #define DISK_NAME_LEN 32 61 - #define ALIAS_LEN 256 62 63 63 64 #include <linux/major.h> 64 65 #include <linux/device.h> ··· 163 166 * disks that can't be partitioned. */ 164 167 165 168 char disk_name[DISK_NAME_LEN]; /* name of major driver */ 166 - char *alias; /* alias name of disk */ 167 169 char *(*devnode)(struct gendisk *gd, mode_t *mode); 168 170 169 171 unsigned int events; /* supported events */