xfs: make growfs initialise the AGFL header
authorDave Chinner <dchinner@redhat.com>
Mon, 12 Nov 2012 11:54:00 +0000 (22:54 +1100)
committerBen Myers <bpm@sgi.com>
Tue, 13 Nov 2012 22:40:59 +0000 (16:40 -0600)
For verification purposes, AGFLs need to be initialised to a known
set of values. For upcoming CRC changes, they are also headers that
need to be initialised. Currently, growfs does neither for the AGFLs
- it ignores them completely. Add initialisation of the AGFL to be
full of invalid block numbers (NULLAGBLOCK) to put the
infrastructure in place needed for CRC support.

Includes a comment clarification from Jeff Liu.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by Rich Johnston <rjohnston@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
fs/xfs/xfs_fsops.c

index 2196830bf5c0e823032c2454ac5601c24c39c3b9..bd9cb7f0b0732773cf094fbbe5cef7e492959a86 100644 (file)
@@ -140,6 +140,7 @@ xfs_growfs_data_private(
        xfs_growfs_data_t       *in)            /* growfs data input struct */
 {
        xfs_agf_t               *agf;
+       struct xfs_agfl         *agfl;
        xfs_agi_t               *agi;
        xfs_agnumber_t          agno;
        xfs_extlen_t            agsize;
@@ -207,7 +208,7 @@ xfs_growfs_data_private(
        nfree = 0;
        for (agno = nagcount - 1; agno >= oagcount; agno--, new -= agsize) {
                /*
-                * AG freelist header block
+                * AG freespace header block
                 */
                bp = xfs_growfs_get_hdr_buf(mp,
                                XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR(mp)),
@@ -243,6 +244,26 @@ xfs_growfs_data_private(
                if (error)
                        goto error0;
 
+               /*
+                * AG freelist header block
+                */
+               bp = xfs_growfs_get_hdr_buf(mp,
+                               XFS_AG_DADDR(mp, agno, XFS_AGFL_DADDR(mp)),
+                               XFS_FSS_TO_BB(mp, 1), 0);
+               if (!bp) {
+                       error = ENOMEM;
+                       goto error0;
+               }
+
+               agfl = XFS_BUF_TO_AGFL(bp);
+               for (bucket = 0; bucket < XFS_AGFL_SIZE(mp); bucket++)
+                       agfl->agfl_bno[bucket] = cpu_to_be32(NULLAGBLOCK);
+
+               error = xfs_bwrite(bp);
+               xfs_buf_relse(bp);
+               if (error)
+                       goto error0;
+
                /*
                 * AG inode header block
                 */