]> git.karo-electronics.de Git - karo-tx-linux.git/commit
md/r5cache: fix io_unit handling in r5l_log_endio()
authorSong Liu <songliubraving@fb.com>
Thu, 3 Aug 2017 17:03:17 +0000 (10:03 -0700)
committerShaohua Li <shli@fb.com>
Tue, 8 Aug 2017 14:42:37 +0000 (07:42 -0700)
commita9501d742127e613d744e29814e9532bacb147e8
tree8f27f82c31b37030a5c15b1bd0227c9d7cb9131e
parentb44886c54a999771060371c3a05d5fedfc7e2102
md/r5cache: fix io_unit handling in r5l_log_endio()

In r5l_log_endio(), once log->io_list_lock is released, the io unit
may be accessed (or even freed) by other threads. Current code
doesn't handle the io_unit properly, which leads to potential race
conditions.

This patch solves this race condition by:

1. Add a pending_stripe count flush_payload. Multiple flush_payloads
   are counted as only one pending_stripe. Flag has_flush_payload is
   added to show whether the io unit has flush_payload;
2. In r5l_log_endio(), check flags has_null_flush and
   has_flush_payload with log->io_list_lock held. After the lock
   is released, this IO unit is only accessed when we know the
   pending_stripe counter cannot be zeroed by other threads.

Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Shaohua Li <shli@fb.com>
drivers/md/raid5-cache.c