• Omar Sandoval's avatar
    btrfs: send: get send buffer pages for protocol v2 · a4b333f2
    Omar Sandoval authored
    For encoded writes in send v2, we will get the encoded data with
    btrfs_encoded_read_regular_fill_pages(), which expects a list of raw
    pages. To avoid extra buffers and copies, we should read directly into
    the send buffer. Therefore, we need the raw pages for the send buffer.
    
    We currently allocate the send buffer with kvmalloc(), which may return
    a kmalloc'd buffer or a vmalloc'd buffer. For vmalloc, we can get the
    pages with vmalloc_to_page(). For kmalloc, we could use virt_to_page().
    However, the buffer size we use (144K) is not a power of two, which in
    theory is not guaranteed to return a page-aligned buffer, and in
    practice would waste a lot of memory due to rounding up to the next
    power of two. 144K is large enough that it usually gets allocated with
    vmalloc(), anyways. So, for send v2, replace kvmalloc() with vmalloc()
    and save the pages in an array.
    Signed-off-by: default avatarOmar Sandoval <osandov@fb.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    a4b333f2
send.c 195 KB