04 Jul, 2017

2 commits

  • Some ->bi_end_io handlers (for example: pi_verify or decrypt handlers)
    need to know original data vector, but after bio traverse io-stack it may
    be advanced, splited and relocated many times so it is hard to guess
    original iterator. Let's add 'bi_done' conter which accounts number
    of bytes iterator was advanced during it's evolution. Later end_io handler
    may easily restore original iterator by rewinding iterator to
    iter->bi_done.

    Note: this change makes sizeof (struct bvec_iter) multiple to 8

    Reviewed-by: Hannes Reinecke
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Dmitry Monakhov
    [hch: switched to true/false return]
    Signed-off-by: Christoph Hellwig
    Signed-off-by: Jens Axboe

    Dmitry Monakhov
     
  • Currently if some one try to advance bvec beyond it's size we simply
    dump WARN_ONCE and continue to iterate beyond bvec array boundaries.
    This simply means that we endup dereferencing/corrupting random memory
    region.

    Sane reaction would be to propagate error back to calling context
    But bvec_iter_advance's calling context is not always good for error
    handling. For safity reason let truncate iterator size to zero which
    will break external iteration loop which prevent us from unpredictable
    memory range corruption. And even it caller ignores an error, it will
    corrupt it's own bvecs, not others.

    This patch does:
    - Return error back to caller with hope that it will react on this
    - Truncate iterator size

    Code was added long time ago here 4550dd6c, luckily no one hit it
    in real life :)

    Signed-off-by: Dmitry Monakhov
    Reviewed-by: Ming Lei
    Reviewed-by: Martin K. Petersen
    [hch: switch to true/false returns instead of errno values]
    Signed-off-by: Christoph Hellwig
    Signed-off-by: Jens Axboe

    Dmitry Monakhov
     

11 Aug, 2016

1 commit

  • Due to the (indirect) nesting of min(..., min(...)), sparse will
    show a variable shadowing warning whenever bvec.h is included.

    Avoid that by assigning the inner min() to a temporary variable first.

    Signed-off-by: Johannes Berg
    Signed-off-by: Jens Axboe

    Johannes Berg
     

10 Jun, 2016

3 commits

  • bvec_iter_advance() only writes the parameter of iterator,
    so the base address of bvec can be marked as const safely.

    Without the change, we can see compiling warning in the
    following patch for implementing iterate_bvec(): lib/iov_iter.c
    with bvec iterator.

    Reviewed-by: Christoph Hellwig
    Signed-off-by: Ming Lei
    Tested-by: Hannes Reinecke
    Signed-off-by: Jens Axboe

    Ming Lei
     
  • This patch moves 'struct bio_vec' and 'struct bvec_iter'
    into 'include/linux/bvec.h', then always include this header
    into 'include/linux/blk_types.h'.

    With this change, both 'struct bvec_iter' and bvec iterator
    helpers don't depend on CONFIG_BLOCK any more, then we can
    use bvec iterator to implement iterate_bvec(): lib/iov_iter.c.

    Reviewed-by: Christoph Hellwig
    Suggested-by: Christoph Hellwig
    Signed-off-by: Ming Lei
    Tested-by: Hannes Reinecke
    Signed-off-by: Jens Axboe

    Ming Lei
     
  • bvec iterator helpers should be used to implement by
    iterate_bvec():lib/iov_iter.c too, and move them into
    one header, so that we can keep bvec iterator header
    out of CONFIG_BLOCK. Then we can remove the reinventing
    of wheel in iterate_bvec().

    Reviewed-by: Christoph Hellwig
    Signed-off-by: Ming Lei
    Tested-by: Hannes Reinecke
    Signed-off-by: Jens Axboe

    Ming Lei