From: "Onur Özkan" <work@onurozkan.dev>
To: Jason Hall <jason.kei.hall@gmail.com>
Cc: a.hindborg@kernel.org, ojeda@kernel.org, lossin@kernel.org,
boqun.feng@gmail.com, aliceryhl@google.com,
rust-for-linux@vger.kernel.org, linux-block@vger.kernel.org
Subject: Re: [PATCH v2] rust: block: use pin_init::zeroed
Date: Thu, 29 Jan 2026 08:32:07 +0300 [thread overview]
Message-ID: <20260129083207.7fa363c1@nimda> (raw)
In-Reply-To: <20260129082710.312ebe6d@nimda>
On Thu, 29 Jan 2026 08:27:10 +0300
Onur Özkan <work@onurozkan.dev> wrote:
> On Wed, 28 Jan 2026 20:07:32 -0700
> Jason Hall <jason.kei.hall@gmail.com> wrote:
>
> > Replace manual unsafe zeroing of block structures with the safe
> > pin_init::zeroed() helper.
> >
> > Suggested-by: Benno Lossin <lossin@kernel.org>
> > Link: https://github.com/Rust-for-Linux/linux/issues/1189
> > Signed-off-by: Jason Hall <jason.kei.hall@gmail.com>
> > ---
> > rust/kernel/block/mq/gen_disk.rs | 4 +---
> > rust/kernel/block/mq/tag_set.rs | 4 +---
> > 2 files changed, 2 insertions(+), 6 deletions(-)
> >
> > diff --git a/rust/kernel/block/mq/gen_disk.rs
> > b/rust/kernel/block/mq/gen_disk.rs index 1ce815c8cdab..649c3d9b1ff9
> > 100644 --- a/rust/kernel/block/mq/gen_disk.rs
> > +++ b/rust/kernel/block/mq/gen_disk.rs
> > @@ -106,9 +106,7 @@ pub fn build<T: Operations>(
> > // SAFETY: T::QueueData was created by the call to
> > `into_foreign()` above drop(unsafe {
> > T::QueueData::from_foreign(data) }); });
> > -
> > - // SAFETY: `bindings::queue_limits` contain only fields
> > that are valid when zeroed.
> > - let mut lim: bindings::queue_limits = unsafe {
> > core::mem::zeroed() };
> > + let mut lim: bindings::queue_limits = pin_init::zeroed();
> >
> > lim.logical_block_size = self.logical_block_size;
> > lim.physical_block_size = self.physical_block_size;
> > diff --git a/rust/kernel/block/mq/tag_set.rs
> > b/rust/kernel/block/mq/tag_set.rs index c3cf56d52bee..dae9df408a86
> > 100644 --- a/rust/kernel/block/mq/tag_set.rs
> > +++ b/rust/kernel/block/mq/tag_set.rs
> > @@ -38,9 +38,7 @@ pub fn new(
> > num_tags: u32,
> > num_maps: u32,
> > ) -> impl PinInit<Self, error::Error> {
> > - // SAFETY: `blk_mq_tag_set` only contains integers and
> > pointers, which
> > - // all are allowed to be 0.
> > - let tag_set: bindings::blk_mq_tag_set = unsafe {
> > core::mem::zeroed() };
> > + let tag_set: bindings::blk_mq_tag_set = pin_init::zeroed();
> > let tag_set: Result<_> =
> > core::mem::size_of::<RequestDataWrapper>() .try_into()
> > .map(|cmd_size| {
>
> Reviewed-by: Onur Özkan <work@onurozkan.dev>
Hmm, I just saw this [1].
[1]:
https://lore.kernel.org/rust-for-linux/176900687943.9724.14786712604002245962.b4-ty@kernel.dk/
It looks like this change has already been applied. :/
-Onur
prev parent reply other threads:[~2026-01-29 5:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-29 3:07 [PATCH v2] rust: block: use pin_init::zeroed Jason Hall
2026-01-29 5:27 ` Onur Özkan
2026-01-29 5:32 ` Onur Özkan [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260129083207.7fa363c1@nimda \
--to=work@onurozkan.dev \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=boqun.feng@gmail.com \
--cc=jason.kei.hall@gmail.com \
--cc=linux-block@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox