Skip to content

Commit

Permalink
block: don't test for partition size in bdget_disk() and blk_lookup_d…
Browse files Browse the repository at this point in the history
…evt()

bdget_disk() and blk_lookup_devt() never cared whether the specified
partition (or disk) is zero sized or not.  I got confused while
converting those not to depend on consecutive minor numbers in commit
5a6411b1178baf534aa9138052864dfa89d3eada and later when dev0 was added
it broke callers which expected to get valid return for zero sized
disk devices.

So, they never needed nr_sects checks in the first place.  Kill them.

This problem was spotted and debugged by Bartlmoiej Zolnierkiewicz.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
  • Loading branch information
Tejun Heo authored and Jens Axboe committed Oct 9, 2008
1 parent 759f8ca commit 2bbedcb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ struct block_device *bdget_disk(struct gendisk *disk, int partno)
struct block_device *bdev = NULL;

part = disk_get_part(disk, partno);
if (part && (part->nr_sects || partno == 0))
if (part)
bdev = bdget(part_devt(part));
disk_put_part(part);

Expand Down Expand Up @@ -1031,7 +1031,7 @@ dev_t blk_lookup_devt(const char *name, int partno)
continue;

part = disk_get_part(disk, partno);
if (part && (part->nr_sects || partno == 0)) {
if (part) {
devt = part_devt(part);
disk_put_part(part);
break;
Expand Down

0 comments on commit 2bbedcb

Please sign in to comment.