[PATCH 21/30] db: verify and calculate dquot CRCs

Dave Chinner
2013-10-30T04:31:36Z

When we set the current Io cursor to point at a dquot block, verify
that the dquot CRC is intact. And prior to writing such an IO
cursor, calculate the dquot CRC.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
db/io.c | 5 ++++-
db/io.h | 1 +
2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/db/io.c b/db/io.c
index 8ddb5e5..7281148 100644
--- a/db/io.c
+++ b/db/io.c
@@ -464,7 +464,9 @@ write_cur(void)

if (iocur_top->ino_buf)
libxfs_dinode_calc_crc(mp, iocur_top->data);
-
+ if (iocur_top->dquot_buf)
+ xfs_update_cksum(iocur_top->data, sizeof(struct xfs_dqblk),
+ XFS_DQUOT_CRC_OFF);
if (iocur_top->bbmap)
write_cur_bbs();
else
@@ -538,6 +540,7 @@ set_cur(
iocur_top->dirino = dirino;
iocur_top->mode = mode;
iocur_top->ino_buf = 0;
+ iocur_top->dquot_buf = 0;

/* store location in ring */
if (ring_flag)
diff --git a/db/io.h b/db/io.h
index 1f8270d..4f24c83 100644
--- a/db/io.h
+++ b/db/io.h
@@ -40,6 +40,7 @@ typedef struct iocur {
struct xfs_buf *bp; /* underlying buffer */
int ino_crc_ok:1;
int ino_buf:1;
+ int dquot_buf:1;
} iocur_t;

#define DB_RING_ADD 1 /* add to ring on set_cur */
--
1.8.4.rc3