mirror of
https://github.com/dominicusin/zfs-win
synced 2025-08-31 14:25:45 +00:00
parallel block reads for raidz, less dnodes in cache (directories only)
This commit is contained in:
@@ -251,19 +251,19 @@ namespace ZFS
|
||||
|
||||
sl.pop_front();
|
||||
|
||||
index = m_head->GetIndex(name.c_str(), index);
|
||||
index = m_head->GetIndex(name.c_str(), ZFS_DIRENT_OBJ(index));
|
||||
|
||||
index = ZFS_DIRENT_OBJ(index);
|
||||
if(index == -1) return false;
|
||||
}
|
||||
|
||||
if(!m_head->Read(index, &dn))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(!m_head->Read(ZFS_DIRENT_OBJ(index), &dn))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(dn.type != DMU_OT_DIRECTORY_CONTENTS && dn.type != DMU_OT_PLAIN_FILE_CONTENTS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(dn.type != DMU_OT_DIRECTORY_CONTENTS && dn.type != DMU_OT_PLAIN_FILE_CONTENTS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@@ -110,26 +110,36 @@ namespace ZFS
|
||||
{
|
||||
VirtualDevice& vdev = children[(size_t)rm.m_col[i].devidx];
|
||||
|
||||
bool success = false;
|
||||
|
||||
if(vdev.dev != NULL)
|
||||
{
|
||||
if(vdev.dev->Read(p, rm.m_col[i].size, rm.m_col[i].offset + 0x400000) == rm.m_col[i].size)
|
||||
{
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!success)
|
||||
{
|
||||
// TODO: reconstruct data
|
||||
|
||||
return false;
|
||||
vdev.dev->BeginRead(p, rm.m_col[i].size, rm.m_col[i].offset + 0x400000);
|
||||
}
|
||||
|
||||
p += rm.m_col[i].size;
|
||||
}
|
||||
|
||||
size_t succeeded = 1;
|
||||
|
||||
for(size_t i = 1; i < rm.m_col.size(); i++) // TODO: nparity > 1
|
||||
{
|
||||
VirtualDevice& vdev = children[(size_t)rm.m_col[i].devidx];
|
||||
|
||||
if(vdev.dev != NULL)
|
||||
{
|
||||
if(vdev.dev->EndRead() == rm.m_col[i].size)
|
||||
{
|
||||
succeeded++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(succeeded < rm.m_col.size())
|
||||
{
|
||||
// TODO: reconstruct data
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -181,23 +191,27 @@ namespace ZFS
|
||||
: m_handle(NULL)
|
||||
, m_start(0)
|
||||
, m_size(0)
|
||||
, m_offset(0)
|
||||
, m_bytes(0)
|
||||
, m_label(NULL)
|
||||
, m_active(NULL)
|
||||
{
|
||||
memset(&m_overlapped, 0, sizeof(m_overlapped));
|
||||
|
||||
m_overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
}
|
||||
|
||||
Device::~Device()
|
||||
{
|
||||
Close();
|
||||
|
||||
CloseHandle(m_overlapped.hEvent);
|
||||
}
|
||||
|
||||
bool Device::Open(const wchar_t* path, uint32_t partition)
|
||||
{
|
||||
Close();
|
||||
|
||||
m_handle = CreateFile(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, (HANDLE)NULL);
|
||||
m_handle = CreateFile(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN | FILE_FLAG_OVERLAPPED, (HANDLE)NULL);
|
||||
|
||||
if(m_handle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
@@ -217,8 +231,6 @@ namespace ZFS
|
||||
}
|
||||
}
|
||||
|
||||
m_offset = 0;
|
||||
|
||||
for(int i = 0; i < 2; i++, partition >>= 8)
|
||||
{
|
||||
uint8_t mbr[0x200];
|
||||
@@ -291,6 +303,8 @@ namespace ZFS
|
||||
{
|
||||
if(m_handle != NULL)
|
||||
{
|
||||
CancelIo(m_handle);
|
||||
|
||||
CloseHandle(m_handle);
|
||||
|
||||
m_handle = NULL;
|
||||
@@ -305,46 +319,49 @@ namespace ZFS
|
||||
|
||||
m_start = 0;
|
||||
m_size = 0;
|
||||
m_offset = 0;
|
||||
m_bytes = 0;
|
||||
|
||||
m_active = NULL;
|
||||
}
|
||||
|
||||
size_t Device::Read(void* buff, size_t size, uint64_t offset)
|
||||
{
|
||||
return BeginRead(buff, size, offset) ? EndRead() : 0;
|
||||
}
|
||||
|
||||
bool Device::BeginRead(void* buff, size_t size, uint64_t offset)
|
||||
{
|
||||
offset += m_start;
|
||||
|
||||
if(m_offset != offset)
|
||||
m_overlapped.Offset = (DWORD)offset;
|
||||
m_overlapped.OffsetHigh = (DWORD)(offset >> 32);
|
||||
|
||||
if(!ReadFile(m_handle, buff, size, NULL, &m_overlapped))
|
||||
{
|
||||
LARGE_INTEGER li, li2;
|
||||
|
||||
li.QuadPart = offset;
|
||||
|
||||
if(!SetFilePointerEx(m_handle, li, &li2, FILE_BEGIN))
|
||||
switch(GetLastError())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
m_offset = offset;
|
||||
}
|
||||
|
||||
// printf("[%d] %p %I64d - %I64d (%d) (%I64d)\n", clock(), this, m_offset, m_offset + size, size, m_bytes);
|
||||
|
||||
DWORD read = 0;
|
||||
|
||||
if(size > 0)
|
||||
{
|
||||
if(ReadFile(m_handle, buff, size, &read, NULL))
|
||||
{
|
||||
m_offset += read;
|
||||
m_bytes += read;
|
||||
case ERROR_IO_PENDING:
|
||||
break;
|
||||
case ERROR_HANDLE_EOF:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return read;
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t Device::EndRead()
|
||||
{
|
||||
DWORD size;
|
||||
|
||||
if(GetOverlappedResult(m_handle, &m_overlapped, &size, TRUE))
|
||||
{
|
||||
return (size_t)size;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// DeviceDesc
|
||||
|
||||
bool DeviceDesc::Init(vdev_phys_t& vd)
|
||||
|
@@ -75,10 +75,10 @@ namespace ZFS
|
||||
HANDLE m_handle;
|
||||
uint64_t m_start;
|
||||
uint64_t m_size;
|
||||
uint64_t m_offset;
|
||||
uint64_t m_bytes;
|
||||
vdev_label_t* m_label;
|
||||
uberblock_t* m_active;
|
||||
OVERLAPPED m_overlapped;
|
||||
|
||||
public:
|
||||
Device();
|
||||
@@ -88,5 +88,7 @@ namespace ZFS
|
||||
void Close();
|
||||
|
||||
size_t Read(void* buff, size_t size, uint64_t offset);
|
||||
bool BeginRead(void* buff, size_t size, uint64_t offset);
|
||||
size_t EndRead();
|
||||
};
|
||||
}
|
@@ -126,7 +126,10 @@ namespace ZFS
|
||||
|
||||
dn->pad3[0] = index;
|
||||
|
||||
m_cache[index] = *dn;
|
||||
if(dn->type != DMU_OT_PLAIN_FILE_CONTENTS)
|
||||
{
|
||||
m_cache[index] = *dn;
|
||||
}
|
||||
}
|
||||
|
||||
return type == DMU_OT_NONE || dn->type == type;
|
||||
|
@@ -33,7 +33,7 @@ namespace ZFS
|
||||
Pool* m_pool;
|
||||
std::vector<uint8_t> m_objset;
|
||||
std::map<uint64_t, ZapObject*> m_objdir;
|
||||
std::map<uint64_t, dnode_phys_t> m_cache; // TODO: only remember the last few nodes
|
||||
std::map<uint64_t, dnode_phys_t> m_cache;
|
||||
BlockReader* m_reader;
|
||||
uint64_t m_count;
|
||||
|
||||
|
@@ -97,7 +97,7 @@ namespace ZFS
|
||||
|
||||
s += Util::UTF8To16(ds->m_name.c_str());
|
||||
|
||||
wprintf(L"[%d] %s\n", clock(), s.c_str());
|
||||
// wprintf(L"[%d] %s\n", clock(), s.c_str());
|
||||
|
||||
for(auto i = ds->m_children.begin(); i != ds->m_children.end(); i++)
|
||||
{
|
||||
@@ -136,7 +136,7 @@ namespace ZFS
|
||||
{
|
||||
Context* ctx = (Context*)DokanFileInfo->DokanOptions->GlobalContext;
|
||||
|
||||
wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
// wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
|
||||
std::wstring fn = FileName;
|
||||
|
||||
@@ -185,7 +185,7 @@ namespace ZFS
|
||||
{
|
||||
Context* ctx = (Context*)DokanFileInfo->DokanOptions->GlobalContext;
|
||||
|
||||
wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
// wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
|
||||
std::wstring fn = FileName;
|
||||
|
||||
@@ -209,7 +209,7 @@ namespace ZFS
|
||||
{
|
||||
Context* ctx = (Context*)DokanFileInfo->DokanOptions->GlobalContext;
|
||||
|
||||
wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
// wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
|
||||
return -ERROR_ACCESS_DENIED;
|
||||
}
|
||||
@@ -220,7 +220,7 @@ namespace ZFS
|
||||
{
|
||||
Context* ctx = (Context*)DokanFileInfo->DokanOptions->GlobalContext;
|
||||
|
||||
wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
// wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
|
||||
if(DokanFileInfo->Context != 0)
|
||||
{
|
||||
@@ -238,7 +238,7 @@ namespace ZFS
|
||||
{
|
||||
Context* ctx = (Context*)DokanFileInfo->DokanOptions->GlobalContext;
|
||||
|
||||
wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
// wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
|
||||
if(DokanFileInfo->Context != 0)
|
||||
{
|
||||
@@ -260,7 +260,7 @@ namespace ZFS
|
||||
{
|
||||
Context* ctx = (Context*)DokanFileInfo->DokanOptions->GlobalContext;
|
||||
|
||||
wprintf(L"%[%d] %s: %s %d %I64d\n", clock(), __FUNCTIONW__, FileName, BufferLength, Offset);
|
||||
// wprintf(L"%[%d] %s: %s %d %I64d\n", clock(), __FUNCTIONW__, FileName, BufferLength, Offset);
|
||||
|
||||
FileContext* fctx = (FileContext*)DokanFileInfo->Context;
|
||||
|
||||
@@ -288,7 +288,7 @@ namespace ZFS
|
||||
{
|
||||
Context* ctx = (Context*)DokanFileInfo->DokanOptions->GlobalContext;
|
||||
|
||||
wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
// wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
|
||||
return -ERROR_ACCESS_DENIED;
|
||||
}
|
||||
@@ -299,7 +299,7 @@ namespace ZFS
|
||||
{
|
||||
Context* ctx = (Context*)DokanFileInfo->DokanOptions->GlobalContext;
|
||||
|
||||
wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
// wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
|
||||
return -ERROR_ACCESS_DENIED;
|
||||
}
|
||||
@@ -311,7 +311,7 @@ namespace ZFS
|
||||
{
|
||||
Context* ctx = (Context*)DokanFileInfo->DokanOptions->GlobalContext;
|
||||
|
||||
wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
// wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
|
||||
FileContext* fctx = (FileContext*)DokanFileInfo->Context;
|
||||
|
||||
@@ -350,7 +350,7 @@ namespace ZFS
|
||||
{
|
||||
Context* ctx = (Context*)DokanFileInfo->DokanOptions->GlobalContext;
|
||||
|
||||
wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
// wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
|
||||
return -ERROR_ACCESS_DENIED;
|
||||
}
|
||||
@@ -363,7 +363,7 @@ namespace ZFS
|
||||
{
|
||||
Context* ctx = (Context*)DokanFileInfo->DokanOptions->GlobalContext;
|
||||
|
||||
wprintf(L"[%d] %s: %s %s\n", clock(), __FUNCTIONW__, PathName, SearchPattern);
|
||||
// wprintf(L"[%d] %s: %s %s\n", clock(), __FUNCTIONW__, PathName, SearchPattern);
|
||||
|
||||
if(DokanFileInfo->Context != 0)
|
||||
{
|
||||
@@ -455,7 +455,7 @@ namespace ZFS
|
||||
{
|
||||
Context* ctx = (Context*)DokanFileInfo->DokanOptions->GlobalContext;
|
||||
|
||||
wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
// wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
|
||||
return -ERROR_ACCESS_DENIED;
|
||||
}
|
||||
@@ -469,7 +469,7 @@ namespace ZFS
|
||||
{
|
||||
Context* ctx = (Context*)DokanFileInfo->DokanOptions->GlobalContext;
|
||||
|
||||
wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
// wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
|
||||
return -ERROR_ACCESS_DENIED;
|
||||
}
|
||||
@@ -480,7 +480,7 @@ namespace ZFS
|
||||
{
|
||||
Context* ctx = (Context*)DokanFileInfo->DokanOptions->GlobalContext;
|
||||
|
||||
wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
// wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
|
||||
return -ERROR_ACCESS_DENIED;
|
||||
}
|
||||
@@ -491,7 +491,7 @@ namespace ZFS
|
||||
{
|
||||
Context* ctx = (Context*)DokanFileInfo->DokanOptions->GlobalContext;
|
||||
|
||||
wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
// wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
|
||||
return -ERROR_ACCESS_DENIED;
|
||||
}
|
||||
@@ -504,7 +504,7 @@ namespace ZFS
|
||||
{
|
||||
Context* ctx = (Context*)DokanFileInfo->DokanOptions->GlobalContext;
|
||||
|
||||
wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
// wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
|
||||
return -ERROR_ACCESS_DENIED;
|
||||
}
|
||||
@@ -516,7 +516,7 @@ namespace ZFS
|
||||
{
|
||||
Context* ctx = (Context*)DokanFileInfo->DokanOptions->GlobalContext;
|
||||
|
||||
wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
// wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
|
||||
return -ERROR_ACCESS_DENIED;
|
||||
}
|
||||
@@ -528,7 +528,7 @@ namespace ZFS
|
||||
{
|
||||
Context* ctx = (Context*)DokanFileInfo->DokanOptions->GlobalContext;
|
||||
|
||||
wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
// wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
|
||||
return -ERROR_ACCESS_DENIED;
|
||||
}
|
||||
@@ -541,7 +541,7 @@ namespace ZFS
|
||||
{
|
||||
Context* ctx = (Context*)DokanFileInfo->DokanOptions->GlobalContext;
|
||||
|
||||
wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
// wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
|
||||
return -ERROR_ACCESS_DENIED;
|
||||
}
|
||||
@@ -554,7 +554,7 @@ namespace ZFS
|
||||
{
|
||||
Context* ctx = (Context*)DokanFileInfo->DokanOptions->GlobalContext;
|
||||
|
||||
wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
// wprintf(L"[%d] %s: %s\n", clock(), __FUNCTIONW__, FileName);
|
||||
|
||||
return -ERROR_ACCESS_DENIED;
|
||||
}
|
||||
@@ -567,7 +567,7 @@ namespace ZFS
|
||||
{
|
||||
Context* ctx = (Context*)DokanFileInfo->DokanOptions->GlobalContext;
|
||||
|
||||
wprintf(L"[%d] %s\n", clock(), __FUNCTIONW__);
|
||||
// wprintf(L"[%d] %s\n", clock(), __FUNCTIONW__);
|
||||
|
||||
uint64_t total = 0;
|
||||
|
||||
@@ -629,7 +629,7 @@ namespace ZFS
|
||||
{
|
||||
Context* ctx = (Context*)DokanFileInfo->DokanOptions->GlobalContext;
|
||||
|
||||
wprintf(L"[%d] %s\n", clock(), __FUNCTIONW__);
|
||||
// wprintf(L"[%d] %s\n", clock(), __FUNCTIONW__);
|
||||
|
||||
if(VolumeNameBuffer != NULL)
|
||||
{
|
||||
@@ -668,7 +668,7 @@ namespace ZFS
|
||||
{
|
||||
Context* ctx = (Context*)DokanFileInfo->DokanOptions->GlobalContext;
|
||||
|
||||
wprintf(L"[%d] %s\n", clock(), __FUNCTIONW__);
|
||||
// wprintf(L"[%d] %s\n", clock(), __FUNCTIONW__);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user