bcachefs: fix up wonky error handling in bch2_seek_pagecache_hole()
authorBrian Foster <bfoster@redhat.com>
Mon, 14 Aug 2023 14:49:42 +0000 (10:49 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:10:11 +0000 (17:10 -0400)
commit8c9b0f7bdc4183573d57f0442693d99cc9758617
treecefa2eeb55d171b36a7994cf27e4e8511d298b14
parent029b85fe417c36b5689093dd4861c7980299a50f
bcachefs: fix up wonky error handling in bch2_seek_pagecache_hole()

The folio_hole_offset() helper returns a mix of bool and int types.
The latter is to support a possible -EAGAIN error code when using
nonblocking locks. This is not only confusing, but the only caller
also essentially ignores errors outside of stopping the range
iteration. This means an -EAGAIN error can't return directly from
folio_hole_offset() and may be lost via bch2_clamp_data_hole().

Fix up the error handling and make it more readable.
__filemap_get_folio() returns -ENOENT instead of NULL when no folio
exists, so reuse the same error code in folio_hole_offset(). Fix up
bch2_seek_pagecache_hole() to return the current offset on -ENOENT,
but otherwise return unexpected error code up to the caller.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/fs-io-pagecache.c