]> git.itanic.dy.fi Git - linux-stable/commitdiff
s390/dasd: Convert to bdev_open_by_path()
authorJan Kara <jack@suse.cz>
Wed, 27 Sep 2023 09:34:20 +0000 (11:34 +0200)
committerChristian Brauner <brauner@kernel.org>
Sat, 28 Oct 2023 11:29:18 +0000 (13:29 +0200)
Convert dasd to use bdev_open_by_path() and pass the handle around.

CC: linux-s390@vger.kernel.org
CC: Christian Borntraeger <borntraeger@linux.ibm.com>
CC: Sven Schnelle <svens@linux.ibm.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Acked-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20230927093442.25915-14-jack@suse.cz
Signed-off-by: Christian Brauner <brauner@kernel.org>
drivers/s390/block/dasd.c
drivers/s390/block/dasd_genhd.c
drivers/s390/block/dasd_int.h
drivers/s390/block/dasd_ioctl.c

index 215597f73be4f336e8723010fa4893537b0a0e93..d440319a7945b8b772c39af354f57dee412fbc16 100644 (file)
@@ -412,7 +412,8 @@ dasd_state_ready_to_online(struct dasd_device * device)
                                        KOBJ_CHANGE);
                        return 0;
                }
-               disk_uevent(device->block->bdev->bd_disk, KOBJ_CHANGE);
+               disk_uevent(device->block->bdev_handle->bdev->bd_disk,
+                           KOBJ_CHANGE);
        }
        return 0;
 }
@@ -432,7 +433,8 @@ static int dasd_state_online_to_ready(struct dasd_device *device)
 
        device->state = DASD_STATE_READY;
        if (device->block && !(device->features & DASD_FEATURE_USERAW))
-               disk_uevent(device->block->bdev->bd_disk, KOBJ_CHANGE);
+               disk_uevent(device->block->bdev_handle->bdev->bd_disk,
+                           KOBJ_CHANGE);
        return 0;
 }
 
@@ -3590,7 +3592,7 @@ int dasd_generic_set_offline(struct ccw_device *cdev)
         * in the other openers.
         */
        if (device->block) {
-               max_count = device->block->bdev ? 0 : -1;
+               max_count = device->block->bdev_handle ? 0 : -1;
                open_count = atomic_read(&device->block->open_count);
                if (open_count > max_count) {
                        if (open_count > 0)
@@ -3636,8 +3638,8 @@ int dasd_generic_set_offline(struct ccw_device *cdev)
                 * so sync bdev first and then wait for our queues to become
                 * empty
                 */
-               if (device->block)
-                       bdev_mark_dead(device->block->bdev, false);
+               if (device->block && device->block->bdev_handle)
+                       bdev_mark_dead(device->block->bdev_handle->bdev, false);
                dasd_schedule_device_bh(device);
                rc = wait_event_interruptible(shutdown_waitq,
                                              _wait_for_empty_queues(device));
index fe5108a1b332eaa62d2a213a11a0dccd8d3c8a24..55e3abe94cde2f617f34afc1c5ad4c98234c34f9 100644 (file)
@@ -127,15 +127,15 @@ void dasd_gendisk_free(struct dasd_block *block)
  */
 int dasd_scan_partitions(struct dasd_block *block)
 {
-       struct block_device *bdev;
+       struct bdev_handle *bdev_handle;
        int rc;
 
-       bdev = blkdev_get_by_dev(disk_devt(block->gdp), BLK_OPEN_READ, NULL,
-                                NULL);
-       if (IS_ERR(bdev)) {
+       bdev_handle = bdev_open_by_dev(disk_devt(block->gdp), BLK_OPEN_READ,
+                                      NULL, NULL);
+       if (IS_ERR(bdev_handle)) {
                DBF_DEV_EVENT(DBF_ERR, block->base,
                              "scan partitions error, blkdev_get returned %ld",
-                             PTR_ERR(bdev));
+                             PTR_ERR(bdev_handle));
                return -ENODEV;
        }
 
@@ -147,16 +147,15 @@ int dasd_scan_partitions(struct dasd_block *block)
                                "scan partitions error, rc %d", rc);
 
        /*
-        * Since the matching blkdev_put call to the blkdev_get in
-        * this function is not called before dasd_destroy_partitions
-        * the offline open_count limit needs to be increased from
-        * 0 to 1. This is done by setting device->bdev (see
-        * dasd_generic_set_offline). As long as the partition
-        * detection is running no offline should be allowed. That
-        * is why the assignment to device->bdev is done AFTER
-        * the BLKRRPART ioctl.
+        * Since the matching bdev_release() call to the
+        * bdev_open_by_path() in this function is not called before
+        * dasd_destroy_partitions the offline open_count limit needs to be
+        * increased from 0 to 1. This is done by setting device->bdev_handle
+        * (see dasd_generic_set_offline). As long as the partition detection
+        * is running no offline should be allowed. That is why the assignment
+        * to block->bdev_handle is done AFTER the BLKRRPART ioctl.
         */
-       block->bdev = bdev;
+       block->bdev_handle = bdev_handle;
        return 0;
 }
 
@@ -166,21 +165,21 @@ int dasd_scan_partitions(struct dasd_block *block)
  */
 void dasd_destroy_partitions(struct dasd_block *block)
 {
-       struct block_device *bdev;
+       struct bdev_handle *bdev_handle;
 
        /*
-        * Get the bdev pointer from the device structure and clear
-        * device->bdev to lower the offline open_count limit again.
+        * Get the bdev_handle pointer from the device structure and clear
+        * device->bdev_handle to lower the offline open_count limit again.
         */
-       bdev = block->bdev;
-       block->bdev = NULL;
+       bdev_handle = block->bdev_handle;
+       block->bdev_handle = NULL;
 
-       mutex_lock(&bdev->bd_disk->open_mutex);
-       bdev_disk_changed(bdev->bd_disk, true);
-       mutex_unlock(&bdev->bd_disk->open_mutex);
+       mutex_lock(&bdev_handle->bdev->bd_disk->open_mutex);
+       bdev_disk_changed(bdev_handle->bdev->bd_disk, true);
+       mutex_unlock(&bdev_handle->bdev->bd_disk->open_mutex);
 
        /* Matching blkdev_put to the blkdev_get in dasd_scan_partitions. */
-       blkdev_put(bdev, NULL);
+       bdev_release(bdev_handle);
 }
 
 int dasd_gendisk_init(void)
index 8a4dbe9d774113836da6dc646a8f00ebac9ea910..2e663131adaf67b869796953d89bd494048aa875 100644 (file)
@@ -650,7 +650,7 @@ struct dasd_block {
        struct gendisk *gdp;
        spinlock_t request_queue_lock;
        struct blk_mq_tag_set tag_set;
-       struct block_device *bdev;
+       struct bdev_handle *bdev_handle;
        atomic_t open_count;
 
        unsigned long blocks;      /* size of volume in blocks */
index d55862605b8286b42abb0a1ea675b585e699b12b..61b9675e2a675e9dc1ec69101d8a4bc368d461c8 100644 (file)
@@ -537,7 +537,7 @@ static int __dasd_ioctl_information(struct dasd_block *block,
         * This must be hidden from user-space.
         */
        dasd_info->open_count = atomic_read(&block->open_count);
-       if (!block->bdev)
+       if (!block->bdev_handle)
                dasd_info->open_count++;
 
        /*