[PATCH 0/7] btrfs: workqueue fixes+cleanups

Omar Sandoval
2019-09-16T18:31:13Z

Hello,

This series fixes a few issues with Btrfs' use of workqueues.

The bulk of this series fixes multiple cases of the same bug: a work
item shouldn't be freed while it potentially depends on any other work
items. Currently, we've mostly been side-stepping this issue by having
different work functions for different work types (see commit
9e0af2376434 ("Btrfs: fix task hang under heavy compressed write").
However, there are cases where a work function can depend on itself,
usually through stacked filesystems (e.g., loop devices).

Patch 1 is a trivial cleanup.

Patches 2-5 fix all of the cases of this bug that I could find. Patch 2
is the ordered_free fix I previously sent [1], now with an updated title
and Josef's fix [2] folded in. Patch 3 fixes the deadlock reported with
my previous cleanup, and patches 4 and 5 fix similar issues.

With all of those fixed, patch 6 is my previous cleanup [3] to get rid
of the different work functions. Patch 7 is the same cleanup [4] as from
before.

Based on misc-next.

Thanks!

1: https://lore.kernel.org/linux-btrfs/0bea516a54b26e4e1c42e6fe47548cb48cc4172b.1565112813.git.osandov@fb.com/
2: https://lore.kernel.org/linux-btrfs/20190821151803.cuyq2yzpdnwgwrmb@MacBook-Pro-91.local/
3: https://lore.kernel.org/linux-btrfs/afaf532af471dd1a8a1f4af9de570127529323b0.1565717248.git.osandov@fb.com/
4: https://lore.kernel.org/linux-btrfs/d4fa1870ffce027ada265a67f4e00d397b683241.1565717248.git.osandov@fb.com/

Omar Sandoval (7):
btrfs: get rid of unnecessary memset() of work item
btrfs: don't prematurely free work in run_ordered_work()
btrfs: don't prematurely free work in end_workqueue_fn()
btrfs: don't prematurely free work in reada_start_machine_worker()
btrfs: don't prematurely free work in scrub_missing_raid56_worker()
btrfs: get rid of unique workqueue helper functions
btrfs: get rid of pointless wtag variable in async-thread.c

fs/btrfs/async-thread.c | 107 +++++++++++++++++------------------
fs/btrfs/async-thread.h | 33 +----------
fs/btrfs/block-group.c | 3 +-
fs/btrfs/delayed-inode.c | 4 +-
fs/btrfs/disk-io.c | 36 ++++--------
fs/btrfs/inode.c | 36 ++++--------
fs/btrfs/ordered-data.c | 1 -
fs/btrfs/qgroup.c | 3 -
fs/btrfs/raid56.c | 5 +-
fs/btrfs/reada.c | 13 ++---
fs/btrfs/scrub.c | 17 +++---
fs/btrfs/volumes.c | 3 +-
include/trace/events/btrfs.h | 6 +-
13 files changed, 97 insertions(+), 170 deletions(-)

--
2.23.0