summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2019-04-06 15:12:21 -0400
committerKent Overstreet <kent.overstreet@gmail.com>2019-04-06 15:15:43 -0400
commit1f34297797b3283a173679b440f3d00316d1486a (patch)
treecbe9cfcbcb15d3e5910ccc4fc757ab2c13b18cdb
parent01f9a4f107dd85beed487464bd90f4406f25c927 (diff)
bcachefs: Pass flags arg to bch2_alloc_write()
-rw-r--r--fs/bcachefs/alloc_background.c28
-rw-r--r--fs/bcachefs/alloc_background.h2
-rw-r--r--fs/bcachefs/ec.c4
-rw-r--r--fs/bcachefs/ec.h2
-rw-r--r--fs/bcachefs/super.c10
-rw-r--r--fs/bcachefs/sysfs.c2
6 files changed, 24 insertions, 24 deletions
diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c
index 5a3065688341..f26332ade3d8 100644
--- a/fs/bcachefs/alloc_background.c
+++ b/fs/bcachefs/alloc_background.c
@@ -358,7 +358,7 @@ err:
static int __bch2_alloc_write_key(struct btree_trans *trans, struct bch_dev *ca,
size_t b, struct btree_iter *iter,
- u64 *journal_seq, unsigned flags)
+ unsigned flags)
{
struct bch_fs *c = trans->c;
#if 0
@@ -396,13 +396,10 @@ static int __bch2_alloc_write_key(struct btree_trans *trans, struct bch_dev *ca,
bch2_trans_update(trans, BTREE_INSERT_ENTRY(iter, &a->k_i));
- ret = bch2_trans_commit(trans, NULL, journal_seq,
- BTREE_INSERT_NOCHECK_RW|
- BTREE_INSERT_NOFAIL|
- BTREE_INSERT_USE_RESERVE|
- BTREE_INSERT_USE_ALLOC_RESERVE|
- BTREE_INSERT_NOMARK|
- flags);
+ ret = bch2_trans_commit(trans, NULL, NULL,
+ BTREE_INSERT_NOFAIL|
+ BTREE_INSERT_NOMARK|
+ flags);
if (ret)
return ret;
@@ -416,14 +413,12 @@ static int __bch2_alloc_write_key(struct btree_trans *trans, struct bch_dev *ca,
return 0;
}
-int bch2_alloc_write(struct bch_fs *c, bool nowait, bool *wrote)
+int bch2_alloc_write(struct bch_fs *c, unsigned flags, bool *wrote)
{
struct bch_dev *ca;
unsigned i;
int ret = 0;
- *wrote = false;
-
for_each_rw_member(ca, c, i) {
struct btree_trans trans;
struct btree_iter *iter;
@@ -444,10 +439,8 @@ int bch2_alloc_write(struct bch_fs *c, bool nowait, bool *wrote)
if (!buckets->b[b].mark.dirty)
continue;
- ret = __bch2_alloc_write_key(&trans, ca, b, iter, NULL,
- nowait
- ? BTREE_INSERT_NOWAIT
- : 0);
+ ret = __bch2_alloc_write_key(&trans, ca, b,
+ iter, flags);
if (ret)
break;
@@ -1682,7 +1675,10 @@ int bch2_fs_allocator_start(struct bch_fs *c)
* XXX: it's possible for this to deadlock waiting on journal reclaim,
* since we're holding btree writes. What then?
*/
- ret = bch2_alloc_write(c, true, &wrote);
+ ret = bch2_alloc_write(c,
+ BTREE_INSERT_NOCHECK_RW|
+ BTREE_INSERT_USE_ALLOC_RESERVE|
+ BTREE_INSERT_NOWAIT, &wrote);
/*
* If bch2_alloc_write() did anything, it may have used some
diff --git a/fs/bcachefs/alloc_background.h b/fs/bcachefs/alloc_background.h
index 65e9b373a350..68934175d888 100644
--- a/fs/bcachefs/alloc_background.h
+++ b/fs/bcachefs/alloc_background.h
@@ -64,7 +64,7 @@ void bch2_dev_allocator_quiesce(struct bch_fs *, struct bch_dev *);
void bch2_dev_allocator_stop(struct bch_dev *);
int bch2_dev_allocator_start(struct bch_dev *);
-int bch2_alloc_write(struct bch_fs *, bool, bool *);
+int bch2_alloc_write(struct bch_fs *, unsigned, bool *);
int bch2_fs_allocator_start(struct bch_fs *);
void bch2_fs_allocator_background_init(struct bch_fs *);
diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c
index 91b86d9d8f5f..9b534f0f6eca 100644
--- a/fs/bcachefs/ec.c
+++ b/fs/bcachefs/ec.c
@@ -1193,7 +1193,7 @@ static int __bch2_stripe_write_key(struct btree_trans *trans,
BTREE_INSERT_NOFAIL|flags);
}
-int bch2_stripes_write(struct bch_fs *c, bool *wrote)
+int bch2_stripes_write(struct bch_fs *c, unsigned flags, bool *wrote)
{
struct btree_trans trans;
struct btree_iter *iter;
@@ -1215,7 +1215,7 @@ int bch2_stripes_write(struct bch_fs *c, bool *wrote)
continue;
ret = __bch2_stripe_write_key(&trans, iter, m, giter.pos,
- new_key, BTREE_INSERT_NOCHECK_RW);
+ new_key, flags);
if (ret)
break;
diff --git a/fs/bcachefs/ec.h b/fs/bcachefs/ec.h
index 2817833086f0..5cfbefcdcc7b 100644
--- a/fs/bcachefs/ec.h
+++ b/fs/bcachefs/ec.h
@@ -150,7 +150,7 @@ void bch2_ec_stop_dev(struct bch_fs *, struct bch_dev *);
void bch2_ec_flush_new_stripes(struct bch_fs *);
int bch2_stripes_read(struct bch_fs *, struct list_head *);
-int bch2_stripes_write(struct bch_fs *, bool *);
+int bch2_stripes_write(struct bch_fs *, unsigned, bool *);
int bch2_ec_mem_alloc(struct bch_fs *, bool);
diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c
index 3fb73abf9fe7..dad012e5ee53 100644
--- a/fs/bcachefs/super.c
+++ b/fs/bcachefs/super.c
@@ -227,13 +227,15 @@ static void __bch2_fs_read_only(struct bch_fs *c)
goto allocator_not_running;
do {
- ret = bch2_stripes_write(c, &wrote);
+ wrote = false;
+
+ ret = bch2_stripes_write(c, BTREE_INSERT_NOCHECK_RW, &wrote);
if (ret) {
bch2_fs_inconsistent(c, "error writing out stripes");
break;
}
- ret = bch2_alloc_write(c, false, &wrote);
+ ret = bch2_alloc_write(c, BTREE_INSERT_NOCHECK_RW, &wrote);
if (ret) {
bch2_fs_inconsistent(c, "error writing out alloc info %i", ret);
break;
@@ -336,7 +338,9 @@ void bch2_fs_read_only(struct bch_fs *c)
if (!bch2_journal_error(&c->journal) &&
!test_bit(BCH_FS_ERROR, &c->flags) &&
!test_bit(BCH_FS_EMERGENCY_RO, &c->flags) &&
- test_bit(BCH_FS_STARTED, &c->flags))
+ test_bit(BCH_FS_STARTED, &c->flags) &&
+ !c->opts.noreplay &&
+ !c->opts.norecovery)
bch2_fs_mark_clean(c);
clear_bit(BCH_FS_RW, &c->flags);
diff --git a/fs/bcachefs/sysfs.c b/fs/bcachefs/sysfs.c
index 7069bea565c2..c21f4715571e 100644
--- a/fs/bcachefs/sysfs.c
+++ b/fs/bcachefs/sysfs.c
@@ -501,7 +501,7 @@ STORE(__bch2_fs)
if (attr == &sysfs_trigger_alloc_write) {
bool wrote;
- bch2_alloc_write(c, false, &wrote);
+ bch2_alloc_write(c, 0, &wrote);
}
if (attr == &sysfs_prune_cache) {