]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: explain page locking and readahead in read_extent_buffer_pages()
authorQu Wenruo <wqu@suse.com>
Thu, 28 Jan 2021 11:25:08 +0000 (19:25 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 8 Feb 2021 21:59:04 +0000 (22:59 +0100)
commit4dc7c5f1d956cff773c4f03594fbb4f8b90d5931
treeec578377a20be06c7341cff4ca120b5bc57e56e2
parent2674e6a3d979b7d9a02dd865bda60f16baaa9d70
btrfs: explain page locking and readahead in read_extent_buffer_pages()

In read_extent_buffer_pages(), if we failed to lock the page atomically,
we just exit with return value 0.

This is counter-intuitive, as normally if we can't lock what we need, we
would return something like EAGAIN.

But that return hides under (wait == WAIT_NONE) branch, which only gets
triggered for readahead.

And for readahead, if we failed to lock the page, it means the extent
buffer is either being read by other thread, or has been read and is
under modification.  Either way the eb will or has been cached, thus
readahead has no need to wait for it.

Add comment on this counter-intuitive behavior.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent_io.c