* Re: [PATCH] rnull: do not zero past the backing page
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
2026-12-04 14:04 ` Andreas Hindborg
2026-12-04 15:03 ` Miguel Ojeda
2 siblings, 1 reply; 6+ messages in thread
From: Philipp Stanner @ 2026-12-04 12:31 UTC (permalink / raw)
To: Vitaly Wool, Andreas Hindborg
Cc: Boqun Feng, Jens Axboe, Miguel Ojeda, Gary Guo, Bjorn Roy Baron,
Benno Lossin, Alice Ryhl, Trevor Gross, Danilo Krummrich,
Daniel Almeida, Tamir Duberstein, Alexandre Courbot, Onur Ozkan,
linux-block, rust-for-linux, linux-kernel
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: ?
>
[…]
> + // 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"
Regards,
P.
> let offset = self.offset() % PAGE_SIZE;
> - let length = (PAGE_SIZE - offset).min(self.len() as usize);
> + let length = (PAGE_SIZE - offset).min(self.len() as usize).min(max_len);
> let page_idx = self.offset() / PAGE_SIZE;
>
> let dst_page = self.page(page_idx);
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] rnull: do not zero past the backing page
2026-12-04 12:31 ` Philipp Stanner
@ 2026-12-04 14:06 ` Andreas Hindborg
0 siblings, 0 replies; 6+ messages in thread
From: Andreas Hindborg @ 2026-12-04 14:06 UTC (permalink / raw)
To: phasta, Vitaly Wool
Cc: Boqun Feng, Jens Axboe, Miguel Ojeda, Gary Guo, Bjorn Roy Baron,
Benno Lossin, Alice Ryhl, Trevor Gross, Danilo Krummrich,
Daniel Almeida, Tamir Duberstein, Alexandre Courbot, Onur Ozkan,
linux-block, rust-for-linux, linux-kernel
"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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] rnull: do not zero past the backing page
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:04 ` Andreas Hindborg
2026-12-04 15:09 ` Jens Axboe
2026-12-04 15:03 ` Miguel Ojeda
2 siblings, 1 reply; 6+ messages in thread
From: Andreas Hindborg @ 2026-12-04 14:04 UTC (permalink / raw)
To: Vitaly Wool
Cc: Boqun Feng, Jens Axboe, Miguel Ojeda, Gary Guo, Bjorn Roy Baron,
Benno Lossin, Alice Ryhl, Trevor Gross, Danilo Krummrich,
Daniel Almeida, Tamir Duberstein, Alexandre Courbot, Onur Ozkan,
linux-block, rust-for-linux, linux-kernel, Vitaly Wool
"Vitaly Wool" <vitaly.wool@konsulko.se> writes:
> 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>
This patch is targeting a downstream tree.
It does not bother me that you send these to list, but it might be
confusing to others.
Best regards,
Andreas Hindborg
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] rnull: do not zero past the backing page
2026-12-04 14:04 ` Andreas Hindborg
@ 2026-12-04 15:09 ` Jens Axboe
0 siblings, 0 replies; 6+ messages in thread
From: Jens Axboe @ 2026-12-04 15:09 UTC (permalink / raw)
To: Andreas Hindborg
Cc: Vitaly Wool, Boqun Feng, Miguel Ojeda, Gary Guo, Bjorn Roy Baron,
Benno Lossin, Alice Ryhl, Trevor Gross, Danilo Krummrich,
Daniel Almeida, Tamir Duberstein, Alexandre Courbot, Onur Ozkan,
linux-block, rust-for-linux, linux-kernel
On Fri, Dec 4, 2026 at 7:04?AM Andreas Hindborg <a.hindborg@kernel.org> wrote:
>
> "Vitaly Wool" <vitaly.wool@konsulko.se> writes:
>
> > 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>
>
> This patch is targeting a downstream tree.
>
> It does not bother me that you send these to list, but it might be
> confusing to others.
Honestly it is just noise, and I'd say the same for any other
out-of-tree driver/code. If it's not in the upstream kernel, it doesn't
belong on the list, so please don't send it there.
--
Jens Axboe
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] rnull: do not zero past the backing page
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:04 ` Andreas Hindborg
@ 2026-12-04 15:03 ` Miguel Ojeda
2 siblings, 0 replies; 6+ messages in thread
From: Miguel Ojeda @ 2026-12-04 15:03 UTC (permalink / raw)
To: Vitaly Wool
Cc: Andreas Hindborg, Boqun Feng, Jens Axboe, Miguel Ojeda, Gary Guo,
Bjorn Roy Baron, Benno Lossin, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
Alexandre Courbot, Onur Ozkan, linux-block, rust-for-linux,
linux-kernel
On Fri, Dec 4, 2026 at 11:45 AM Vitaly Wool <vitaly.wool@konsulko.se> wrote:
>
> Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
This tag is not expected anymore. Instead, please explain the tools
used in the cover letter.
Cheers,
Miguel
^ permalink raw reply [flat|nested] 6+ messages in thread