65#define LZO_PAGE_SIZE 4096
92 ERR(
"out of memory\n");
109 switch (
Vcb->superblock.csum_type) {
129 switch (
Vcb->superblock.csum_type) {
160 WARN(
"hash was invalid\n");
173 WARN(
"hash was invalid\n");
183 switch (
Vcb->superblock.csum_type) {
203 switch (
Vcb->superblock.csum_type) {
238 bool checksum_error =
false;
245 WARN(
"stripe %u returned error %08lx\n",
j,
context->stripes[
j].iosb.Status);
247 return context->stripes[
j].iosb.Status;
261 checksum_error =
true;
264 checksum_error =
true;
271 checksum_error =
true;
274 ERR(
"check_csum returned %08lx\n",
Status);
287 bool recovered =
false;
291 ERR(
"out of memory\n");
298 Vcb->superblock.node_size, (
uint8_t*)t2,
false);
300 WARN(
"sync_read_phys returned %08lx\n",
Status);
307 ERR(
"recovering from checksum error at %I64x, device %I64x\n",
addr,
devices[
stripe]->devitem.dev_id);
312 t2,
Vcb->superblock.node_size);
314 WARN(
"write_data_phys returned %08lx\n",
Status);
320 }
else if (t2->address !=
addr || checksum_error)
329 ERR(
"unrecoverable checksum error at %I64x\n",
addr);
342 ERR(
"out of memory\n");
348 bool recovered =
false;
354 Vcb->superblock.sector_size,
sector,
false);
356 WARN(
"sync_read_phys returned %08lx\n",
Status);
369 WARN(
"write_data_phys returned %08lx\n",
Status);
401 WARN(
"stripe %u returned error %08lx\n",
i,
context->stripes[
i].iosb.Status);
403 return context->stripes[
i].iosb.Status;
417 ERR(
"unrecoverable checksum error at %I64x, device %I64x\n",
addr,
devices[
stripe]->devitem.dev_id);
419 if (checksum_error) {
423 WARN(
"address of tree was %I64x, not %I64x as expected\n", th->
address,
addr);
447 ERR(
"unrecoverable checksum error at %I64x, device %I64x\n",
addr,
devices[
stripe]->devitem.dev_id);
459 ERR(
"check_csum returned %08lx\n",
Status);
471 bool checksum_error =
false;
476 WARN(
"stripe %u returned error %08lx\n",
j,
context->stripes[
j].iosb.Status);
478 return context->stripes[
j].iosb.Status;
487 checksum_error =
true;
490 WARN(
"address of tree was %I64x, not %I64x as expected\n", th->
address,
addr);
491 checksum_error =
true;
495 checksum_error =
true;
502 checksum_error =
true;
504 ERR(
"check_csum returned %08lx\n",
Status);
516 bool recovered =
false;
520 ERR(
"out of memory\n");
538 Vcb->superblock.node_size, (
uint8_t*)t2,
false);
540 WARN(
"sync_read_phys returned %08lx\n",
Status);
547 ERR(
"recovering from checksum error at %I64x, device %I64x\n",
addr,
devices[
stripe +
j]->devitem.dev_id);
552 cis[
stripe + badsubstripe].
offset + off, t2,
Vcb->superblock.node_size);
554 WARN(
"write_data_phys returned %08lx\n",
Status);
560 }
else if (t2->address !=
addr || checksum_error)
569 ERR(
"unrecoverable checksum error at %I64x\n",
addr);
582 ERR(
"out of memory\n");
590 bool recovered =
false;
609 Vcb->superblock.sector_size,
sector,
false);
611 WARN(
"sync_read_phys returned %08lx\n",
Status);
616 ERR(
"recovering from checksum error at %I64x, device %I64x\n",
addr + ((
uint64_t)
i <<
Vcb->sector_shift),
devices[stripe2 +
j]->devitem.dev_id);
619 if (!
Vcb->readonly && !
devices[stripe2 + badsubstripe]->readonly &&
devices[stripe2 + badsubstripe]->devobj) {
621 cis[stripe2 + badsubstripe].
offset + off,
sector,
Vcb->superblock.sector_size);
623 WARN(
"write_data_phys returned %08lx\n",
Status);
654 bool checksum_error =
false;
657 bool no_success =
true;
661 WARN(
"stripe %u returned error %08lx\n",
j,
context->stripes[
j].iosb.Status);
663 return context->stripes[
j].iosb.Status;
676 le =
c->partial_stripes.
Flink;
677 while (le != &
c->partial_stripes) {
685 while (runlength != 0) {
697 uint64_t runend = runstart + (runlength <<
Vcb->sector_shift);
719 checksum_error =
true;
720 if (!no_success && !degraded)
723 checksum_error =
true;
724 if (!no_success && !degraded)
732 WARN(
"checksum error\n");
733 checksum_error =
true;
735 ERR(
"check_csum returned %08lx\n",
Status);
739 checksum_error =
true;
747 bool recovered =
false,
first =
true, failed =
false;
752 ERR(
"out of memory\n");
768 ERR(
"sync_read_phys returned %08lx\n",
Status);
778 ERR(
"sync_read_phys returned %08lx\n",
Status);
784 do_xor(t2, t2 +
Vcb->superblock.node_size,
Vcb->superblock.node_size);
800 ERR(
"recovering from checksum error at %I64x, device %I64x\n",
addr,
devices[
stripe]->devitem.dev_id);
807 WARN(
"write_data_phys returned %08lx\n",
Status);
815 ERR(
"unrecoverable checksum error at %I64x\n",
addr);
828 ERR(
"out of memory\n");
844 bool recovered =
false,
first =
true, failed =
false;
855 ERR(
"sync_read_phys returned %08lx\n",
Status);
864 sector +
Vcb->superblock.sector_size,
false);
866 ERR(
"sync_read_phys returned %08lx\n",
Status);
894 WARN(
"write_data_phys returned %08lx\n",
Status);
919 if (missing1 == num_stripes - 2 || missing2 == num_stripes - 2) {
920 uint16_t missing = missing1 == (num_stripes - 2) ? missing2 : missing1;
975 denom =
gdiv(1, gyx ^ 1);
976 a =
gmul(gyx, denom);
999 bool checksum_error =
false;
1002 bool no_success =
true;
1006 WARN(
"stripe %u returned error %08lx\n",
j,
context->stripes[
j].iosb.Status);
1010 return context->stripes[
j].iosb.Status;
1023 le =
c->partial_stripes.
Flink;
1024 while (le != &
c->partial_stripes) {
1032 while (runlength != 0) {
1044 uint64_t runend = runstart + (runlength <<
Vcb->sector_shift);
1066 checksum_error =
true;
1070 checksum_error =
true;
1079 WARN(
"checksum error\n");
1080 checksum_error =
true;
1082 ERR(
"check_csum returned %08lx\n",
Status);
1085 }
else if (degraded)
1086 checksum_error =
true;
1088 if (!checksum_error)
1093 uint16_t k, physstripe, parity1, parity2, error_stripe = 0;
1095 bool recovered =
false, failed =
false;
1100 ERR(
"out of memory\n");
1114 if (
j != physstripe) {
1117 sector + (
k *
Vcb->superblock.node_size),
false);
1119 ERR(
"sync_read_phys returned %08lx\n",
Status);
1148 Vcb->superblock.node_size);
1159 ERR(
"recovering from checksum error at %I64x, device %I64x\n",
addr,
devices[physstripe]->devitem.dev_id);
1167 WARN(
"write_data_phys returned %08lx\n",
Status);
1176 bool read_q =
false;
1182 ERR(
"sync_read_phys returned %08lx\n",
Status);
1213 ERR(
"recovering from checksum error at %I64x, device %I64x\n",
addr,
devices[physstripe]->devitem.dev_id);
1221 WARN(
"write_data_phys returned %08lx\n",
Status);
1226 if (
devices[error_stripe_phys] &&
devices[error_stripe_phys]->devobj) {
1228 ERR(
"recovering from parity error at %I64x, device %I64x\n",
addr,
devices[error_stripe_phys]->devitem.dev_id);
1237 Vcb->superblock.node_size);
1240 Vcb->superblock.node_size);
1245 devices[error_stripe_phys]->devitem.dev_id);
1254 if (!
Vcb->readonly &&
devices[error_stripe_phys] &&
devices[error_stripe_phys]->devobj && !
devices[error_stripe_phys]->readonly) {
1256 sector + (error_stripe *
Vcb->superblock.node_size),
Vcb->superblock.node_size);
1258 WARN(
"write_data_phys returned %08lx\n",
Status);
1267 ERR(
"unrecoverable checksum error at %I64x\n",
addr);
1280 ERR(
"out of memory\n");
1286 uint16_t physstripe, parity1, parity2;
1298 bool recovered =
false, failed =
false;
1307 if (
j != physstripe) {
1312 ERR(
"sync_read_phys returned %08lx\n",
Status);
1349 ERR(
"recovering from checksum error at %I64x, device %I64x\n",
addr + ((
uint64_t)
i <<
Vcb->sector_shift),
1350 devices[physstripe]->devitem.dev_id);
1358 WARN(
"write_data_phys returned %08lx\n",
Status);
1366 bool read_q =
false;
1372 ERR(
"sync_read_phys returned %08lx\n",
Status);
1405 ERR(
"recovering from checksum error at %I64x, device %I64x\n",
1414 WARN(
"write_data_phys returned %08lx\n",
Status);
1419 if (
devices[error_stripe_phys] &&
devices[error_stripe_phys]->devobj) {
1421 ERR(
"recovering from parity error at %I64x, device %I64x\n",
addr + ((
uint64_t)
i <<
Vcb->sector_shift),
1422 devices[error_stripe_phys]->devitem.dev_id);
1431 Vcb->superblock.sector_size);
1434 Vcb->superblock.sector_size);
1438 ERR(
"recovering from checksum error at %I64x, device %I64x\n",
1440 devices[error_stripe_phys]->devitem.dev_id);
1449 if (!
Vcb->readonly &&
devices[error_stripe_phys] &&
devices[error_stripe_phys]->devobj && !
devices[error_stripe_phys]->readonly) {
1451 sector + ((
unsigned int)error_stripe <<
Vcb->sector_shift),
Vcb->superblock.sector_size);
1453 WARN(
"write_data_phys returned %08lx\n",
Status);
1462 ERR(
"unrecoverable checksum error at %I64x\n",
addr + ((
uint64_t)
i <<
Vcb->sector_shift));
1487 uint16_t i, startoffstripe, allowed_missing, missing_devices = 0;
1493 if (
Vcb->log_to_phys_loaded) {
1498 ERR(
"get_chunk_from_address failed\n");
1515 while (le != &
Vcb->sys_chunks) {
1528 ERR(
"out of memory\n");
1544 ERR(
"could not find chunk for %I64x in bootstrap\n",
addr);
1557 allowed_missing = 0;
1560 allowed_missing = 1;
1563 allowed_missing = 1;
1566 allowed_missing = 1;
1569 allowed_missing = 2;
1572 allowed_missing = 2;
1575 allowed_missing = 3;
1578 allowed_missing = 0;
1588 ERR(
"out of memory\n");
1602 context.sector_size =
Vcb->superblock.sector_size;
1632 ERR(
"out of memory\n");
1641 ERR(
"out of memory\n");
1655 ERR(
"MmProbeAndLockPages threw exception %08lx\n",
Status);
1663 if (startoffstripe >
i)
1665 else if (startoffstripe ==
i)
1666 context.stripes[
i].stripestart = startoff;
1670 if (endoffstripe >
i)
1672 else if (endoffstripe ==
i)
1673 context.stripes[
i].stripeend = endoff + 1;
1681 ERR(
"IoAllocateMdl failed\n");
1692 ERR(
"out of memory\n");
1711 stripeoff[
stripe] += readlen;
1713 }
else if (
length - pos < ci->stripe_length) {
1741 orig_ls =
c->last_stripe;
1758 ERR(
"out of memory\n");
1766 context.startoffstripe = startoffstripe;
1777 ERR(
"out of memory\n");
1791 ERR(
"MmProbeAndLockPages threw exception %08lx\n",
Status);
1800 ERR(
"out of memory\n");
1811 bool stripeset =
false;
1813 if (startoffstripe >
i)
1815 else if (startoffstripe ==
i)
1820 if (endoffstripe >
i)
1822 else if (endoffstripe ==
i)
1829 context.stripes[
i+
j].stripestart = sstart;
1833 if (sstart !=
send) {
1837 ERR(
"IoAllocateMdl failed\n");
1853 context.stripes[
i+
j].stripestart = sstart;
1858 if (sstart !=
send) {
1862 ERR(
"IoAllocateMdl failed\n");
1876 ERR(
"could not find stripe to read\n");
1885 ERR(
"out of memory\n");
1905 stripeoff[
stripe] += readlen;
1907 }
else if (
length - pos < ci->stripe_length) {
1930 orig_ls =
i =
c->last_stripe;
1938 ERR(
"no devices available to service request\n");
1954 ERR(
"out of memory\n");
1961 ERR(
"IoAllocateMdl failed\n");
1971 ERR(
"IoAllocateMdl failed\n");
1985 ERR(
"MmProbeAndLockPages threw exception %08lx\n",
Status);
1995 bool need_dummy =
false;
2004 ERR(
"out of memory\n");
2013 ERR(
"out of memory\n");
2027 ERR(
"MmProbeAndLockPages threw exception %08lx\n",
Status);
2044 if (
i == startoffstripe) {
2073 for (
i = 0;
i < startoffstripe;
i++) {
2103 if (endoffstripe ==
i) {
2106 }
else if (endoffstripe >
i)
2120 false,
false,
NULL);
2123 ERR(
"IoAllocateMdl failed\n");
2135 ERR(
"out of memory\n");
2144 ERR(
"IoAllocateMdl failed\n");
2158 ERR(
"out of memory\n");
2183 stripeoff[
stripe] = readlen;
2197 stripeoff[
stripe] = readlen;
2236 stripeoff[
stripe] += readlen;
2254 bool need_dummy =
false;
2263 ERR(
"out of memory\n");
2272 ERR(
"out of memory\n");
2286 ERR(
"MmProbeAndLockPages threw exception %08lx\n",
Status);
2303 if (
i == startoffstripe) {
2332 for (
i = 0;
i < startoffstripe;
i++) {
2365 if (endoffstripe ==
i) {
2368 }
else if (endoffstripe >
i)
2384 ERR(
"IoAllocateMdl failed\n");
2396 ERR(
"out of memory\n");
2405 ERR(
"IoAllocateMdl failed\n");
2419 ERR(
"out of memory\n");
2444 stripeoff[
stripe] = readlen;
2458 stripeoff[
stripe] = readlen;
2468 while (
stripe != parity1) {
2505 stripeoff[
stripe] += readlen;
2531 if (missing_devices > allowed_missing) {
2532 ERR(
"not enough devices to service request (%u missing)\n", missing_devices);
2551 ERR(
"IoAllocateIrp failed\n");
2559 ERR(
"IoMakeAssociatedIrp failed\n");
2572 if (!
context.stripes[
i].Irp->AssociatedIrp.SystemBuffer) {
2573 ERR(
"out of memory\n");
2599 need_to_wait =
false;
2603 need_to_wait =
true;
2625 ERR(
"read_data_raid0 returned %08lx\n",
Status);
2641 ERR(
"read_data_raid10 returned %08lx\n",
Status);
2656 ERR(
"read_data_dup returned %08lx\n",
Status);
2669 Status =
read_data_raid5(
Vcb, file_read ?
context.va :
buf,
addr,
length, &
context, ci,
devices,
offset,
generation,
c, missing_devices > 0 ?
true :
false);
2671 ERR(
"read_data_raid5 returned %08lx\n",
Status);
2684 Status =
read_data_raid6(
Vcb, file_read ?
context.va :
buf,
addr,
length, &
context, ci,
devices,
offset,
generation,
c, missing_devices > 0 ?
true :
false);
2686 ERR(
"read_data_raid6 returned %08lx\n",
Status);
2724 if (!
Vcb->log_to_phys_loaded)
2739 TRACE(
"tried to read beyond end of stream\n");
2744 WARN(
"tried to read zero bytes\n");
2748 if (
start + length < fcb->adsdata.Length)
2756 if (pbr) *pbr = readlen;
2810 WARN(
"Tried to read beyond end of file\n");
2836 last_end =
ext->offset +
len;
2840 if (
ext->offset > last_end &&
ext->offset >
start + bytes_read) {
2852 WARN(
"Encryption not supported\n");
2858 WARN(
"Other encodings not supported\n");
2889 ERR(
"out of memory\n");
2894 decomp_alloc =
true;
2896 decomp =
data + bytes_read;
2897 decomp_alloc =
false;
2903 ERR(
"zlib_decompress returned %08lx\n",
Status);
2909 ERR(
"extent data was truncated\n");
2918 ERR(
"lzo_decompress returned %08lx\n",
Status);
2925 ERR(
"zstd_decompress returned %08lx\n",
Status);
2954 ERR(
"out of memory\n");
2959 rp->mdl = (
Irp &&
Irp->MdlAddress) ?
true :
false;
2960 rp->extents[0].off =
start + bytes_read -
ext->offset;
2962 rp->num_extents = 1;
2963 rp->csum_free =
false;
2972 if (rp->addr & (
fcb->
Vcb->superblock.sector_size - 1)) {
2973 rp->bumpoff = rp->addr & (
fcb->
Vcb->superblock.sector_size - 1);
2974 rp->addr -= rp->bumpoff;
2983 (
length & (
fcb->
Vcb->superblock.sector_size - 1)) == 0) {
2984 rp->buf =
data + bytes_read;
2985 rp->buf_free =
false;
2988 rp->buf_free =
true;
2991 ERR(
"out of memory\n");
3003 ERR(
"get_chunk_from_address(%I64x) failed\n", rp->addr);
3018 rp->csum =
ext->csum;
3022 rp->data =
data + bytes_read;
3024 rp->extents[0].ed_offset = ed2->
offset;
3025 rp->extents[0].ed_size = ed2->
size;
3026 rp->extents[0].ed_num_bytes = ed2->
num_bytes;
3030 bytes_read += rp->read;
3052 WARN(
"Unsupported extent data type %u\n", ed->
type);
3057 last_end =
ext->offset +
len;
3070 le = read_parts.
Flink->Flink;
3071 while (le != &read_parts) {
3083 rp2->
c = last_rp->
c;
3088 if (last_rp->
csum) {
3093 ERR(
"out of memory\n");
3109 ERR(
"out of memory\n");
3159 le = read_parts.
Flink;
3160 while (le != &read_parts) {
3163 Status =
read_data(
fcb->
Vcb, rp->
addr, rp->
to_read, rp->
csum,
false, rp->
buf, rp->
c,
NULL,
Irp, 0, rp->
mdl,
3166 ERR(
"read_data returned %08lx\n",
Status);
3178 ULONG outlen, inlen, off2;
3198 partlen = *(
uint32_t*)(buf2 + inoff);
3200 if (partlen < inlen) {
3202 inoff += partlen +
sizeof(
uint32_t);
3203 inlen -= partlen +
sizeof(
uint32_t);
3211 buf2 = &buf2[inoff];
3226 ERR(
"out of memory\n");
3233 ERR(
"out of memory\n");
3248 inpageoff, &ccj->
cj);
3250 ERR(
"add_calc_job_decomp returned %08lx\n",
Status);
3269 if (
length > 0 &&
start + bytes_read < fcb->inode_item.st_size) {
3349 WARN(
"tried to read locked region\n");
3354 TRACE(
"tried to read zero bytes\n");
3359 TRACE(
"tried to read with offset after file end (%I64x >= %I64x)\n",
start,
fcb->
Header.FileSize.QuadPart);
3386 Irp->IoStatus.Information +=
addon;
3387 *bytes_read = (
ULONG)
Irp->IoStatus.Information;
3396 if (
Irp->MdlAddress && !
data) {
3397 ERR(
"MmGetSystemAddressForMdlSafe returned NULL\n");
3404 Irp->IoStatus.Information = *bytes_read =
length;
3433 TRACE(
"CcCopyReadEx could not wait\n");
3438 TRACE(
"CcCopyReadEx finished\n");
3440 TRACE(
"CcCopyRead(%p, %I64x, %lx, %u, %p, %p)\n",
FileObject,
IrpSp->
Parameters.
Read.ByteOffset.QuadPart,
length, wait,
data, &
Irp->IoStatus);
3443 TRACE(
"CcCopyRead could not wait\n");
3448 TRACE(
"CcCopyRead finished\n");
3456 Irp->IoStatus.Information +=
addon;
3457 *bytes_read = (
ULONG)
Irp->IoStatus.Information;
3474 ERR(
"read_stream returned %08lx\n",
Status);
3479 ERR(
"read_file returned %08lx\n",
Status);
3482 *bytes_read +=
addon;
3483 TRACE(
"read %lu bytes\n", *bytes_read);
3485 Irp->IoStatus.Information = *bytes_read;
3511 ULONG bytes_read = 0;
3516 bool acquired_fcb_lock =
false, wait;
3532 Irp->IoStatus.Information = 0;
3546 ERR(
"fcb was NULL\n");
3554 ERR(
"ccb was NULL\n");
3560 WARN(
"insufficient privileges\n");
3565 if (
fcb ==
Vcb->volume_fcb) {
3566 TRACE(
"reading volume FCB\n");
3602 acquired_fcb_lock =
true;
3607 if (acquired_fcb_lock)
3617 TRACE(
"Irp->IoStatus.Status = %08lx\n",
Irp->IoStatus.Status);
3618 TRACE(
"Irp->IoStatus.Information = %Iu\n",
Irp->IoStatus.Information);
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
unsigned short int uint16_t
static const addon_info_t * addon
#define InterlockedDecrement
HRESULT read_stream(BSCallback *, IStream *, void *, DWORD, DWORD *) DECLSPEC_HIDDEN
void blake2b(void *out, size_t outlen, const void *in, size_t inlen)
NTSTATUS read_file(fcb *fcb, uint8_t *data, uint64_t start, uint64_t length, ULONG *pbr, PIRP Irp) __attribute__((nonnull(1
uint8_t gdiv(uint8_t a, uint8_t b)
_Post_satisfies_ static stripe __inline void get_raid0_offset(_In_ uint64_t off, _In_ uint64_t stripe_length, _In_ uint16_t num_stripes, _Out_ uint64_t *stripeoff, _Out_ uint16_t *stripe)
bool add_thread_job(device_extension *Vcb, PIRP Irp)
uint8_t gmul(uint8_t a, uint8_t b)
void do_calc_job(device_extension *Vcb, uint8_t *data, uint32_t sectors, void *csum)
NTSTATUS zlib_decompress(uint8_t *inbuf, uint32_t inlen, uint8_t *outbuf, uint32_t outlen)
void galois_double(uint8_t *data, uint32_t len)
NTSTATUS zstd_decompress(uint8_t *inbuf, uint32_t inlen, uint8_t *outbuf, uint32_t outlen)
#define _Dispatch_type_(a)
NTSTATUS lzo_decompress(uint8_t *inbuf, uint32_t inlen, uint8_t *outbuf, uint32_t outlen, uint32_t inpageoff)
NTSTATUS do_read_job(PIRP Irp)
VOID(__stdcall * tFsRtlUpdateDiskCounters)(ULONG64 BytesRead, ULONG64 BytesWritten)
NTSTATUS add_calc_job_decomp(device_extension *Vcb, uint8_t compression, void *in, unsigned int inlen, void *out, unsigned int outlen, unsigned int off, calc_job **pcj)
NTSTATUS vol_read(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
static __inline POPLOCK fcb_oplock(fcb *fcb)
NTSTATUS NTSTATUS NTSTATUS NTSTATUS NTSTATUS chunk * get_chunk_from_address(device_extension *Vcb, uint64_t address) __attribute__((nonnull(1)))
VOID(__stdcall * tPsUpdateDiskCounters)(PEPROCESS Process, ULONG64 BytesRead, ULONG64 BytesWritten, ULONG ReadOperationCount, ULONG WriteOperationCount, ULONG FlushOperationCount)
void galois_divpower(uint8_t *data, uint8_t div, uint32_t readlen)
NTSTATUS write_data_phys(_In_ PDEVICE_OBJECT device, _In_ PFILE_OBJECT fileobj, _In_ uint64_t address, _In_reads_bytes_(length) void *data, _In_ uint32_t length)
PEPROCESS __stdcall PsGetThreadProcess(_In_ PETHREAD Thread)
void calc_sha256(uint8_t *hash, const void *input, size_t len)
void calc_thread_main(device_extension *Vcb, calc_job *cj)
BOOLEAN(__stdcall * tCcCopyReadEx)(PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset, ULONG Length, BOOLEAN Wait, PVOID Buffer, PIO_STATUS_BLOCK IoStatus, PETHREAD IoIssuerThread)
static __inline void * map_user_buffer(PIRP Irp, ULONG priority)
NTSTATUS bool void get_raid56_lock_range(chunk *c, uint64_t address, uint64_t length, uint64_t *lockaddr, uint64_t *locklen) __attribute__((nonnull(1
VOID NTAPI CcMdlReadComplete(IN PFILE_OBJECT FileObject, IN PMDL MdlChain)
VOID NTAPI CcMdlRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, OUT PMDL *MdlChain, OUT PIO_STATUS_BLOCK IoStatus)
VOID NTAPI CcFlushCache(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, OUT OPTIONAL PIO_STATUS_BLOCK IoStatus)
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))
#define STATUS_NOT_IMPLEMENTED
#define RtlFindNextForwardRunClear
#define RtlFindFirstRunClear
#define NT_SUCCESS(StatCode)
#define crc32(crc, buf, len)
static const WCHAR *const ext[]
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
void log_device_error(_In_ device_extension *Vcb, _Inout_ device *dev, _In_ int error)
void chunk_lock_range(_In_ device_extension *Vcb, _In_ chunk *c, _In_ uint64_t start, _In_ uint64_t length)
void chunk_unlock_range(_In_ device_extension *Vcb, _In_ chunk *c, _In_ uint64_t start, _In_ uint64_t length)
bool is_top_level(_In_ PIRP Irp)
NTSTATUS sync_read_phys(_In_ PDEVICE_OBJECT DeviceObject, _In_ PFILE_OBJECT FileObject, _In_ uint64_t StartingOffset, _In_ ULONG Length, _Out_writes_bytes_(Length) PUCHAR Buffer, _In_ bool override)
void init_file_cache(_In_ PFILE_OBJECT FileObject, _In_ CC_FILE_SIZES *ccfs)
_In_ uint64_t _In_ uint64_t _In_ uint64_t generation
_Ret_maybenull_ device * find_device_from_uuid(_In_ device_extension *Vcb, _In_ BTRFS_UUID *uuid)
#define BTRFS_COMPRESSION_LZO
#define BTRFS_DEV_STAT_GENERATION_ERRORS
#define BTRFS_COMPRESSION_ZLIB
#define BTRFS_COMPRESSION_ZSTD
#define EXTENT_TYPE_PREALLOC
#define BTRFS_DEV_STAT_READ_ERRORS
#define BTRFS_ENCODING_NONE
#define EXTENT_TYPE_INLINE
#define BLOCK_FLAG_RAID1C4
#define BTRFS_DEV_STAT_WRITE_ERRORS
#define EXTENT_TYPE_REGULAR
#define BTRFS_COMPRESSION_NONE
#define BLOCK_FLAG_RAID1C3
#define BTRFS_ENCRYPTION_NONE
#define BTRFS_DEV_STAT_CORRUPTION_ERRORS
_In_ PIO_STACK_LOCATION IrpSp
static struct all_devices * devices
#define RemoveEntryList(Entry)
#define InsertTailList(ListHead, Entry)
#define InsertHeadList(ListHead, Entry)
#define ExAllocatePoolWithTag(hernya, size, tag)
#define IsListEmpty(ListHead)
#define PsGetCurrentThread()
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
#define RtlCompareMemory(s1, s2, l)
#define KeInitializeEvent(pEvt, foo, foo2)
#define KeSetEvent(pEvt, foo, foo2)
#define RemoveTailList(ListHead)
#define RemoveHeadList(ListHead)
#define InitializeListHead(ListHead)
#define ExAcquireResourceSharedLite(res, wait)
BOOLEAN NTAPI FsRtlCheckLockForReadAccess(IN PFILE_LOCK FileLock, IN PIRP Irp)
@ ReadDataStatus_MissingDevice
tCcCopyReadEx fCcCopyReadEx
NTSTATUS check_csum(device_extension *Vcb, uint8_t *data, uint32_t sectors, void *csum)
void raid6_recover2(uint8_t *sectors, uint16_t num_stripes, ULONG sector_size, uint16_t missing1, uint16_t missing2, uint8_t *out)
static NTSTATUS read_data_raid6(device_extension *Vcb, uint8_t *buf, uint64_t addr, uint32_t length, read_data_context *context, CHUNK_ITEM *ci, device **devices, uint64_t offset, uint64_t generation, chunk *c, bool degraded)
NTSTATUS do_read(PIRP Irp, bool wait, ULONG *bytes_read)
bool check_sector_csum(device_extension *Vcb, void *buf, void *csum)
tPsUpdateDiskCounters fPsUpdateDiskCounters
tFsRtlUpdateDiskCounters fFsRtlUpdateDiskCounters
static NTSTATUS read_data_raid0(device_extension *Vcb, uint8_t *buf, uint64_t addr, uint32_t length, read_data_context *context, CHUNK_ITEM *ci, device **devices, uint64_t generation, uint64_t offset)
static NTSTATUS read_data_raid5(device_extension *Vcb, uint8_t *buf, uint64_t addr, uint32_t length, read_data_context *context, CHUNK_ITEM *ci, device **devices, uint64_t offset, uint64_t generation, chunk *c, bool degraded)
void get_sector_csum(device_extension *Vcb, void *buf, void *csum)
static NTSTATUS read_data_dup(device_extension *Vcb, uint8_t *buf, uint64_t addr, read_data_context *context, CHUNK_ITEM *ci, device **devices, uint64_t generation)
static NTSTATUS read_data_raid10(device_extension *Vcb, uint8_t *buf, uint64_t addr, uint32_t length, read_data_context *context, CHUNK_ITEM *ci, device **devices, uint64_t generation, uint64_t offset)
bool check_tree_checksum(device_extension *Vcb, tree_header *th)
void get_tree_checksum(device_extension *Vcb, tree_header *th, void *csum)
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
#define FSRTL_FLAG2_IS_PAGING_FILE
GLint GLint GLint GLint GLint x
GLuint GLuint GLsizei GLenum type
GLint GLint GLint GLint GLint GLint y
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLdouble GLdouble GLdouble GLdouble q
GLboolean GLboolean GLboolean b
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint GLsizei GLsizei * length
GLenum const GLvoid * addr
GLboolean GLboolean GLboolean GLboolean a
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
#define EXCEPTION_EXECUTE_HANDLER
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
VOID NTAPI MmProbeAndLockPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
VOID NTAPI MmUnlockPages(IN PMDL Mdl)
VOID NTAPI MmBuildMdlForNonPagedPool(IN PMDL Mdl)
static PIO_STATUS_BLOCK iosb
DRIVER_DISPATCH(nfs41_FsdDispatch)
#define _Function_class_(n)
#define _Out_writes_bytes_(s)
#define _In_reads_bytes_opt_(s)
#define IoSkipCurrentIrpStackLocation(Irp)
BOOLEAN NTAPI CcCopyRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus)
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
ULONG NTAPI ExIsResourceAcquiredSharedLite(IN PERESOURCE Resource)
#define IoCompleteRequest
BOOLEAN NTAPI IoIsOperationSynchronous(IN PIRP Irp)
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
PIRP NTAPI IoGetTopLevelIrp(VOID)
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
VOID NTAPI IoFreeIrp(IN PIRP Irp)
PIRP NTAPI IoMakeAssociatedIrp(IN PIRP Irp, IN CCHAR StackSize)
BOOLEAN NTAPI IoIsSystemThread(IN PETHREAD Thread)
#define STATUS_INTERNAL_ERROR
#define STATUS_FILE_LOCK_CONFLICT
#define STATUS_UNEXPECTED_IO_ERROR
NTSTATUS NTAPI FsRtlCheckOplock(IN POPLOCK Oplock, IN PIRP Irp, IN PVOID Context, IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL)
#define _SEH2_GetExceptionCode()
#define _SEH2_EXCEPT(...)
#define offsetof(TYPE, MEMBER)
#define STATUS_DEVICE_NOT_READY
#define STATUS_MORE_PROCESSING_REQUIRED
#define STATUS_END_OF_FILE
#define BTRFS_TYPE_DIRECTORY
#define BLOCK_FLAG_DUPLICATE
#define BLOCK_FLAG_RAID10
LARGE_INTEGER ValidDataLength
LARGE_INTEGER AllocationSize
struct _IO_STACK_LOCATION::@4104::@4108 Read
union _IO_STACK_LOCATION::@1611 Parameters
struct _LIST_ENTRY * Blink
struct _LIST_ENTRY * Flink
struct _device_extension * Vcb
FSRTL_ADVANCED_FCB_HEADER Header
uint16_t sectors_per_stripe
read_data_stripe * stripes
enum read_data_status status
struct read_data_context * context
read_part_extent extents[1]
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define CONTAINING_RECORD(address, type, field)
#define STATUS_INVALID_DEVICE_REQUEST
#define STATUS_ACCESS_DENIED
#define STATUS_INVALID_PARAMETER
#define STATUS_INSUFFICIENT_RESOURCES
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
_In_ PDEVICE_OBJECT DeviceObject
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
#define IoIsErrorUserInduced(Status)
#define IRP_DEALLOCATE_BUFFER
#define IRP_INPUT_OPERATION
#define FO_SYNCHRONOUS_IO
#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority)
XXH_PUBLIC_API unsigned long long XXH64(const void *input, size_t len, unsigned long long seed)