]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
gfs2: Add a crc field to resource group headers
authorAndrew Price <anprice@redhat.com>
Tue, 12 Dec 2017 17:42:30 +0000 (11:42 -0600)
committerBob Peterson <rpeterso@redhat.com>
Tue, 12 Dec 2017 17:43:42 +0000 (11:43 -0600)
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>
fs/gfs2/rgrp.c
include/uapi/linux/gfs2_ondisk.h

index a9184903a9f5bc87affeac3e691ebcbfac24fcf2..e8aba6fa1472fd2d3ddffed6817e81f2419ca36c 100644 (file)
@@ -34,6 +34,7 @@
 #include "log.h"
 #include "inode.h"
 #include "trace_gfs2.h"
+#include "dir.h"
 
 #define BFITNOENT ((u32)~0)
 #define NO_BLOCK ((u64)~0)
@@ -1047,6 +1048,7 @@ static void gfs2_rgrp_out(struct gfs2_rgrpd *rgd, void *buf)
 {
        struct gfs2_rgrpd *next = gfs2_rgrpd_get_next(rgd);
        struct gfs2_rgrp *str = buf;
+       u32 crc;
 
        str->rg_flags = cpu_to_be32(rgd->rd_flags & ~GFS2_RDF_MASK);
        str->rg_free = cpu_to_be32(rgd->rd_free);
@@ -1059,6 +1061,9 @@ static void gfs2_rgrp_out(struct gfs2_rgrpd *rgd, void *buf)
        str->rg_data0 = cpu_to_be64(rgd->rd_data0);
        str->rg_data = cpu_to_be32(rgd->rd_data);
        str->rg_bitbytes = cpu_to_be32(rgd->rd_bitbytes);
+       str->rg_crc = 0;
+       crc = gfs2_disk_hash(buf, sizeof(struct gfs2_rgrp));
+       str->rg_crc = cpu_to_be32(crc);
 
        memset(&str->rg_reserved, 0, sizeof(str->rg_reserved));
 }
index 648e0cbca574abd71811c2cb91cb93960ed9d361..09f0920f07e96c49aa1749499a4bcc3a41f5835b 100644 (file)
@@ -197,8 +197,9 @@ struct gfs2_rgrp {
        __be64 rg_data0;     /* First data location */
        __be32 rg_data;      /* Number of data blocks in rgrp */
        __be32 rg_bitbytes;  /* Number of bytes in data bitmaps */
+       __be32 rg_crc;       /* crc32 of the structure with this field 0 */
 
-       __u8 rg_reserved[64]; /* Several fields from gfs1 now reserved */
+       __u8 rg_reserved[60]; /* Several fields from gfs1 now reserved */
 };
 
 /*