]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
xfs: fix unbalanced inode reclaim flush locking
authorBrian Foster <bfoster@redhat.com>
Wed, 9 Nov 2016 21:23:22 +0000 (08:23 +1100)
committerDave Chinner <david@fromorbit.com>
Wed, 9 Nov 2016 21:23:22 +0000 (08:23 +1100)
commit98efe8af1c9ffac47e842b7a75ded903e2f028da
tree9305e6e6013f166bb305a612b24121efd5769617
parent5d829300bee000980a09ac2ccb761cb25867b67c
xfs: fix unbalanced inode reclaim flush locking

Filesystem shutdown testing on an older distro kernel has uncovered an
imbalanced locking pattern for the inode flush lock in
xfs_reclaim_inode(). Specifically, there is a double unlock sequence
between the call to xfs_iflush_abort() and xfs_reclaim_inode() at the
"reclaim:" label.

This actually does not cause obvious problems on current kernels due to
the current flush lock implementation. Older kernels use a counting
based flush lock mechanism, however, which effectively breaks the lock
indefinitely when an already unlocked flush lock is repeatedly unlocked.
Though this only currently occurs on filesystem shutdown, it has
reproduced the effect of elevating an fs shutdown to a system-wide crash
or hang.

As it turns out, the flush lock is not actually required for the reclaim
logic in xfs_reclaim_inode() because by that time we have already cycled
the flush lock once while holding ILOCK_EXCL. Therefore, remove the
additional flush lock/unlock cycle around the 'reclaim:' label and
update branches into this label to release the flush lock where
appropriate. Add an assert to xfs_ifunlock() to help prevent future
occurences of the same problem.

Reported-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
fs/xfs/xfs_icache.c
fs/xfs/xfs_inode.h