Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp618995ybh; Tue, 21 Jul 2020 03:55:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxtoglMadH5TuqpeVBWyhXNb0GmCCcPj82UdvxoKKogHKsJJVZgeFmlVz00JmIJ+udAx2jF X-Received: by 2002:aa7:d50d:: with SMTP id y13mr25636541edq.230.1595328931451; Tue, 21 Jul 2020 03:55:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595328931; cv=none; d=google.com; s=arc-20160816; b=RcapzmlVEUAWPHSKr1ksymh1SB88uVr3yvhRNmKwNsgeyV3V5k20TQxE0MWFewpObC ZxYFRWXWjf7fT1w3paJ45H5V887ZAE+gkDsiLuIyYzVDisqrb9y3ZWGOr+951nUdIufA YkIbPRBuvdM/JiTHQcz5QeAxc4vMBC0fdFo4aws1/+VaqxXlgkm9ux4B+SKO1+uIM9lA 5EtEPtaqiZL4/WSB7iDexhVtMGmMmVRrYnS3ud9Bd2KIxkmoUnZHX52+8m2MuiO0abKA GFN2P6KE9UMaqqYioDtbGJeKAzTyA7hMaWNIQAKxC/TJ7WqzlIgurpgXnT4QCSaPzIwm fbeA== 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=oFWGludvELnToYPGkXRL/IpOnO2KtH2SYm6kXUDscgk=; b=TC2fFrDZfuw3mjQYmax+f29ipfEkuh+jwPvCxpz9DeNsq9D40tFHcRffOfN7nRsBwD +ovy2e/D8VJpQ+DrxO6iauz3MnbAGkyuBgDphei0fTzhnFW/OHZA6F5PlDtHtrU9cAz8 4cRoJrsiRQqR7EGlaXcGvDZJVHNofFySXQeTBNDSS59GQ2GeB6hsaK4AGp4K/xTkqyQN vLaPg1Cg5XF7Syiun+ifFIt6NrUa5GDA2ukGopb7Yf3TjfngSslCeyqRcCq7Eu7wcfTC 5mg85W7cUmccMy+kO8H5YHA8S5nKWG/vpVlw0V28LIcuDD+u5e6bXKrwQCIVoE3noDjZ 3gpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Zw1rn9gF; 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 f16si12230907ejb.557.2020.07.21.03.55.09; Tue, 21 Jul 2020 03:55:31 -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=Zw1rn9gF; 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 S1729313AbgGUKyn (ORCPT + 99 others); Tue, 21 Jul 2020 06:54:43 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:49171 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729423AbgGUKym (ORCPT ); Tue, 21 Jul 2020 06:54:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595328881; 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=oFWGludvELnToYPGkXRL/IpOnO2KtH2SYm6kXUDscgk=; b=Zw1rn9gFFjSwXbe25rlBu8wrt7VHVMoKDznyt8EYIR869u/ypvh42oGonMK/bBFgGudcg/ WacEFGNf370Ig/yb+rHZ/BPDYZ4ozyFknv194j64C0W69Und+9LFWEI+XNFq6KI4uzb3Sw goXmz5qDovY72e+YqaTDmv2BtKGsQnQ= 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-370-PjdjcO50NH2_x-dheKbKbA-1; Tue, 21 Jul 2020 06:54:39 -0400 X-MC-Unique: PjdjcO50NH2_x-dheKbKbA-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 A06CF193F562; Tue, 21 Jul 2020 10:54:36 +0000 (UTC) Received: from localhost.localdomain (unknown [10.35.206.163]) by smtp.corp.redhat.com (Postfix) with ESMTP id D88637621A; Tue, 21 Jul 2020 10:54:26 +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 05/10] block: null: use blk_is_valid_logical_block_size Date: Tue, 21 Jul 2020 13:52:34 +0300 Message-Id: <20200721105239.8270-6-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 slightly changes the behavier of the driver, when given invalid block size (non power of two, or below 512 bytes), but shoudn't matter. Signed-off-by: Maxim Levitsky --- drivers/block/null_blk_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c index 87b31f9ca362e..e4df4b903b90b 100644 --- a/drivers/block/null_blk_main.c +++ b/drivers/block/null_blk_main.c @@ -1684,8 +1684,8 @@ static int null_init_tag_set(struct nullb *nullb, struct blk_mq_tag_set *set) static int null_validate_conf(struct nullb_device *dev) { - dev->blocksize = round_down(dev->blocksize, 512); - dev->blocksize = clamp_t(unsigned int, dev->blocksize, 512, 4096); + if (!blk_is_valid_logical_block_size(dev->blocksize)) + return -ENODEV; if (dev->queue_mode == NULL_Q_MQ && dev->use_per_node_hctx) { if (dev->submit_queues != nr_online_nodes) @@ -1865,7 +1865,7 @@ static int __init null_init(void) struct nullb *nullb; struct nullb_device *dev; - if (g_bs > PAGE_SIZE) { + if (!blk_is_valid_logical_block_size(g_bs)) { pr_warn("invalid block size\n"); pr_warn("defaults block size to %lu\n", PAGE_SIZE); g_bs = PAGE_SIZE; -- 2.26.2