]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
common/ext4: reformat external logs during mdrestore operations
authorDarrick J. Wong <djwong@kernel.org>
Thu, 20 Feb 2025 21:47:06 +0000 (13:47 -0800)
committerZorro Lang <zlang@kernel.org>
Thu, 6 Mar 2025 13:25:55 +0000 (21:25 +0800)
The e2image file format doesn't support the capture of external log
devices, which means that mdrestore ought to reformat the external log
to get the restored filesystem to work again.  The common/populate code
could already do this, so push it to the common ext4 helper.

While we're at it, fix the uncareful usage of SCRATCH_LOGDEV in the
populate code.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
common/ext4
common/populate

index 13921bb8165a4dadcff0803db529f5c87ea114af..e1b336d3d20cbaaf2e0e008c4a8ffbd427a3c36f 100644 (file)
@@ -134,7 +134,8 @@ _ext4_mdrestore()
 {
        local metadump="$1"
        local device="$2"
-       shift; shift
+       local logdev="$3"
+       shift; shift; shift
        local options="$@"
 
        # If we're configured for compressed dumps and there isn't already an
@@ -148,6 +149,20 @@ _ext4_mdrestore()
        test -r "$metadump" || return 1
 
        $E2IMAGE_PROG $options -r "${metadump}" "${SCRATCH_DEV}"
+       res=$?
+       test $res -ne 0 && return $res
+
+       # ext4 cannot e2image external logs, so we have to reformat the log
+       # device to match the restored fs
+       if [ "${logdev}" != "none" ]; then
+               local fsuuid="$($DUMPE2FS_PROG -h "${SCRATCH_DEV}" 2>/dev/null | \
+                               grep 'Journal UUID:' | \
+                               sed -e 's/Journal UUID:[[:space:]]*//g')"
+               $MKFS_EXT4_PROG -O journal_dev "${logdev}" \
+                               -F -U "${fsuuid}"
+               res=$?
+       fi
+       return $res
 }
 
 # this test requires the ext4 kernel support crc feature on scratch device
index e6804cbc6114ba19f541576606115a658905f65b..32dc5275e2debdce6af58c6f9f05036f77bb1d6c 100644 (file)
@@ -1034,20 +1034,12 @@ _scratch_populate_restore_cached() {
                return $?
                ;;
        "ext2"|"ext3"|"ext4")
-               _ext4_mdrestore "${metadump}" "${SCRATCH_DEV}"
-               ret=$?
-               test $ret -ne 0 && return $ret
-
-               # ext4 cannot e2image external logs, so we have to reformat
-               # the scratch device to match the restored fs
-               if [ -n "${SCRATCH_LOGDEV}" ]; then
-                       local fsuuid="$($DUMPE2FS_PROG -h "${SCRATCH_DEV}" 2>/dev/null | \
-                                       grep 'Journal UUID:' | \
-                                       sed -e 's/Journal UUID:[[:space:]]*//g')"
-                       $MKFS_EXT4_PROG -O journal_dev "${SCRATCH_LOGDEV}" \
-                                       -F -U "${fsuuid}"
-               fi
-               return 0
+               local logdev=none
+               [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
+                       logdev=$SCRATCH_LOGDEV
+
+               _ext4_mdrestore "${metadump}" "${SCRATCH_DEV}" "${logdev}"
+               return $?
                ;;
        esac
        return 1