aboutsummaryrefslogtreecommitdiffstats
path: root/block/genhd.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2011-11-10 03:03:55 -0500
committerJens Axboe <axboe@kernel.dk>2011-11-10 03:03:55 -0500
commitd0985394e7fee6b25a7cc8335d45bc1c1a8ab2d3 (patch)
tree44f19c0500580fd0c3ea39f355c9636bec59d677 /block/genhd.c
parent1ea6b8f48918282bdca0b32a34095504ee65bab5 (diff)
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>
Diffstat (limited to 'block/genhd.c')
-rw-r--r--block/genhd.c71
1 files changed, 0 insertions, 71 deletions
diff --git a/block/genhd.c b/block/genhd.c
index 9253839714ff..02e9fca80825 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -19,7 +19,6 @@
19#include <linux/mutex.h> 19#include <linux/mutex.h>
20#include <linux/idr.h> 20#include <linux/idr.h>
21#include <linux/log2.h> 21#include <linux/log2.h>
22#include <linux/ctype.h>
23 22
24#include "blk.h" 23#include "blk.h"
25 24
@@ -916,74 +915,6 @@ static int __init genhd_device_init(void)
916 915
917subsys_initcall(genhd_device_init); 916subsys_initcall(genhd_device_init);
918 917
919static ssize_t alias_show(struct device *dev,
920 struct device_attribute *attr, char *buf)
921{
922 struct gendisk *disk = dev_to_disk(dev);
923 ssize_t ret = 0;
924
925 if (disk->alias)
926 ret = snprintf(buf, ALIAS_LEN, "%s\n", disk->alias);
927 return ret;
928}
929
930static ssize_t alias_store(struct device *dev, struct device_attribute *attr,
931 const char *buf, size_t count)
932{
933 struct gendisk *disk = dev_to_disk(dev);
934 char *alias;
935 char *envp[] = { NULL, NULL };
936 unsigned char c;
937 int i;
938 ssize_t ret = count;
939
940 if (!count)
941 return -EINVAL;
942
943 if (count >= ALIAS_LEN) {
944 printk(KERN_ERR "alias: alias is too long\n");
945 return -EINVAL;
946 }
947
948 /* Validation check */
949 for (i = 0; i < count; i++) {
950 c = buf[i];
951 if (i == count - 1 && c == '\n')
952 break;
953 if (!isalnum(c) && c != '_' && c != '-') {
954 printk(KERN_ERR "alias: invalid alias\n");
955 return -EINVAL;
956 }
957 }
958
959 if (disk->alias) {
960 printk(KERN_INFO "alias: %s is already assigned (%s)\n",
961 disk->disk_name, disk->alias);
962 return -EINVAL;
963 }
964
965 alias = kasprintf(GFP_KERNEL, "%s", buf);
966 if (!alias)
967 return -ENOMEM;
968
969 if (alias[count - 1] == '\n')
970 alias[count - 1] = '\0';
971
972 envp[0] = kasprintf(GFP_KERNEL, "ALIAS=%s", alias);
973 if (!envp[0]) {
974 kfree(alias);
975 return -ENOMEM;
976 }
977
978 disk->alias = alias;
979 printk(KERN_INFO "alias: assigned %s to %s\n", alias, disk->disk_name);
980
981 kobject_uevent_env(&dev->kobj, KOBJ_ADD, envp);
982
983 kfree(envp[0]);
984 return ret;
985}
986
987static ssize_t disk_range_show(struct device *dev, 918static ssize_t disk_range_show(struct device *dev,
988 struct device_attribute *attr, char *buf) 919 struct device_attribute *attr, char *buf)
989{ 920{
@@ -1043,7 +974,6 @@ static ssize_t disk_discard_alignment_show(struct device *dev,
1043 return sprintf(buf, "%d\n", queue_discard_alignment(disk->queue)); 974 return sprintf(buf, "%d\n", queue_discard_alignment(disk->queue));
1044} 975}
1045 976
1046static DEVICE_ATTR(alias, S_IRUGO|S_IWUSR, alias_show, alias_store);
1047static DEVICE_ATTR(range, S_IRUGO, disk_range_show, NULL); 977static DEVICE_ATTR(range, S_IRUGO, disk_range_show, NULL);
1048static DEVICE_ATTR(ext_range, S_IRUGO, disk_ext_range_show, NULL); 978static DEVICE_ATTR(ext_range, S_IRUGO, disk_ext_range_show, NULL);
1049static DEVICE_ATTR(removable, S_IRUGO, disk_removable_show, NULL); 979static DEVICE_ATTR(removable, S_IRUGO, disk_removable_show, NULL);
@@ -1066,7 +996,6 @@ static struct device_attribute dev_attr_fail_timeout =
1066#endif 996#endif
1067 997
1068static struct attribute *disk_attrs[] = { 998static struct attribute *disk_attrs[] = {
1069 &dev_attr_alias.attr,
1070 &dev_attr_range.attr, 999 &dev_attr_range.attr,
1071 &dev_attr_ext_range.attr, 1000 &dev_attr_ext_range.attr,
1072 &dev_attr_removable.attr, 1001 &dev_attr_removable.attr,