From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Stefan Haberland <sth@linux.ibm.com>,
Jan Hoeppner <hoeppner@linux.ibm.com>,
linux-block@vger.kernel.org, linux-s390@vger.kernel.org
Subject: [PATCH 06/10] dasd: use blk_drop_partitions instead of badly reimplementing it
Date: Tue, 14 Apr 2020 09:28:58 +0200 [thread overview]
Message-ID: <20200414072902.324936-7-hch@lst.de> (raw)
In-Reply-To: <20200414072902.324936-1-hch@lst.de>
Use the blk_drop_partitions function instead of messing around with
ioctls that get kernel pointers. For this blk_drop_partitions needs
to be exported, which it normally shouldn't - make an exception for
s390 only.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/partitions/core.c | 4 ++++
drivers/s390/block/dasd_genhd.c | 20 ++++----------------
2 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/block/partitions/core.c b/block/partitions/core.c
index deccc3fbcd37..8c5295ca8ea6 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -624,6 +624,10 @@ int blk_drop_partitions(struct block_device *bdev)
return 0;
}
+#ifdef CONFIG_S390
+/* for historic reasons in the DASD driver */
+EXPORT_SYMBOL_GPL(blk_drop_partitions);
+#endif
static bool blk_add_partition(struct gendisk *disk, struct block_device *bdev,
struct parsed_partitions *state, int p)
diff --git a/drivers/s390/block/dasd_genhd.c b/drivers/s390/block/dasd_genhd.c
index 7d079154f849..af5b0ecb8f89 100644
--- a/drivers/s390/block/dasd_genhd.c
+++ b/drivers/s390/block/dasd_genhd.c
@@ -143,9 +143,6 @@ int dasd_scan_partitions(struct dasd_block *block)
*/
void dasd_destroy_partitions(struct dasd_block *block)
{
- /* The two structs have 168/176 byte on 31/64 bit. */
- struct blkpg_partition bpart;
- struct blkpg_ioctl_arg barg;
struct block_device *bdev;
/*
@@ -155,19 +152,10 @@ void dasd_destroy_partitions(struct dasd_block *block)
bdev = block->bdev;
block->bdev = NULL;
- /*
- * See fs/partition/check.c:delete_partition
- * Can't call delete_partitions directly. Use ioctl.
- * The ioctl also does locking and invalidation.
- */
- memset(&bpart, 0, sizeof(struct blkpg_partition));
- memset(&barg, 0, sizeof(struct blkpg_ioctl_arg));
- barg.data = (void __force __user *) &bpart;
- barg.op = BLKPG_DEL_PARTITION;
- for (bpart.pno = block->gdp->minors - 1; bpart.pno > 0; bpart.pno--)
- ioctl_by_bdev(bdev, BLKPG, (unsigned long) &barg);
-
- invalidate_partition(block->gdp, 0);
+ mutex_lock(&bdev->bd_mutex);
+ blk_drop_partitions(bdev);
+ mutex_unlock(&bdev->bd_mutex);
+
/* Matching blkdev_put to the blkdev_get in dasd_scan_partitions. */
blkdev_put(bdev, FMODE_READ);
set_capacity(block->gdp, 0);
--
2.25.1
next prev parent reply other threads:[~2020-04-14 7:29 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-14 7:28 more partition handling cleanups v2 Christoph Hellwig
2020-04-14 7:28 ` [PATCH 01/10] block: refactor blkpg_ioctl Christoph Hellwig
2020-04-14 8:09 ` Johannes Thumshirn
2020-04-14 7:28 ` [PATCH 02/10] block: pass a hd_struct to delete_partition Christoph Hellwig
2020-04-14 7:28 ` [PATCH 03/10] block: cleanup hd_struct freeing Christoph Hellwig
2020-04-14 7:28 ` [PATCH 04/10] block: remove hd_struct_kill Christoph Hellwig
2020-04-14 7:28 ` [PATCH 05/10] block: remove the disk argument from blk_drop_partitions Christoph Hellwig
2020-04-14 7:28 ` Christoph Hellwig [this message]
2020-04-14 7:28 ` [PATCH 07/10] block: don't call invalidate_partition " Christoph Hellwig
2020-04-14 8:12 ` Johannes Thumshirn
2020-04-14 7:29 ` [PATCH 08/10] block: simplify block device syncing in bdev_del_partition Christoph Hellwig
2020-04-14 7:29 ` [PATCH 09/10] block: mark invalidate_partition static Christoph Hellwig
2020-04-14 7:29 ` [PATCH 10/10] block: fold bdev_unhash_inode into invalidate_partition Christoph Hellwig
2020-04-20 17:26 ` more partition handling cleanups v2 Christoph Hellwig
2020-04-20 17:35 ` Jens Axboe
-- strict thread matches above, loose matches on Subject: below --
2020-04-08 19:44 Christoph Hellwig
2020-04-08 19:44 ` [PATCH 06/10] dasd: use blk_drop_partitions instead of badly reimplementing it Christoph Hellwig
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=20200414072902.324936-7-hch@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=hoeppner@linux.ibm.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=sth@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox