提交 9438b3e0 编写于 作者: D Dan Williams 提交者: Jens Axboe

block: hide badblocks attribute by default

Commit 99e6608c "block: Add badblock management for gendisks"
allowed for drivers like pmem and software-raid to advertise a list of
bad media areas. However, it inadvertently added a 'badblocks' to all
block devices. Lets clean this up by having the 'badblocks' attribute
not be visible when the driver has not populated a 'struct badblocks'
instance in the gendisk.

Cc: Jens Axboe <axboe@fb.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Reported-by: NVishal Verma <vishal.l.verma@intel.com>
Signed-off-by: NDan Williams <dan.j.williams@intel.com>
Tested-by: NVishal Verma <vishal.l.verma@intel.com>
Signed-off-by: NJens Axboe <axboe@fb.com>
上级 21c6e939
...@@ -1060,8 +1060,19 @@ static struct attribute *disk_attrs[] = { ...@@ -1060,8 +1060,19 @@ static struct attribute *disk_attrs[] = {
NULL NULL
}; };
static umode_t disk_visible(struct kobject *kobj, struct attribute *a, int n)
{
struct device *dev = container_of(kobj, typeof(*dev), kobj);
struct gendisk *disk = dev_to_disk(dev);
if (a == &dev_attr_badblocks.attr && !disk->bb)
return 0;
return a->mode;
}
static struct attribute_group disk_attr_group = { static struct attribute_group disk_attr_group = {
.attrs = disk_attrs, .attrs = disk_attrs,
.is_visible = disk_visible,
}; };
static const struct attribute_group *disk_attr_groups[] = { static const struct attribute_group *disk_attr_groups[] = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册