Re: Retrieving

Qu Wenruo
2019-01-13T11:02:55Z

[-- Attachment #1.1: Type: text/plain, Size: 1530 bytes --]

On 2019/1/13 下午6:19, Tobias Reinhard wrote:
> Hi,
>
> I want to read the complete CSUM-Tree from userspace. I tried it via the
> ioctl. This is what the code looks like:
>
> struct btrfs_sv2_args sv2_args;
> int fd = open(filename, O_RDONLY);
> sv2_args.key.tree_id = BTRFS_CSUM_TREE_OBJECTID;
> sv2_args.key.min_objectid = 0;
> sv2_args.key.max_objectid = -1;
> sv2_args.key.min_offset = 0;
> sv2_args.key.max_offset = -1;
> sv2_args.key.min_transid = 0;
> sv2_args.key.max_transid = -1;
> sv2_args.key.min_type = BTRFS_CSUM_ITEM_KEY;
> sv2_args.key.max_type = BTRFS_CSUM_ITEM_KEY;
> sv2_args.key.nr_items = -1;
> sv2_args.buf_size = sizeof(sv2_args.buf);
> ioctl(fd, BTRFS_IOC_TREE_SEARCH_V2, &sv2_args);
>
> But the device is not small and I hit the limit of the
> btrfs_sv2_args.buf which seems to be 16 MB.
>
> How can I get the *complete* CSUM-Tree?
>
> Limiting to offset does not work (My first idea was to do it this way
> and get it in chunks).

That's strange.

Are you still using 0~-1 objectid and 0~-1 type, just last_offset~-1?

Have tried searching using the following parameters?
min_objectid = max_objectid = BTRFS_EXTENT_CSUM_OBJECTID
min_type = max_type = BTRFS_CSUM_ITEM_KEY;
min_offset = last_found_csum_offset
max_offset = -1

Thanks,
Qu

>
> Limiting to a single transid does not work as well because even one
> transid is larger than the limit.
>
> Kernel is 4.15.
>
> Any help would be appreciated.
>
> Best Regards
>
> Tobias
>

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]