diff --git a/cloud/filestore/libs/storage/fastshard/impl/naive_mirrored/shard.cpp b/cloud/filestore/libs/storage/fastshard/impl/naive_mirrored/shard.cpp index 584eac48eaa..f54f1d692aa 100644 --- a/cloud/filestore/libs/storage/fastshard/impl/naive_mirrored/shard.cpp +++ b/cloud/filestore/libs/storage/fastshard/impl/naive_mirrored/shard.cpp @@ -905,6 +905,20 @@ auto CreateAttrs(ui64 id, ui32 mode, ui64 size, ui64 uid, ui64 gid) return attrs; } +//////////////////////////////////////////////////////////////////////////////// + +silk::LogLevel LogLevel(const NProto::TError& e) +{ + switch (e.GetCode()) { + case E_FS_EXIST: + case E_FS_NOENT: return silk::LogLevel::DEBUG; + case E_REJECTED: return silk::LogLevel::WARN; + default: break; + } + + return silk::LogLevel::ERROR; +} + //////////////////////////////////////////////////////////////////////////////// // // TODO(#5895) - implement layout dump @@ -1182,7 +1196,8 @@ class TFiberShardImpl NProto::TNodeAttr attr; auto error = GetNodeAttr(request.GetNodeId(), name, &attr); if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "GetNodeAttrBatch::GetNodeAttr error=%s", FormatError(error).c_str()); *response.MutableError() = std::move(error); @@ -1208,6 +1223,8 @@ class TFiberShardImpl } } + SILK_DEBUG("GetNodeAttr name=%s ino=%lu", name.c_str(), nodeId); + return Nodes.GetNode(nodeId, attr); } @@ -1227,7 +1244,8 @@ class TFiberShardImpl NProto::TNodeAttr attr; auto error = GetNodeAttr(request.GetNodeId(), request.GetName(), &attr); if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "GetNodeAttr::GetNodeAttr error=%s", FormatError(error).c_str()); *response.MutableError() = std::move(error); @@ -1260,7 +1278,8 @@ class TFiberShardImpl response.MutableNode(), writeContext); if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "SetNodeAttr::Nodes.UpdateNode error=%s", FormatError(error).c_str()); *response.MutableError() = std::move(error); @@ -1272,7 +1291,8 @@ class TFiberShardImpl std::move(writeContext.Headers), std::move(writeContext.PageGroups)); if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "SetNodeAttr::WriteLogRecord error=%s", FormatError(error).c_str()); *response.MutableError() = std::move(error); @@ -1281,6 +1301,11 @@ class TFiberShardImpl PageStore->CommitPages(pages); } + SILK_DEBUG( + "SetNodeAttr ino=%lu update=%s", + request.GetNodeId(), + request.GetUpdate().ShortUtf8DebugString().Quote().c_str()); + return response; } @@ -1295,7 +1320,8 @@ class TFiberShardImpl ui64 nodeId = 0; auto error = Nodes.AllocateNodeId(&nodeId); if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "CreateNodeImpl::Nodes.AllocateNodeId error=%s", FormatError(error).c_str()); return error; @@ -1310,12 +1336,15 @@ class TFiberShardImpl error = Nodes.PutNode(*attr, writeContext); if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "CreateNodeImpl::Nodes.PutNode error=%s", FormatError(error).c_str()); return error; } + SILK_DEBUG("CreateNodeImpl name=%s ino=%lu", name.c_str(), nodeId); + return Names.Put(name, attr->GetId(), writeContext); } @@ -1356,7 +1385,8 @@ class TFiberShardImpl } if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "CreateNode::CreateNodeImpl error=%s", FormatError(error).c_str()); *response.MutableError() = std::move(error); @@ -1368,7 +1398,8 @@ class TFiberShardImpl std::move(writeContext.Headers), std::move(writeContext.PageGroups)); if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "CreateNode::WriteLogRecord error=%s", FormatError(error).c_str()); *response.MutableError() = std::move(error); @@ -1376,6 +1407,11 @@ class TFiberShardImpl return response; } + SILK_DEBUG( + "CreateNode name=%s ino=%lu", + request.GetName().c_str(), + attr.GetId()); + PageStore->CommitPages(pages); *response.MutableNode() = std::move(attr); return response; @@ -1400,14 +1436,15 @@ class TFiberShardImpl // TODO(#5894): take Links into account. // + ui64 nodeId = 0; { std::lock_guard g(Mutex); wcg.Init(); - ui64 nodeId = 0; auto error = Names.Get(request.GetName(), &nodeId); if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "UnlinkNode::Names.Get error=%s", FormatError(error).c_str()); *response.MutableError() = std::move(error); @@ -1416,7 +1453,8 @@ class TFiberShardImpl error = Names.Delete(request.GetName(), writeContext); if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "UnlinkNode::Names.Delete error=%s", FormatError(error).c_str()); *response.MutableError() = std::move(error); @@ -1426,7 +1464,8 @@ class TFiberShardImpl TNodeTableSlot slot{}; error = Nodes.DeleteNode(nodeId, writeContext, &slot); if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "UnlinkNode::Nodes.DeleteNode error=%s", FormatError(error).c_str()); *response.MutableError() = std::move(error); @@ -1455,7 +1494,8 @@ class TFiberShardImpl } if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "UnlinkNode::PageIndex.Delete error=%s", FormatError(error).c_str()); *response.MutableError() = std::move(error); @@ -1468,7 +1508,8 @@ class TFiberShardImpl error = PageAllocator.Deallocate(storagePageClusterIds, writeContext); if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "UnlinkNode::PageAllocator.Deallocate error=%s", FormatError(error).c_str()); *response.MutableError() = std::move(error); @@ -1481,7 +1522,8 @@ class TFiberShardImpl std::move(writeContext.Headers), std::move(writeContext.PageGroups)); if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "UnlinkNode::WriteLogRecord error=%s", FormatError(error).c_str()); *response.MutableError() = std::move(error); @@ -1489,6 +1531,11 @@ class TFiberShardImpl return response; } + SILK_DEBUG( + "UnlinkNode name=%s ino=%lu", + request.GetName().c_str(), + nodeId); + PageStore->CommitPages(pages); return response; } @@ -1521,7 +1568,8 @@ class TFiberShardImpl if (request.GetName().empty()) { auto error = Nodes.GetNode(nodeId, &attr); if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "CreateHandle::Nodes.GetNode error=%s", FormatError(error).c_str()); *response.MutableError() = std::move(error); @@ -1538,7 +1586,8 @@ class TFiberShardImpl writeContext, &attr); if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "CreateHandle::CreateNodeImpl error=%s", FormatError(error).c_str()); *response.MutableError() = std::move(error); @@ -1551,7 +1600,8 @@ class TFiberShardImpl request.GetName()); } } else if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "CreateHandle::Names.Get error=%s", FormatError(error).c_str()); *response.MutableError() = std::move(error); @@ -1563,7 +1613,8 @@ class TFiberShardImpl auto error = Nodes.GetNode(nodeId, &attr); if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "CreateHandle::Nodes.GetNode error=%s", FormatError(error).c_str()); *response.MutableError() = std::move(error); @@ -1572,7 +1623,8 @@ class TFiberShardImpl } if (HasError(response.GetError())) { - SILK_DEBUG( + SILK_LOG( + LogLevel(response.GetError()), "CreateHandle error=%s", FormatError(response.GetError()).c_str()); return response; @@ -1582,7 +1634,8 @@ class TFiberShardImpl ui64 handle = 0; auto error = Handles.AllocateHandle(&handle); if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "CreateHandle::Handles.AllocateHandle error=%s", FormatError(error).c_str()); *response.MutableError() = std::move(error); @@ -1593,7 +1646,8 @@ class TFiberShardImpl error = Handles.Put({.Handle = handle, .NodeId = nodeId}, writeContext); if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "CreateHandle::Handles.Put error=%s", FormatError(error).c_str()); *response.MutableError() = std::move(error); @@ -1607,7 +1661,8 @@ class TFiberShardImpl std::move(writeContext.Headers), std::move(writeContext.PageGroups)); if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "CreateHandle::WriteLogRecord error=%s", FormatError(error).c_str()); *response.MutableError() = std::move(error); @@ -1615,6 +1670,12 @@ class TFiberShardImpl return response; } + SILK_DEBUG( + "CreateHandle name=%s ino=%lu handle=%lu", + request.GetName().c_str(), + nodeId, + handle); + PageStore->CommitPages(pages); response.SetHandle(handle); @@ -1639,7 +1700,8 @@ class TFiberShardImpl auto error = Handles.Delete(request.GetHandle(), writeContext); if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "DestroyHandle::Handles.Delete error=%s", FormatError(error).c_str()); *response.MutableError() = std::move(error); @@ -1651,7 +1713,8 @@ class TFiberShardImpl } if (HasError(response.GetError())) { - SILK_DEBUG( + SILK_LOG( + LogLevel(response.GetError()), "DestroyHandle error=%s", FormatError(response.GetError()).c_str()); return response; @@ -1662,7 +1725,8 @@ class TFiberShardImpl std::move(writeContext.Headers), std::move(writeContext.PageGroups)); if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "DestroyHandle::WriteLogRecord error=%s", FormatError(error).c_str()); *response.MutableError() = std::move(error); @@ -1670,6 +1734,8 @@ class TFiberShardImpl return response; } + SILK_DEBUG("DestroyHandle handle=%lu", request.GetHandle()); + PageStore->CommitPages(pages); return response; @@ -1687,7 +1753,8 @@ class TFiberShardImpl ui64 nodeId = 0; auto error = Handles.Get(request.GetHandle(), &nodeId); if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "WriteData::Handles.Get error=%s", FormatError(error).c_str()); *response.MutableError() = std::move(error); @@ -1717,7 +1784,8 @@ class TFiberShardImpl InvalidStoragePageClusterId); error = {}; } else if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "WriteData::PageIndex.Get error=%s", FormatError(error).c_str()); break; @@ -1731,7 +1799,10 @@ class TFiberShardImpl } if (HasError(error)) { - SILK_DEBUG("WriteData error=%s", FormatError(error).c_str()); + SILK_LOG( + LogLevel(error), + "WriteData error=%s", + FormatError(error).c_str()); *response.MutableError() = std::move(error); return response; } @@ -1753,7 +1824,8 @@ class TFiberShardImpl &newStoragePageClusterIds, writeContext); if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "WriteData::PageAllocator.Allocate error=%s", FormatError(error).c_str()); *response.MutableError() = std::move(error); @@ -1800,7 +1872,8 @@ class TFiberShardImpl slot.StoragePageClusterId = *storagePageClusterIdIt; error = PageIndex.Put(slot, writeContext); if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "WriteData::PageIndex.Put error=%s", FormatError(error).c_str()); break; @@ -1840,7 +1913,8 @@ class TFiberShardImpl &page); if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "WriteData::PageStore.ReadPage error=%s", FormatError(error).c_str()); break; @@ -1866,8 +1940,15 @@ class TFiberShardImpl std::move(page), writeContext.PageGroups); + SILK_DEBUG( + "WriteData ino=%lu handle=%lu storagePage=%lu", + nodeId, + request.GetHandle(), + storagePageNo); + if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "WriteData::PageStore.WritePage error=%s", FormatError(error).c_str()); break; @@ -1878,7 +1959,10 @@ class TFiberShardImpl } if (HasError(error)) { - SILK_DEBUG("WriteData error=%s", FormatError(error).c_str()); + SILK_LOG( + LogLevel(error), + "WriteData error=%s", + FormatError(error).c_str()); break; } @@ -1886,7 +1970,10 @@ class TFiberShardImpl } if (HasError(error)) { - SILK_DEBUG("WriteData error=%s", FormatError(error).c_str()); + SILK_LOG( + LogLevel(error), + "WriteData error=%s", + FormatError(error).c_str()); PageAllocator.RollbackAllocation( newStoragePageClusterIds, @@ -1904,7 +1991,8 @@ class TFiberShardImpl error = Nodes.ResizeNode(nodeId, endOffset, writeContext); if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "WriteData::Nodes.ResizeNode error=%s", FormatError(error).c_str()); @@ -1927,7 +2015,8 @@ class TFiberShardImpl std::move(writeContext.Headers), std::move(writeContext.PageGroups)); if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "WriteData::WriteLogRecord error=%s", FormatError(error).c_str()); *response.MutableError() = std::move(error); @@ -1949,6 +2038,8 @@ class TFiberShardImpl return response; } + SILK_DEBUG("WriteData ino=%lu handle=%lu", nodeId, request.GetHandle()); + PageStore->CommitPages(pages); return response; @@ -1966,7 +2057,8 @@ class TFiberShardImpl ui64 nodeId = 0; auto error = Handles.Get(request.GetHandle(), &nodeId); if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "ReadData::Handles.Get error=%s", FormatError(error).c_str()); *response.MutableError() = std::move(error); @@ -2008,7 +2100,8 @@ class TFiberShardImpl } if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "ReadData::PageIndex.Get error=%s", FormatError(error).c_str()); break; @@ -2037,8 +2130,15 @@ class TFiberShardImpl TString page; error = PageStore->ReadPage(0 /* lsn */, storagePageNo, &page); + SILK_DEBUG( + "ReadData ino=%lu handle=%lu storagePage=%lu", + nodeId, + request.GetHandle(), + storagePageNo); + if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "ReadData::PageStore.ReadPage error=%s", FormatError(error).c_str()); break; @@ -2060,17 +2160,25 @@ class TFiberShardImpl } if (HasError(error)) { - SILK_DEBUG("ReadData error=%s", FormatError(error).c_str()); + SILK_LOG( + LogLevel(error), + "ReadData error=%s", + FormatError(error).c_str()); break; } } if (HasError(error)) { - SILK_DEBUG("ReadData error=%s", FormatError(error).c_str()); + SILK_LOG( + LogLevel(error), + "ReadData error=%s", + FormatError(error).c_str()); buffer.clear(); *response.MutableError() = std::move(error); } + SILK_DEBUG("ReadData ino=%lu handle=%lu", nodeId, request.GetHandle()); + return response; } @@ -2198,7 +2306,8 @@ class TFiberShardImpl auto error = Storage->AcquireDevices(); if (HasError(error)) { - SILK_DEBUG( + SILK_LOG( + LogLevel(error), "AcquireIfNeeded::Storage.AcquireDevices error=%s", FormatError(error).c_str()); *response.MutableError() = std::move(error);