[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260127063658.GA25894@lst.de>
Date: Tue, 27 Jan 2026 07:36:58 +0100
From: Christoph Hellwig <hch@....de>
To: Eric Biggers <ebiggers@...nel.org>
Cc: Christoph Hellwig <hch@....de>, "Darrick J. Wong" <djwong@...nel.org>,
Al Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>,
David Sterba <dsterba@...e.com>, Theodore Ts'o <tytso@....edu>,
Jaegeuk Kim <jaegeuk@...nel.org>, Chao Yu <chao@...nel.org>,
Andrey Albershteyn <aalbersh@...hat.com>,
Matthew Wilcox <willy@...radead.org>, linux-fsdevel@...r.kernel.org,
linux-btrfs@...r.kernel.org, linux-ext4@...r.kernel.org,
linux-f2fs-devel@...ts.sourceforge.net, fsverity@...ts.linux.dev
Subject: Re: [PATCH 07/16] fsverity: don't issue readahead for non-ENOENT
errors from __filemap_get_folio
On Mon, Jan 26, 2026 at 10:20:55PM -0800, Eric Biggers wrote:
> > That's new to me, and I can't find anything in the documentation or
> > implementation suggesting that. Your example code above also does
> > this as does plenty of code in the kernel elsewhere.
>
> Not sure why this is controversial.
It wasn't controversial until you came up with that claim.
> The documentation for PTR_ERR() is
> clear that it's for error pointers:
Yes, but anything that stores an ERR_PTR is an error pointer. There
never has been any explicit requirement to first call IS_ERR.
One very common pattern is to extract it first an then check
for errors like:
error = PTR_ERR(ptr);
if (IS_ERR(ptr)))
goto handler_error;
one could come up with arguments that this is special, because error
is not used until after the branch. But there's plenty of other code
like:
type = alg_get_type(sa->salg_type);
if (PTR_ERR(type) == -ENOENT) {
request_module("algif-%s", sa->salg_type);
type = alg_get_type(sa->salg_type);
}
if (IS_ERR(type))
return PTR_ERR(type);
> * PTR_ERR - Extract the error code from an error pointer.
> * @ptr: An error pointer.
> * Return: The error code within @ptr.
> */
> static inline long __must_check PTR_ERR(__force const void *ptr)
> {
> return (long) ptr;
> }
>
> Yes, it's really just a cast, and 'PTR_ERR(folio) == -ENOENT' actually
> still works when folio isn't necessarily an error pointer. But normally
> it would be written as a pointer comparison as I suggested.
You suggestion is using PTR_ERR before checking, to quote from the
previous mail:
> Or as a diff from this series:
>
> - if (PTR_ERR(folio) == -ENOENT ||
> - !(IS_ERR(folio) && !folio_test_uptodate(folio))) {
> + if (folio == ERR_PTR(-ENOENT) ||
> + (!IS_ERR(folio) && !folio_test_uptodate(folio))) {
Powered by blists - more mailing lists