linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zygo Blaxell <ce3g8jdj@umail.furryterror.org>
To: Tobias Reinhard <trtracer@gmail.com>
Cc: "linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Re: Retrieving
Date: Fri, 25 Jan 2019 16:22:22 -0500	[thread overview]
Message-ID: <20190125212222.GA9995@hungrycats.org> (raw)
In-Reply-To: <4472aad4-86cb-7ce2-6055-1ff8d6955969@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1680 bytes --]

On Sun, Jan 13, 2019 at 11:19:04AM +0100, Tobias Reinhard wrote:
> 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).

The search key is (objectid, BTRFS_CSUM_ITEM_KEY, offset) and the key is
treated as a single 136-bit integer for filtering and sorting purposes.
According to key order:

	(123, BTRFS_CSUM_ITEM_KEY, 456) < (124, BTRFS_CSUM_ITEM_KEY, 234)

You must iterate by objectid (the extent bytenr), key, and offset (the
length of the csum data).  In many btrfs trees you will get extra data
in the search results with different type fields which you will have
to discard.

> 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: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

      parent reply	other threads:[~2019-01-25 21:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-13 10:19 Retrieving Tobias Reinhard
2019-01-13 11:02 ` Retrieving Qu Wenruo
2019-01-25 16:59   ` Retrieving CSUM-Tree Tobias Reinhard
2019-01-25 18:05     ` Hans van Kranenburg
2019-01-25 20:45       ` Tobias Reinhard
2019-01-25 20:49         ` Hans van Kranenburg
2019-01-25 21:22 ` Zygo Blaxell [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190125212222.GA9995@hungrycats.org \
    --to=ce3g8jdj@umail.furryterror.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=trtracer@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).