On Tue, Nov 26, 2019 at 06:17:03PM +0100, David Sterba wrote: > > + /* Verify the device is back in a pristine state */ > > + ASSERT(!test_bit(BTRFS_DEV_STATE_FLUSH_SENT, &device->dev_state)); > > + ASSERT(!test_bit(BTRFS_DEV_STATE_REPLACE_TGT, &device->dev_state)); > > + ASSERT(list_empty(&device->dev_alloc_list)); > > + ASSERT(list_empty(&device->post_commit_list)); > > + ASSERT(atomic_read(&device->reada_in_flight) == 0); > > + ASSERT(atomic_read(&device->dev_stats_ccnt) == 0); > > + ASSERT(RB_EMPTY_ROOT(&device->alloc_state.state)); > > I went through members of the device struct, lots of them are set once > so don't change. last_flush_error is set and read during commit, > > Besides the dev_state bits handled above, I think tre rest should be > here too, ie. BTRFS_DEV_STATE_IN_FS_METADATA and > BTRFS_DEV_STATE_MISSING (though this might be ok to keep as-is). So BTRFS_DEV_STATE_MISSING should stay, the state is changed through the scanning. BTRFS_DEV_STATE_IN_FS_METADATA should be asserted for 'not-set', this is normally set_bit at mount time so the last use of devices with the bit set should set it back to zero.
