• Chengguang Xu's avatar
    ovl: improving copy-up efficiency for big sparse file · b504c654
    Chengguang Xu authored
    Current copy-up is not efficient for big sparse file,
    It's not only slow but also wasting more disk space
    when the target lower file has huge hole inside.
    This patch tries to recognize file hole and skip it
    during copy-up.
    
    Detail logic of hole detection as below:
    When we detect next data position is larger than current
    position we will skip that hole, otherwise we copy
    data in the size of OVL_COPY_UP_CHUNK_SIZE. Actually,
    it may not recognize all kind of holes and sometimes
    only skips partial of hole area. However, it will be
    enough for most of the use cases.
    
    Additionally, this optimization relies on lseek(2)
    SEEK_DATA implementation, so for some specific
    filesystems which do not support this feature
    will behave as before on copy-up.
    Reviewed-by: default avatarAmir Goldstein <amir73il@gmail.com>
    Signed-off-by: default avatarChengguang Xu <cgxu519@mykernel.net>
    Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
    b504c654
copy_up.c 21.5 KB