From patchwork Wed Jan 3 12:55:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13510024 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 B651419465; Wed, 3 Jan 2024 12:55:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YVaLnsEf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EEF00C433CB; Wed, 3 Jan 2024 12:55:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704286532; bh=L1B+sEXRETIx3ANuEWFkg77MUvIZc1j2UlM5lbdWQt8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=YVaLnsEfZjcAWDZHX2QkgEjc11sr64xbacMRlSMH8MrpdFxdgmi482Yf2/POihtu9 p/xzWp3sulgX5j0u89WN3g+VuGBmjvgbtYr1ZtIQWmjH1DYOooMzuONSs9lhrZYKv0 7I8oX8okMZLcQvHpTI1DOqIz6xg1ag2oHn3sMQ9SXaf/+oMGCTWzXcxwyAP7nRyK+7 D26IPfoN9NhPP07D1DDzMCUknEjD273gK0Uq7S8R8sIqpFB16ZbGfVlv2+FMIEOgip ILkMI7uGPpwB5E3py+ygrYue8ZeC7W5pyCyTs0I0u7X4wQxydirL3/tD92VVEWrrGJ muOjgZ6ma3Zgw== From: Christian Brauner Date: Wed, 03 Jan 2024 13:55:00 +0100 Subject: [PATCH RFC 02/34] block/ioctl: port blkdev_bszset() to file Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240103-vfs-bdev-file-v1-2-6c8ee55fb6ef@kernel.org> References: <20240103-vfs-bdev-file-v1-0-6c8ee55fb6ef@kernel.org> In-Reply-To: <20240103-vfs-bdev-file-v1-0-6c8ee55fb6ef@kernel.org> To: Jan Kara , Christoph Hellwig , Jens Axboe Cc: "Darrick J. Wong" , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, Christian Brauner X-Mailer: b4 0.13-dev-4e032 X-Developer-Signature: v=1; a=openpgp-sha256; l=972; i=brauner@kernel.org; h=from:subject:message-id; bh=L1B+sEXRETIx3ANuEWFkg77MUvIZc1j2UlM5lbdWQt8=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaROjbTWn3Bqj9DrX462r0x+PXS7XKfnIf2i6aW4YIHC4 VXNlnFfOkpZGMS4GGTFFFkc2k3C5ZbzVGw2ytSAmcPKBDKEgYtTACaixcDw383nYcvBy7Lpyo8j E9i9bXiOxnLkfF4uu5X99bsEs48uzgz/gx5viLRqzonetUgmZOk8We/LT8rMXr3M9J2bK/Dq4Nc 9zAA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Signed-off-by: Christian Brauner --- block/ioctl.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/block/ioctl.c b/block/ioctl.c index 4160f4e6bd5b..d04641fe541c 100644 --- a/block/ioctl.c +++ b/block/ioctl.c @@ -468,7 +468,7 @@ static int blkdev_bszset(struct block_device *bdev, blk_mode_t mode, int __user *argp) { int ret, n; - struct bdev_handle *handle; + struct file *file; if (!capable(CAP_SYS_ADMIN)) return -EACCES; @@ -480,12 +480,11 @@ static int blkdev_bszset(struct block_device *bdev, blk_mode_t mode, if (mode & BLK_OPEN_EXCL) return set_blocksize(bdev, n); - handle = bdev_open_by_dev(bdev->bd_dev, mode, &bdev, NULL); - if (IS_ERR(handle)) + file = bdev_file_open_by_dev(bdev->bd_dev, mode, &bdev, NULL); + if (IS_ERR(file)) return -EBUSY; ret = set_blocksize(bdev, n); - bdev_release(handle); - + fput(file); return ret; }