// SPDX-License-Identifier: GPL-2.0-only
/*
 * Complete definition from Linux v6.18 fs/buffer.c.
 * Source: https://github.com/torvalds/linux/blob/v6.18/fs/buffer.c
 * Copyright (C) 1991, 1992, 2002  Linus Torvalds
 * Kernel excerpt; not a standalone user-space program.
 * The book's exact source tag is not asserted.
 */

static struct buffer_head *__bread_slow(struct buffer_head *bh)
{
	lock_buffer(bh);
	if (buffer_uptodate(bh)) {
		unlock_buffer(bh);
		return bh;
	} else {
		get_bh(bh);
		bh->b_end_io = end_buffer_read_sync;
		submit_bh(REQ_OP_READ, bh);
		wait_on_buffer(bh);
		if (buffer_uptodate(bh))
			return bh;
	}
	brelse(bh);
	return NULL;
}
