Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2575988lqp; Mon, 25 Mar 2024 03:14:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXtJbfYBRCWd/3PjIMWN1u1GHASUp88jy0hV765PR8eKimS0tZB4I0fyicYwJRMypTOnAOdvNO6pkfHyzEzuVlfbFOCegWv9tIvLOl0Nw== X-Google-Smtp-Source: AGHT+IGXXehGIQfx9UE9lMdP5OCycOYoaj0n8510ITMjguN816XzZoUacUJUtmctX44jjBbtuas9 X-Received: by 2002:a05:6a00:14c7:b0:6e6:e587:4859 with SMTP id w7-20020a056a0014c700b006e6e5874859mr7463524pfu.14.1711361652089; Mon, 25 Mar 2024 03:14:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711361652; cv=pass; d=google.com; s=arc-20160816; b=rZhuHHnDhU6O81NlQsVGVRF96XJC0altth0LR/iwSR4a58ul/EzAoe2q1v06yeAsv7 Wzg+wopfIgrD7erOUqTeZrwV7j+izm+lXULnQjyxtWwh39dd2yeiQsB0SjR1FmiR/2ok /iOdwFn7qHhiBPjHLhUflHv/h+VLIU22aSrcng4jQzZ6op0VpZMyCNTgZaz7oqDNcBbo auBWfeEgpD5i7qOKDILdqgROLLagdrPo/CazhIhKoIXExTng9+J5Xq73CxFtB0sGaPzi rJ6UBlHyFS/B4URiaBXPt5A1tTQTvBCF2ZHpzxEROdamZFzj3mT406pkhl32ZQtC11tG piag== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=G8QIrmiT6gdQRueKM8OE3CRoQKpaP9SYE6BrsZ9BdvQ=; fh=H6IwHjyFKPSQwJBGdA4WdAbhECFrPZtYOVvoxAMT13s=; b=cCwVDMN8xHb4O686I5B8irA+lGFc31uG1G+AkzG7RmyzhyaSnOcmFcs7Bh9NMpqo4B RfXeJ0iVmcXbSNp5ylJfjfG+NjISbYfta65+bPZKKjbkz+c0V26G053cvONoahMZrU/i GUpLCxDBddzBXVwoEapSZCm/nq74DPl/l5ReNMumb7HICtuvt2R4PZ8BCK1z6YtIsf/g wENeX4MV/qgrmrcIVzXr+ZFAoLwelsaBHyGF/fLVfFe31ERGc0z7N4tAn/fuJmzcATP+ tcj1k8YWHneGt5xHfvT988LCXwVTrQZea99cmRaaQCMw8w10PLFQnVQtPfuvO+V0MQPe y4Sw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AdyeCg25; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116126-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116126-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id m6-20020a637106000000b005dcbba4b76csi7215466pgc.331.2024.03.25.03.14.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 03:14:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-116126-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AdyeCg25; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116126-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116126-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 55531B3C628 for ; Mon, 25 Mar 2024 08:33:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5206A3AD1B8; Mon, 25 Mar 2024 03:31:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AdyeCg25" 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 BCBFE17A39D; Sun, 24 Mar 2024 23:41:00 +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=1711323660; cv=none; b=iguVXZRgKB+xQyi1t0qpgscAXUIp/PMYx4EGTzRb+mnuq3vb2semPduwERaIm66ca1U/tfN+DnlrSL7a7jybXZUjc6jBAoBZwTd1ed1hZbMYrG+hPeIi6B+Jd2L7ZwXG9KAFunn5wgJD9dhwy7xwYCShhIaNL1zv6R5MdQ6KNtY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711323660; c=relaxed/simple; bh=EvF6yk0rVIb8AReax+xdLMBHydsrlD1ehkezoEOOnWA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eiLoL/OSXh7vD3IpnRXhdVZviQSK5hDzZhYUo+LXIB+x8X81eKk3jekfeuMDdIewIAbERh34bvsfEoeDAmKS4efa3bnb1I/IUvVTuRCboST4mMd0yUtGKaYh9WTdwmwmM0ohVv6JrdMcXXJODvC0pPorvSCvobH0OpL8Z+R4C6c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AdyeCg25; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1A27C433B2; Sun, 24 Mar 2024 23:40:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711323660; bh=EvF6yk0rVIb8AReax+xdLMBHydsrlD1ehkezoEOOnWA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AdyeCg25p2rL5CKYilX8cdFD5P/8DR5BdPkB1zLnBrvrDfQiM86qTR96bvgjV/A0i 0SieehzSoBvfnj9gwG36oLddjWK/SGG67OCAER5dvOPqHQq7SSXJai10YhcGA72Buv A2zqbCiEuoMJhMnUk/OHxSIbgf9XSmmjYVYBaLZxYsZCoRpn9IciHV0Ht3xF8nk3M5 EdmuJwmkq8wUZAm5EFmEbsklkie+serjO1aWxy+jPkcSkEkoyl2Ywknlmyl97Dt1zQ lcBOtoOhDXF/skYlp79AgAIvEp6kNDtpxmutx7rCy8Ncxm4ENS5jIQcOTsuHdr7CSG M2CgPosJp+puQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Christoph Hellwig , Jens Axboe , Sasha Levin Subject: [PATCH 5.10 032/238] block: add a new set_read_only method Date: Sun, 24 Mar 2024 19:37:00 -0400 Message-ID: <20240324234027.1354210-33-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324234027.1354210-1-sashal@kernel.org> References: <20240324234027.1354210-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: 8bit 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 about 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 e7eed7dadb5cf..24f8042f12b60 100644 --- a/block/ioctl.c +++ b/block/ioctl.c @@ -405,6 +405,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 98fdf5a31fd66..583824f111079 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1883,6 +1883,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.43.0