From: Maxim Levitsky <mlevitsk@redhat.com> To: linux-kernel@vger.kernel.org Cc: Keith Busch <kbusch@kernel.org>, Josef Bacik <josef@toxicpanda.com>, linux-block@vger.kernel.org (open list:BLOCK LAYER), Sagi Grimberg <sagi@grimberg.me>, Jens Axboe <axboe@kernel.dk>, linux-nvme@lists.infradead.org (open list:NVM EXPRESS DRIVER), linux-scsi@vger.kernel.org (open list:SCSI CDROM DRIVER), Tejun Heo <tj@kernel.org>, Bart Van Assche <bvanassche@acm.org>, "Martin K. Petersen" <martin.petersen@oracle.com>, Damien Le Moal <damien.lemoal@wdc.com>, Jason Wang <jasowang@redhat.com>, Maxim Levitsky <maximlevitsky@gmail.com>, Stefan Hajnoczi <stefanha@redhat.com>, Colin Ian King <colin.king@canonical.com>, "Michael S. Tsirkin" <mst@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Ulf Hansson <ulf.hansson@linaro.org>, Ajay Joshi <ajay.joshi@wdc.com>, Ming Lei <ming.lei@redhat.com>, linux-mmc@vger.kernel.org (open list:SONY MEMORYSTICK SUBSYSTEM), Christoph Hellwig <hch@lst.de>, Satya Tangirala <satyat@google.com>, nbd@other.debian.org (open list:NETWORK BLOCK DEVICE (NBD)), Hou Tao <houtao1@huawei.com>, Jens Axboe <axboe@fb.com>, virtualization@lists.linux-foundation.org (open list:VIRTIO CORE AND NET DRIVERS), "James E.J. Bottomley" <jejb@linux.ibm.com>, Alex Dubov <oakad@yahoo.com>, Maxim Levitsky <mlevitsk@redhat.com> Subject: [PATCH 04/10] block: nbd: use blk_is_valid_logical_block_size Date: Tue, 21 Jul 2020 13:52:33 +0300 [thread overview] Message-ID: <20200721105239.8270-5-mlevitsk@redhat.com> (raw) In-Reply-To: <20200721105239.8270-1-mlevitsk@redhat.com> This allows to remove nbd's own check for valid block size Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> --- drivers/block/nbd.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index ce7e9f223b20b..2cd9c4e824f8b 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -1347,14 +1347,6 @@ static void nbd_clear_sock_ioctl(struct nbd_device *nbd, nbd_config_put(nbd); } -static bool nbd_is_valid_blksize(unsigned long blksize) -{ - if (!blksize || !is_power_of_2(blksize) || blksize < 512 || - blksize > PAGE_SIZE) - return false; - return true; -} - static void nbd_set_cmd_timeout(struct nbd_device *nbd, u64 timeout) { nbd->tag_set.timeout = timeout * HZ; @@ -1379,7 +1371,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd, case NBD_SET_BLKSIZE: if (!arg) arg = NBD_DEF_BLKSIZE; - if (!nbd_is_valid_blksize(arg)) + if (!blk_is_valid_logical_block_size(arg)) return -EINVAL; nbd_size_set(nbd, arg, div_s64(config->bytesize, arg)); @@ -1811,7 +1803,7 @@ static int nbd_genl_size_set(struct genl_info *info, struct nbd_device *nbd) bsize = nla_get_u64(info->attrs[NBD_ATTR_BLOCK_SIZE_BYTES]); if (!bsize) bsize = NBD_DEF_BLKSIZE; - if (!nbd_is_valid_blksize(bsize)) { + if (!blk_is_valid_logical_block_size(bsize)) { printk(KERN_ERR "Invalid block size %llu\n", bsize); return -EINVAL; } -- 2.26.2
WARNING: multiple messages have this Message-ID (diff)
From: Maxim Levitsky <mlevitsk@redhat.com> To: linux-kernel@vger.kernel.org Cc: Keith Busch <kbusch@kernel.org>, Josef Bacik <josef@toxicpanda.com>, "open list:BLOCK LAYER" <linux-block@vger.kernel.org>, Sagi Grimberg <sagi@grimberg.me>, Jens Axboe <axboe@kernel.dk>, "open list:NVM EXPRESS DRIVER" <linux-nvme@lists.infradead.org>, "open list:SCSI CDROM DRIVER" <linux-scsi@vger.kernel.org>, Tejun Heo <tj@kernel.org>, Bart Van Assche <bvanassche@acm.org>, "Martin K. Petersen" <martin.petersen@oracle.com>, Damien Le Moal <damien.lemoal@wdc.com>, Jason Wang <jasowang@redhat.com>, Maxim Levitsky <maximlevitsky@gmail.com>, Stefan Hajnoczi <stefanha@redhat.com>, Colin Ian King <colin.king@canonical.com>, "Michael S. Tsirkin" <mst@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Ulf Hansson <ulf.hansson@linaro.org>, Ajay Joshi <ajay.joshi@wd> Subject: [PATCH 04/10] block: nbd: use blk_is_valid_logical_block_size Date: Tue, 21 Jul 2020 13:52:33 +0300 [thread overview] Message-ID: <20200721105239.8270-5-mlevitsk@redhat.com> (raw) In-Reply-To: <20200721105239.8270-1-mlevitsk@redhat.com> This allows to remove nbd's own check for valid block size Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> --- drivers/block/nbd.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index ce7e9f223b20b..2cd9c4e824f8b 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -1347,14 +1347,6 @@ static void nbd_clear_sock_ioctl(struct nbd_device *nbd, nbd_config_put(nbd); } -static bool nbd_is_valid_blksize(unsigned long blksize) -{ - if (!blksize || !is_power_of_2(blksize) || blksize < 512 || - blksize > PAGE_SIZE) - return false; - return true; -} - static void nbd_set_cmd_timeout(struct nbd_device *nbd, u64 timeout) { nbd->tag_set.timeout = timeout * HZ; @@ -1379,7 +1371,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd, case NBD_SET_BLKSIZE: if (!arg) arg = NBD_DEF_BLKSIZE; - if (!nbd_is_valid_blksize(arg)) + if (!blk_is_valid_logical_block_size(arg)) return -EINVAL; nbd_size_set(nbd, arg, div_s64(config->bytesize, arg)); @@ -1811,7 +1803,7 @@ static int nbd_genl_size_set(struct genl_info *info, struct nbd_device *nbd) bsize = nla_get_u64(info->attrs[NBD_ATTR_BLOCK_SIZE_BYTES]); if (!bsize) bsize = NBD_DEF_BLKSIZE; - if (!nbd_is_valid_blksize(bsize)) { + if (!blk_is_valid_logical_block_size(bsize)) { printk(KERN_ERR "Invalid block size %llu\n", bsize); return -EINVAL; } -- 2.26.2
next prev parent reply other threads:[~2020-07-21 10:54 UTC|newest] Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-07-21 10:52 [PATCH 00/10] RFC: move logical block size checking to the block core Maxim Levitsky 2020-07-21 10:52 ` Maxim Levitsky 2020-07-21 10:52 ` [PATCH 01/10] block: introduce blk_is_valid_logical_block_size Maxim Levitsky 2020-07-21 10:52 ` Maxim Levitsky 2020-07-21 11:05 ` Damien Le Moal 2020-07-21 11:05 ` Damien Le Moal 2020-07-21 11:09 ` Maxim Levitsky 2020-07-21 11:09 ` Maxim Levitsky 2020-07-21 11:31 ` Damien Le Moal 2020-07-21 11:31 ` Damien Le Moal 2020-07-21 15:13 ` Christoph Hellwig 2020-07-21 15:13 ` Christoph Hellwig 2020-07-22 8:50 ` Maxim Levitsky 2020-07-22 8:50 ` Maxim Levitsky 2020-07-23 9:13 ` [block] 4c873fbf07: WARNING:at_block/blk-settings.c:#blk_queue_logical_block_size kernel test robot 2020-07-23 9:13 ` kernel test robot 2020-07-21 10:52 ` [PATCH 02/10] block: virtio-blk: check logical block size Maxim Levitsky 2020-07-21 10:52 ` Maxim Levitsky 2020-07-21 11:07 ` Damien Le Moal 2020-07-21 11:07 ` Damien Le Moal 2020-07-21 15:14 ` Christoph Hellwig 2020-07-21 15:14 ` Christoph Hellwig 2020-07-22 2:55 ` Martin K. Petersen 2020-07-22 2:55 ` Martin K. Petersen 2020-07-22 9:11 ` Maxim Levitsky 2020-07-22 9:11 ` Maxim Levitsky 2020-07-28 14:27 ` Maxim Levitsky 2020-07-29 4:32 ` Martin K. Petersen 2020-07-28 15:44 ` Stefan Hajnoczi 2020-07-21 10:52 ` [PATCH 03/10] block: loop: use blk_is_valid_logical_block_size Maxim Levitsky 2020-07-21 10:52 ` Maxim Levitsky 2020-07-21 11:08 ` Damien Le Moal 2020-07-21 11:08 ` Damien Le Moal 2020-07-21 10:52 ` Maxim Levitsky [this message] 2020-07-21 10:52 ` [PATCH 04/10] block: nbd: " Maxim Levitsky 2020-07-21 11:09 ` Damien Le Moal 2020-07-21 11:09 ` Damien Le Moal 2020-07-21 10:52 ` [PATCH 05/10] block: null: " Maxim Levitsky 2020-07-21 10:52 ` Maxim Levitsky 2020-07-21 11:15 ` Damien Le Moal 2020-07-21 11:15 ` Damien Le Moal 2020-07-21 12:42 ` Maxim Levitsky 2020-07-21 12:42 ` Maxim Levitsky 2020-07-21 10:52 ` [PATCH 06/10] block: ms_block: " Maxim Levitsky 2020-07-21 10:52 ` Maxim Levitsky 2020-07-21 11:17 ` Damien Le Moal 2020-07-21 11:17 ` Damien Le Moal 2020-07-21 10:52 ` [PATCH 07/10] block: mspro_blk: " Maxim Levitsky 2020-07-21 10:52 ` Maxim Levitsky 2020-07-21 11:17 ` Damien Le Moal 2020-07-21 11:17 ` Damien Le Moal 2020-07-21 10:52 ` [PATCH 08/10] block: nvme: " Maxim Levitsky 2020-07-21 10:52 ` Maxim Levitsky 2020-07-21 11:23 ` Damien Le Moal 2020-07-21 11:23 ` Damien Le Moal 2020-07-21 10:52 ` [PATCH 09/10] block: scsi: sd: " Maxim Levitsky 2020-07-21 10:52 ` Maxim Levitsky 2020-07-21 11:25 ` Damien Le Moal 2020-07-21 11:25 ` Damien Le Moal 2020-07-21 12:55 ` Maxim Levitsky 2020-07-21 12:55 ` Maxim Levitsky 2020-07-21 10:52 ` [PATCH 10/10] block: scsi: sr: " Maxim Levitsky 2020-07-21 10:52 ` Maxim Levitsky 2020-07-21 11:29 ` Damien Le Moal 2020-07-21 11:29 ` Damien Le Moal
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=20200721105239.8270-5-mlevitsk@redhat.com \ --to=mlevitsk@redhat.com \ --cc=ajay.joshi@wdc.com \ --cc=axboe@fb.com \ --cc=axboe@kernel.dk \ --cc=bvanassche@acm.org \ --cc=colin.king@canonical.com \ --cc=damien.lemoal@wdc.com \ --cc=hch@lst.de \ --cc=houtao1@huawei.com \ --cc=jasowang@redhat.com \ --cc=jejb@linux.ibm.com \ --cc=josef@toxicpanda.com \ --cc=kbusch@kernel.org \ --cc=linux-block@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mmc@vger.kernel.org \ --cc=linux-nvme@lists.infradead.org \ --cc=linux-scsi@vger.kernel.org \ --cc=martin.petersen@oracle.com \ --cc=maximlevitsky@gmail.com \ --cc=ming.lei@redhat.com \ --cc=mst@redhat.com \ --cc=nbd@other.debian.org \ --cc=oakad@yahoo.com \ --cc=pbonzini@redhat.com \ --cc=sagi@grimberg.me \ --cc=satyat@google.com \ --cc=stefanha@redhat.com \ --cc=tj@kernel.org \ --cc=ulf.hansson@linaro.org \ --cc=virtualization@lists.linux-foundation.org \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.