Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp511045lqj; Sun, 2 Jun 2024 08:37:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVyZR7rDXAJ/lrVcSqC+6eDnBjS1U6B5N9GpYCtHjyNUI5gS4Qr+vgR7dPz08yFMUe8Mv6AiJTaUd16aTzv6Mg5sW0wM/td4cQt8iZKIg== X-Google-Smtp-Source: AGHT+IEVjPsp8xbw1LLBhNm6YNcLNLSaKn6ojSn9bD8q3NonW8PsklNfOIhb1pCCmvQZ0BnQ8PSE X-Received: by 2002:a05:6a21:2792:b0:1ac:f796:963c with SMTP id adf61e73a8af0-1b26f286edcmr5872000637.56.1717342638426; Sun, 02 Jun 2024 08:37:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717342638; cv=pass; d=google.com; s=arc-20160816; b=p7P7dtu4ONQv0e1kCc8mOZ3KONX2gMz7hxgI9NuJ8WDUljipP8CdWDY+8bPp6M/TB9 iNBC+8yFw2+OyBy5dUCFtankYu35kAzyrCXraR+1zOEv8sWS2BlowAkYjybHfMw3xSac I9pnDDJw7D8MdHjWKTDjO+Y7uGpXh+m8hs7FpJvXGjriM7E+NI4z3rg8c7er9VRQs8C2 5/IZzu+dwcI4TMZ+MNYSgP91HvkeflQwYIikNm3Tcz66X4J0NnHqouWt7RuVte32EnD6 6U+XkNjGuBcQasmlryoYe6i4KlTfdIAEn5/nUgKJ0OluKgiXMLJWX8IJT+FXnmBbVKjs GU4A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=bJwF3q+t+A1DpoaxsaOYNQPfvGAIw2IDRpun6/tsk/o=; fh=OqZChGD6kbjmc4r1PcgIRYKLP/iuNfNAAJXKJX7PqbY=; b=yzKY5p+qMiWAWyedkJA475k3hxAtAYcO1jzk2mmFiJOgPC+kLnvLo6P6DLYcSGLlzb aRsdVa4Z3s5HKSDMAMmT08tgPGxzax+HRRIXPgQIj9ANgyGRRYLO1gIrMPUPbMmYFsEp qsKKY5W9iPlMcpFYJnyNeVOevNPzsKUgS84VISu4yZ2M4KQ/QK0xEjvNuBFgEHVjweO+ moLfbxhYA83DkaBMowhfFpmrnLWoEF+M1cIZNRFCe0Jn6ot4kW3STNv8622tC5mmoTZ1 vjBKP3l2Tb1E7gwOpye5WnyHRXpkrFxOKFl/X3kQ1Wb1mxFzUzMsxsebEcK4F31+EeWk Z+hw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@metaspace-dk.20230601.gappssmtp.com header.s=20230601 header.b="mrPD/MEG"; arc=pass (i=1 dkim=pass dkdomain=metaspace-dk.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-198180-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198180-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c40d7f80ddsi4874994a12.726.2024.06.02.08.37.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jun 2024 08:37:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-198180-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@metaspace-dk.20230601.gappssmtp.com header.s=20230601 header.b="mrPD/MEG"; arc=pass (i=1 dkim=pass dkdomain=metaspace-dk.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-198180-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198180-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 07ED3B2135E for ; Sun, 2 Jun 2024 09:28:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DF7C02C1AC; Sun, 2 Jun 2024 09:28:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=metaspace-dk.20230601.gappssmtp.com header.i=@metaspace-dk.20230601.gappssmtp.com header.b="mrPD/MEG" Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BDA392C684 for ; Sun, 2 Jun 2024 09:28:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717320487; cv=none; b=YvsW/qZkDX9pd5sTtjmCJycPK0KR2EBJm1Gg5b5SUZwJY1Dg91Kx2HaKgwBvq9mgQqwepCiobQEFQ3c1/qjV6riELFTmp+cAinMwqJ5f3C4pnvaaAgo54CNRVJi3GPDi8vOHJoaOLzyMZQGkEcasHFoaLiWLdafoU7u4yNQlr9Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717320487; c=relaxed/simple; bh=J6TIPS1GAf2SCnwgcDej5TyjCcgyhxhkgcJ3f/46rQM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=EZ+5wcNSLje0p2BQvZmtHUoGouI6qOOKDm5lXUKPlw0smLw+xeubPUcBOzVRloSP9UeaAOw07qbp3Bt+VVJ1GGYwk4U1EEdWacdbDsQJO0x3V4BNLJD6lAOnzUfvZZwRJUYDAI4x8sfFBoszURS6iSo3HGc2DTCIYT9FTxgkIzA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=metaspace.dk; spf=none smtp.mailfrom=metaspace.dk; dkim=pass (2048-bit key) header.d=metaspace-dk.20230601.gappssmtp.com header.i=@metaspace-dk.20230601.gappssmtp.com header.b=mrPD/MEG; arc=none smtp.client-ip=209.85.218.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=metaspace.dk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=metaspace.dk Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a683868f463so247338566b.0 for ; Sun, 02 Jun 2024 02:28:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=metaspace-dk.20230601.gappssmtp.com; s=20230601; t=1717320483; x=1717925283; darn=vger.kernel.org; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=bJwF3q+t+A1DpoaxsaOYNQPfvGAIw2IDRpun6/tsk/o=; b=mrPD/MEGRoyx2A9ueQ+jZ6rSYNqo5bJctavsrZ3W8CN7Hd4EIMyNmhDvDBf0KEBmfu IlGHXQHHYfLJy1INosOhOlifsqz8WOO3tOaB7KHpCZ/LaFXOsiAx9eroArEhdVpU9GPt DDsRgzQR7DXG7rYJ5QmWzVwdCPHYdb/R0bEU4jaswHhPKELa3mJ2m1oZw7de0/GeO12h 8827Jn5TjM7NhnH/hfTzHufrAbWS+pMWdens59YHGwl+KAnG0xQ2cZLi9C/rVeNaJ0QT e128x20f7pmPaEg827F5MSkJBXBuC4saUtIOffBz+k7JUWNNu5ZWDdfISdDv5uLQbIKM kj/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717320483; x=1717925283; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bJwF3q+t+A1DpoaxsaOYNQPfvGAIw2IDRpun6/tsk/o=; b=LhUfUcdKXNv6EgfifLNy1Y2sgwCKUEMfBF8YA/I8kS0bhsp0b527IO21KOF2PgcBJ6 IXbvStoJjKcl0PgUs4A7SjAzisApQHyGHxDxxfTdrvO4eQMzuPjMfWpk190QIdHdnsEM AvjDTcf3ok5gEGG5HHlDAqA8qs8xROnDPbFcM44ECJKJ4AdnwTQZ6+avhTQQNsjuWoH+ 6/jRR/TRCNhArkhBSl/0n21YMm8dQbJ0dJbQtdpNlFGnNhWNJcZS79MqJKdNU0ZMrV6a KRWiecerNcZFhSoArqFqFyqqXrun0XPVoCiy9b4+QQMLrLqxk+we2Lss+v2SNNfjVxwe uQOA== X-Forwarded-Encrypted: i=1; AJvYcCVWU9BnxJD7+bmQXlygruGuPKbIZJ5Enm3UoIUcxTQyDMlILNkc8FbOVPhN8VlBvlwQnMg2Z7bmdHEh696ifUwFRgTfCw+8YVrGyMKV X-Gm-Message-State: AOJu0Yz7px8lZbAr5rEgiNA5lTHsel/E0O55Xrdz09wJJctm/hIIagNZ Z8S2t59l11z53VccapIkmRLaN1hSX+VTAWNVYSEBtV4fg5bgTleMXCORt0CqfIQ= X-Received: by 2002:a17:907:9284:b0:a62:5ff6:c728 with SMTP id a640c23a62f3a-a6822157081mr494056866b.76.1717320482689; Sun, 02 Jun 2024 02:28:02 -0700 (PDT) Received: from localhost ([79.142.230.34]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a68c162a69csm155894266b.187.2024.06.02.02.28.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jun 2024 02:28:02 -0700 (PDT) From: Andreas Hindborg To: Matthew Wilcox Cc: Keith Busch , 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 , =?utf-8?Q?Bj=C3=B6rn?= Roy Baron , Benno Lossin , Alice Ryhl , Chaitanya Kulkarni , Luis Chamberlain , Yexuan Yang <1182282462@bupt.edu.cn>, Sergio =?utf-8?Q?Gonz=C3=A1lez?= Collado , Joel Granados , "Pankaj Raghav (Samsung)" , Daniel Gomez , Niklas Cassel , Philipp Stanner , Conor Dooley , Johannes Thumshirn , Matias =?utf-8?Q?Bj=C3=B8rling?= , 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 In-Reply-To: (Matthew Wilcox's message of "Sun, 2 Jun 2024 04:49:21 +0100") References: <20240601134005.621714-1-nmi@metaspace.dk> <20240601134005.621714-3-nmi@metaspace.dk> <875xusoetn.fsf@metaspace.dk> Date: Sun, 02 Jun 2024 11:27:55 +0200 Message-ID: <87sexvn17o.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 Matthew Wilcox writes: > 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 safe to do so already? Otherwise we just remove it when it is safe, no biggie. > Is it considered "good style" in > Rust to omit the brackets here? Yes, the compiler will complain if you add parenthesis here. ```rust fn main() { if (true) { return; } } ``` Building this will give you: ```text warning: unnecessary parentheses around `if` condition --> src/main.rs:2:8 | 2 | if (true) { | ^ ^ | = note: `#[warn(unused_parens)]` on by default help: remove these parentheses | 2 - if (true) { 2 + if true { | warning: `playground` (bin "playground") generated 1 warning (run `cargo fix --bin "playground"` to apply 1 suggestion) Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.64s Running `target/debug/playground` ``` If you omit the `{}` block after the `if` it is a syntax error. Best regards, Andreas