• Boris Burkov's avatar
    btrfs: add helper for inline owner ref lookup · 8d299091
    Boris Burkov authored
    Inline ref parsing is a bit tricky and relies on a decent amount of
    implicit information, so I think it is beneficial to have a helper
    function for reading the owner ref, if only to "document" the format,
    along with the write path.
    
    The main subtlety of note which I was missing by open-coding this was
    that it is important to check whether or not inline refs are present
    *at all*. i.e., if we are writing out a new extent under squotas, we
    will always use a big enough item for the inline ref and have it.
    However, it is possible that some random item predating squotas will not
    have any inline refs. In that case, trying to read the "type" field of
    the first inline ref will just be reading garbage in the form of
    whatever is in the next item.
    
    This will be used by the extent free-ing path, which looks up data
    extent owners as well as a relocation path which needs to grab the owner
    before relocating an extent.
    Signed-off-by: default avatarBoris Burkov <boris@bur.io>
    Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    8d299091
extent-tree.h 5.03 KB