diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2019-02-20 16:00:03 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2019-04-03 12:44:08 -0400 |
commit | ae007d9260966d69adf9dc6c90ae2afb0a07bb03 (patch) | |
tree | 0093c5be898c1cd0a79dd57fdada6d55913e5866 | |
parent | 16d24f5f3f5c703fc44c3c8f61599ff5d15533eb (diff) |
bcachefs: fix a deadlock on startup
-rw-r--r-- | fs/bcachefs/alloc_background.c | 4 | ||||
-rw-r--r-- | fs/bcachefs/journal_io.c | 9 |
2 files changed, 10 insertions, 3 deletions
diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c index 9d3af6f379a0..faf124f0def0 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -1677,7 +1677,6 @@ int bch2_fs_allocator_start(struct bch_fs *c) { struct bch_dev *ca; unsigned i; - bool wrote; int ret; down_read(&c->gc_lock); @@ -1696,8 +1695,7 @@ int bch2_fs_allocator_start(struct bch_fs *c) } set_bit(BCH_FS_ALLOCATOR_RUNNING, &c->flags); - - return bch2_alloc_write(c, false, &wrote); + return 0; } void bch2_fs_allocator_background_init(struct bch_fs *c) diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c index 338729f532b4..0a536f157ebb 100644 --- a/fs/bcachefs/journal_io.c +++ b/fs/bcachefs/journal_io.c @@ -888,10 +888,19 @@ err: static unsigned journal_dev_buckets_available(struct journal *j, struct journal_device *ja) { + struct bch_fs *c = container_of(j, struct bch_fs, journal); unsigned next = (ja->cur_idx + 1) % ja->nr; unsigned available = (ja->last_idx + ja->nr - next) % ja->nr; /* + * Allocator startup needs some journal space before we can do journal + * replay: + */ + if (available && + test_bit(BCH_FS_ALLOCATOR_STARTED, &c->flags)) + available--; + + /* * Don't use the last bucket unless writing the new last_seq * will make another bucket available: */ |