bcachefs: Fix lifetime issue in device iterator helpers
authorKent Overstreet <kent.overstreet@linux.dev>
Sat, 4 May 2024 16:55:44 +0000 (12:55 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Mon, 6 May 2024 14:58:17 +0000 (10:58 -0400)
commit18b4abcead744322feb90ba31450e7d770e928bd
treea0f18630106602e3e030d5a693119572e7856449
parent3a2d0259274202432e5119463dd4cf5f9fabed98
bcachefs: Fix lifetime issue in device iterator helpers

bch2_get_next_dev() and bch2_get_next_online_dev() iterate over devices,
dropping and taking refs as they go; we can't access the previous device
(for ca->dev_idx) after we've dropped our ref to it, unless we take
rcu_read_lock() first.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/sb-members.h