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) {
239 bool checksum_error =
false;
246 WARN(
"stripe %u returned error %08lx\n",
j,
context->stripes[
j].iosb.Status);
248 return context->stripes[
j].iosb.Status;
262 checksum_error =
true;
265 checksum_error =
true;
272 checksum_error =
true;
275 ERR(
"check_csum returned %08lx\n",
Status);
288 bool recovered =
false;
292 ERR(
"out of memory\n");
299 Vcb->superblock.node_size, (
uint8_t*)t2,
false);
301 WARN(
"sync_read_phys returned %08lx\n",
Status);
308 ERR(
"recovering from checksum error at %I64x, device %I64x\n",
addr,
devices[
stripe]->devitem.dev_id);
313 t2,
Vcb->superblock.node_size);
315 WARN(
"write_data_phys returned %08lx\n",
Status);
321 }
else if (t2->address !=
addr || checksum_error)
330 ERR(
"unrecoverable checksum error at %I64x\n",
addr);
343 ERR(
"out of memory\n");
349 bool recovered =
false;
355 Vcb->superblock.sector_size,
sector,
false);
357 WARN(
"sync_read_phys returned %08lx\n",
Status);
370 WARN(
"write_data_phys returned %08lx\n",
Status);
404 WARN(
"stripe %I64u returned error %08lx\n",
i,
context->stripes[
i].iosb.Status);
406 return context->stripes[
i].iosb.Status;
420 ERR(
"unrecoverable checksum error at %I64x, device %I64x\n",
addr,
devices[
stripe]->devitem.dev_id);
422 if (checksum_error) {
426 WARN(
"address of tree was %I64x, not %I64x as expected\n", th->
address,
addr);
443 for (
i = 0;
i <
length /
Vcb->superblock.sector_size;
i++) {
450 ERR(
"unrecoverable checksum error at %I64x, device %I64x\n",
addr,
devices[
stripe]->devitem.dev_id);
462 ERR(
"check_csum returned %08lx\n",
Status);
475 bool checksum_error =
false;
480 WARN(
"stripe %u returned error %08lx\n",
j,
context->stripes[
j].iosb.Status);
482 return context->stripes[
j].iosb.Status;
491 checksum_error =
true;
494 WARN(
"address of tree was %I64x, not %I64x as expected\n", th->
address,
addr);
495 checksum_error =
true;
499 checksum_error =
true;
506 checksum_error =
true;
508 ERR(
"check_csum returned %08lx\n",
Status);
520 bool recovered =
false;
524 ERR(
"out of memory\n");
542 Vcb->superblock.node_size, (
uint8_t*)t2,
false);
544 WARN(
"sync_read_phys returned %08lx\n",
Status);
551 ERR(
"recovering from checksum error at %I64x, device %I64x\n",
addr,
devices[
stripe +
j]->devitem.dev_id);
556 cis[
stripe + badsubstripe].
offset + off, t2,
Vcb->superblock.node_size);
558 WARN(
"write_data_phys returned %08lx\n",
Status);
564 }
else if (t2->address !=
addr || checksum_error)
573 ERR(
"unrecoverable checksum error at %I64x\n",
addr);
586 ERR(
"out of memory\n");
594 bool recovered =
false;
613 Vcb->superblock.sector_size,
sector,
false);
615 WARN(
"sync_read_phys returned %08lx\n",
Status);
623 if (!
Vcb->readonly && !
devices[stripe2 + badsubstripe]->readonly &&
devices[stripe2 + badsubstripe]->devobj) {
625 cis[stripe2 + badsubstripe].
offset + off,
sector,
Vcb->superblock.sector_size);
627 WARN(
"write_data_phys returned %08lx\n",
Status);
659 bool checksum_error =
false;
662 bool no_success =
true;
666 WARN(
"stripe %u returned error %08lx\n",
j,
context->stripes[
j].iosb.Status);
668 return context->stripes[
j].iosb.Status;
681 le =
c->partial_stripes.
Flink;
682 while (le != &
c->partial_stripes) {
690 while (runlength != 0) {
706 uint64_t runend = runstart + (runlength *
Vcb->superblock.sector_size);
711 runend = runstart + (runlength *
Vcb->superblock.sector_size);
734 checksum_error =
true;
735 if (!no_success && !degraded)
738 checksum_error =
true;
739 if (!no_success && !degraded)
747 WARN(
"checksum error\n");
748 checksum_error =
true;
750 ERR(
"check_csum returned %08lx\n",
Status);
754 checksum_error =
true;
762 bool recovered =
false,
first =
true, failed =
false;
767 ERR(
"out of memory\n");
783 ERR(
"sync_read_phys returned %08lx\n",
Status);
793 ERR(
"sync_read_phys returned %08lx\n",
Status);
799 do_xor(t2, t2 +
Vcb->superblock.node_size,
Vcb->superblock.node_size);
815 ERR(
"recovering from checksum error at %I64x, device %I64x\n",
addr,
devices[
stripe]->devitem.dev_id);
822 WARN(
"write_data_phys returned %08lx\n",
Status);
830 ERR(
"unrecoverable checksum error at %I64x\n",
addr);
843 ERR(
"out of memory\n");
859 bool recovered =
false,
first =
true, failed =
false;
870 ERR(
"sync_read_phys returned %08lx\n",
Status);
879 sector +
Vcb->superblock.sector_size,
false);
881 ERR(
"sync_read_phys returned %08lx\n",
Status);
909 WARN(
"write_data_phys returned %08lx\n",
Status);
934 if (missing1 == num_stripes - 2 || missing2 == num_stripes - 2) {
935 uint16_t missing = missing1 == (num_stripes - 2) ? missing2 : missing1;
989 }
else if (
stripe == missing1)
991 else if (
stripe == missing2)
998 denom =
gdiv(1, gyx ^ 1);
999 a =
gmul(gyx, denom);
1000 b =
gmul(gx, denom);
1023 bool checksum_error =
false;
1026 bool no_success =
true;
1030 WARN(
"stripe %u returned error %08lx\n",
j,
context->stripes[
j].iosb.Status);
1034 return context->stripes[
j].iosb.Status;
1047 le =
c->partial_stripes.
Flink;
1048 while (le != &
c->partial_stripes) {
1056 while (runlength != 0) {
1072 uint64_t runend = runstart + (runlength *
Vcb->superblock.sector_size);
1077 runend = runstart + (runlength *
Vcb->superblock.sector_size);
1100 checksum_error =
true;
1104 checksum_error =
true;
1113 WARN(
"checksum error\n");
1114 checksum_error =
true;
1116 ERR(
"check_csum returned %08lx\n",
Status);
1119 }
else if (degraded)
1120 checksum_error =
true;
1122 if (!checksum_error)
1127 uint16_t k, physstripe, parity1, parity2, error_stripe;
1129 bool recovered =
false, failed =
false;
1134 ERR(
"out of memory\n");
1148 if (
j != physstripe) {
1151 sector + (
k *
Vcb->superblock.node_size),
false);
1153 ERR(
"sync_read_phys returned %08lx\n",
Status);
1182 Vcb->superblock.node_size);
1193 ERR(
"recovering from checksum error at %I64x, device %I64x\n",
addr,
devices[physstripe]->devitem.dev_id);
1201 WARN(
"write_data_phys returned %08lx\n",
Status);
1210 bool read_q =
false;
1216 ERR(
"sync_read_phys returned %08lx\n",
Status);
1247 ERR(
"recovering from checksum error at %I64x, device %I64x\n",
addr,
devices[physstripe]->devitem.dev_id);
1255 WARN(
"write_data_phys returned %08lx\n",
Status);
1260 if (
devices[error_stripe_phys] &&
devices[error_stripe_phys]->devobj) {
1262 ERR(
"recovering from parity error at %I64x, device %I64x\n",
addr,
devices[error_stripe_phys]->devitem.dev_id);
1271 Vcb->superblock.node_size);
1274 Vcb->superblock.node_size);
1279 devices[error_stripe_phys]->devitem.dev_id);
1288 if (!
Vcb->readonly &&
devices[error_stripe_phys] &&
devices[error_stripe_phys]->devobj && !
devices[error_stripe_phys]->readonly) {
1290 sector + (error_stripe *
Vcb->superblock.node_size),
Vcb->superblock.node_size);
1292 WARN(
"write_data_phys returned %08lx\n",
Status);
1301 ERR(
"unrecoverable checksum error at %I64x\n",
addr);
1314 ERR(
"out of memory\n");
1320 uint16_t physstripe, parity1, parity2;
1332 bool recovered =
false, failed =
false;
1341 if (
j != physstripe) {
1344 sector + (
k *
Vcb->superblock.sector_size),
false);
1346 ERR(
"sync_read_phys returned %08lx\n",
Status);
1383 ERR(
"recovering from checksum error at %I64x, device %I64x\n",
addr +
UInt32x32To64(
i,
Vcb->superblock.sector_size),
1384 devices[physstripe]->devitem.dev_id);
1392 WARN(
"write_data_phys returned %08lx\n",
Status);
1400 bool read_q =
false;
1406 ERR(
"sync_read_phys returned %08lx\n",
Status);
1439 ERR(
"recovering from checksum error at %I64x, device %I64x\n",
1448 WARN(
"write_data_phys returned %08lx\n",
Status);
1453 if (
devices[error_stripe_phys] &&
devices[error_stripe_phys]->devobj) {
1456 devices[error_stripe_phys]->devitem.dev_id);
1465 Vcb->superblock.sector_size);
1468 Vcb->superblock.sector_size);
1472 ERR(
"recovering from checksum error at %I64x, device %I64x\n",
1474 devices[error_stripe_phys]->devitem.dev_id);
1483 if (!
Vcb->readonly &&
devices[error_stripe_phys] &&
devices[error_stripe_phys]->devobj && !
devices[error_stripe_phys]->readonly) {
1485 sector + (error_stripe *
Vcb->superblock.sector_size),
Vcb->superblock.sector_size);
1487 WARN(
"write_data_phys returned %08lx\n",
Status);
1521 uint16_t i, startoffstripe, allowed_missing, missing_devices = 0;
1527 if (
Vcb->log_to_phys_loaded) {
1532 ERR(
"get_chunk_from_address failed\n");
1549 while (le != &
Vcb->sys_chunks) {
1562 ERR(
"out of memory\n");
1578 ERR(
"could not find chunk for %I64x in bootstrap\n",
addr);
1591 allowed_missing = 0;
1594 allowed_missing = 1;
1597 allowed_missing = 1;
1600 allowed_missing = 1;
1603 allowed_missing = 2;
1606 allowed_missing = 2;
1609 allowed_missing = 3;
1612 allowed_missing = 0;
1622 ERR(
"out of memory\n");
1636 context.sector_size =
Vcb->superblock.sector_size;
1666 ERR(
"out of memory\n");
1675 ERR(
"out of memory\n");
1689 ERR(
"MmProbeAndLockPages threw exception %08lx\n",
Status);
1697 if (startoffstripe >
i)
1699 else if (startoffstripe ==
i)
1700 context.stripes[
i].stripestart = startoff;
1704 if (endoffstripe >
i)
1706 else if (endoffstripe ==
i)
1707 context.stripes[
i].stripeend = endoff + 1;
1715 ERR(
"IoAllocateMdl failed\n");
1726 ERR(
"out of memory\n");
1745 stripeoff[
stripe] += readlen;
1747 }
else if (
length - pos < ci->stripe_length) {
1775 orig_ls =
c->last_stripe;
1792 ERR(
"out of memory\n");
1800 context.startoffstripe = startoffstripe;
1811 ERR(
"out of memory\n");
1825 ERR(
"MmProbeAndLockPages threw exception %08lx\n",
Status);
1834 ERR(
"out of memory\n");
1845 bool stripeset =
false;
1847 if (startoffstripe >
i)
1849 else if (startoffstripe ==
i)
1854 if (endoffstripe >
i)
1856 else if (endoffstripe ==
i)
1863 context.stripes[
i+
j].stripestart = sstart;
1867 if (sstart !=
send) {
1871 ERR(
"IoAllocateMdl failed\n");
1887 context.stripes[
i+
j].stripestart = sstart;
1892 if (sstart !=
send) {
1896 ERR(
"IoAllocateMdl failed\n");
1910 ERR(
"could not find stripe to read\n");
1919 ERR(
"out of memory\n");
1939 stripeoff[
stripe] += readlen;
1941 }
else if (
length - pos < ci->stripe_length) {
1964 orig_ls =
i =
c->last_stripe;
1972 ERR(
"no devices available to service request\n");
1988 ERR(
"out of memory\n");
1995 ERR(
"IoAllocateMdl failed\n");
2005 ERR(
"IoAllocateMdl failed\n");
2019 ERR(
"MmProbeAndLockPages threw exception %08lx\n",
Status);
2029 bool need_dummy =
false;
2038 ERR(
"out of memory\n");
2047 ERR(
"out of memory\n");
2061 ERR(
"MmProbeAndLockPages threw exception %08lx\n",
Status);
2078 if (
i == startoffstripe) {
2107 for (
i = 0;
i < startoffstripe;
i++) {
2137 if (endoffstripe ==
i) {
2140 }
else if (endoffstripe >
i)
2154 false,
false,
NULL);
2157 ERR(
"IoAllocateMdl failed\n");
2169 ERR(
"out of memory\n");
2178 ERR(
"IoAllocateMdl failed\n");
2192 ERR(
"out of memory\n");
2217 stripeoff[
stripe] = readlen;
2231 stripeoff[
stripe] = readlen;
2270 stripeoff[
stripe] += readlen;
2288 bool need_dummy =
false;
2297 ERR(
"out of memory\n");
2306 ERR(
"out of memory\n");
2320 ERR(
"MmProbeAndLockPages threw exception %08lx\n",
Status);
2337 if (
i == startoffstripe) {
2366 for (
i = 0;
i < startoffstripe;
i++) {
2399 if (endoffstripe ==
i) {
2402 }
else if (endoffstripe >
i)
2418 ERR(
"IoAllocateMdl failed\n");
2430 ERR(
"out of memory\n");
2439 ERR(
"IoAllocateMdl failed\n");
2453 ERR(
"out of memory\n");
2478 stripeoff[
stripe] = readlen;
2492 stripeoff[
stripe] = readlen;
2502 while (
stripe != parity1) {
2539 stripeoff[
stripe] += readlen;
2565 if (missing_devices > allowed_missing) {
2566 ERR(
"not enough devices to service request (%u missing)\n", missing_devices);
2585 ERR(
"IoAllocateIrp failed\n");
2593 ERR(
"IoMakeAssociatedIrp failed\n");
2606 if (!
context.stripes[
i].Irp->AssociatedIrp.SystemBuffer) {
2607 ERR(
"out of memory\n");
2633 need_to_wait =
false;
2637 need_to_wait =
true;
2659 ERR(
"read_data_raid0 returned %08lx\n",
Status);
2675 ERR(
"read_data_raid10 returned %08lx\n",
Status);
2690 ERR(
"read_data_dup returned %08lx\n",
Status);
2703 Status =
read_data_raid5(
Vcb, file_read ?
context.va :
buf,
addr,
length, &
context, ci,
devices,
offset,
generation,
c, missing_devices > 0 ?
true :
false);
2705 ERR(
"read_data_raid5 returned %08lx\n",
Status);
2718 Status =
read_data_raid6(
Vcb, file_read ?
context.va :
buf,
addr,
length, &
context, ci,
devices,
offset,
generation,
c, missing_devices > 0 ?
true :
false);
2720 ERR(
"read_data_raid6 returned %08lx\n",
Status);
2758 if (!
Vcb->log_to_phys_loaded)
2772 TRACE(
"tried to read beyond end of stream\n");
2777 WARN(
"tried to read zero bytes\n");
2789 if (pbr) *pbr = readlen;
2842 WARN(
"Tried to read beyond end of file\n");
2866 last_end =
ext->offset +
len;
2870 if (
ext->offset > last_end &&
ext->offset >
start + bytes_read) {
2882 WARN(
"Encryption not supported\n");
2888 WARN(
"Other encodings not supported\n");
2919 ERR(
"out of memory\n");
2924 decomp_alloc =
true;
2926 decomp =
data + bytes_read;
2927 decomp_alloc =
false;
2933 ERR(
"zlib_decompress returned %08lx\n",
Status);
2939 ERR(
"extent data was truncated\n");
2948 ERR(
"lzo_decompress returned %08lx\n",
Status);
2955 ERR(
"zstd_decompress returned %08lx\n",
Status);
2983 ERR(
"out of memory\n");
2988 rp->
mdl = (
Irp &&
Irp->MdlAddress) ?
true :
false;
3001 if (rp->
addr %
fcb->
Vcb->superblock.sector_size > 0) {
3020 ERR(
"out of memory\n");
3032 ERR(
"get_chunk_from_address(%I64x) failed\n", rp->
addr);
3058 bytes_read += rp->
read;
3080 WARN(
"Unsupported extent data type %u\n",
ed->
type);
3085 last_end =
ext->offset +
len;
3098 le = read_parts.
Flink->Flink;
3099 while (le != &read_parts) {
3111 rp2->
c = last_rp->
c;
3116 if (last_rp->
csum) {
3121 ERR(
"out of memory\n");
3137 ERR(
"out of memory\n");
3187 le = read_parts.
Flink;
3188 while (le != &read_parts) {
3191 Status =
read_data(
fcb->
Vcb, rp->
addr, rp->
to_read, rp->
csum,
false, rp->
buf, rp->
c,
NULL,
Irp, 0, rp->
mdl,
3194 ERR(
"read_data returned %08lx\n",
Status);
3208 #endif // __REACTOS__ 3210 ULONG outlen, inlen, off2;
3230 partlen = *(
uint32_t*)(buf2 + inoff);
3232 if (partlen < inlen) {
3234 inoff += partlen +
sizeof(
uint32_t);
3235 inlen -= partlen +
sizeof(
uint32_t);
3243 buf2 = &buf2[inoff];
3252 ERR(
"out of memory\n");
3261 ERR(
"out of memory\n");
3271 inpageoff, &ccj->
cj);
3273 ERR(
"add_calc_job_decomp returned %08lx\n",
Status);
3300 if (
length > 0 &&
start + bytes_read < fcb->inode_item.st_size) {
3382 WARN(
"tried to read locked region\n");
3387 TRACE(
"tried to read zero bytes\n");
3392 TRACE(
"tried to read with offset after file end (%I64x >= %I64x)\n",
start,
fcb->
Header.FileSize.QuadPart);
3401 if (
Irp->MdlAddress && !
data) {
3402 ERR(
"MmGetSystemAddressForMdlSafe returned NULL\n");
3409 Irp->IoStatus.Information = *bytes_read =
length;
3442 TRACE(
"CcCopyReadEx could not wait\n");
3447 TRACE(
"CcCopyReadEx finished\n");
3449 TRACE(
"CcCopyRead(%p, %I64x, %lx, %u, %p, %p)\n",
FileObject,
IrpSp->
Parameters.Read.ByteOffset.QuadPart,
length, wait,
data, &
Irp->IoStatus);
3452 TRACE(
"CcCopyRead could not wait\n");
3457 TRACE(
"CcCopyRead finished\n");
3466 Irp->IoStatus.Information +=
addon;
3467 *bytes_read = (
ULONG)
Irp->IoStatus.Information;
3484 ERR(
"read_stream returned %08lx\n",
Status);
3489 ERR(
"read_file returned %08lx\n",
Status);
3492 *bytes_read +=
addon;
3493 TRACE(
"read %lu bytes\n", *bytes_read);
3495 Irp->IoStatus.Information = *bytes_read;
3521 ULONG bytes_read = 0;
3526 bool acquired_fcb_lock =
false, wait;