Skip to contentSkip to conversation

Add CRC checks to the AGI

PATCH In review Christoph Hellwig 2 participants 2 messages Sep 25, 2008 – Dec 3, 2008 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 7/9 Add CRC checks to the AGI

From: Dave Chinner <[email protected]>

[hch: minor adaptions]

fs/xfs/xfs_ag.h +6 -0
Index: linux-2.6-xfs/fs/xfs/xfs_ag.h
===================================================================
@@ -123,6 +123,8 @@ typedef struct xfs_agi {
 	 * still being referenced.
 	 */
 	__be32		agi_unlinked[XFS_AGI_UNLINKED_BUCKETS];
+	__be32		agi_crc;	/* crc of agi sector */
+	uuid_t		agi_uuid;	/* uuid of filesystem */
 } xfs_agi_t;
 
 #define	XFS_AGI_MAGICNUM	0x00000001
@@ -136,6 +138,9 @@ typedef struct xfs_agi {
 #define	XFS_AGI_NEWINO		0x00000100
 #define	XFS_AGI_DIRINO		0x00000200
 #define	XFS_AGI_UNLINKED	0x00000400
+/*
+ * XXX(hch): update for the CRC additions?  It's unused anyway..
+ */
 #define	XFS_AGI_NUM_BITS	11
 #define	XFS_AGI_ALL_BITS	((1 << XFS_AGI_NUM_BITS) - 1)
 
@@ -144,6 +149,7 @@ typedef struct xfs_agi {
 #define	XFS_AGI_BLOCK(mp)	XFS_HDR_BLOCK(mp, XFS_AGI_DADDR(mp))
 #define	XFS_BUF_TO_AGI(bp)	((xfs_agi_t *)XFS_BUF_PTR(bp))
 
+extern void xfs_agi_calc_crc(struct xfs_buf *bp);
 extern int xfs_read_agi(struct xfs_mount *mp, struct xfs_trans *tp,
 				xfs_agnumber_t agno, struct xfs_buf **bpp);
 
fs/xfs/xfs_fsops.c +2 -0
Index: linux-2.6-xfs/fs/xfs/xfs_fsops.c
===================================================================
@@ -239,8 +239,10 @@ xfs_growfs_data_private(
 		agi->agi_freecount = 0;
 		agi->agi_newino = cpu_to_be32(NULLAGINO);
 		agi->agi_dirino = cpu_to_be32(NULLAGINO);
+		uuid_copy(&agi->agi_uuid, &mp->m_sb.sb_uuid);
 		for (bucket = 0; bucket < XFS_AGI_UNLINKED_BUCKETS; bucket++)
 			agi->agi_unlinked[bucket] = cpu_to_be32(NULLAGINO);
+		xfs_buf_set_io_callback(bp, xfs_agi_calc_crc);
 		error = xfs_bwrite(mp, bp);
 		if (error) {
 			goto error0;
fs/xfs/xfs_ialloc.c +46 -5

89 lines not on this page · raw message

fs/xfs/xfs_log_recover.c +3 -0
Index: linux-2.6-xfs/fs/xfs/xfs_log_recover.c
===================================================================
@@ -1944,6 +1944,9 @@ xlog_recover_do_reg_buffer(
 	case XFS_SB_MAGIC:
 		xfs_sb_calc_crc(bp);
 		break;
+ 	case XFS_AGI_MAGIC:
+		xfs_agi_calc_crc(bp);
+		break;
 	default:
 		break;
 	}