2425 {
2436
2437 TRACE(
"(%p, %p, %I64x, %I64x)\n",
Vcb,
c, stripe_start, stripe_end);
2438
2439 full_stripe_len = (
c->chunk_item->num_stripes - num_parity_stripes) *
c->chunk_item->stripe_length;
2440 run_start =
c->offset + (stripe_start * full_stripe_len);
2441 run_end =
c->offset + ((stripe_end + 1) * full_stripe_len);
2442
2443 searchkey.
obj_id = run_start;
2445 searchkey.
offset = 0xffffffffffffffff;
2446
2449 ERR(
"find_item returned %08lx\n",
Status);
2451 }
2452
2453 num_sectors = (
uint32_t)(((stripe_end - stripe_start + 1) * full_stripe_len) >>
Vcb->sector_shift);
2455
2457 if (!allocarr) {
2458 ERR(
"out of memory\n");
2460 }
2461
2463 if (!treearr) {
2464 ERR(
"out of memory\n");
2467 }
2468
2471
2474
2476 if (!
context.parity_scratch) {
2477 ERR(
"out of memory\n");
2481 }
2482
2485 if (!csumarr) {
2486 ERR(
"out of memory\n");
2491 }
2492
2495
2498 ERR(
"out of memory\n");
2504 }
2505 }
2506
2509 if (!
context.parity_scratch2) {
2510 ERR(
"out of memory\n");
2514
2518 }
2519
2521 }
2522 }
2523
2524 do {
2526
2528 break;
2529
2532
2536 bool extent_is_tree = false;
2537
2539
2541 extent_is_tree = true;
2542 else {
2544
2549 }
2550
2552 extent_is_tree = true;
2553 }
2554
2555 if (extent_is_tree)
2560
2563 searchkey.
offset = extent_start;
2564
2567 ERR(
"find_item returned %08lx\n",
Status);
2569 }
2570
2571 do {
2573
2575 break;
2576
2580
2582
2585 (
ULONG)(((csum_end - csum_start) *
Vcb->csum_size) >>
Vcb->sector_shift));
2586 }
2587
2589
2591 tp2 = next_tp2;
2593 }
2594 }
2595 }
2596
2598
2602
2605 ERR(
"out of memory\n");
2608 }
2609
2610 max_read = (
uint32_t)
min(1048576 /
c->chunk_item->stripe_length, stripe_end - stripe_start + 1);
2611
2612 for (
i = 0;
i <
c->chunk_item->num_stripes;
i++) {
2616
2617 ERR(
"out of memory\n");
2618
2619 for (
j = 0;
j <
i;
j++) {
2621 }
2623
2626 }
2627
2629 if (!
context.stripes[
i].errorarr) {
2631
2632 ERR(
"out of memory\n");
2633
2635
2636 for (
j = 0;
j <
i;
j++) {
2638 }
2640
2643 }
2644
2646
2648 context.stripes[
i].rewrite =
false;
2649 }
2650
2652
2654
2656
2657 do {
2660 bool need_wait = false;
2661
2662 if (max_read < stripe_end + 1 -
stripe)
2663 read_stripes = max_read;
2664 else
2666
2667 context.stripes_left =
c->chunk_item->num_stripes;
2668
2669
2670 for (
i = 0;
i <
c->chunk_item->num_stripes;
i++) {
2671 if (
c->devices[
i]->devobj) {
2673
2675
2677 ERR(
"IoAllocateIrp failed\n");
2679 goto end3;
2680 }
2681
2683
2687
2690 if (!
context.stripes[
i].Irp->AssociatedIrp.SystemBuffer) {
2691 ERR(
"out of memory\n");
2693 goto end3;
2694 }
2695
2697
2701 if (!
context.stripes[
i].Irp->MdlAddress) {
2702 ERR(
"IoAllocateMdl failed\n");
2704 goto end3;
2705 }
2706
2708
2714
2716 ERR(
"MmProbeAndLockPages threw exception %08lx\n",
Status);
2718 goto end3;
2719 }
2720 } else
2722
2724
2727
2729 context.stripes[
i].missing =
false;
2730
2732
2733 Vcb->scrub.data_scrubbed += read_stripes *
c->chunk_item->stripe_length;
2734 need_wait = true;
2735 } else {
2738 missing_devices++;
2740 }
2741 }
2742
2744 ERR(
"too many missing devices (%u, maximum 1)\n", missing_devices);
2746 goto end3;
2748 ERR(
"too many missing devices (%u, maximum 2)\n", missing_devices);
2750 goto end3;
2751 }
2752
2753 if (need_wait) {
2755
2756 for (
i = 0;
i <
c->chunk_item->num_stripes;
i++) {
2757 if (
c->devices[
i]->devobj)
2759 }
2760
2762 }
2763
2764
2765 for (
i = 0;
i <
c->chunk_item->num_stripes;
i++) {
2769 goto end3;
2770 }
2771 }
2772
2774 for (
i = 0;
i < read_stripes;
i++) {
2776 }
2777 } else {
2778 for (
i = 0;
i < read_stripes;
i++) {
2780 }
2781 }
2783
2784end3:
2785 for (
i = 0;
i <
c->chunk_item->num_stripes;
i++) {
2790 }
2793
2796 context.stripes[
i].buf, (
uint32_t)(read_stripes *
c->chunk_item->stripe_length));
2797
2799 ERR(
"write_data_phys returned %08lx\n",
Status);
2801 goto end2;
2802 }
2803 }
2804 }
2805 }
2806
2808 break;
2809 }
while (
stripe < stripe_end);
2810
2811end2:
2813
2814 for (
i = 0;
i <
c->chunk_item->num_stripes;
i++) {
2817 }
2819
2824
2827
2831 }
2832
2834}
unsigned short int uint16_t
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)
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)
#define BTRFS_DEV_STAT_READ_ERRORS
#define BTRFS_DEV_STAT_WRITE_ERRORS
_In_ PIO_STACK_LOCATION IrpSp
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)
static CRYPT_DATA_BLOB b2[]
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
VOID NTAPI IoFreeIrp(IN PIRP Irp)
#define STATUS_UNEXPECTED_IO_ERROR
#define _SEH2_GetExceptionCode()
#define _SEH2_EXCEPT(...)
static void scrub_raid5_stripe(device_extension *Vcb, chunk *c, scrub_context_raid56 *context, uint64_t stripe_start, uint64_t bit_start, uint64_t num, uint16_t missing_devices)
static void scrub_raid6_stripe(device_extension *Vcb, chunk *c, scrub_context_raid56 *context, uint64_t stripe_start, uint64_t bit_start, uint64_t num, uint16_t missing_devices)
struct _IO_STACK_LOCATION::@3974::@3978 Read
union _IO_STACK_LOCATION::@1575 Parameters
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
#define IRP_DEALLOCATE_BUFFER
#define IRP_INPUT_OPERATION