All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Christian Brauner <brauner@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>, <linux-fsdevel@vger.kernel.org>,
	<linux-block@vger.kernel.org>,
	Christoph Hellwig <hch@infradead.org>, Jan Kara <jack@suse.cz>,
	linux-s390@vger.kernel.org,
	Christian Borntraeger <borntraeger@linux.ibm.com>,
	Sven Schnelle <svens@linux.ibm.com>,
	Christoph Hellwig <hch@lst.de>
Subject: [PATCH 14/29] s390/dasd: Convert to bdev_open_by_path()
Date: Wed, 23 Aug 2023 12:48:25 +0200	[thread overview]
Message-ID: <20230823104857.11437-14-jack@suse.cz> (raw)
In-Reply-To: <20230818123232.2269-1-jack@suse.cz>

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>
Signed-off-by: Jan Kara <jack@suse.cz>
---
 drivers/s390/block/dasd.c       | 12 +++++----
 drivers/s390/block/dasd_genhd.c | 45 ++++++++++++++++-----------------
 drivers/s390/block/dasd_int.h   |  2 +-
 drivers/s390/block/dasd_ioctl.c |  2 +-
 4 files changed, 31 insertions(+), 30 deletions(-)

diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 215597f73be4..16a2d631a169 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -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));
diff --git a/drivers/s390/block/dasd_genhd.c b/drivers/s390/block/dasd_genhd.c
index fe5108a1b332..55e3abe94cde 100644
--- a/drivers/s390/block/dasd_genhd.c
+++ b/drivers/s390/block/dasd_genhd.c
@@ -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)
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index 0aa56351da72..73c5eb0ae6ad 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -646,7 +646,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 */
diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c
index d55862605b82..61b9675e2a67 100644
--- a/drivers/s390/block/dasd_ioctl.c
+++ b/drivers/s390/block/dasd_ioctl.c
@@ -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++;
 
 	/*
-- 
2.35.3


  parent reply	other threads:[~2023-08-23 10:50 UTC|newest]

Thread overview: 166+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-23 10:48 [PATCH v3 0/29] block: Make blkdev_get_by_*() return handle Jan Kara
2023-09-27  9:34 ` [dm-devel] [PATCH v4 " Jan Kara
2023-09-27  9:34 ` Jan Kara
2023-09-27  9:34 ` Jan Kara
2023-09-27  9:34 ` [f2fs-dev] " Jan Kara
2023-09-27  9:34 ` Jan Kara
2023-08-23 10:48 ` [PATCH v3 " Jan Kara
2023-08-23 10:48 ` [dm-devel] " Jan Kara
2023-08-23 10:48 ` Jan Kara
2023-08-23 10:48 ` Jan Kara
2023-08-23 10:48 ` [f2fs-dev] " Jan Kara
2023-08-23 10:48 ` [PATCH 01/29] block: Provide bdev_open_* functions Jan Kara
2023-08-25 11:44   ` Christian Brauner
2023-08-23 10:48 ` [PATCH 02/29] block: Use bdev_open_by_dev() in blkdev_open() Jan Kara
2023-08-25  2:28   ` Al Viro
2023-08-25  9:45     ` Jan Kara
2023-08-25 13:29       ` Christian Brauner
2023-08-28 16:46         ` Jan Kara
2023-08-29 11:03           ` Christian Brauner
2023-08-23 10:48 ` [PATCH 03/29] block: Use bdev_open_by_dev() in disk_scan_partitions() and blkdev_bszset() Jan Kara
2023-08-25 11:45   ` Christian Brauner
2023-08-23 10:48 ` [PATCH 04/29] drdb: Convert to use bdev_open_by_path() Jan Kara
2023-08-25 11:47   ` Christian Brauner
2023-08-23 10:48 ` [PATCH 05/29] pktcdvd: Convert to bdev_open_by_dev() Jan Kara
2023-08-25 11:53   ` Christian Brauner
2023-08-23 10:48 ` [PATCH 06/29] rnbd-srv: Convert to use bdev_open_by_path() Jan Kara
2023-08-25 11:55   ` Christian Brauner
2023-08-23 10:48 ` [PATCH 07/29] xen/blkback: Convert to bdev_open_by_dev() Jan Kara
2023-08-25 11:56   ` Christian Brauner
2023-08-23 10:48 ` [PATCH 08/29] zram: Convert to use bdev_open_by_dev() Jan Kara
2023-08-25 11:57   ` Christian Brauner
2023-08-23 10:48 ` [PATCH 09/29] bcache: Convert to bdev_open_by_path() Jan Kara
2023-08-25 12:06   ` Christian Brauner
2023-08-23 10:48 ` [PATCH 10/29] dm: Convert to bdev_open_by_dev() Jan Kara
2023-08-23 10:48   ` [dm-devel] " Jan Kara
2023-08-25 12:08   ` Christian Brauner
2023-08-25 12:08     ` [dm-devel] " Christian Brauner
2023-08-23 10:48 ` [PATCH 11/29] md: " Jan Kara
2023-08-25 12:09   ` Christian Brauner
2023-08-23 10:48 ` [PATCH 12/29] mtd: block2mtd: Convert to bdev_open_by_dev/path() Jan Kara
2023-08-23 10:48   ` Jan Kara
2023-08-25 12:11   ` Christian Brauner
2023-08-25 12:11     ` Christian Brauner
2023-08-23 10:48 ` [PATCH 13/29] nvmet: Convert to bdev_open_by_path() Jan Kara
2023-08-23 19:36   ` Chaitanya Kulkarni
2023-08-25 12:12   ` Christian Brauner
2023-08-23 10:48 ` Jan Kara [this message]
2023-08-25 12:14   ` [PATCH 14/29] s390/dasd: " Christian Brauner
2023-09-27 21:43   ` Stefan Haberland
2023-10-02 11:24     ` Jan Kara
2023-08-23 10:48 ` [PATCH 15/29] scsi: target: " Jan Kara
2023-08-25 12:15   ` Christian Brauner
2023-08-23 10:48 ` [PATCH 16/29] PM: hibernate: Convert to bdev_open_by_dev() Jan Kara
2023-08-25 12:17   ` Christian Brauner
2023-08-23 10:48 ` [PATCH 17/29] PM: hibernate: Drop unused snapshot_test argument Jan Kara
2023-08-25 12:18   ` Christian Brauner
2023-08-23 10:48 ` [PATCH 18/29] mm/swap: Convert to use bdev_open_by_dev() Jan Kara
2023-08-25 12:19   ` Christian Brauner
2023-08-23 10:48 ` [PATCH 19/29] fs: Convert to bdev_open_by_dev() Jan Kara
2023-08-25 12:20   ` Christian Brauner
2023-08-23 10:48 ` [PATCH 20/29] btrfs: Convert to bdev_open_by_path() Jan Kara
2023-08-25 12:26   ` Christian Brauner
2023-08-23 10:48 ` [PATCH 21/29] erofs: Convert to use bdev_open_by_path() Jan Kara
2023-08-23 10:48   ` Jan Kara
2023-08-25 12:27   ` Christian Brauner
2023-08-25 12:27     ` Christian Brauner
2023-08-23 10:48 ` [PATCH 22/29] ext4: Convert to bdev_open_by_dev() Jan Kara
2023-08-25 12:29   ` Christian Brauner
2023-08-23 10:48 ` [f2fs-dev] [PATCH 23/29] f2fs: Convert to bdev_open_by_dev/path() Jan Kara
2023-08-23 10:48   ` Jan Kara
2023-08-25 12:30   ` [f2fs-dev] " Christian Brauner
2023-08-25 12:30     ` Christian Brauner
2023-08-28 12:57   ` [f2fs-dev] " Chao Yu
2023-08-28 12:57     ` Chao Yu
2023-08-28 16:35     ` [f2fs-dev] " Jan Kara
2023-08-28 16:35       ` Jan Kara
2023-08-23 10:48 ` [PATCH 24/29] jfs: Convert to bdev_open_by_dev() Jan Kara
2023-08-25 12:31   ` Christian Brauner
2023-08-23 10:48 ` [PATCH 25/29] nfs/blocklayout: Convert to use bdev_open_by_dev/path() Jan Kara
2023-08-25 12:33   ` Christian Brauner
2023-08-23 10:48 ` [PATCH 26/29] ocfs2: Convert to use bdev_open_by_dev() Jan Kara
2023-08-25 12:34   ` Christian Brauner
2023-08-23 10:48 ` [PATCH 27/29] reiserfs: Convert to bdev_open_by_dev/path() Jan Kara
2023-08-23 10:48   ` Jan Kara
2023-08-25 12:35   ` Christian Brauner
2023-08-23 10:48 ` [PATCH 28/29] xfs: Convert to bdev_open_by_path() Jan Kara
2023-08-23 22:11   ` Dave Chinner
2023-08-24 10:28     ` Jan Kara
2023-08-24 20:29       ` Jan Kara
2023-08-24 23:06         ` Dave Chinner
2023-08-25 12:38         ` Christian Brauner
2023-08-23 10:48 ` [PATCH 29/29] block: Remove blkdev_get_by_*() functions Jan Kara
2023-08-25 12:42   ` Christian Brauner
2023-08-25 13:32 ` [PATCH v3 0/29] block: Make blkdev_get_by_*() return handle Christian Brauner
2023-08-25 13:32   ` Christian Brauner
2023-08-25 13:32   ` Christian Brauner
2023-08-25 13:32   ` [dm-devel] " Christian Brauner
2023-08-25 13:32   ` Christian Brauner
2023-08-25 13:32   ` [f2fs-dev] " Christian Brauner
2023-08-28 17:07   ` Jan Kara
2023-08-28 17:07     ` Jan Kara
2023-08-28 17:07     ` [dm-devel] " Jan Kara
2023-08-28 17:07     ` Jan Kara
2023-08-28 17:07     ` Jan Kara
2023-08-28 17:07     ` [f2fs-dev] " Jan Kara
2023-08-29 11:02     ` Christian Brauner
2023-08-29 11:02       ` Christian Brauner
2023-08-29 11:02       ` [dm-devel] " Christian Brauner
2023-08-29 11:02       ` Christian Brauner
2023-08-29 11:02       ` Christian Brauner
2023-08-29 11:02       ` [f2fs-dev] " Christian Brauner
2023-09-27  9:34 ` [PATCH 01/29] block: Provide bdev_open_* functions Jan Kara
2023-09-27  9:34 ` [PATCH 02/29] block: Use bdev_open_by_dev() in blkdev_open() Jan Kara
2023-09-27  9:34 ` [PATCH 03/29] block: Use bdev_open_by_dev() in disk_scan_partitions() and blkdev_bszset() Jan Kara
2023-09-27  9:34 ` [PATCH 04/29] drdb: Convert to use bdev_open_by_path() Jan Kara
2023-09-27  9:34 ` [PATCH 05/29] pktcdvd: Convert to bdev_open_by_dev() Jan Kara
2023-09-27  9:34 ` [PATCH 06/29] rnbd-srv: Convert to use bdev_open_by_path() Jan Kara
2023-09-27  9:34 ` [PATCH 07/29] xen/blkback: Convert to bdev_open_by_dev() Jan Kara
2023-09-27  9:34 ` [PATCH 08/29] zram: Convert to use bdev_open_by_dev() Jan Kara
2023-09-27  9:34 ` [PATCH 09/29] bcache: Convert to bdev_open_by_path() Jan Kara
2023-09-27  9:34 ` [PATCH 10/29] dm: Convert to bdev_open_by_dev() Jan Kara
2023-09-27  9:34   ` [dm-devel] " Jan Kara
2023-09-27  9:34 ` [PATCH 11/29] md: " Jan Kara
2023-09-27  9:34 ` [PATCH 12/29] mtd: block2mtd: Convert to bdev_open_by_dev/path() Jan Kara
2023-09-27  9:34   ` Jan Kara
2023-09-27  9:34 ` [PATCH 13/29] nvmet: Convert to bdev_open_by_path() Jan Kara
2023-09-27  9:34 ` [PATCH 14/29] s390/dasd: " Jan Kara
2023-09-27  9:34 ` [PATCH 15/29] scsi: target: " Jan Kara
2023-09-27 15:36   ` Martin K. Petersen
2023-09-27  9:34 ` [PATCH 16/29] PM: hibernate: Convert to bdev_open_by_dev() Jan Kara
2023-09-27  9:34 ` [PATCH 17/29] PM: hibernate: Drop unused snapshot_test argument Jan Kara
2023-09-27  9:34 ` [PATCH 18/29] mm/swap: Convert to use bdev_open_by_dev() Jan Kara
2023-09-27  9:34 ` [PATCH 19/29] fs: Convert to bdev_open_by_dev() Jan Kara
2023-09-27  9:34 ` [PATCH 20/29] btrfs: Convert to bdev_open_by_path() Jan Kara
2023-09-27  9:34 ` [PATCH 21/29] erofs: Convert to use bdev_open_by_path() Jan Kara
2023-09-27  9:34   ` Jan Kara
2023-09-27  9:34 ` [PATCH 22/29] ext4: Convert to bdev_open_by_dev() Jan Kara
2023-09-27  9:34 ` [PATCH 23/29] f2fs: Convert to bdev_open_by_dev/path() Jan Kara
2023-09-27  9:34   ` [f2fs-dev] " Jan Kara
2023-09-27  9:34 ` [PATCH 24/29] jfs: Convert to bdev_open_by_dev() Jan Kara
2023-09-27  9:34 ` [PATCH 25/29] nfs/blocklayout: Convert to use bdev_open_by_dev/path() Jan Kara
2023-09-27  9:34 ` [PATCH 26/29] ocfs2: Convert to use bdev_open_by_dev() Jan Kara
2023-09-27  9:34 ` [PATCH 27/29] reiserfs: Convert to bdev_open_by_dev/path() Jan Kara
2023-09-27  9:34   ` Jan Kara
2023-09-27  9:34 ` [PATCH 28/29] xfs: Convert to bdev_open_by_path() Jan Kara
2023-09-27 15:40   ` Darrick J. Wong
2023-09-27  9:34 ` [PATCH 29/29] block: Remove blkdev_get_by_*() functions Jan Kara
2023-09-27 14:19 ` [PATCH v4 0/29] block: Make blkdev_get_by_*() return handle Jens Axboe
2023-09-27 14:19   ` Jens Axboe
2023-09-27 14:19   ` Jens Axboe
2023-09-27 14:19   ` [dm-devel] " Jens Axboe
2023-09-27 14:19   ` Jens Axboe
2023-09-27 14:19   ` [f2fs-dev] " Jens Axboe
2023-09-27 16:21 ` Christian Brauner
2023-09-27 16:21   ` Christian Brauner
2023-09-27 16:21   ` Christian Brauner
2023-09-27 16:21   ` [dm-devel] " Christian Brauner
2023-09-27 16:21   ` Christian Brauner
2023-09-27 16:21   ` [f2fs-dev] " Christian Brauner
2023-10-02  7:57   ` Jan Kara
2023-10-02  7:57     ` Jan Kara
2023-10-02  7:57     ` [dm-devel] " Jan Kara
2023-10-02  7:57     ` Jan Kara
2023-10-02  7:57     ` Jan Kara
2023-10-02  7:57     ` [f2fs-dev] " Jan Kara
  -- strict thread matches above, loose matches on Subject: below --
2023-08-11 11:04 [PATCH v2 " Jan Kara
2023-08-11 11:04 ` [PATCH 14/29] s390/dasd: Convert to bdev_open_by_path() Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230823104857.11437-14-jack@suse.cz \
    --to=jack@suse.cz \
    --cc=axboe@kernel.dk \
    --cc=borntraeger@linux.ibm.com \
    --cc=brauner@kernel.org \
    --cc=hch@infradead.org \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=svens@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.