diff options
author | Andreas Gruenbacher <agruenba@redhat.com> | 2018-01-16 23:07:57 +0100 |
---|---|---|
committer | Bob Peterson <rpeterso@redhat.com> | 2018-01-22 07:06:15 -0700 |
commit | 0ff5916ad4eb857e03e7586665d1c022ef3277f6 (patch) | |
tree | 0aa2f49c36c8c7d574a8d037e6495119e63beabd /fs/gfs2 | |
parent | 88b65ce5fdd9ac75df1534cf6503db0ccb230ecb (diff) |
gfs2: Get rid of gfs2_log_header_in
Get rid of gfs2_log_header_in by integrating it into get_log_header.
Clean up the crc32 computations and use the same functions for encoding
and decoding to make things less confusing. Eliminate lh_hash from
gfs2_log_header_host which is completely useless.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Diffstat (limited to 'fs/gfs2')
-rw-r--r-- | fs/gfs2/incore.h | 1 | ||||
-rw-r--r-- | fs/gfs2/log.c | 2 | ||||
-rw-r--r-- | fs/gfs2/recovery.c | 44 |
3 files changed, 17 insertions, 30 deletions
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index 9d4d7367175f..e0557b8a590a 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h @@ -44,7 +44,6 @@ struct gfs2_log_header_host { u32 lh_flags; /* GFS2_LOG_HEAD_... */ u32 lh_tail; /* Block number of log tail */ u32 lh_blkno; - u32 lh_hash; }; /* diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c index b9889ae5fd7c..c27cbcebfe88 100644 --- a/fs/gfs2/log.c +++ b/fs/gfs2/log.c @@ -680,7 +680,7 @@ void gfs2_write_log_header(struct gfs2_sbd *sdp, u64 seq, u32 tail, lh->lh_flags = cpu_to_be32(flags); lh->lh_tail = cpu_to_be32(tail); lh->lh_blkno = cpu_to_be32(sdp->sd_log_flush_head); - hash = gfs2_disk_hash(page_address(page), sizeof(struct gfs2_log_header)); + hash = ~crc32(~0, lh, sizeof(*lh)); lh->lh_hash = cpu_to_be32(hash); gfs2_log_write_page(sdp, page); diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c index 5d3431219425..975f32166dfe 100644 --- a/fs/gfs2/recovery.c +++ b/fs/gfs2/recovery.c @@ -118,22 +118,6 @@ void gfs2_revoke_clean(struct gfs2_jdesc *jd) } } -static int gfs2_log_header_in(struct gfs2_log_header_host *lh, const void *buf) -{ - const struct gfs2_log_header *str = buf; - - if (str->lh_header.mh_magic != cpu_to_be32(GFS2_MAGIC) || - str->lh_header.mh_type != cpu_to_be32(GFS2_METATYPE_LH)) - return 1; - - lh->lh_sequence = be64_to_cpu(str->lh_sequence); - lh->lh_flags = be32_to_cpu(str->lh_flags); - lh->lh_tail = be32_to_cpu(str->lh_tail); - lh->lh_blkno = be32_to_cpu(str->lh_blkno); - lh->lh_hash = be32_to_cpu(str->lh_hash); - return 0; -} - /** * get_log_header - read the log header for a given segment * @jd: the journal @@ -151,29 +135,33 @@ static int gfs2_log_header_in(struct gfs2_log_header_host *lh, const void *buf) static int get_log_header(struct gfs2_jdesc *jd, unsigned int blk, struct gfs2_log_header_host *head) { + struct gfs2_log_header *lh; 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; + lh = (void *)bh->b_data; - hash = crc32_le((u32)~0, bh->b_data, sizeof(struct gfs2_log_header) - - sizeof(u32)); - hash = crc32_le(hash, (unsigned char const *)¬hing, sizeof(nothing)); - hash ^= (u32)~0; - error = gfs2_log_header_in(&lh, bh->b_data); - brelse(bh); + hash = crc32(~0, lh, sizeof(*lh) - 4); + hash = ~crc32_le_shift(hash, 4); /* assume lh_hash is zero */ - if (error || lh.lh_blkno != blk || lh.lh_hash != hash) - return 1; + error = lh->lh_header.mh_magic != cpu_to_be32(GFS2_MAGIC) || + lh->lh_header.mh_type != cpu_to_be32(GFS2_METATYPE_LH) || + be32_to_cpu(lh->lh_blkno) != blk || + be32_to_cpu(lh->lh_hash) != hash; - *head = lh; + brelse(bh); - return 0; + if (!error) { + head->lh_sequence = be64_to_cpu(lh->lh_sequence); + head->lh_flags = be32_to_cpu(lh->lh_flags); + head->lh_tail = be32_to_cpu(lh->lh_tail); + head->lh_blkno = be32_to_cpu(lh->lh_blkno); + } + return error; } /** |