]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
db: enable metadump on CRC filesystems
authorDave Chinner <dchinner@redhat.com>
Wed, 13 Nov 2013 06:40:55 +0000 (06:40 +0000)
committerRich Johnston <rjohnston@sgi.com>
Thu, 14 Nov 2013 14:58:26 +0000 (08:58 -0600)
Now that we can calculate CRCs through xfs_db, we can add support
for recalculating CRCs on obfuscated metadump images. This simply
requires us to call the write verifier manually before writing the
buffer to the metadump image.

We don't need to do anything special to mdrestore, as the metadata
blocks it reads from the image file will already have all the
correct CRCs in them. Hence it can be mostly oblivious to the fact
that the filesystem it is restoring contains CRCs.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Rich Johnston <rjohnston@sgi.com>
db/metadump.c
mdrestore/xfs_mdrestore.c

index ac6a4d64894fd2db778235362c90b260de297047..117dc420e02e9f2f505a02d8e601f118faf991bf 100644 (file)
@@ -172,6 +172,22 @@ write_buf(
        __int64_t       off;
        int             i;
 
+       /*
+        * Run the write verifier to recalculate the buffer CRCs and check
+        * we are writing something valid to disk
+        */
+       if (buf->bp && buf->bp->b_ops) {
+               buf->bp->b_error = 0;
+               buf->bp->b_ops->verify_write(buf->bp);
+               if (buf->bp->b_error) {
+                       fprintf(stderr,
+       _("%s: write verifer failed on bno 0x%llx/0x%x\n"),
+                               __func__, (long long)buf->bp->b_bn,
+                               buf->bp->b_bcount);
+                       return buf->bp->b_error;
+               }
+       }
+
        for (i = 0, off = buf->bb, data = buf->data;
                        i < buf->blen;
                        i++, off++, data += BBSIZE) {
@@ -1727,6 +1743,9 @@ copy_inode_chunk(
 
                if (!process_inode(agno, agino + i, dip))
                        goto pop_out;
+
+               /* calculate the new CRC for the inode */
+               xfs_dinode_calc_crc(mp, dip);
        }
 skip_processing:
        if (!write_buf(iocur_top))
@@ -2053,11 +2072,6 @@ metadump_f(
                return 0;
        }
 
-       if (xfs_sb_version_hascrc(&mp->m_sb) && dont_obfuscate == 0) {
-               print_warning("Can't obfuscate CRC enabled filesystems yet.");
-               return 0;
-       }
-
        metablock = (xfs_metablock_t *)calloc(BBSIZE + 1, BBSIZE);
        if (metablock == NULL) {
                print_warning("memory allocation failure");
index fe61766e640e479aa65da97068612f7f36351162..e57bdb2100534aafda2cdd0c13ca5af7095f7a15 100644 (file)
@@ -109,9 +109,6 @@ perform_restore(
        if (sb.sb_magicnum != XFS_SB_MAGIC)
                fatal("bad magic number for primary superblock\n");
 
-       if (xfs_sb_version_hascrc(&sb))
-               fatal("Can't restore CRC enabled filesystems yet.\n");
-
        ((xfs_dsb_t*)block_buffer)->sb_inprogress = 1;
 
        if (is_target_file)  {