From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) (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 BCB8A1514F3 for ; Sat, 1 Jun 2024 15:36:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717256204; cv=none; b=Vi2JsbW79ZZQmxJZSzmq6uSyLe6mqWzgZPa+k7B+TtLXrpDFx7HMlWEBVeYDXAzOev45CqNjbbfoN6ps2toKKJXkaDWZN5Fp2wd15TwnZrW8dJU+BXgo5BR81xRHD4avjdzAuIA0GEx3jBdM3eRre2xb/DWYQ9JYOe39aBBOEIQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717256204; c=relaxed/simple; bh=UJzyeKAYQUkDfPXuX4Gh0F75hNL3c58hA/E5ST/iYXQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=f0ET2i4GPt2mUkhqetEYF5MQBNnhNmRZY4vL4v7qABJsVVoEuyO2W4LXChitHGLMrLXCuZD8iuu3tL5x1JwU/VIyG3FlMnau9vH/KxN5mXUuqS02UQQcLp9rrB+C23qkai+ETIKJ7aNqXML1gPweXkS3/QZ6wVFhyJneJT801dA= 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=1thZxSr5; arc=none smtp.client-ip=209.85.208.46 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 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="1thZxSr5" Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-5755fafa5a7so3592768a12.1 for ; Sat, 01 Jun 2024 08:36:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=metaspace-dk.20230601.gappssmtp.com; s=20230601; t=1717256201; x=1717861001; 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=RG4mdKV7OIkDQVn0D+lJqcvduyeFLy88y+yPCt8VgJg=; b=1thZxSr5IbtFVSx14kleRZ/1r8lV5cawht7W9essypjlqjyWIaoqPCPquV7aDTtBuF JB2EZE6USz7N4E9G/NQ5rsvngXwKpVjoHn7lQ+cU38zTmS5e6bUOMFRWXvI33JnIPGHp fh/PHTCm63S13mbAEfgWUfVngBopb61zkoDs52TZJjMlxfU1lDCD8ZBHhAvIv04k0UwI +QR4YpwxiuSlgvqzwHZIWtXHCLpMOXWBdG8m0lZKLH+SzCOFTmsC4r2Tkops1vR9ZdzW zteAW8TZSFFZwDIhrZcRSSEmVBNmG+VeTW85FmkBDaytjSQbX4LtHdfRK+9JdemMwX/8 zwIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717256201; x=1717861001; 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=RG4mdKV7OIkDQVn0D+lJqcvduyeFLy88y+yPCt8VgJg=; b=nZBYqtV7xadY9PL6xRrtSufDQhr1flnm74K3giMZ6xmF7uqvlTCky0wu0mR0V8uHil ta2C3KfbcR8BfFOUhgGS7Qg2ZhwspKdIDtYR09A0OEKjVpckU7Ff60RUCBbw/FArIe7/ ZOTT0MF0NrZgFVTmViALGWuv7qtUQuIufqnrEg4LaipWo5UHTgk/+ZxiLOLwzrS5VmKE zdsu3T+rlNLIICA1EnL42hbV5+hOYu74EBP5IoG+Hj88z9mkDeldpxUxFMmm+vNK6oCQ MdFLfSgAfPymunN8H4mB29EZhhwxHi95beHNI83f+BpgliXwB/AheqcQDvYqe+HiNcFo Nz9w== X-Forwarded-Encrypted: i=1; AJvYcCW5So2haGTi8K9JhpMmAowPgv5aumGalTr5Z09G10AkcodB/clMaARkmArFwWBScLOyZhdf2Y+Bll3R+IzqP5BxrpZHtNKycDpYjJ+2rVo= X-Gm-Message-State: AOJu0Ywhk/sl9CC22/h7JyvTtvmHebobWHSOfufhj+07kUPlK+bdy2Fq 59GhLY2QHXaW7Z7lwfUVvJHmnf21T4qOdx4owgcqfHVJ7bGiVBVRzzWCpotCrL4= X-Google-Smtp-Source: AGHT+IHlPfHm7R5+PsnhAdZL8Bjz73GnNc+xErZ2ejagpR66zS69NtSW4diw3pf6CusB73or4F1ZUg== X-Received: by 2002:a05:6402:2313:b0:578:f472:d9d5 with SMTP id 4fb4d7f45d1cf-57a364ac87dmr3114186a12.37.1717256200889; Sat, 01 Jun 2024 08:36:40 -0700 (PDT) Received: from localhost ([79.142.230.34]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57a31c6d4b6sm2348973a12.74.2024.06.01.08.36.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jun 2024 08:36:40 -0700 (PDT) From: Andreas Hindborg To: Keith Busch Cc: Jens Axboe , Christoph Hellwig , Damien Le Moal , Bart Van Assche , Hannes Reinecke , Ming Lei , "linux-block@vger.kernel.org" , Andreas Hindborg , Greg KH , Matthew Wilcox , 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: (Keith Busch's message of "Sat, 1 Jun 2024 08:24:29 -0600") References: <20240601134005.621714-1-nmi@metaspace.dk> <20240601134005.621714-3-nmi@metaspace.dk> Date: Sat, 01 Jun 2024 17:36:20 +0200 Message-ID: <875xusoetn.fsf@metaspace.dk> Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Keith Busch writes: > On Sat, Jun 01, 2024 at 03:40:04PM +0200, Andreas Hindborg wrote: >> +impl kernel::Module for NullBlkModule { >> + fn init(_module: &'static ThisModule) -> Result { >> + pr_info!("Rust null_blk loaded\n"); >> + let tagset = Arc::pin_init(TagSet::try_new(1, 256, 1), flags::GFP_KERNEL)?; >> + >> + let disk = { >> + let block_size: u16 = 4096; >> + if block_size % 512 != 0 || !(512..=4096).contains(&block_size) { >> + return Err(kernel::error::code::EINVAL); >> + } > > You've set block_size to the literal 4096, then validate its value > immediately after? Am I missing some way this could ever be invalid? Good catch. It is because I have a patch in the outbound queue that allows setting the block size via a module parameter. The module parameter patch is not upstream yet. Once I have that up, I will send the patch with the block size config. Do you think it is OK to have this redundancy? It would only be for a few cycles. Best regards, Andreas