[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200721105239.8270-5-mlevitsk@redhat.com>
Date: Tue, 21 Jul 2020 13:52:33 +0300
From: Maxim Levitsky <mlevitsk@...hat.com>
To: linux-kernel@...r.kernel.org
Cc: Keith Busch <kbusch@...nel.org>,
Josef Bacik <josef@...icpanda.com>,
linux-block@...r.kernel.org (open list:BLOCK LAYER),
Sagi Grimberg <sagi@...mberg.me>, Jens Axboe <axboe@...nel.dk>,
linux-nvme@...ts.infradead.org (open list:NVM EXPRESS DRIVER),
linux-scsi@...r.kernel.org (open list:SCSI CDROM DRIVER),
Tejun Heo <tj@...nel.org>,
Bart Van Assche <bvanassche@....org>,
"Martin K. Petersen" <martin.petersen@...cle.com>,
Damien Le Moal <damien.lemoal@....com>,
Jason Wang <jasowang@...hat.com>,
Maxim Levitsky <maximlevitsky@...il.com>,
Stefan Hajnoczi <stefanha@...hat.com>,
Colin Ian King <colin.king@...onical.com>,
"Michael S. Tsirkin" <mst@...hat.com>,
Paolo Bonzini <pbonzini@...hat.com>,
Ulf Hansson <ulf.hansson@...aro.org>,
Ajay Joshi <ajay.joshi@....com>,
Ming Lei <ming.lei@...hat.com>,
linux-mmc@...r.kernel.org (open list:SONY MEMORYSTICK SUBSYSTEM),
Christoph Hellwig <hch@....de>,
Satya Tangirala <satyat@...gle.com>,
nbd@...er.debian.org (open list:NETWORK BLOCK DEVICE (NBD)),
Hou Tao <houtao1@...wei.com>, Jens Axboe <axboe@...com>,
virtualization@...ts.linux-foundation.org (open list:VIRTIO CORE AND
NET DRIVERS), "James E.J. Bottomley" <jejb@...ux.ibm.com>,
Alex Dubov <oakad@...oo.com>,
Maxim Levitsky <mlevitsk@...hat.com>
Subject: [PATCH 04/10] block: nbd: use blk_is_valid_logical_block_size
This allows to remove nbd's own check for valid block size
Signed-off-by: Maxim Levitsky <mlevitsk@...hat.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
Powered by blists - more mailing lists