summaryrefslogtreecommitdiff
path: root/libbcachefs/btree_cache.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-02-27 12:01:32 -0500
committerKent Overstreet <kent.overstreet@gmail.com>2022-02-27 12:01:32 -0500
commit03498f946430c1fbb411f94af7f9a366f4a7cd51 (patch)
tree225f584fbe5bcb8f72ebc5c624e1a8d9e8fa235c /libbcachefs/btree_cache.c
parentb1a2ab6eeffc62d32f648d9267dc101da77567d1 (diff)
Update bcachefs sources to 04036b4910 bcachefs: Fix a memory leak
Diffstat (limited to 'libbcachefs/btree_cache.c')
-rw-r--r--libbcachefs/btree_cache.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/libbcachefs/btree_cache.c b/libbcachefs/btree_cache.c
index 00d4b182..1347b1fc 100644
--- a/libbcachefs/btree_cache.c
+++ b/libbcachefs/btree_cache.c
@@ -15,6 +15,13 @@
struct lock_class_key bch2_btree_node_lock_key;
+const char * const bch2_btree_node_flags[] = {
+#define x(f) #f,
+ BTREE_FLAGS()
+#undef x
+ NULL
+};
+
void bch2_recalc_btree_reserve(struct bch_fs *c)
{
unsigned i, reserve = 16;
@@ -217,15 +224,13 @@ wait_on_io:
goto wait_on_io;
}
- if (btree_node_noevict(b))
- goto out_unlock;
-
- if (!btree_node_may_write(b))
+ if (btree_node_noevict(b) ||
+ btree_node_write_blocked(b) ||
+ btree_node_will_make_reachable(b))
goto out_unlock;
if (btree_node_dirty(b)) {
- if (!flush ||
- test_bit(BCH_FS_HOLD_BTREE_WRITES, &c->flags))
+ if (!flush)
goto out_unlock;
/*
* Using the underscore version because we don't want to compact
@@ -234,9 +239,9 @@ wait_on_io:
* the post write cleanup:
*/
if (bch2_verify_btree_ondisk)
- bch2_btree_node_write(c, b, SIX_LOCK_intent);
+ bch2_btree_node_write(c, b, SIX_LOCK_intent, 0);
else
- __bch2_btree_node_write(c, b, false);
+ __bch2_btree_node_write(c, b, 0);
six_unlock_write(&b->c.lock);
six_unlock_intent(&b->c.lock);
@@ -415,7 +420,7 @@ void bch2_fs_btree_cache_exit(struct bch_fs *c)
if (btree_node_dirty(b))
bch2_btree_complete_write(c, b, btree_current_write(b));
- clear_btree_node_dirty(c, b);
+ clear_btree_node_dirty_acct(c, b);
btree_node_data_free(c, b);
}
@@ -1059,7 +1064,7 @@ wait_on_io:
six_lock_write(&b->c.lock, NULL, NULL);
if (btree_node_dirty(b)) {
- __bch2_btree_node_write(c, b, false);
+ __bch2_btree_node_write(c, b, 0);
six_unlock_write(&b->c.lock);
six_unlock_intent(&b->c.lock);
goto wait_on_io;