From nobody Fri Dec 19 20:11:17 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD2AD291B76; Sun, 24 Mar 2024 23:50:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711324240; cv=none; b=qqNJHC5N0DKPAfdLmJYcRkRkyye47R2OVuhnuuH8kRsSR4HgGfxX8M9QWTNY8A2nZTIuBWhapq3Yn79Knn6JVPOK5JQaaMSh7TIhKWJL9Fgue6vrUuvUzXNMubdQjRvoQmGrwbv7QtjeaoHrkjK+dj+uWNGNTYPfldQEjIBtons= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711324240; c=relaxed/simple; bh=M5YgR7dp89qvG5/MBGCVJI1h4SHXDq4czn6ZSPk3NT4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L0bF4ASScNL4jN3yoWcepPm2ynBxybkNJa6VfDi7Vyz5qxqa+W5XKAWLeGIHtuWxjKM8ym3U+U7L7cNxUlKZaKo8TKIXvtRykz+z3vhCzyjLBniV71IucAlW+zRWxFpP37WhJA/3ZIgjBAnOZuGzZuM42qd05LHSNaDqAVy+2V4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=q3kDPozZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="q3kDPozZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4584C433C7; Sun, 24 Mar 2024 23:50:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711324238; bh=M5YgR7dp89qvG5/MBGCVJI1h4SHXDq4czn6ZSPk3NT4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q3kDPozZOAEILnXDZF9VvnoSotmHR28PBVIdCy0pynr/qHf9kLh+PM4dRvGddQ9x3 Hi2HCL08f3Mv8JUjlevKDyT0foTNmTv3TSy03NF5UC8xGffSbI/wO7KSa1ilBrHJlE ZOLIDeFTl7p/LBBphgaPegc/y6LG1vjp25xuQPXQGpIl4VREJ5n0zEUeGy9dBoBF6L W1XfjXmdeeg9WaSPQqXuMRbkNMCzkIrmH39HmHOa0SKup4/mx9Ni40cyWji4+UuBgK TEj6r8OsW5LIUX0nqvHZ97dNYzELDjncUrPHr+/WJInom9mbUKn4UgrosmqZCQzz+G seiT5igIIiDVQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Christoph Hellwig , Jens Axboe , Sasha Levin Subject: [PATCH 4.19 021/148] block: add a new set_read_only method Date: Sun, 24 Mar 2024 19:48:05 -0400 Message-ID: <20240324235012.1356413-22-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324235012.1356413-1-sashal@kernel.org> References: <20240324235012.1356413-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Christoph Hellwig [ Upstream commit e00adcadf3af7a8335026d71ab9f0e0a922191ac ] Add a new method to allow for driver-specific processing when setting or clearing the block device read-only state. This allows to replace the cumbersome and error-prone override of the whole ioctl implementation. Signed-off-by: Christoph Hellwig Signed-off-by: Jens Axboe Stable-dep-of: 9674f54e41ff ("md: Don't clear MD_CLOSING when the raid is a= bout to stop") Signed-off-by: Sasha Levin --- 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 3884d810efd27..6d6c4f4c411a6 100644 --- a/block/ioctl.c +++ b/block/ioctl.c @@ -451,6 +451,11 @@ static int blkdev_roset(struct block_device *bdev, fmo= de_t mode, return ret; if (get_user(n, (int __user *)arg)) return -EFAULT; + if (bdev->bd_disk->fops->set_read_only) { + ret =3D 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 ac407c1d4d40f..8f0aafae09d97 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1997,6 +1997,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); struct module *owner; --=20 2.43.0