mirror of
https://github.com/markusressel/zfs-inplace-rebalancing
synced 2026-02-05 05:24:07 +00:00
Replace MD5 with CRC32 for 2x checksum speed (#57)
* Replace MD5 with CRC32 for 2x checksum speed * Use % builtin instead of awk for better performance
This commit is contained in:
parent
9e5aadff04
commit
9b233fdeaf
@ -137,25 +137,25 @@ function rebalance() {
|
|||||||
# Linux
|
# Linux
|
||||||
|
|
||||||
# file attributes
|
# file attributes
|
||||||
original_md5=$(lsattr "${file_path}")
|
original_checksum=$(lsattr "${file_path}")
|
||||||
# remove anything after the last space
|
# remove anything after the last space
|
||||||
original_md5=${original_md5% *}
|
original_checksum=${original_checksum% *}
|
||||||
# file permissions, owner, group, size, modification time
|
# file permissions, owner, group, size, modification time
|
||||||
original_md5="${original_md5} $(stat -c "%A %U %G %s %Y" "${file_path}")"
|
original_checksum="${original_checksum} $(stat -c "%A %U %G %s %Y" "${file_path}")"
|
||||||
# file content
|
# file content
|
||||||
original_md5="${original_md5} $(md5sum -b "${file_path}")"
|
original_checksum="${original_checksum} $(cksum "${file_path}")"
|
||||||
|
|
||||||
|
|
||||||
# file attributes
|
# file attributes
|
||||||
copy_md5=$(lsattr "${tmp_file_path}")
|
copy_checksum=$(lsattr "${tmp_file_path}")
|
||||||
# remove anything after the last space
|
# remove anything after the last space
|
||||||
copy_md5=${copy_md5% *}
|
copy_checksum=${copy_checksum% *}
|
||||||
# file permissions, owner, group, size, modification time
|
# file permissions, owner, group, size, modification time
|
||||||
copy_md5="${copy_md5} $(stat -c "%A %U %G %s %Y" "${tmp_file_path}")"
|
copy_checksum="${copy_checksum} $(stat -c "%A %U %G %s %Y" "${tmp_file_path}")"
|
||||||
# file content
|
# file content
|
||||||
copy_md5="${copy_md5} $(md5sum -b "${tmp_file_path}")"
|
copy_checksum="${copy_checksum} $(cksum "${file_path}")"
|
||||||
# remove the temporary extension
|
# remove the temporary extension
|
||||||
copy_md5=${copy_md5%"${tmp_extension}"}
|
copy_checksum=${copy_checksum%"${tmp_extension}"}
|
||||||
elif [[ "${OSName}" == "darwin"* ]] || [[ "${OSName}" == "freebsd"* ]]; then
|
elif [[ "${OSName}" == "darwin"* ]] || [[ "${OSName}" == "freebsd"* ]]; then
|
||||||
# Mac OS
|
# Mac OS
|
||||||
# FreeBSD
|
# FreeBSD
|
||||||
@ -163,25 +163,25 @@ function rebalance() {
|
|||||||
# note: no lsattr on Mac OS or FreeBSD
|
# note: no lsattr on Mac OS or FreeBSD
|
||||||
|
|
||||||
# file permissions, owner, group size, modification time
|
# file permissions, owner, group size, modification time
|
||||||
original_md5="$(stat -f "%Sp %Su %Sg %z %m" "${file_path}")"
|
original_checksum="$(stat -f "%Sp %Su %Sg %z %m" "${file_path}")"
|
||||||
# file content
|
# file content
|
||||||
original_md5="${original_md5} $(md5 -q "${file_path}")"
|
original_checksum="${original_checksum} $(cksum "${file_path}")"
|
||||||
|
|
||||||
# file permissions, owner, group size, modification time
|
# file permissions, owner, group size, modification time
|
||||||
copy_md5="$(stat -f "%Sp %Su %Sg %z %m" "${tmp_file_path}")"
|
copy_checksum="$(stat -f "%Sp %Su %Sg %z %m" "${tmp_file_path}")"
|
||||||
# file content
|
# file content
|
||||||
copy_md5="${copy_md5} $(md5 -q "${tmp_file_path}")"
|
copy_checksum="${copy_checksum} $(cksum "${file_path}")"
|
||||||
# remove the temporary extension
|
# remove the temporary extension
|
||||||
copy_md5=${copy_md5%"${tmp_extension}"}
|
copy_checksum=${copy_checksum%"${tmp_extension}"}
|
||||||
else
|
else
|
||||||
echo "Unsupported OS type: $OSTYPE"
|
echo "Unsupported OS type: $OSTYPE"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${original_md5}" == "${copy_md5}"* ]]; then
|
if [[ "${original_checksum}" == "${copy_checksum}"* ]]; then
|
||||||
color_echo "${Green}" "MD5 OK"
|
color_echo "${Green}" "Checksum OK"
|
||||||
else
|
else
|
||||||
color_echo "${Red}" "MD5 FAILED: ${original_md5} != ${copy_md5}"
|
color_echo "${Red}" "Checksum FAILED: ${original_checksum} != ${copy_checksum}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user