Skip to content
Snippets Groups Projects
  • Zach Brown's avatar
    fcb82f88
    dio: remove bogus refcounting BUG_ON · fcb82f88
    Zach Brown authored
    
    Badari Pulavarty reported a case of this BUG_ON is triggering during
    testing.  It's completely bogus and should be removed.
    
    It's trying to notice if we left references to the dio hanging around in
    the sync case.  They should have been dropped as IO completed while this
    path was in dio_await_completion().  This condition will also be
    checked, via some twisty logic, by the BUG_ON(ret != -EIOCBQUEUED) a few
    lines lower.  So to start this BUG_ON() is redundant.
    
    More fatally, it's dereferencing dio-> after having dropped its
    reference.  It's only safe to dereference the dio after releasing the
    lock if the final reference was just dropped.  Another CPU might free
    the dio in bio completion and reuse the memory after this path drops the
    dio lock but before the BUG_ON() is evaluated.
    
    This patch passed aio+dio regression unit tests and aio-stress on ext3.
    
    Signed-off-by: default avatarZach Brown <zach.brown@oracle.com>
    Cc: Badari Pulavarty <pbadari@us.ibm.com>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    fcb82f88
    History
    dio: remove bogus refcounting BUG_ON
    Zach Brown authored
    
    Badari Pulavarty reported a case of this BUG_ON is triggering during
    testing.  It's completely bogus and should be removed.
    
    It's trying to notice if we left references to the dio hanging around in
    the sync case.  They should have been dropped as IO completed while this
    path was in dio_await_completion().  This condition will also be
    checked, via some twisty logic, by the BUG_ON(ret != -EIOCBQUEUED) a few
    lines lower.  So to start this BUG_ON() is redundant.
    
    More fatally, it's dereferencing dio-> after having dropped its
    reference.  It's only safe to dereference the dio after releasing the
    lock if the final reference was just dropped.  Another CPU might free
    the dio in bio completion and reuse the memory after this path drops the
    dio lock but before the BUG_ON() is evaluated.
    
    This patch passed aio+dio regression unit tests and aio-stress on ext3.
    
    Signed-off-by: default avatarZach Brown <zach.brown@oracle.com>
    Cc: Badari Pulavarty <pbadari@us.ibm.com>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Code owners
Assign users and groups as approvers for specific file changes. Learn more.