• Josef Bacik's avatar
    Btrfs: add a io_ctl struct and helpers for dealing with the space cache · a67509c3
    Josef Bacik authored
    In writing and reading the space cache we have one big loop that keeps track of
    which page we are on and then a bunch of sizeable loops underneath this big loop
    to try and read/write out properly.  Especially in the write case this makes
    things hugely complicated and hard to follow, and makes our error checking and
    recovery equally as complex.  So add a io_ctl struct with a bunch of helpers to
    keep track of the pages we have, where we are, if we have enough space etc.
    This unifies how we deal with the pages we're writing and keeps all the messy
    tracking internal.  This allows us to kill the big loops in both the read and
    write case and makes reviewing and chaning the write and read paths much
    simpler.  I've run xfstests and stress.sh on this code and it survives.  Thanks,
    Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
    a67509c3
free-space-cache.c 67.5 KB