Skip to content

Commit

Permalink
block: hide badblocks attribute by default
Browse files Browse the repository at this point in the history
Commit 99e6608 "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 <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Martin K. Petersen <[email protected]>
Reported-by: Vishal Verma <[email protected]>
Signed-off-by: Dan Williams <[email protected]>
Tested-by: Vishal Verma <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
djbw authored and axboe committed Apr 28, 2017
1 parent 21c6e93 commit 9438b3e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1060,8 +1060,19 @@ static struct attribute *disk_attrs[] = {
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 = {
.attrs = disk_attrs,
.is_visible = disk_visible,
};

static const struct attribute_group *disk_attr_groups[] = {
Expand Down

0 comments on commit 9438b3e

Please sign in to comment.