/* Returns: 0 on success, 1 if the header was invalid or incomplete, errno on error  */
static int get_log_header(struct gfs2_jdesc *jd, unsigned int blk, struct gfs2_log_header_host *head)
/* Returns: 0 on success, 1 if the header was invalid or incomplete, errno on error  */
static int get_log_header(struct gfs2_jdesc *jd, unsigned int blk, struct gfs2_log_header_host *head)
{
	struct buffer_head *bh;
	struct gfs2_log_header_host uninitialized_var(lh);
	const u32 nothing = 0;
	u32 hash;
	int error;
	error = gfs2_replay_read_block(jd, blk, &bh);
	if (error)
		return error;
	hash = crc32_le((u32)~0, bh->b_data, sizeof(struct gfs2_log_header) -
					     sizeof(u32));
	hash = crc32_le(hash, (unsigned char const *)&nothing, sizeof(nothing));
	hash ^= (u32)~0;
	error = gfs2_log_header_in(&lh, bh->b_data);
	brelse(bh);
	if (error || lh.lh_blkno != blk || lh.lh_hash != hash)
		return 1;
	*head = lh;
	return 0;
}