Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp631335ybh; Tue, 21 Jul 2020 04:12:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+hzKT+JaoATuYifqDPvsqm5F8CF9h8ZytrYDec/0Li41swNQbWNurY8C2F0fGh4E5TEVd X-Received: by 2002:a17:906:365a:: with SMTP id r26mr25226133ejb.52.1595329974927; Tue, 21 Jul 2020 04:12:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595329974; cv=none; d=google.com; s=arc-20160816; b=KON3VobW8qTv/gjtLLPbWj5IP606AzNMGmz/Cb/tCCLJwThOltTGFCu/MYTWjPTG/B hiM+GlkNTCarCDQn/8ylIiCk+A807tLeJz65Xz+EciXzey6Op+xkSK60rYdDGMkJ3Pk9 Q3vxHtU/z7RasncSoNXXPPk7xbncE4zQjO1D2133QcvPnGvIAfjaAYh3ViQIq7zJywwM 2/dq6GJyDkVlj2WLK65+WZvXL1tVE6K8+B+F5RXheonFmFYVOP6+40z0CkxJBHN5Lnd0 QrPXCMVMj19eymE3RswqFMNuYiDXo7eN2MtH+pQwMEpliB9o2GQg1ZRU0bjHxjdJZwnD 96zQ== 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 :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=1LZAXnntkLhkcLOqby4Ic/aYn82wdCMM/OIUvTatqoM=; b=jX67xUEm7S5Nv+6bD9DahKUB4sUElsdqu8Evv8twwLofUS85CyVubu16gPNUpHyX87 MR7tlWsZkLgJFajjpooR17DnET0O5hrbGftcOAUAfn7IN+BdF2sa/LYH6F3pVRxGRXjt yMYP1qvcR/HKnv6ykQg6qbR4kDPk2R/VHDgORX/Ih2UIq4XVnVSLR3ioQEkb1PTU42/m Ul71C1hnGrHZksAjWx6fT6wHYVd6s1m8SVdyH1eqKvkV+7DgZG8nIRgqTsMtazJxFjIm kCKM8Ah7q8C84gUNDR7bQkWpsm/CrtyS+TbTZHEfTFXFzdetLEclzQPWPfptRPuTiCPn pHRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dBQSG4n6; 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 v5si11698129edl.202.2020.07.21.04.12.32; Tue, 21 Jul 2020 04:12:54 -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=dBQSG4n6; 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 S1729487AbgGULJn (ORCPT + 99 others); Tue, 21 Jul 2020 07:09:43 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:51600 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729794AbgGULJm (ORCPT ); Tue, 21 Jul 2020 07:09:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595329780; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1LZAXnntkLhkcLOqby4Ic/aYn82wdCMM/OIUvTatqoM=; b=dBQSG4n6EkEEky90BykmxS+77oBoYv+6gneF7KuwR1dPFSLkWT+CS0dhxGbCQ3rhIdFRx0 Oh6vzxsqw6EJU89DkJ00rO69O4XA+NvICS7y1TaeGkqpdApK1mDrsK3AXpXGvXrmMfKaLR Nptq6QtwzDWTxFD7tmhXz4SptNfd2qI= 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-316-5iDd30yMNTuz4Sd4x5-MNA-1; Tue, 21 Jul 2020 07:09:36 -0400 X-MC-Unique: 5iDd30yMNTuz4Sd4x5-MNA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 673A9100AA23; Tue, 21 Jul 2020 11:09:33 +0000 (UTC) Received: from starship (unknown [10.35.206.163]) by smtp.corp.redhat.com (Postfix) with ESMTP id BEC5F1755E; Tue, 21 Jul 2020 11:09:17 +0000 (UTC) Message-ID: Subject: Re: [PATCH 01/10] block: introduce blk_is_valid_logical_block_size From: Maxim Levitsky To: Damien Le Moal , "linux-kernel@vger.kernel.org" Cc: Keith Busch , Josef Bacik , "open list:BLOCK LAYER" , Sagi Grimberg , Jens Axboe , "open list:NVM EXPRESS DRIVER" , "open list:SCSI CDROM DRIVER" , Tejun Heo , Bart Van Assche , "Martin K. Petersen" , Jason Wang , Maxim Levitsky , Stefan Hajnoczi , Colin Ian King , "Michael S. Tsirkin" , Paolo Bonzini , Ulf Hansson , Ajay Joshi , Ming Lei , "open list:SONY MEMORYSTICK SUBSYSTEM" , Christoph Hellwig , Satya Tangirala , "open list:NETWORK BLOCK DEVICE (NBD)" , Hou Tao , Jens Axboe , "open list:VIRTIO CORE AND NET DRIVERS" , "James E.J. Bottomley" , Alex Dubov Date: Tue, 21 Jul 2020 14:09:16 +0300 In-Reply-To: References: <20200721105239.8270-1-mlevitsk@redhat.com> <20200721105239.8270-2-mlevitsk@redhat.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.3 (3.36.3-1.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2020-07-21 at 11:05 +0000, Damien Le Moal wrote: > On 2020/07/21 19:53, Maxim Levitsky wrote: > > Kernel block layer has never supported logical block > > sizes less that SECTOR_SIZE nor larger that PAGE_SIZE. > > > > Some drivers have runtime configurable block size, > > so it makes sense to have common helper for that. > > ...common helper to check the validity of the logical block size set by the driver. Agree, will fix. > > ("for that" does not refer to a clear action) > > > Signed-off-by: Maxim Levitsky > > --- > > block/blk-settings.c | 18 ++++++++++++++++++ > > include/linux/blkdev.h | 1 + > > 2 files changed, 19 insertions(+) > > > > diff --git a/block/blk-settings.c b/block/blk-settings.c > > index 9a2c23cd97007..3c4ef0d00c2bc 100644 > > --- a/block/blk-settings.c > > +++ b/block/blk-settings.c > > @@ -311,6 +311,21 @@ void blk_queue_max_segment_size(struct request_queue *q, unsigned int max_size) > > } > > EXPORT_SYMBOL(blk_queue_max_segment_size); > > > > + > > +/** > > + * blk_check_logical_block_size - check if logical block size is supported > > + * by the kernel > > + * @size: the logical block size, in bytes > > + * > > + * Description: > > + * This function checks if the block layers supports given block size > > + **/ > > +bool blk_is_valid_logical_block_size(unsigned int size) > > +{ > > + return size >= SECTOR_SIZE && size <= PAGE_SIZE && !is_power_of_2(size); Note here a typo, made in last minute change which I didn't test. It should be without '!' Best regards, Maxim Levitsky > > +} > > +EXPORT_SYMBOL(blk_is_valid_logical_block_size); > > + > > /** > > * blk_queue_logical_block_size - set logical block size for the queue > > * @q: the request queue for the device > > @@ -323,6 +338,8 @@ EXPORT_SYMBOL(blk_queue_max_segment_size); > > **/ > > void blk_queue_logical_block_size(struct request_queue *q, unsigned int size) > > { > > + WARN_ON(!blk_is_valid_logical_block_size(size)); > > + > > q->limits.logical_block_size = size; > > > > if (q->limits.physical_block_size < size) > > @@ -330,6 +347,7 @@ void blk_queue_logical_block_size(struct request_queue *q, unsigned int size) > > > > if (q->limits.io_min < q->limits.physical_block_size) > > q->limits.io_min = q->limits.physical_block_size; > > + > > white line change. > > > } > > EXPORT_SYMBOL(blk_queue_logical_block_size); > > > > diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h > > index 57241417ff2f8..2ed3151397e41 100644 > > --- a/include/linux/blkdev.h > > +++ b/include/linux/blkdev.h > > @@ -1099,6 +1099,7 @@ extern void blk_queue_max_write_same_sectors(struct request_queue *q, > > unsigned int max_write_same_sectors); > > extern void blk_queue_max_write_zeroes_sectors(struct request_queue *q, > > unsigned int max_write_same_sectors); > > +extern bool blk_is_valid_logical_block_size(unsigned int size); > > extern void blk_queue_logical_block_size(struct request_queue *, unsigned int); > > extern void blk_queue_max_zone_append_sectors(struct request_queue *q, > > unsigned int max_zone_append_sectors); > > > >