]> www.infradead.org Git - users/hch/block.git/commitdiff
block: move bd_part_count to struct gendisk
authorChristoph Hellwig <hch@lst.de>
Mon, 12 Apr 2021 07:57:08 +0000 (09:57 +0200)
committerChristoph Hellwig <hch@lst.de>
Mon, 24 May 2021 13:23:31 +0000 (15:23 +0200)
The bd_part_count value only makes sense for whole devices, so move it
to struct gendisk and give it a more descriptive name.

Signed-off-by: Christoph Hellwig <hch@lst.de>
block/ioctl.c
fs/block_dev.c
include/linux/blk_types.h
include/linux/genhd.h

index 8ba1ed8defd0bb1d705e28531c122b952c3168af..24beec9ca9c95b776c6976bb5e6d5f129420c326 100644 (file)
@@ -89,7 +89,7 @@ static int blkdev_reread_part(struct block_device *bdev, fmode_t mode)
                return -EINVAL;
        if (!capable(CAP_SYS_ADMIN))
                return -EACCES;
-       if (bdev->bd_part_count)
+       if (bdev->bd_disk->open_partitions)
                return -EBUSY;
 
        /*
index cd45b54e86b478ff0e6921e7d97ebf540aed9ebe..ac9b3c158a770ad12b1d3120a8e1e1704835caef 100644 (file)
@@ -1253,7 +1253,7 @@ int bdev_disk_changed(struct block_device *bdev, bool invalidate)
                return -ENXIO;
 
 rescan:
-       if (bdev->bd_part_count)
+       if (disk->open_partitions)
                return -EBUSY;
        sync_blockdev(bdev);
        invalidate_bdev(bdev);
@@ -1348,7 +1348,7 @@ static int blkdev_get_part(struct block_device *part, fmode_t mode)
        if (!bdev_nr_sectors(part))
                goto out_blkdev_put;
 
-       whole->bd_part_count++;
+       disk->open_partitions++;
        set_init_blocksize(part);
        if (part->bd_bdi == &noop_backing_dev_info)
                part->bd_bdi = bdi_get(disk->queue->backing_dev_info);
@@ -1370,7 +1370,7 @@ static void blkdev_put_part(struct block_device *part, fmode_t mode)
        if (--part->bd_openers)
                return;
        blkdev_flush_mapping(part);
-       whole->bd_part_count--;
+       whole->bd_disk->open_partitions--;
        blkdev_put_whole(whole, mode);
        bdput(whole);
 }
index a09660671fa47ec263595ab99dacb9917531e5c4..fd3860d18d7ed7da0fd9508a49c6f87d5f85cefb 100644 (file)
@@ -39,9 +39,6 @@ struct block_device {
 #endif
        struct kobject          *bd_holder_dir;
        u8                      bd_partno;
-       /* number of times partitions within this device have been opened. */
-       unsigned                bd_part_count;
-
        spinlock_t              bd_size_lock; /* for bd_inode->i_size updates */
        struct gendisk *        bd_disk;
        struct backing_dev_info *bd_bdi;
index 55072e17ea8298783fd4a2ed5ba0c56fb5319546..a093ec40c0a23b3efc032cc8b3df9ff4e0bb962a 100644 (file)
@@ -155,6 +155,7 @@ struct gendisk {
 #define GD_READ_ONLY                   1
 
        struct mutex open_mutex;        /* open/close mutex */
+       unsigned open_partitions;       /* number of open partitions */
 
        struct kobject *slave_dir;