----- Original Message -----
> When reading in buffers from disk, set a new BH_Verify buffer head flag. In
> gfs2_metatype_check, skip the check if BH_Verify is cleared and clear the
> flag
> when checking. That way, we'll only check the metatype once when reading
> buffers from disk, and not when the buffers were already in the page cache.
>
> While touching this code, convert two 'be32_to_cpu(magic) == GFS2_MAGIC'
> checks
> into 'magic == cpu_to_be32(GFS2_MAGIC)'.
>
> Signed-off-by: Andreas Gruenbacher <[email protected]>
> ---
(snip)
> static inline int gfs2_metatype_check(struct gfs2_sbd *sdp,
> - struct buffer_head *bh,
> - u16 type)
> + struct buffer_head *bh, u16 type)
> {
> - struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data;
> - u32 magic = be32_to_cpu(mh->mh_magic);
> - u16 t = be32_to_cpu(mh->mh_type);
> - if (unlikely(magic != GFS2_MAGIC))
> - return gfs2_meta_check_ii(sdp, bh, "magic number", (void
> *)_RET_IP_);
> - if (unlikely(t != type))
> - return gfs2_metatype_check_ii(sdp, bh, type, t,
> - (void *)_RET_IP_);
> - return 0;
> + if (!buffer_verify(bh))
> + return 0;
> + return gfs2_metatype_check_ii(sdp, bh, type, (void *)_RET_IP_);
May I suggest simplifying with:
if (!test_clear_buffer_verify(bh))
return 0;
Regards,
Bob Peterson