• Zach Brown's avatar
    [PATCH] dio: formalize bio counters as a dio reference count · 0273201e
    Zach Brown authored
    Previously we had two confusing counts of bio progress.  'bio_count' was
    decremented as bios were processed and freed by the dio core.  It was used to
    indicate final completion of the dio operation.  'bios_in_flight' reflected
    how many bios were between submit_bio() and bio->end_io.  It was used by the
    sync path to decide when to wake up and finish completing bios and was ignored
    by the async path.
    
    This patch collapses the two notions into one notion of a dio reference count.
     bios hold a dio reference when they're between submit_bio and bio->end_io.
    
    Since bios_in_flight was only used in the sync path it is now equivalent to
    dio->refcount - 1 which accounts for direct_io_worker() holding a reference
    for the duration of the operation.
    
    dio_bio_complete() -> finished_one_bio() was called from the sync path after
    finding bios on the list that the bio->end_io function had deposited.
    finished_one_bio() can not drop the dio reference on behalf of these bios now
    because bio->end_io already has.  The is_async test in finished_one_bio()
    meant that it never actually did anything other than drop the bio_count for
    sync callers.  So we remove its refcount decrement, don't call it from
    dio_bio_complete(), and hoist its call up into the async dio_bio_complete()
    caller after an explicit refcount decrement.  It is renamed dio_complete_aio()
    to reflect the remaining work it actually does.
    Signed-off-by: default avatarZach Brown <zach.brown@oracle.com>
    Cc: Badari Pulavarty <pbadari@us.ibm.com>
    Cc: Suparna Bhattacharya <suparna@in.ibm.com>
    Acked-by: default avatarJeff Moyer <jmoyer@redhat.com>
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    0273201e
direct-io.c 34.8 KB