Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp346588ybg; Tue, 28 Jul 2020 07:32:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtXlhi20wYIGME+pYyZ212B939IuU7BH0907ph2q/ANRXcoW5A9NFNBuaHfU8rFD2oGeVb X-Received: by 2002:a17:906:454c:: with SMTP id s12mr11421617ejq.339.1595946720307; Tue, 28 Jul 2020 07:32:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595946720; cv=none; d=google.com; s=arc-20160816; b=QfV4VcSyR5/Ey4oqeBFvkg3JpIoRbbH/avYwP0ABRULblQrwS5dR11nmHhstP1quYd f8/bOjgh9/bL1B2m24IxsUk9KZ+dCjOerUwDWu/a+1rNMf41j1t/Sg0unT/mtYpHHxHx M8WHIIErudMLkz97Dro17B8fPuxx2PLqq8v539ivi9QSohlIxB8Q7xoOM+t2iLtTooid nxp34AvjNFQI8A6jUUeR4RSrqrAt9edGiULp6Ni5VAxeD9HLotEYklQJKgvn49wDfVRR sJ4OUMm0T4YowvCbF92nCnYiakHPTEsK81w7ak5B7F1TXEV49SiM3sW9xqltXb1AE6Pj KAJQ== 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=Vk76CkPyZ5T42guo8MQRmFanU+aGvXip0+duA6MP1QY=; b=tJOdHVJTKYrQEtIYJfPAx8KrxPVcX0ji9jHpcobvdGFgZO0fCFyncMV5Cp+uUxHNZA 5DEXBWIUQZhMiTl+7z/gC3mMgO0xQlXn+dxa99ayK4De1pmknOf5R062ko8C9v7MV2v8 ytftre/hIJHEkvRaQ6uTRAM6iS22nAp8ILs5dmL6VAfsJEyqLWitcq6Mh8l3Wo15kZ3n ZPi+cRs0NQSbP2z+48lkFgaFF+XVUhyllu4i4f5OoqnMtxb8CgKCv4vz45BFz8UteNvN D6w3cAJBjI6afqpj0Ofrc+PfxQB77DVjaScCUh6DEtKN8gCGvvdEyt7q08bfvs5M8r9m B50g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=E2pBQjL4; 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 v20si7534425ejc.227.2020.07.28.07.31.37; Tue, 28 Jul 2020 07:32:00 -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=E2pBQjL4; 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 S1730368AbgG1O2F (ORCPT + 99 others); Tue, 28 Jul 2020 10:28:05 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:58759 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729410AbgG1O2F (ORCPT ); Tue, 28 Jul 2020 10:28:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595946484; 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=Vk76CkPyZ5T42guo8MQRmFanU+aGvXip0+duA6MP1QY=; b=E2pBQjL4iMvgit8efOcYKJjaRS6k7ZKRaHjRpBOQQEj4RWJHNNbCOsLk3yZ05Xnxs8q99Q JuR1pCe94g+9VoYR3v30g3OnXKjSlrGKF51auqM8ENdf+E/GpvSpmj+TPWpHD3eCEmqndd E6N+ZeBC+0Vlxhl8WjuW9JRfSzgO4uc= 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-337-Jz4k5rM7NTirOgcPGnRijg-1; Tue, 28 Jul 2020 10:28:02 -0400 X-MC-Unique: Jz4k5rM7NTirOgcPGnRijg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 80CAEE91C; Tue, 28 Jul 2020 14:27:58 +0000 (UTC) Received: from fedora-32-enviroment (unknown [10.35.206.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA66F10013C4; Tue, 28 Jul 2020 14:27:42 +0000 (UTC) Message-ID: <25011fed186bd8bfd1f25640158fbce60a7ad9ef.camel@redhat.com> Subject: Re: [PATCH 02/10] block: virtio-blk: check logical block size From: Maxim Levitsky To: "Martin K. Petersen" , Christoph Hellwig Cc: linux-kernel@vger.kernel.org, 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 , Damien Le Moal , 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" , 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, 28 Jul 2020 17:27:41 +0300 In-Reply-To: References: <20200721105239.8270-1-mlevitsk@redhat.com> <20200721105239.8270-3-mlevitsk@redhat.com> <20200721151437.GB10620@lst.de> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.2 (3.36.2-1.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2020-07-22 at 12:11 +0300, Maxim Levitsky wrote: > On Tue, 2020-07-21 at 22:55 -0400, Martin K. Petersen wrote: > > Christoph, > > > > > Hmm, I wonder if we should simply add the check and warning to > > > blk_queue_logical_block_size and add an error in that case. Then > > > drivers only have to check the error return, which might add a lot > > > less boiler plate code. > > > > Yep, I agree. > > > > I also agree that this would be cleaner (I actually tried to implement > this the way you suggest), but let me explain my reasoning for doing > it > this way. > > The problem is that most current users of blk_queue_logical_block_size > (43 uses in the tree, out of which only 9 use constant block size) > check > for the block size relatively early, often store it in some internal > struct etc, prior to calling blk_queue_logical_block_size thus making > them only to rely on blk_queue_logical_block_size as the check for > block size validity will need non-trivial changes in their code. > > Instead of this adding blk_is_valid_logical_block_size allowed me > to trivially convert most of the uses. > > For RFC I converted only some drivers that I am more familiar with > and/or can test but I can remove the driver's own checks in most other > drivers with low chance of introducing a bug, even if I can't test the > driver. > > What do you think? > > I can also both make blk_queue_logical_block_size return an error > value, > and have blk_is_valid_logical_block_size and use either of these > checks, > depending on the driver with eventual goal of un-exporting > blk_is_valid_logical_block_size. > > Also note that I did add WARN_ON to blk_queue_logical_block_size. Any update on this? Best regards, Maxim Levitsky > > Best regards, > Maxim Levitsky