• Omar Sandoval's avatar
    btrfs: simplify direct I/O read repair · fd9d6670
    Omar Sandoval authored
    Direct I/O read repair was originally implemented in commit 8b110e39
    ("Btrfs: implement repair function when direct read fails"). This
    implementation is unnecessarily complicated. There is major code
    duplication between __btrfs_subio_endio_read() (checks checksums and
    handles I/O errors for files with checksums),
    __btrfs_correct_data_nocsum() (handles I/O errors for files without
    checksums), btrfs_retry_endio() (checks checksums and handles I/O errors
    for retries of files with checksums), and btrfs_retry_endio_nocsum()
    (handles I/O errors for retries of files without checksum). If it sounds
    like these should be one function, that's because they should.
    Additionally, these functions are very hard to follow due to their
    excessive use of goto.
    
    This commit replaces the original implementation. After the previous
    commit getting rid of orig_bio, we can reuse the same endio callback for
    repair I/O and the original I/O, we just need to track the file offset
    and original iterator in the repair bio. We can also unify the handling
    of files with and without checksums and simplify the control flow. We
    also no longer have to wait for each repair I/O to complete one by one.
    Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
    Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
    Signed-off-by: default avatarOmar Sandoval <osandov@fb.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    fd9d6670
inode.c 284 KB