diff options
author | Alexander Rutkovsky <alexvru@ydb.tech> | 2024-10-31 13:59:58 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-31 13:59:58 +0300 |
commit | 55a88ca3df71acb3c7fc4a085a02f2d27461b9e7 (patch) | |
tree | 8015b96cee71997d2ddaaf7abc4cd28039674814 | |
parent | ec5b47eabfa979006f708489316447380612b13d (diff) | |
download | ydb-55a88ca3df71acb3c7fc4a085a02f2d27461b9e7.tar.gz |
Fix PDisk drive size estimation code (#11098)
-rw-r--r-- | ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl_metadata.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl_metadata.cpp b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl_metadata.cpp index d604b3232a..16eba5ba26 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl_metadata.cpp +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl_metadata.cpp @@ -620,7 +620,15 @@ namespace NKikimr::NPDisk { true, fmt.DataKey, 0, 0, 1); const size_t bytesToWrite = payload.size(); - const ui64 deviceSizeInBytes = DriveData.Size & ~ui64(DefaultSectorSize - 1); + ui64 rawDeviceSize = 0; + try { + bool isBlockDevice = false; + DetectFileParameters(Cfg->Path, rawDeviceSize, isBlockDevice); + } catch (const std::exception&) { + rawDeviceSize = 0; + } + + const ui64 deviceSizeInBytes = rawDeviceSize & ~ui64(DefaultSectorSize - 1); auto& cur = unformatted.Format; const ui64 endOffset = !cur || cur->Offset + cur->Length + bytesToWrite <= deviceSizeInBytes ? deviceSizeInBytes @@ -629,7 +637,7 @@ namespace NKikimr::NPDisk { if (endOffset < bytesToWrite + FormatSectorSize * ReplicationFactor) { // way too large metadata P_LOG(PRI_ERROR, BPD01, "ProcessWriteMetadata (unformatted): not enough free space", (EndOffset, endOffset), - (RawDeviceSize, DriveData.Size), + (RawDeviceSize, rawDeviceSize), (DeviceSizeInBytes, deviceSizeInBytes), (BytesToWrite, bytesToWrite)); PCtx->ActorSystem->Send(write.Sender, new TEvWriteMetadataResult(EPDiskMetadataOutcome::ERROR, std::nullopt)); |