From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796393193; b=ziObnuTQN8yvlijRS1R+sdcQ22bztuUk9sJas9SIcHz18eC/9oNiorkc1axia2OrKjAz 7E6nbojIXgLd/JoLmq7vhnOFLfMzQWkfL7BbmxxtGBfINzJtoPDF9wxW64H6u6hJUO8yl M3B33YbMWSbHUGhDsdpU4EJXTazQ1Onj/gPYJ+/ybYdtKieP0GICLfDdGCROP2a72hOSk ERpT+D7EzPXlDlEHgMHKcX/Zeu4XD+Di8icI8asBZ3zWFC8hAP4O/V2lIdUC+FDQuiAqW u9OZmcVjEyNvQJG5enYmOCLqIRhfb6JRmxmPccEMbeCd63g5jfSWkCUGFSviK0cC+yg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796393193; h=Received:DKIM-Signature:From:To:Cc:Subject:In-Reply-To:References: Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=Do6gG54j6PhEzerBDO/uYsPYX/FUkOd7EHwL6vwtBWY=; b=INdqLVxu0k5hwdU8zVk+RD2kdxDUDBolbiDmhoLgskGH4SxtH0p4CBl9231xBFBV+Z8q l+Lm7V+OXt37rMpkoyhFtybN4sjzqXZMYKJjENIwKT5Zoww2q4QJbHhhUnY0YzpNPb/+T r5FaahNN+F4mgBqbOhJpl5v9k+XvTbdXO1L+3KQoTNyafI86qZTaGWo9dKbocF/fFCkwn 5LHzKxBpwjUUSg6pmeC8gr1qjAVIgL7lAjM1AU62FD/UEdr3WDnyccm8fUS/Koruvz1xT K7OoLXp4gCcDpQi3kVW+KTNWdn85ODyFcpMzupebXJyYOtggpEsNLrbEeiqAD6UTPgA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UlTX+v2l; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41677606A322; Fri, 4 Dec 2026 14:06:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UlTX+v2l Received: by smtp.kernel.org (Postfix) with ESMTPSA id 776FC1F000C2; Fri, 4 Dec 2026 14:06:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796393193; bh=Do6gG54j6PhEzerBDO/uYsPYX/FUkOd7EHwL6vwtBWY=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=UlTX+v2lfB+6Q7BiHXglSMWrzH7lX80ogUDRVUEsJryg6f73fr+5wvCRu+7dD8CIZ bWZ2fqScCO0JHiGKJBDfZOyeubF4xMgp19PYt1JL/hGOVmd2eJDRnSgSMCY4fdDy65 oMVQJh5yvs6wWzrS1jSBRHdizBZLHhshkzRqWXUBPfPGdxWjSquUneBYb4NKl1D3Kp gSuLlu8bpWsdlPuu+Msx2K1IYEtCMSUPJYx6hJuv2Yj5jjbdaXN0w5dHEPBfQBcjPy Y/60u9Chp5USs1KpOKSUsqWMcYwLJmJLPaqxGWi3NqEXgp9BapiE5DKMH3udcJIlT2 eZoFjVw1Fo98A== From: Andreas Hindborg To: phasta@kernel.org, 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@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 In-Reply-To: References: <20261204104434.234417-1-vitaly.wool@konsulko.se> Date: Fri, 04 Dec 2026 15:06:17 +0100 Message-ID: <87ld655eee.fsf@t14s.mail-host-address-is-not-set> X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable "Philipp Stanner" 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 >> Assisted-By: Claude Opus 5.5 > > So does it need Fixes: ? No, the code it fixes is not merged yet. > >> > > [=E2=80=A6] > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 // C= AST: Casting from `usize` to `u64` never overflows. >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sect= or +=3D copied as u64 >> block::SECTOR_SHIFT; > > If it always works, can't it be written as u64::from(copied)? > >> =C2=A0=C2=A0=C2=A0=C2=A0 /// Copy zeroes to the current page of this seg= ment. >> =C2=A0=C2=A0=C2=A0=C2=A0 /// >> -=C2=A0=C2=A0=C2=A0 /// Copies=C2=A0 `PAGE_SIZE - (self.offset() % PAGE_= SIZE` bytes of data to this >> -=C2=A0=C2=A0=C2=A0 /// segment starting at `self.offset()`. This call w= ill advance offset and reduce length of >> -=C2=A0=C2=A0=C2=A0 /// `self`. >> +=C2=A0=C2=A0=C2=A0 /// Copies at most `max_len` zero bytes to this segm= ent starting at `self.offset()`, and never >> +=C2=A0=C2=A0=C2=A0 /// past the end of the current page, i.e. at most `= PAGE_SIZE - (self.offset() % PAGE_SIZE)` >> +=C2=A0=C2=A0=C2=A0 /// bytes. This call will advance offset and reduce = length of `self`. >> =C2=A0=C2=A0=C2=A0=C2=A0 /// >> =C2=A0=C2=A0=C2=A0=C2=A0 /// Returns the number of bytes written to this= segment. >> =C2=A0=C2=A0=C2=A0=C2=A0 #[inline] >> -=C2=A0=C2=A0=C2=A0 pub fn zero_page(&mut self) -> usize { >> +=C2=A0=C2=A0=C2=A0 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 =3D=3D 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