Commit 8865716
btrfs-progs: re-enable tree search v2 ioctl
Commit d73e698 ("btrfs-progs: temporarily disable usage of v2 of
search tree ioctl") turned off TREE_SEARCH_V2 detection because it led
to an infinite loop in load_chunk_info() (reachable via 'btrfs
filesystem usage', reproducible by mkfs-tests/001): from the second
item in the returned buffer the data read back as all zeros while
nr_items was non-zero, so the search key never advanced.
The root cause is the type of the variable-sized buffer buf in struct
btrfs_ioctl_search_args_v2: it is declared as __u64[], but the buffer
holds a packed byte stream addressed by byte offsets. Adding such an
offset to a __u64 pointer in btrfs_tree_search_data() scaled it by 8,
so every item after the first landed past the valid data and read
zeros, which fed a zeroed key back into the search and spun forever.
Declare buf as __u8 in all in-tree copies of the struct so the offset
arithmetic is in bytes, and restore the tree search autodetection so
callers use the v2 ioctl when supported. The struct size is unchanged:
buf stays 8-byte aligned after the __u64 buf_size.
Considering a lot of subcommands are utilizing tree-search ioctl, hide
the v2 tree search behind experimental build first, only after we have
confirmed everything is fine move it out of experimental builds.
Suggested-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: You-Kai Zheng <ykzheng@synology.com>
[ Hide the v2 tree search behind experimental builds ]
Signed-off-by: Qu Wenruo <wqu@suse.com>1 parent 0dd8a92 commit 8865716
4 files changed
Lines changed: 5 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
708 | 708 | | |
709 | 709 | | |
710 | 710 | | |
711 | | - | |
712 | | - | |
713 | | - | |
714 | | - | |
715 | | - | |
| 711 | + | |
716 | 712 | | |
717 | 713 | | |
718 | | - | |
719 | 714 | | |
| 715 | + | |
720 | 716 | | |
721 | 717 | | |
722 | 718 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
626 | 626 | | |
627 | 627 | | |
628 | 628 | | |
629 | | - | |
| 629 | + | |
630 | 630 | | |
631 | 631 | | |
632 | 632 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
385 | 385 | | |
386 | 386 | | |
387 | 387 | | |
388 | | - | |
| 388 | + | |
389 | 389 | | |
390 | 390 | | |
391 | 391 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
590 | 590 | | |
591 | 591 | | |
592 | 592 | | |
593 | | - | |
| 593 | + | |
594 | 594 | | |
595 | 595 | | |
596 | 596 | | |
| |||
0 commit comments