linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-raid@vger.kernel.org, Jan Hoeppner <hoeppner@linux.ibm.com>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	linux-s390@vger.kernel.org, Richard Weinberger <richard@nod.at>,
	linux-block@vger.kernel.org, Song Liu <song@kernel.org>,
	linux-bcache@vger.kernel.org, linux-mtd@lists.infradead.org,
	Stefan Haberland <sth@linux.ibm.com>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Ilya Dryomov <idryomov@gmail.com>,
	ceph-devel@vger.kernel.org
Subject: [PATCH 04/11] block: add a new set_read_only method
Date: Sat, 31 Oct 2020 09:58:03 +0100	[thread overview]
Message-ID: <20201031085810.450489-5-hch@lst.de> (raw)
In-Reply-To: <20201031085810.450489-1-hch@lst.de>

Add a new method to allow driver-specific callout when setting or
clearing the block device read-only state.  This allow to replace the
cumbersome and error prone override of the whole ioctl implementation.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/ioctl.c          | 5 +++++
 include/linux/blkdev.h | 1 +
 2 files changed, 6 insertions(+)

diff --git a/block/ioctl.c b/block/ioctl.c
index c6d8863f040945..a6fa16b9770593 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -389,6 +389,11 @@ static int blkdev_roset(struct block_device *bdev, fmode_t mode,
 		return ret;
 	if (get_user(n, (int __user *)arg))
 		return -EFAULT;
+	if (bdev->bd_disk->fops->set_read_only) {
+		ret = bdev->bd_disk->fops->set_read_only(bdev, n);
+		if (ret)
+			return ret;
+	}
 	set_device_ro(bdev, n);
 	return 0;
 }
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 639cae2c158b59..5c1ba8a8d2bc7e 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1850,6 +1850,7 @@ struct block_device_operations {
 	void (*unlock_native_capacity) (struct gendisk *);
 	int (*revalidate_disk) (struct gendisk *);
 	int (*getgeo)(struct block_device *, struct hd_geometry *);
+	int (*set_read_only)(struct block_device *bdev, bool ro);
 	/* this callback is with swap_lock and sometimes page table lock held */
 	void (*swap_slot_free_notify) (struct block_device *, unsigned long);
 	int (*report_zones)(struct gendisk *, sector_t sector,
-- 
2.28.0


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  parent reply	other threads:[~2020-10-31  9:10 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-31  8:57 block ioctl cleanups Christoph Hellwig
2020-10-31  8:58 ` [PATCH 01/11] mtd_blkdevs: don't override BLKFLSBUF Christoph Hellwig
2020-10-31 21:32   ` Richard Weinberger
2020-10-31 23:11   ` antlists
2020-10-31  8:58 ` [PATCH 02/11] mtip32xx: return -ENOTTY for all unhanled ioctls Christoph Hellwig
2020-10-31 14:58   ` Jens Axboe
2020-11-01 10:27     ` Christoph Hellwig
2020-11-01 16:45       ` Jens Axboe
2020-10-31  8:58 ` [PATCH 03/11] block: don't call into the driver for BLKFLSBUF Christoph Hellwig
2020-10-31  8:58 ` Christoph Hellwig [this message]
2020-10-31  8:58 ` [PATCH 05/11] rbd: implement ->set_read_only to hook into BLKROSET processing Christoph Hellwig
2020-11-02 11:30   ` Ilya Dryomov
2020-10-31  8:58 ` [PATCH 06/11] md: " Christoph Hellwig
2020-11-03  0:19   ` James Troup
2020-11-03  9:32     ` Christoph Hellwig
2020-10-31  8:58 ` [PATCH 07/11] dasd: " Christoph Hellwig
2020-10-31  8:58 ` [PATCH 08/11] block: don't call into the driver for BLKROSET Christoph Hellwig
2020-10-31  8:58 ` [PATCH 09/11] loop: use set_disk_ro Christoph Hellwig
2020-10-31  8:58 ` [PATCH 10/11] block: remove set_device_ro Christoph Hellwig
2020-10-31  8:58 ` [PATCH 11/11] block: remove __blkdev_driver_ioctl Christoph Hellwig
2020-11-01 16:46 ` block ioctl cleanups Jens Axboe

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=20201031085810.450489-5-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=ceph-devel@vger.kernel.org \
    --cc=hoeppner@linux.ibm.com \
    --cc=idryomov@gmail.com \
    --cc=linux-bcache@vger.kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=song@kernel.org \
    --cc=sth@linux.ibm.com \
    --cc=vigneshr@ti.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;
as well as URLs for NNTP newsgroup(s).