From patchwork Sat Oct 31 08:58:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 314208 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81326C4741F for ; Sat, 31 Oct 2020 09:04:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3FC9A20756 for ; Sat, 31 Oct 2020 09:04:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Ym5ZpzHK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726514AbgJaJEx (ORCPT ); Sat, 31 Oct 2020 05:04:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726435AbgJaJEx (ORCPT ); Sat, 31 Oct 2020 05:04:53 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC892C0613D5; Sat, 31 Oct 2020 02:04:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=ccFP0prAIqmawhHUijWCb+7+0K8IzQR5e/dvexyFO7w=; b=Ym5ZpzHKJJlJDCRVypUAPGA7II 66cevz7I1EwaypqqFcVa4mhtzXPSi14G+BSzgrfzXjomstRfmzNHCsxM5hd29idZSqhKB1/O4HyWG cI6qz9Lwu++xOvn9i+X8tPtN8trZ9oJtLj76lZSWkXb3ZLGYjohpW/C91ZUiGJDWAilob25tuOxU8 wWmbGMxU1XT1LIZmT1gjKko1SC7eCo8YP6MVaFj8XbUPgjJpMHk0q7JXRlJcdwutx3Bh5cFR0nxhS jV54N+PYZt0wvKMUO99H8jx8u1/OuX1wJitqfVVZIpjpCZ/SAnQ8ifL/aOAbUP72QXrCbKu6iqTeH +dYElAMg==; Received: from 089144193201.atnat0002.highway.a1.net ([89.144.193.201] helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kYmoY-00076g-4q; Sat, 31 Oct 2020 09:04:46 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Ilya Dryomov , Song Liu , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Stefan Haberland , Jan Hoeppner , linux-block@vger.kernel.org, ceph-devel@vger.kernel.org, linux-bcache@vger.kernel.org, linux-raid@vger.kernel.org, linux-mtd@lists.infradead.org, linux-s390@vger.kernel.org Subject: [PATCH 02/11] mtip32xx: return -ENOTTY for all unhanled ioctls Date: Sat, 31 Oct 2020 09:58:01 +0100 Message-Id: <20201031085810.450489-3-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201031085810.450489-1-hch@lst.de> References: <20201031085810.450489-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org -ENOTTY is the convention for "driver does not support this ioctl". Use it properly in mtip32xx instead of the bogys -EINVAL. Signed-off-by: Christoph Hellwig --- drivers/block/mtip32xx/mtip32xx.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c index 153e2cdecb4d40..893be95eceb34e 100644 --- a/drivers/block/mtip32xx/mtip32xx.c +++ b/drivers/block/mtip32xx/mtip32xx.c @@ -2029,7 +2029,7 @@ static int mtip_hw_ioctl(struct driver_data *dd, unsigned int cmd, } default: - return -EINVAL; + return -ENOTTY; } return 0; } @@ -3215,12 +3215,7 @@ static int mtip_block_ioctl(struct block_device *dev, if (unlikely(test_bit(MTIP_DDF_REMOVE_PENDING_BIT, &dd->dd_flag))) return -ENOTTY; - switch (cmd) { - case BLKFLSBUF: - return -ENOTTY; - default: - return mtip_hw_ioctl(dd, cmd, arg); - } + return mtip_hw_ioctl(dd, cmd, arg); } #ifdef CONFIG_COMPAT @@ -3254,8 +3249,6 @@ static int mtip_block_compat_ioctl(struct block_device *dev, return -ENOTTY; switch (cmd) { - case BLKFLSBUF: - return -ENOTTY; case HDIO_DRIVE_TASKFILE: { struct mtip_compat_ide_task_request_s __user *compat_req_task; ide_task_request_t req_task; From patchwork Sat Oct 31 08:58:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 314207 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7FF53C4741F for ; Sat, 31 Oct 2020 09:09:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 414492076E for ; Sat, 31 Oct 2020 09:09:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="avUELUV3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726655AbgJaJJV (ORCPT ); Sat, 31 Oct 2020 05:09:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726633AbgJaJJQ (ORCPT ); Sat, 31 Oct 2020 05:09:16 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0783FC0613D5; Sat, 31 Oct 2020 02:09:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=OiUmdoSHZP63qL9I/2lDrMgJxBc58lxBm3D9V3Apw8o=; b=avUELUV3Di73qF3if5rpf+y2wc UB4eqvw38pSjxiNRuFHaZzRQo9mfpjHNxa7Cu2Rs4DEgJiqRzJSKCTpiMuQEXSWvalYGHIZgn0u0p 4b6fuFnrbSHSLQ+iDxiDM9FreLtjPF3fwkyAUNFbxqv9qMvVtnR2Aoj/eG60MAzL++x8kZhy+b6UJ Auu+SH+lV+FE04D6xP6N6igkb4+WRu7lU6NjilFN098ZCXIxQS/cfMBZpUIPRRoZzfzophy/wgT44 Shj7YKI2kY3CfKoN4a8HRNtcpKsG8AxKdEXRcGe5KnFT8YTC6enKGNZFM0MT9wadSzYjR1v2vKDp4 hkNVxZJA==; Received: from 089144193201.atnat0002.highway.a1.net ([89.144.193.201] helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kYmsm-0007NT-8Q; Sat, 31 Oct 2020 09:09:09 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Ilya Dryomov , Song Liu , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Stefan Haberland , Jan Hoeppner , linux-block@vger.kernel.org, ceph-devel@vger.kernel.org, linux-bcache@vger.kernel.org, linux-raid@vger.kernel.org, linux-mtd@lists.infradead.org, linux-s390@vger.kernel.org Subject: [PATCH 04/11] block: add a new set_read_only method Date: Sat, 31 Oct 2020 09:58:03 +0100 Message-Id: <20201031085810.450489-5-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201031085810.450489-1-hch@lst.de> References: <20201031085810.450489-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org 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 --- 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, From patchwork Sat Oct 31 08:58:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 314206 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2274C4741F for ; Sat, 31 Oct 2020 09:13:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7979A20756 for ; Sat, 31 Oct 2020 09:13:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="OAKSzvXD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726536AbgJaJNj (ORCPT ); Sat, 31 Oct 2020 05:13:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726487AbgJaJNj (ORCPT ); Sat, 31 Oct 2020 05:13:39 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0488BC0613D5; Sat, 31 Oct 2020 02:13:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=T4/2E4hHl2bV3QYU66vd1sTpw1p+o0kbPKiW51leCy0=; b=OAKSzvXDWNnbRc37WQsJtXnRKX QPDujXztENAqD26VipEGJrxLb013rE4wrMVMRy6YnZCgzLiKGIJmLa3aI2dSA7Am1oMbVxEwlu71p Ro1x80eO77sHvmQ0AWTuJRYuSzwdvHGuAXFnUOqVUfMZTtBEbVp4fQY5Df8cfUI5BJ4RgeApMXPuS cKpPDkiudLYwtWPx4aNcV6/fuawRpcXRy895P5CNeKToAfdjvHqyCNFF/KrsWKbVtgYHVMXFrrNR2 KkmqVJsKSEhdBGQAkeIgCvX3afYRhce8CNmnQBrdHKps+PWfArXz91tj8OQd2NjVGUMkhqostEBGT PVZIWxRA==; Received: from 089144193201.atnat0002.highway.a1.net ([89.144.193.201] helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kYmx0-0007k0-Gm; Sat, 31 Oct 2020 09:13:31 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Ilya Dryomov , Song Liu , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Stefan Haberland , Jan Hoeppner , linux-block@vger.kernel.org, ceph-devel@vger.kernel.org, linux-bcache@vger.kernel.org, linux-raid@vger.kernel.org, linux-mtd@lists.infradead.org, linux-s390@vger.kernel.org Subject: [PATCH 06/11] md: implement ->set_read_only to hook into BLKROSET processing Date: Sat, 31 Oct 2020 09:58:05 +0100 Message-Id: <20201031085810.450489-7-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201031085810.450489-1-hch@lst.de> References: <20201031085810.450489-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Implement the ->set_read_only method instead of parsing the actual ioctl command. Signed-off-by: Christoph Hellwig --- drivers/md/md.c | 62 ++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 98bac4f304ae26..8c027b81b78c0d 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -7480,7 +7480,6 @@ static inline bool md_ioctl_valid(unsigned int cmd) { switch (cmd) { case ADD_NEW_DISK: - case BLKROSET: case GET_ARRAY_INFO: case GET_BITMAP_FILE: case GET_DISK_INFO: @@ -7507,7 +7506,6 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode, int err = 0; void __user *argp = (void __user *)arg; struct mddev *mddev = NULL; - int ro; bool did_set_md_closing = false; if (!md_ioctl_valid(cmd)) @@ -7687,35 +7685,6 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode, goto unlock; } break; - - case BLKROSET: - if (get_user(ro, (int __user *)(arg))) { - err = -EFAULT; - goto unlock; - } - err = -EINVAL; - - /* if the bdev is going readonly the value of mddev->ro - * does not matter, no writes are coming - */ - if (ro) - goto unlock; - - /* are we are already prepared for writes? */ - if (mddev->ro != 1) - goto unlock; - - /* transitioning to readauto need only happen for - * arrays that call md_write_start - */ - if (mddev->pers) { - err = restart_array(mddev); - if (err == 0) { - mddev->ro = 2; - set_disk_ro(mddev->gendisk, 0); - } - } - goto unlock; } /* @@ -7809,6 +7778,36 @@ static int md_compat_ioctl(struct block_device *bdev, fmode_t mode, } #endif /* CONFIG_COMPAT */ +static int md_set_read_only(struct block_device *bdev, bool ro) +{ + struct mddev *mddev = bdev->bd_disk->private_data; + int err; + + err = mddev_lock(mddev); + if (err) + return err; + + if (!mddev->raid_disks && !mddev->external) { + err = -ENODEV; + goto out_unlock; + } + + /* + * Transitioning to readauto need only happen for arrays that call + * md_write_start and which are not ready for writes yet. + */ + if (!ro && mddev->ro == 1 && mddev->pers) { + err = restart_array(mddev); + if (err) + goto out_unlock; + mddev->ro = 2; + } + +out_unlock: + mddev_unlock(mddev); + return err; +} + static int md_open(struct block_device *bdev, fmode_t mode) { /* @@ -7886,6 +7885,7 @@ const struct block_device_operations md_fops = #endif .getgeo = md_getgeo, .check_events = md_check_events, + .set_read_only = md_set_read_only, }; static int md_thread(void *arg) From patchwork Sat Oct 31 08:58:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 314205 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1F84C4742C for ; Sat, 31 Oct 2020 09:18:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9D8E020756 for ; Sat, 31 Oct 2020 09:18:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="gsAsqe/H" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726571AbgJaJSA (ORCPT ); Sat, 31 Oct 2020 05:18:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726499AbgJaJSA (ORCPT ); Sat, 31 Oct 2020 05:18:00 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB3E8C0613D5; Sat, 31 Oct 2020 02:17:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=QiPy3Lgic6nDpUFxJOfw2mawJ5uhHq47Zrqs9uu41iQ=; b=gsAsqe/HGXmFvNBDIcqnTyqeSv /+fW7OH+gdIj4TucEQO+LoO2ozVQ+EVh7iYOD7kLiyplBB1e430DA3owtMUjzhWEGI0GX2oArMOP/ AdvpDzoM3UZUYfwicg85oLsBgjfn7bGXJrWHXfCjHSAfIVOQvReCvVgL/Afwn5SZdqoKHn+ZMpL8n 8tgIxQFnMCFvDXOLSz/5Wtye7yWjLtbi+RHFWWSX2Utw9cxWuQfgZf+T08/ZxUXdTOIu8gj5kuVbn hq+cIJdBMTO7KHleVianKloWF7X6KmM8BnNOFU+GWyYLaWHYkLjmIulGD9G3dZPNMDPOw5c/deflw T80Bh1wg==; Received: from 089144193201.atnat0002.highway.a1.net ([89.144.193.201] helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kYn1G-00080G-Kq; Sat, 31 Oct 2020 09:17:55 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Ilya Dryomov , Song Liu , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Stefan Haberland , Jan Hoeppner , linux-block@vger.kernel.org, ceph-devel@vger.kernel.org, linux-bcache@vger.kernel.org, linux-raid@vger.kernel.org, linux-mtd@lists.infradead.org, linux-s390@vger.kernel.org Subject: [PATCH 08/11] block: don't call into the driver for BLKROSET Date: Sat, 31 Oct 2020 09:58:07 +0100 Message-Id: <20201031085810.450489-9-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201031085810.450489-1-hch@lst.de> References: <20201031085810.450489-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Now that all drivers that want to hook into setting or clearing the read-only flag use the set_read_only method this code can be removed. Signed-off-by: Christoph Hellwig --- block/ioctl.c | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/block/ioctl.c b/block/ioctl.c index a6fa16b9770593..96cb4544736468 100644 --- a/block/ioctl.c +++ b/block/ioctl.c @@ -346,26 +346,6 @@ static int blkdev_pr_clear(struct block_device *bdev, return ops->pr_clear(bdev, c.key); } -/* - * Is it an unrecognized ioctl? The correct returns are either - * ENOTTY (final) or ENOIOCTLCMD ("I don't know this one, try a - * fallback"). ENOIOCTLCMD gets turned into ENOTTY by the ioctl - * code before returning. - * - * Confused drivers sometimes return EINVAL, which is wrong. It - * means "I understood the ioctl command, but the parameters to - * it were wrong". - * - * We should aim to just fix the broken drivers, the EINVAL case - * should go away. - */ -static inline int is_unrecognized_ioctl(int ret) -{ - return ret == -EINVAL || - ret == -ENOTTY || - ret == -ENOIOCTLCMD; -} - static int blkdev_flushbuf(struct block_device *bdev, fmode_t mode, unsigned cmd, unsigned long arg) { @@ -384,9 +364,6 @@ static int blkdev_roset(struct block_device *bdev, fmode_t mode, if (!capable(CAP_SYS_ADMIN)) return -EACCES; - ret = __blkdev_driver_ioctl(bdev, mode, cmd, arg); - if (!is_unrecognized_ioctl(ret)) - return ret; if (get_user(n, (int __user *)arg)) return -EFAULT; if (bdev->bd_disk->fops->set_read_only) { From patchwork Sat Oct 31 08:58:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 314204 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19141C4742C for ; Sat, 31 Oct 2020 09:22:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D2EA220756 for ; Sat, 31 Oct 2020 09:22:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="SbajBFLZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726576AbgJaJWW (ORCPT ); Sat, 31 Oct 2020 05:22:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726424AbgJaJWW (ORCPT ); Sat, 31 Oct 2020 05:22:22 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FAC5C0613D5; Sat, 31 Oct 2020 02:22:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=3MSvK9iNSy+DFtMSDiSadE/QmhEKeo+2u5OIDmRr7vM=; b=SbajBFLZzxSbqHTnfyUDYuOs9Q AlPTPMQiJMVpCj4HUo+9SAYnxuk256+8XFZq6L3QIAbl55avttLUr1mYwtiSc3wyQJbjJxqOe4XVN DarPmrRVAn0nxozPoBogGFe891rSl6V7IyXzu8wp1f/YteqWLA00iRfmtsyzrQ6zfEytVMBZvoYyY SafyPEGeBDFIK+daVu/yiKf3LyaiWMcHPfAh0aBzuxHv55ltSEk0/A1E9/g8wnFmNqsS1AWyGGIDA 7KYCHxbB3ra4Gz9MWNDrjYa8H/Yp4R+3rt1Dic5t+ctBW18UOx7BCpdNMBr8f6fdlWfTwm/dsO/Nl UQRskgqA==; Received: from 089144193201.atnat0002.highway.a1.net ([89.144.193.201] helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kYn5U-0008II-Mm; Sat, 31 Oct 2020 09:22:17 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Ilya Dryomov , Song Liu , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Stefan Haberland , Jan Hoeppner , linux-block@vger.kernel.org, ceph-devel@vger.kernel.org, linux-bcache@vger.kernel.org, linux-raid@vger.kernel.org, linux-mtd@lists.infradead.org, linux-s390@vger.kernel.org Subject: [PATCH 10/11] block: remove set_device_ro Date: Sat, 31 Oct 2020 09:58:09 +0100 Message-Id: <20201031085810.450489-11-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201031085810.450489-1-hch@lst.de> References: <20201031085810.450489-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Fold set_device_ro into its only remaining caller. Signed-off-by: Christoph Hellwig --- block/genhd.c | 7 ------- block/ioctl.c | 2 +- include/linux/genhd.h | 1 - 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/block/genhd.c b/block/genhd.c index 0a273211fec283..a487590b365e89 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -1843,13 +1843,6 @@ static void set_disk_ro_uevent(struct gendisk *gd, int ro) kobject_uevent_env(&disk_to_dev(gd)->kobj, KOBJ_CHANGE, envp); } -void set_device_ro(struct block_device *bdev, int flag) -{ - bdev->bd_part->policy = flag; -} - -EXPORT_SYMBOL(set_device_ro); - void set_disk_ro(struct gendisk *disk, int flag) { struct disk_part_iter piter; diff --git a/block/ioctl.c b/block/ioctl.c index 96cb4544736468..04255dc5f3bff3 100644 --- a/block/ioctl.c +++ b/block/ioctl.c @@ -371,7 +371,7 @@ static int blkdev_roset(struct block_device *bdev, fmode_t mode, if (ret) return ret; } - set_device_ro(bdev, n); + bdev->bd_part->policy = n; return 0; } diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 38f23d75701379..f232f26d7c777b 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -304,7 +304,6 @@ extern void del_gendisk(struct gendisk *gp); extern struct gendisk *get_gendisk(dev_t dev, int *partno); extern struct block_device *bdget_disk(struct gendisk *disk, int partno); -extern void set_device_ro(struct block_device *bdev, int flag); extern void set_disk_ro(struct gendisk *disk, int flag); static inline int get_disk_ro(struct gendisk *disk)