diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-02-29 15:56:40 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-04-05 23:43:22 -0400 |
commit | e015b9ce8edc7f80e4dac379862de65eb7635c60 (patch) | |
tree | 1986885dfb737c371c7ca537f726de0a6fd5c9f0 | |
parent | 4ce417d4da07ed9fe0172e082dc65b3a6472b372 (diff) |
fixup bcachefs: Disk space accounting rewrite
-rw-r--r-- | fs/bcachefs/super.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c index c094cc15e853..4b2ce2128811 100644 --- a/fs/bcachefs/super.c +++ b/fs/bcachefs/super.c @@ -1632,16 +1632,6 @@ int bch2_dev_remove(struct bch_fs *c, struct bch_dev *ca, int flags) if (ret) goto err; - /* - * We need to flush the entire journal to get rid of keys that reference - * the device being removed before removing the superblock entry - */ - bch2_journal_flush_all_pins(&c->journal); - - /* - * this is really just needed for the bch2_replicas_gc_(start|end) - * calls, and could be cleaned up: - */ ret = bch2_journal_flush_device_pins(&c->journal, ca->dev_idx); bch_err_msg(ca, ret, "bch2_journal_flush_device_pins()"); if (ret) @@ -1680,6 +1670,17 @@ int bch2_dev_remove(struct bch_fs *c, struct bch_dev *ca, int flags) bch2_dev_free(ca); /* + * At this point the device object has been removed in-core, but the + * on-disk journal might still refer to the device index via sb device + * usage entries. Recovery fails if it sees usage information for an + * invalid device. Flush journal pins to push the back of the journal + * past now invalid device index references before we update the + * superblock, but after the device object has been removed so any + * further journal writes elide usage info for the device. + */ + bch2_journal_flush_all_pins(&c->journal); + + /* * Free this device's slot in the bch_member array - all pointers to * this device must be gone: */ |