On Mon, Jan 26, 2026 at 12:53:01PM -0800, Eric Biggers wrote:
> Then for the final version in generic_readahead_merkle_tree(), one
> option would be:
> 
>       struct folio *folio;
> 
>       folio = __filemap_get_folio(inode->i_mapping, index, FGP_ACCESSED, 0);
>       if (folio == ERR_PTR(-ENOENT) ||
>           (!IS_ERR(folio) && !folio_test_uptodate(folio))) {
>               DEFINE_READAHEAD(ractl, NULL, NULL, inode->i_mapping, index);
> 
>               page_cache_ra_unbounded(&ractl, nr_pages, 0);
>       }
>       if (!IS_ERR(folio))
>               folio_put(folio);
> 
> Or as a diff from this series:

I ended up doing the second version (which is what I intended to do
anyway, but messed up the brace placement) in this patch.  It then
automatically carries over to the readahead split.

> 
> -     if (PTR_ERR(folio) == -ENOENT ||
> -         !(IS_ERR(folio) && !folio_test_uptodate(folio))) {
> +     if (folio == ERR_PTR(-ENOENT) ||
> +         (!IS_ERR(folio) && !folio_test_uptodate(folio))) {
> 
> (Note that PTR_ERR() shouldn't be used before it's known that the
> pointer is an error pointer.)

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.



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to