Skip to content

Commit b8c873e

Browse files
author
Al Viro
committed
wrapper for access to ->bd_partno
On the next step it's going to get folded into a field where flags will go. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 3f9b8fb commit b8c873e

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

block/early-lookup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static int __init devt_from_partuuid(const char *uuid_str, dev_t *devt)
7878
* to the partition number found by UUID.
7979
*/
8080
*devt = part_devt(dev_to_disk(dev),
81-
dev_to_bdev(dev)->bd_partno + offset);
81+
bdev_partno(dev_to_bdev(dev)) + offset);
8282
} else {
8383
*devt = dev->devt;
8484
}

block/partitions/core.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ static struct parsed_partitions *check_partition(struct gendisk *hd)
173173
static ssize_t part_partition_show(struct device *dev,
174174
struct device_attribute *attr, char *buf)
175175
{
176-
return sprintf(buf, "%d\n", dev_to_bdev(dev)->bd_partno);
176+
return sprintf(buf, "%d\n", bdev_partno(dev_to_bdev(dev)));
177177
}
178178

179179
static ssize_t part_start_show(struct device *dev,
@@ -250,7 +250,7 @@ static int part_uevent(const struct device *dev, struct kobj_uevent_env *env)
250250
{
251251
const struct block_device *part = dev_to_bdev(dev);
252252

253-
add_uevent_var(env, "PARTN=%u", part->bd_partno);
253+
add_uevent_var(env, "PARTN=%u", bdev_partno(part));
254254
if (part->bd_meta_info && part->bd_meta_info->volname[0])
255255
add_uevent_var(env, "PARTNAME=%s", part->bd_meta_info->volname);
256256
return 0;
@@ -267,7 +267,7 @@ void drop_partition(struct block_device *part)
267267
{
268268
lockdep_assert_held(&part->bd_disk->open_mutex);
269269

270-
xa_erase(&part->bd_disk->part_tbl, part->bd_partno);
270+
xa_erase(&part->bd_disk->part_tbl, bdev_partno(part));
271271
kobject_put(part->bd_holder_dir);
272272

273273
device_del(&part->bd_device);
@@ -338,8 +338,8 @@ static struct block_device *add_partition(struct gendisk *disk, int partno,
338338
pdev->parent = ddev;
339339

340340
/* in consecutive minor range? */
341-
if (bdev->bd_partno < disk->minors) {
342-
devt = MKDEV(disk->major, disk->first_minor + bdev->bd_partno);
341+
if (bdev_partno(bdev) < disk->minors) {
342+
devt = MKDEV(disk->major, disk->first_minor + bdev_partno(bdev));
343343
} else {
344344
err = blk_alloc_ext_minor();
345345
if (err < 0)
@@ -404,7 +404,7 @@ static bool partition_overlaps(struct gendisk *disk, sector_t start,
404404

405405
rcu_read_lock();
406406
xa_for_each_start(&disk->part_tbl, idx, part, 1) {
407-
if (part->bd_partno != skip_partno &&
407+
if (bdev_partno(part) != skip_partno &&
408408
start < part->bd_start_sect + bdev_nr_sectors(part) &&
409409
start + length > part->bd_start_sect) {
410410
overlap = true;

include/linux/blkdev.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,11 @@ void invalidate_disk(struct gendisk *disk);
720720
void set_disk_ro(struct gendisk *disk, bool read_only);
721721
void disk_uevent(struct gendisk *disk, enum kobject_action action);
722722

723+
static inline u8 bdev_partno(const struct block_device *bdev)
724+
{
725+
return bdev->bd_partno;
726+
}
727+
723728
static inline int get_disk_ro(struct gendisk *disk)
724729
{
725730
return disk->part0->bd_read_only ||
@@ -1095,7 +1100,7 @@ static inline int sb_issue_zeroout(struct super_block *sb, sector_t block,
10951100

10961101
static inline bool bdev_is_partition(struct block_device *bdev)
10971102
{
1098-
return bdev->bd_partno;
1103+
return bdev_partno(bdev) != 0;
10991104
}
11001105

11011106
enum blk_default_limits {

lib/vsprintf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ char *bdev_name(char *buf, char *end, struct block_device *bdev,
972972
*buf = 'p';
973973
buf++;
974974
}
975-
buf = number(buf, end, bdev->bd_partno, spec);
975+
buf = number(buf, end, bdev_partno(bdev), spec);
976976
}
977977
return buf;
978978
}

0 commit comments

Comments
 (0)