Skip to content

Commit

Permalink
block: don't look at the struct device dev_t in disk_devt
Browse files Browse the repository at this point in the history
The hidden gendisks introduced in the next patch need to keep the dev
field in their struct device empty so that udev won't try to create
block device nodes for them.  To support that rewrite disk_devt to
look at the major and first_minor fields in the gendisk itself instead
of looking into the struct device.

Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: Johannes Thumshirn <[email protected]>
Reviewed-by: Hannes Reinecke <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Christoph Hellwig authored and axboe committed Nov 3, 2017
1 parent ef71de8 commit 517bf3c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
4 changes: 0 additions & 4 deletions block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -649,10 +649,6 @@ void device_add_disk(struct device *parent, struct gendisk *disk)
return;
}
disk_to_dev(disk)->devt = devt;

/* ->major and ->first_minor aren't supposed to be
* dereferenced from here on, but set them just in case.
*/
disk->major = MAJOR(devt);
disk->first_minor = MINOR(devt);

Expand Down
2 changes: 1 addition & 1 deletion include/linux/genhd.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ static inline bool disk_part_scan_enabled(struct gendisk *disk)

static inline dev_t disk_devt(struct gendisk *disk)
{
return disk_to_dev(disk)->devt;
return MKDEV(disk->major, disk->first_minor);
}

static inline dev_t part_devt(struct hd_struct *part)
Expand Down

0 comments on commit 517bf3c

Please sign in to comment.