Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp304387lqj; Sat, 1 Jun 2024 22:06:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXR/n0fKcWlKHwIU6leb1LGZ6+21teSUqFAr+aRUcI/aLkNzkdF0mCWicBSAJMYCb5MrpihF+tlECW2KnpHggkk4Yi839Qm6j2nOjeePA== X-Google-Smtp-Source: AGHT+IHVl7KeOCtMup5RvoPao71J807Wn9sQOoMAWxjJxv/WtBR1TpZ3GAAtsGO0ogrX+jDmHlie X-Received: by 2002:a17:90a:8582:b0:2bd:e936:b28 with SMTP id 98e67ed59e1d1-2c1dc583606mr5124336a91.20.1717304770891; Sat, 01 Jun 2024 22:06:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717304770; cv=pass; d=google.com; s=arc-20160816; b=d7SLXMfeaVBJnas0MU9I9TTxd1yMjy2g15yL+C/OIEwYZdJFLgVYCMmbOVVn1UKgWO cnrJn93gQpBDOGwjZ9PaYYgbLY8R5m5E9GFnNLlfaeXp17WafrLCTbauwqVpVGPBKK1U zr4H/4f1SHUtGTFgkZjj9VsGWzw9OJRuPHfCW1onmfTlr5HepKGdg0mwG5zMtAC7fO+x 9RzEydElBkMbt7ZPillCtz7BfoPzExisj7Byn4NCma15XA1HARYVesWpVUn3bcIbsnFJ GsrQaI3BXMmndJm5l6oIUNy6OLmyJB+p3ypeCtzqsnL5TBl/EOZA2sU77nkeGCym4TTx i4rA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=o7NoMXzPthc9zQlJ66cfUGuyRStXBoiGWt66Jwklgk8=; fh=OssBq9YvwTwKyOujbvRUDrkctUyNRW/YzDY4cIeNmHw=; b=NtNV86OeOTjlaPgkyE7EMpV8AixImQHreu5DWMkarIvR6dR5ZV1Hpp3an8vkCg3ijN um4EyW363DdsOfLFrgMvT8wx4OZTa2lgQYIpvY37KEZPR8CMEZU2Telxz7P0ozXE7DP2 x4rTFOxBNOS40yUfWQQ+i4uyK+auzpQ0WmjumtwYVH3e9cPf+RrgRkIeYeypEEa1yeYy JM2y9eFzYKGj2lyg8df542wow2lMxO+uwh7rPOoJZZZccX854vNrq24xpB8ZWodCQW5G UnIHVgvhMhANWSI6R0MUAwBwav3gzh13OcGVpHHW7xQY4MFfMAXcdPj6UcTF3aw/ehRG Gj0A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=KbMIzHs5; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-198113-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198113-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c1c282bf79si4433852a91.123.2024.06.01.22.06.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jun 2024 22:06:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-198113-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=KbMIzHs5; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-198113-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198113-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5DFAA282739 for ; Sun, 2 Jun 2024 03:49:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8F5B1BA5E; Sun, 2 Jun 2024 03:49:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="KbMIzHs5" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE28333FE; Sun, 2 Jun 2024 03:49:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717300177; cv=none; b=jePFDSloUdBfj/S48GNJ7hIiAV2JnAtiTAlzy3vVEzbY+mOtoH7spkJD6O/Xm7Q2PUN3KlDoEtDsYqW/DrmbxaXG3BoEE9cIB3tA2VEZI9khaThNy9qSqIXmSG9AJTCvKg7iWWlmiSu1OB4+TQbdYGVlVtzSQu40ybox2F0Ouog= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717300177; c=relaxed/simple; bh=nI+JdCdtSJsrLAJ8ilaI4AYR3YEqWcnZFiRDQVHYHO8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ChoxLPI/jGzmrT3pI1ZuLqiQWeupN6UtrJQtViWtt0FLLGrYhy+PSMlTpj4RmCHt04DradaoPJM8k8nBR+rz7qvf/RVxJNgW9EM+GcRSoz4oGibioVU/v6xTqH7qJpZ3hj0TyY06O25Vqf+UpvzjvzMCk5urhvyMf1UvhbsP9WA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=KbMIzHs5; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=o7NoMXzPthc9zQlJ66cfUGuyRStXBoiGWt66Jwklgk8=; b=KbMIzHs5gt1BcRON61TXatunNp q3vENuIK+gxN6Givz28UrOa3Uc8zlgPpsxgsGti80Yxy7URNy2r5h2EWzydq0h1qljXa/4f12VrQg ZbId0F5kiYsw/TJxH9jXcTjD6cPiXrVR1uJ+zy1Y9CX8/DG9uYpz6Q7cIezrHEx1+S9vHlqeIaLBX YnTOEv4PPHUFeMm2kqbzdqP0unuraFAlyI4W8aCeI1HYe//ziQqUpuRPYnSb0pak9t5NNgMJI4ocI zJzfF+gMyiUKkXPxzpOKUmq6YQ8G/LjvX2iKHO/eNK+9QABDKwE4OjkLk2ZuOPdCnkoFBEVihi5zw JfIiXu8g==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sDcDh-0000000D1A1-0j0Z; Sun, 02 Jun 2024 03:49:21 +0000 Date: Sun, 2 Jun 2024 04:49:21 +0100 From: Matthew Wilcox To: Keith Busch Cc: Andreas Hindborg , Jens Axboe , Christoph Hellwig , Damien Le Moal , Bart Van Assche , Hannes Reinecke , Ming Lei , "linux-block@vger.kernel.org" , Andreas Hindborg , Greg KH , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Alice Ryhl , Chaitanya Kulkarni , Luis Chamberlain , Yexuan Yang <1182282462@bupt.edu.cn>, Sergio =?iso-8859-1?Q?Gonz=E1lez?= Collado , Joel Granados , "Pankaj Raghav (Samsung)" , Daniel Gomez , Niklas Cassel , Philipp Stanner , Conor Dooley , Johannes Thumshirn , Matias =?iso-8859-1?Q?Bj=F8rling?= , open list , "rust-for-linux@vger.kernel.org" , "lsf-pc@lists.linux-foundation.org" , "gost.dev@samsung.com" Subject: Re: [PATCH v4 2/3] rust: block: add rnull, Rust null_blk implementation Message-ID: References: <20240601134005.621714-1-nmi@metaspace.dk> <20240601134005.621714-3-nmi@metaspace.dk> <875xusoetn.fsf@metaspace.dk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Sat, Jun 01, 2024 at 10:01:40AM -0600, Keith Busch wrote: > It's fine, just wondering why it's there. But it also allows values like > 1536 and 3584, which are not valid block sizes, so I think you want the > check to be: > > if !(512..=4096).contains(&block_size) || ((block_size & (block_size - 1)) != 0) I'd drop the range check. We're pretty close to landing the bs>PS patches, so just if block_size & block_size - 1 != 0 should be enough of a validation. Is it considered "good style" in Rust to omit the brackets here?