fix(storage): complete pending metadata and quorum fixes (#4375)

This commit is contained in:
Zhengchao An
2026-07-07 23:22:54 +08:00
committed by GitHub
parent 5533e080b0
commit 3ed414cdb4
9 changed files with 1356 additions and 59 deletions
+76 -1
View File
@@ -87,6 +87,22 @@ pub enum StorageErrorCode {
RebalanceAlreadyRunning,
OperationCanceled,
NamespaceLockQuorumUnavailable,
MaxVersionsExceeded,
InconsistentDisk,
UnsupportedDisk,
DiskNotDir,
DiskOngoingReq,
PathNotFound,
BitrotHashAlgoInvalid,
CrossDeviceLink,
LessData,
MoreData,
OutdatedXLMeta,
PartMissingOrCorrupt,
ShortWrite,
SourceStalled,
Timeout,
InvalidPath,
}
impl StorageErrorCode {
@@ -156,6 +172,22 @@ impl StorageErrorCode {
Self::RebalanceAlreadyRunning => 0x40,
Self::OperationCanceled => 0x41,
Self::NamespaceLockQuorumUnavailable => 0x42,
Self::MaxVersionsExceeded => 0x43,
Self::InconsistentDisk => 0x44,
Self::UnsupportedDisk => 0x45,
Self::DiskNotDir => 0x46,
Self::DiskOngoingReq => 0x47,
Self::PathNotFound => 0x48,
Self::BitrotHashAlgoInvalid => 0x49,
Self::CrossDeviceLink => 0x4A,
Self::LessData => 0x4B,
Self::MoreData => 0x4C,
Self::OutdatedXLMeta => 0x4D,
Self::PartMissingOrCorrupt => 0x4E,
Self::ShortWrite => 0x4F,
Self::SourceStalled => 0x50,
Self::Timeout => 0x51,
Self::InvalidPath => 0x52,
}
}
@@ -225,6 +257,22 @@ impl StorageErrorCode {
0x40 => Some(Self::RebalanceAlreadyRunning),
0x41 => Some(Self::OperationCanceled),
0x42 => Some(Self::NamespaceLockQuorumUnavailable),
0x43 => Some(Self::MaxVersionsExceeded),
0x44 => Some(Self::InconsistentDisk),
0x45 => Some(Self::UnsupportedDisk),
0x46 => Some(Self::DiskNotDir),
0x47 => Some(Self::DiskOngoingReq),
0x48 => Some(Self::PathNotFound),
0x49 => Some(Self::BitrotHashAlgoInvalid),
0x4A => Some(Self::CrossDeviceLink),
0x4B => Some(Self::LessData),
0x4C => Some(Self::MoreData),
0x4D => Some(Self::OutdatedXLMeta),
0x4E => Some(Self::PartMissingOrCorrupt),
0x4F => Some(Self::ShortWrite),
0x50 => Some(Self::SourceStalled),
0x51 => Some(Self::Timeout),
0x52 => Some(Self::InvalidPath),
_ => None,
}
}
@@ -301,9 +349,36 @@ mod tests {
(StorageErrorCode::NamespaceLockQuorumUnavailable, 0x42),
];
const DISK_PRESERVATION_ERROR_CODES: &[(StorageErrorCode, u32)] = &[
(StorageErrorCode::MaxVersionsExceeded, 0x43),
(StorageErrorCode::InconsistentDisk, 0x44),
(StorageErrorCode::UnsupportedDisk, 0x45),
(StorageErrorCode::DiskNotDir, 0x46),
(StorageErrorCode::DiskOngoingReq, 0x47),
(StorageErrorCode::PathNotFound, 0x48),
(StorageErrorCode::BitrotHashAlgoInvalid, 0x49),
(StorageErrorCode::CrossDeviceLink, 0x4A),
(StorageErrorCode::LessData, 0x4B),
(StorageErrorCode::MoreData, 0x4C),
(StorageErrorCode::OutdatedXLMeta, 0x4D),
(StorageErrorCode::PartMissingOrCorrupt, 0x4E),
(StorageErrorCode::ShortWrite, 0x4F),
(StorageErrorCode::SourceStalled, 0x50),
(StorageErrorCode::Timeout, 0x51),
(StorageErrorCode::InvalidPath, 0x52),
];
#[test]
fn storage_error_codes_roundtrip() {
for (error_code, raw_code) in ERROR_CODES {
for (error_code, raw_code) in ERROR_CODES.iter().chain(DISK_PRESERVATION_ERROR_CODES) {
assert_eq!(error_code.as_u32(), *raw_code);
assert_eq!(StorageErrorCode::from_u32(*raw_code), Some(*error_code));
}
}
#[test]
fn storage_error_disk_preservation_codes_roundtrip() {
for (error_code, raw_code) in DISK_PRESERVATION_ERROR_CODES {
assert_eq!(error_code.as_u32(), *raw_code);
assert_eq!(StorageErrorCode::from_u32(*raw_code), Some(*error_code));
}