linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ilya Dryomov <idryomov@gmail.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@kernel.dk>, Song Liu <song@kernel.org>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Stefan Haberland <sth@linux.ibm.com>,
	Jan Hoeppner <hoeppner@linux.ibm.com>,
	linux-block <linux-block@vger.kernel.org>,
	Ceph Development <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: Re: [PATCH 05/11] rbd: implement ->set_read_only to hook into BLKROSET processing
Date: Mon, 2 Nov 2020 12:30:05 +0100	[thread overview]
Message-ID: <CAOi1vP_-GydZpwuR2DWpNmz2N2Wf7MHDbXudLB=t5xuEEq3Y=w@mail.gmail.com> (raw)
In-Reply-To: <20201031085810.450489-6-hch@lst.de>

On Sat, Oct 31, 2020 at 10:11 AM Christoph Hellwig <hch@lst.de> wrote:
>
> Implement the ->set_read_only method instead of parsing the actual
> ioctl command.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  drivers/block/rbd.c | 41 ++++-------------------------------------
>  1 file changed, 4 insertions(+), 37 deletions(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index f84128abade319..37f8fc28004acb 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -692,12 +692,9 @@ static void rbd_release(struct gendisk *disk, fmode_t mode)
>         put_device(&rbd_dev->dev);
>  }
>
> -static int rbd_ioctl_set_ro(struct rbd_device *rbd_dev, unsigned long arg)
> +static int rbd_set_read_only(struct block_device *bdev, bool ro)
>  {
> -       int ro;
> -
> -       if (get_user(ro, (int __user *)arg))
> -               return -EFAULT;
> +       struct rbd_device *rbd_dev = bdev->bd_disk->private_data;
>
>         /*
>          * Both images mapped read-only and snapshots can't be marked
> @@ -706,47 +703,17 @@ static int rbd_ioctl_set_ro(struct rbd_device *rbd_dev, unsigned long arg)
>         if (!ro) {
>                 if (rbd_is_ro(rbd_dev))
>                         return -EROFS;
> -
>                 rbd_assert(!rbd_is_snap(rbd_dev));

If you repost, please leave this empty line.

>         }
>
> -       /* Let blkdev_roset() handle it */
> -       return -ENOTTY;
> -}
> -
> -static int rbd_ioctl(struct block_device *bdev, fmode_t mode,
> -                       unsigned int cmd, unsigned long arg)
> -{
> -       struct rbd_device *rbd_dev = bdev->bd_disk->private_data;
> -       int ret;
> -
> -       switch (cmd) {
> -       case BLKROSET:
> -               ret = rbd_ioctl_set_ro(rbd_dev, arg);
> -               break;
> -       default:
> -               ret = -ENOTTY;
> -       }
> -
> -       return ret;
> -}
> -
> -#ifdef CONFIG_COMPAT
> -static int rbd_compat_ioctl(struct block_device *bdev, fmode_t mode,
> -                               unsigned int cmd, unsigned long arg)
> -{
> -       return rbd_ioctl(bdev, mode, cmd, arg);
> +       return 0;
>  }
> -#endif /* CONFIG_COMPAT */
>
>  static const struct block_device_operations rbd_bd_ops = {
>         .owner                  = THIS_MODULE,
>         .open                   = rbd_open,
>         .release                = rbd_release,
> -       .ioctl                  = rbd_ioctl,
> -#ifdef CONFIG_COMPAT
> -       .compat_ioctl           = rbd_compat_ioctl,
> -#endif
> +       .set_read_only          = rbd_set_read_only,
>  };
>
>  /*
> --
> 2.28.0
>

With that nit,

Acked-by: Ilya Dryomov <idryomov@gmail.com>

Thanks,

                Ilya

  reply	other threads:[~2020-11-02 11:30 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 ` [PATCH 04/11] block: add a new set_read_only method Christoph Hellwig
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 [this message]
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='CAOi1vP_-GydZpwuR2DWpNmz2N2Wf7MHDbXudLB=t5xuEEq3Y=w@mail.gmail.com' \
    --to=idryomov@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=ceph-devel@vger.kernel.org \
    --cc=hch@lst.de \
    --cc=hoeppner@linux.ibm.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).