Linux block layer
 help / color / mirror / Atom feed
From: Andreas Hindborg <a.hindborg@kernel.org>
To: phasta@kernel.org, Vitaly Wool <vitaly.wool@konsulko.se>
Cc: Boqun Feng <boqun@kernel.org>, Jens Axboe <axboe@kernel.dk>,
	Miguel Ojeda <ojeda@kernel.org>, Gary Guo <gary@garyguo.net>,
	Bjorn Roy Baron <bjorn3_gh@protonmail.com>,
	Benno Lossin <lossin@kernel.org>,
	Alice Ryhl <aliceryhl@google.com>,
	Trevor Gross <tmgross@umich.edu>,
	Danilo Krummrich <dakr@kernel.org>,
	Daniel Almeida <daniel.almeida@collabora.com>,
	Tamir Duberstein <tamird@kernel.org>,
	Alexandre Courbot <acourbot@nvidia.com>,
	Onur Ozkan <work@onurozkan.dev>,
	linux-block@vger.kernel.org, rust-for-linux@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rnull: do not zero past the backing page
Date: Fri, 04 Dec 2026 15:06:17 +0100	[thread overview]
Message-ID: <87ld655eee.fsf@t14s.mail-host-address-is-not-set> (raw)
In-Reply-To: <b3ecf7048bdd29f9719222da0566dcff97fa9aeb.camel@mailbox.org>

"Philipp Stanner" <phasta@mailbox.org> writes:

> On Fri, 2026-12-04 at 11:44 +0100, Vitaly Wool wrote:
>> When a read hits a backing page that was never written, rnull fills the
>> segment with zeroes up to the end of the segment's current page, which
>> is a page of the bio, not of the backing store. If the read does not
>> start at the beginning of the backing page, the zeroes run on into the
>> next backing page, which may hold data, and the read returns zeroes for
>> it. For instance, with 512 byte blocks, a direct read of 4K at sector 7
>> into a page aligned buffer, where only sector 8 was written, returns
>> zeroes for sector 8. Fix this.
>>
>> Signed-off-by: Vitaly Wool <vitaly.wool@konsulko.se>
>> Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
>
> So does it need Fixes: ?

No, the code it fixes is not merged yet.

>
>>
>
> […]
>
>> +            // CAST: Casting from `usize` to `u64` never overflows.
>> +            sector += copied as u64 >> block::SECTOR_SHIFT;
>
> If it always works, can't it be written as u64::from(copied)?
>
>>      /// Copy zeroes to the current page of this segment.
>>      ///
>> -    /// Copies  `PAGE_SIZE - (self.offset() % PAGE_SIZE` bytes of data to this
>> -    /// segment starting at `self.offset()`. This call will advance offset and reduce length of
>> -    /// `self`.
>> +    /// Copies at most `max_len` zero bytes to this segment starting at `self.offset()`, and never
>> +    /// past the end of the current page, i.e. at most `PAGE_SIZE - (self.offset() % PAGE_SIZE)`
>> +    /// bytes. This call will advance offset and reduce length of `self`.
>>      ///
>>      /// Returns the number of bytes written to this segment.
>>      #[inline]
>> -    pub fn zero_page(&mut self) -> usize {
>> +    pub fn zero_page(&mut self, max_len: usize) -> usize {
>
> The function name would make me think that this zeros the entire page.
> Maybe a different name might make sense?
>
> And what about max_len == 0? Often API functions use that for "write
> till the end"

I'm going to rename it, it is not a good name after the change.

Best regards,
Andreas Hindborg



  reply	other threads:[~2026-12-04 14:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <sGTKQRb-QRAf07fuubXVdjrXgGYXvjpZnRp_7FPf0yGHtvNVjQR5zRxsJkKgLpwjzrtjENdsZdZHzylAZl2YBQ==@protonmail.internalid>
2026-12-04 10:44 ` [PATCH] rnull: do not zero past the backing page Vitaly Wool
2026-12-04 12:31   ` Philipp Stanner
2026-12-04 14:06     ` Andreas Hindborg [this message]
2026-12-04 14:04   ` Andreas Hindborg
2026-12-04 15:09     ` Jens Axboe
2026-12-04 15:03   ` Miguel Ojeda

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=87ld655eee.fsf@t14s.mail-host-address-is-not-set \
    --to=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=aliceryhl@google.com \
    --cc=axboe@kernel.dk \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=gary@garyguo.net \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=phasta@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tamird@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=vitaly.wool@konsulko.se \
    --cc=work@onurozkan.dev \
    /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