28 Jul, 2017

1 commit

  • When a lba either hits the cache or corresponds to an empty entry in the
    L2P table, we need to advance the bio according to the position in which
    the lba is located. Otherwise, we will copy data in the wrong page, thus
    causing data corruption for the application.

    In case of a cache hit, we assumed that bio->bi_iter.bi_idx would
    contain the correct index, but this is no necessarily true. Instead, use
    the local bio advance counter and iterator. This guarantees that lbas
    hitting the cache are copied into the right bv_page.

    In case of an empty L2P entry, we omitted to advance the bio. In the
    cases when the same I/O also contains a cache hit, data corresponding
    to this lba will be copied to the wrong bv_page. Fix this by advancing
    the bio as we do in the case of a cache hit.

    Fixes: a4bd217b4326 lightnvm: physical block device (pblk) target

    Signed-off-by: Javier González
    Signed-off-by: Jens Axboe

    Javier González
     

01 Jul, 2017

3 commits

  • When a read is directed to the cache, we risk that the lba has been
    updated during the time we made the L2P table lookup and the time we are
    actually reading form the cache. We intentionally not hold the L2P lock
    not to block other threads.

    While strict ordering is not a guarantee at this level (unless REQ_FLUSH
    has been previously issued), we have experience that some databases that
    have recently implemented direct I/O support, issue metadata reads very
    close to the writes, without issuing a fsync in the middle. An easy way
    to support them while they is to make an extra effort and check the L2P
    map right before reading the cache.

    Signed-off-by: Javier González
    Signed-off-by: Matias Bjørling
    Signed-off-by: Jens Axboe

    Javier González
     
  • When removing a pblk instance, pad the current line using asynchronous
    I/O. This reduces the removal time from ~1 minute in the worst case to a
    couple of seconds.

    Signed-off-by: Javier González
    Signed-off-by: Matias Bjørling
    Signed-off-by: Jens Axboe

    Javier González
     
  • When user threads place data into the write buffer, they reserve space
    and do the memory copy out of the lock. As a consequence, when the write
    thread starts persisting data, there is a chance that it is not copied
    yet. In this case, avoid polling, and schedule before retrying.

    Signed-off-by: Javier González
    Signed-off-by: Matias Bjørling
    Signed-off-by: Jens Axboe

    Javier González
     

27 Jun, 2017

3 commits

  • Due to user writes being decoupled from media writes because of the need
    of an intermediate write buffer, irrecoverable media write errors lead
    to pblk stalling; user writes fill up the buffer and end up in an
    infinite retry loop.

    In order to let user writes fail gracefully, it is necessary for pblk to
    keep track of its own internal state and prevent further writes from
    being placed into the write buffer.

    This patch implements a state machine to keep track of internal errors
    and, in case of failure, fail further user writes in an standard way.
    Depending on the type of error, pblk will do its best to persist
    buffered writes (which are already acknowledged) and close down on a
    graceful manner. This way, data might be recovered by re-instantiating
    pblk. Such state machine paves out the way for a state-based FTL log.

    Signed-off-by: Javier González
    Signed-off-by: Matias Bjørling
    Signed-off-by: Jens Axboe

    Javier González
     
  • At the moment, in order to get enough read parallelism, we have recycled
    several lines at the same time. This approach has proven not to work
    well when reaching capacity, since we end up mixing valid data from all
    lines, thus not maintaining a sustainable free/recycled line ratio.

    The new design, relies on a two level workqueue mechanism. In the first
    level, we read the metadata for a number of lines based on the GC list
    they reside on (this is governed by the number of valid sectors in each
    line). In the second level, we recycle a single line at a time. Here, we
    issue reads in parallel, while a single GC write thread places data in
    the write buffer. This design allows to (i) only move data from one line
    at a time, thus maintaining a sane free/recycled ration and (ii)
    maintain the GC writer busy with recycled data.

    Signed-off-by: Javier González
    Signed-off-by: Matias Bjørling
    Signed-off-by: Jens Axboe

    Javier González
     
  • Erase I/Os are scheduled with the following goals in mind: (i) minimize
    LUNs collisions with write I/Os, and (ii) even out the price of erasing
    on every write, instead of putting all the burden on when garbage
    collection runs. This works well on the current design, but is specific
    to the default mapping algorithm.

    This patch generalizes the erase path so that other mapping algorithms
    can select an arbitrary line to be erased instead. It also gets rid of
    the erase semaphore since it creates jittering for user writes.

    Signed-off-by: Javier González
    Signed-off-by: Matias Bjørling
    Signed-off-by: Jens Axboe

    Javier González
     

17 Apr, 2017

1 commit

  • This patch introduces pblk, a host-side translation layer for
    Open-Channel SSDs to expose them like block devices. The translation
    layer allows data placement decisions, and I/O scheduling to be
    managed by the host, enabling users to optimize the SSD for their
    specific workloads.

    An open-channel SSD has a set of LUNs (parallel units) and a
    collection of blocks. Each block can be read in any order, but
    writes must be sequential. Writes may also fail, and if a block
    requires it, must also be reset before new writes can be
    applied.

    To manage the constraints, pblk maintains a logical to
    physical address (L2P) table, write cache, garbage
    collection logic, recovery scheme, and logic to rate-limit
    user I/Os versus garbage collection I/Os.

    The L2P table is fully-associative and manages sectors at a
    4KB granularity. Pblk stores the L2P table in two places, in
    the out-of-band area of the media and on the last page of a
    line. In the cause of a power failure, pblk will perform a
    scan to recover the L2P table.

    The user data is organized into lines. A line is data
    striped across blocks and LUNs. The lines enable the host to
    reduce the amount of metadata to maintain besides the user
    data and makes it easier to implement RAID or erasure coding
    in the future.

    pblk implements multi-tenant support and can be instantiated
    multiple times on the same drive. Each instance owns a
    portion of the SSD - both regarding I/O bandwidth and
    capacity - providing I/O isolation for each case.

    Finally, pblk also exposes a sysfs interface that allows
    user-space to peek into the internals of pblk. The interface
    is available at /dev/block/*/pblk/ where * is the block
    device name exposed.

    This work also contains contributions from:
    Matias Bjørling
    Simon A. F. Lund
    Young Tack Jin
    Huaicheng Li

    Signed-off-by: Javier González
    Signed-off-by: Matias Bjørling
    Signed-off-by: Jens Axboe

    Javier González