fs: ubifs: fix shrink_tnc assertion warning
A race condition was found making this assertion invalid.
Suppose there are two clean znodes and one dirty znode in TNC. The
per-filesystem atomic_t @clean_zn_cnt is (2). If commit start, dirty_znode
is set to COW_ZNODE in get_znodes_to_commit() in case of potentially ops
on this znode. We clear COW bit and DIRTY bit in write_index() without
@tnc_mutex locked. We don't increase @clean_zn_cnt in this place. As the
comments in write_index() shows, if another process hold @tnc_mutex and
dirty this znode after we clean it, @clean_zn_cnt would be decreased to
(1). We will increase @clean_zn_cnt to (2) with @tnc_mutex locked in
free_obsolete_znodes() to keep it right.
If shrink_tnc() performs between decrease and increase, it will release
other 2 clean znodes it holds and found @clean_zn_cnt is less than zero
(1 - 2 = -1), then hit the assertion. Because free_obsolete_znodes() will
soon correct @clean_zn_cnt and no harm to fs in this case.
CRs-Fixed: 623246
Change-Id: Ie6f229c0740c5dd7377d457827bce2c4e947297d
Signed-off-by:
Dolev Raviv <draviv@codeaurora.org>
Loading
Please register or sign in to comment