Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp618865ybh; Tue, 21 Jul 2020 03:55:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqB2amGpSVl+M0LldllH1b1C/EJ+wfVE6mG141eQ6LKx9uPH2sXrkoNU7c282WM1cSJPg4 X-Received: by 2002:a17:906:1453:: with SMTP id q19mr25654387ejc.111.1595328917535; Tue, 21 Jul 2020 03:55:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595328917; cv=none; d=google.com; s=arc-20160816; b=0YbYZf+g46JOSSIS9j1mXlrMyFQzEyAU/KjrwaeQdy76a3g6v49zibn7m04XGLaUwl NScBDYxerIrKfh+skTzN9/8CZheeFmUyQ4RzcUKpiS6B6B7eVIZwy+smXnA/ofjpPhVo 205AKLYUkhpoLBFY9/YTrAcMp+DBTITs6xaqce4ur261Hpdfmoxt7MW+mzGlbwZD+EfW JU4K020u4U+S/YWjqHaxdM6SzEQoqGoamEXtDOLysLPN1wQN11avqisLzjJZHFuhAeKZ eZkj0bOLU9pfDAT+7dkBHZ4tVDcufrGHtsc9jEqyZ07LJFlROpkSl4QnFK28XSEl7fzP J0iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=R7PAK6mGU4s5P/JIBkrc14kuKjwtZGCYHATtOZzdKG0=; b=PxOZplv1fnlXCOJqjRN9/Arq5Mzx/hx0EWaW2q/4ZBz5nVXbYPspo6YCNCYWM4ryhM dW+FQO3SE/kBvONH5RVWzA0Uszi+r5fk5Go6BvME4SE8NbW9uoWzG9cTSFSBHceHec8c GIVW+Qu02plddc3teYmbOw8SVAje7zP6RMaDGHdc6I6KSv6Sb2I7AtMk4WE3wkrzvRTN K4Lx823YzQZAEeymH8LIupjmsiu3JEUsw6mx24/4J7Av3O7IL0/h8idxZlwmDgFB6/8G u1aniHAKuVY0iU9lzgZQlh7c3rsg/Id08z8PV9PHCkpy/bZM1vlkDUnL0DIiQojIcd0e gXiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=W1xAkgg5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id co19si11938267edb.605.2020.07.21.03.54.54; Tue, 21 Jul 2020 03:55:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=W1xAkgg5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729414AbgGUKyf (ORCPT + 99 others); Tue, 21 Jul 2020 06:54:35 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:21441 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727949AbgGUKye (ORCPT ); Tue, 21 Jul 2020 06:54:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595328873; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R7PAK6mGU4s5P/JIBkrc14kuKjwtZGCYHATtOZzdKG0=; b=W1xAkgg5DL7qdqBBdzlzspLdsdKSwpL4byCsvwpiExC7dDTFyY9vWtidCRm/+f5OI1UqOd d84cbdhoJb2VGCsRi/bJDLV40lM07E+eRwIBiKma2qbjH8pGMTDXvhYOdT0o4Fj3qRCday mqfVLAyKDOg4/TSB8qLJz2fs4A9r0t4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-172-VDQQoSfTN4-IxGxUDewhHQ-1; Tue, 21 Jul 2020 06:54:29 -0400 X-MC-Unique: VDQQoSfTN4-IxGxUDewhHQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 76E051009600; Tue, 21 Jul 2020 10:54:26 +0000 (UTC) Received: from localhost.localdomain (unknown [10.35.206.163]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F7177621A; Tue, 21 Jul 2020 10:54:11 +0000 (UTC) From: Maxim Levitsky To: linux-kernel@vger.kernel.org Cc: Keith Busch , Josef Bacik , linux-block@vger.kernel.org (open list:BLOCK LAYER), Sagi Grimberg , Jens Axboe , linux-nvme@lists.infradead.org (open list:NVM EXPRESS DRIVER), linux-scsi@vger.kernel.org (open list:SCSI CDROM DRIVER), Tejun Heo , Bart Van Assche , "Martin K. Petersen" , Damien Le Moal , Jason Wang , Maxim Levitsky , Stefan Hajnoczi , Colin Ian King , "Michael S. Tsirkin" , Paolo Bonzini , Ulf Hansson , Ajay Joshi , Ming Lei , linux-mmc@vger.kernel.org (open list:SONY MEMORYSTICK SUBSYSTEM), Christoph Hellwig , Satya Tangirala , nbd@other.debian.org (open list:NETWORK BLOCK DEVICE (NBD)), Hou Tao , Jens Axboe , virtualization@lists.linux-foundation.org (open list:VIRTIO CORE AND NET DRIVERS), "James E.J. Bottomley" , Alex Dubov , Maxim Levitsky Subject: [PATCH 04/10] block: nbd: use blk_is_valid_logical_block_size Date: Tue, 21 Jul 2020 13:52:33 +0300 Message-Id: <20200721105239.8270-5-mlevitsk@redhat.com> In-Reply-To: <20200721105239.8270-1-mlevitsk@redhat.com> References: <20200721105239.8270-1-mlevitsk@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This allows to remove nbd's own check for valid block size Signed-off-by: Maxim Levitsky --- 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