aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Price <anprice@redhat.com>2017-12-12 12:42:30 -0500
committerBob Peterson <rpeterso@redhat.com>2017-12-12 12:43:42 -0500
commit850d2d915fa69011bef9bd668499cce889fdd8b3 (patch)
tree7dbc81bc6579f08027b72d2f11f519bf3c76131c
parent166725d96322473305e35f9d580591a01697ab29 (diff)
gfs2: Add a crc field to resource group headers
Add the rg_crc field to store a crc32 of the gfs2_rgrp structure. This allows us to check resource group headers' integrity and removes the requirement to check them against the rindex entries in fsck. If this field is found to be zero, it should be ignored (or updated with an accurate value). Signed-off-by: Andrew Price <anprice@redhat.com> Signed-off-by: Bob Peterson <rpeterso@redhat.com>
-rw-r--r--fs/gfs2/rgrp.c5
-rw-r--r--include/uapi/linux/gfs2_ondisk.h3
2 files changed, 7 insertions, 1 deletions
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index a9184903a9f5..e8aba6fa1472 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -34,6 +34,7 @@
34#include "log.h" 34#include "log.h"
35#include "inode.h" 35#include "inode.h"
36#include "trace_gfs2.h" 36#include "trace_gfs2.h"
37#include "dir.h"
37 38
38#define BFITNOENT ((u32)~0) 39#define BFITNOENT ((u32)~0)
39#define NO_BLOCK ((u64)~0) 40#define NO_BLOCK ((u64)~0)
@@ -1047,6 +1048,7 @@ static void gfs2_rgrp_out(struct gfs2_rgrpd *rgd, void *buf)
1047{ 1048{
1048 struct gfs2_rgrpd *next = gfs2_rgrpd_get_next(rgd); 1049 struct gfs2_rgrpd *next = gfs2_rgrpd_get_next(rgd);
1049 struct gfs2_rgrp *str = buf; 1050 struct gfs2_rgrp *str = buf;
1051 u32 crc;
1050 1052
1051 str->rg_flags = cpu_to_be32(rgd->rd_flags & ~GFS2_RDF_MASK); 1053 str->rg_flags = cpu_to_be32(rgd->rd_flags & ~GFS2_RDF_MASK);
1052 str->rg_free = cpu_to_be32(rgd->rd_free); 1054 str->rg_free = cpu_to_be32(rgd->rd_free);
@@ -1059,6 +1061,9 @@ static void gfs2_rgrp_out(struct gfs2_rgrpd *rgd, void *buf)
1059 str->rg_data0 = cpu_to_be64(rgd->rd_data0); 1061 str->rg_data0 = cpu_to_be64(rgd->rd_data0);
1060 str->rg_data = cpu_to_be32(rgd->rd_data); 1062 str->rg_data = cpu_to_be32(rgd->rd_data);
1061 str->rg_bitbytes = cpu_to_be32(rgd->rd_bitbytes); 1063 str->rg_bitbytes = cpu_to_be32(rgd->rd_bitbytes);
1064 str->rg_crc = 0;
1065 crc = gfs2_disk_hash(buf, sizeof(struct gfs2_rgrp));
1066 str->rg_crc = cpu_to_be32(crc);
1062 1067
1063 memset(&str->rg_reserved, 0, sizeof(str->rg_reserved)); 1068 memset(&str->rg_reserved, 0, sizeof(str->rg_reserved));
1064} 1069}
diff --git a/include/uapi/linux/gfs2_ondisk.h b/include/uapi/linux/gfs2_ondisk.h
index 648e0cbca574..09f0920f07e9 100644
--- a/include/uapi/linux/gfs2_ondisk.h
+++ b/include/uapi/linux/gfs2_ondisk.h
@@ -197,8 +197,9 @@ struct gfs2_rgrp {
197 __be64 rg_data0; /* First data location */ 197 __be64 rg_data0; /* First data location */
198 __be32 rg_data; /* Number of data blocks in rgrp */ 198 __be32 rg_data; /* Number of data blocks in rgrp */
199 __be32 rg_bitbytes; /* Number of bytes in data bitmaps */ 199 __be32 rg_bitbytes; /* Number of bytes in data bitmaps */
200 __be32 rg_crc; /* crc32 of the structure with this field 0 */
200 201
201 __u8 rg_reserved[64]; /* Several fields from gfs1 now reserved */ 202 __u8 rg_reserved[60]; /* Several fields from gfs1 now reserved */
202}; 203};
203 204
204/* 205/*