wrapper for access to ->bd_partno
authorAl Viro <viro@zeniv.linux.org.uk>
Fri, 12 Apr 2024 05:01:36 +0000 (01:01 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 2 May 2024 21:48:09 +0000 (17:48 -0400)
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>
block/early-lookup.c
block/partitions/core.c
include/linux/blkdev.h
lib/vsprintf.c

index 3effbd0d35e9fa0eb1f24b1131f3eca2ad4b6656..3fb57f7d2b1276df8857b71da7d5891b3d0061b0 100644 (file)
@@ -78,7 +78,7 @@ static int __init devt_from_partuuid(const char *uuid_str, dev_t *devt)
                 * to the partition number found by UUID.
                 */
                *devt = part_devt(dev_to_disk(dev),
-                                 dev_to_bdev(dev)->bd_partno + offset);
+                                 bdev_partno(dev_to_bdev(dev)) + offset);
        } else {
                *devt = dev->devt;
        }
index b11e88c82c8cfa9e179b05a6633f0b1294d818da..edd5309dc4ba733709c1073365accd27dbdd3c20 100644 (file)
@@ -173,7 +173,7 @@ static struct parsed_partitions *check_partition(struct gendisk *hd)
 static ssize_t part_partition_show(struct device *dev,
                                   struct device_attribute *attr, char *buf)
 {
-       return sprintf(buf, "%d\n", dev_to_bdev(dev)->bd_partno);
+       return sprintf(buf, "%d\n", bdev_partno(dev_to_bdev(dev)));
 }
 
 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)
 {
        const struct block_device *part = dev_to_bdev(dev);
 
-       add_uevent_var(env, "PARTN=%u", part->bd_partno);
+       add_uevent_var(env, "PARTN=%u", bdev_partno(part));
        if (part->bd_meta_info && part->bd_meta_info->volname[0])
                add_uevent_var(env, "PARTNAME=%s", part->bd_meta_info->volname);
        return 0;
@@ -267,7 +267,7 @@ void drop_partition(struct block_device *part)
 {
        lockdep_assert_held(&part->bd_disk->open_mutex);
 
-       xa_erase(&part->bd_disk->part_tbl, part->bd_partno);
+       xa_erase(&part->bd_disk->part_tbl, bdev_partno(part));
        kobject_put(part->bd_holder_dir);
 
        device_del(&part->bd_device);
@@ -338,8 +338,8 @@ static struct block_device *add_partition(struct gendisk *disk, int partno,
        pdev->parent = ddev;
 
        /* in consecutive minor range? */
-       if (bdev->bd_partno < disk->minors) {
-               devt = MKDEV(disk->major, disk->first_minor + bdev->bd_partno);
+       if (bdev_partno(bdev) < disk->minors) {
+               devt = MKDEV(disk->major, disk->first_minor + bdev_partno(bdev));
        } else {
                err = blk_alloc_ext_minor();
                if (err < 0)
@@ -404,7 +404,7 @@ static bool partition_overlaps(struct gendisk *disk, sector_t start,
 
        rcu_read_lock();
        xa_for_each_start(&disk->part_tbl, idx, part, 1) {
-               if (part->bd_partno != skip_partno &&
+               if (bdev_partno(part) != skip_partno &&
                    start < part->bd_start_sect + bdev_nr_sectors(part) &&
                    start + length > part->bd_start_sect) {
                        overlap = true;
index c3e8f7cf96be9e1c10169d2e7afe31696082eb8f..32549d6759557b81a11a834d44c3742d8f06df14 100644 (file)
@@ -720,6 +720,11 @@ void invalidate_disk(struct gendisk *disk);
 void set_disk_ro(struct gendisk *disk, bool read_only);
 void disk_uevent(struct gendisk *disk, enum kobject_action action);
 
+static inline u8 bdev_partno(const struct block_device *bdev)
+{
+       return bdev->bd_partno;
+}
+
 static inline int get_disk_ro(struct gendisk *disk)
 {
        return disk->part0->bd_read_only ||
@@ -1095,7 +1100,7 @@ static inline int sb_issue_zeroout(struct super_block *sb, sector_t block,
 
 static inline bool bdev_is_partition(struct block_device *bdev)
 {
-       return bdev->bd_partno;
+       return bdev_partno(bdev) != 0;
 }
 
 enum blk_default_limits {
index 3f9f1b959ef026e48f0feaa2d55a1a12332f890e..cdd4e2314bfc6ed6800ae4ed7ebcb4e5432b20bb 100644 (file)
@@ -972,7 +972,7 @@ char *bdev_name(char *buf, char *end, struct block_device *bdev,
                                *buf = 'p';
                        buf++;
                }
-               buf = number(buf, end, bdev->bd_partno, spec);
+               buf = number(buf, end, bdev_partno(bdev), spec);
        }
        return buf;
 }