Update bcachefs sources to 6dc2a699c6 bcachefs: bch2_path_put_nokeep()

This commit is contained in:
Kent Overstreet 2022-10-11 06:40:24 -04:00
parent 0398adf20f
commit e66011cd2c
6 changed files with 33 additions and 13 deletions

View File

@ -1 +1 @@
55f0b5944bb7f02baa6b7b854fd4d294d974bfb6
6dc2a699c6d2e04027bdc670141e6f313c751ff0

View File

@ -816,9 +816,11 @@ static inline struct bbpos bp_to_bbpos(struct bch_backpointer bp)
static size_t btree_nodes_fit_in_ram(struct bch_fs *c)
{
struct sysinfo i;
u64 mem_bytes;
si_meminfo(&i);
return (i.totalram >> 1) / btree_bytes(c);
mem_bytes = i.totalram * i.mem_unit;
return (mem_bytes >> 1) / btree_bytes(c);
}
int bch2_get_btree_in_memory_pos(struct btree_trans *trans,
@ -1005,7 +1007,7 @@ int bch2_check_backpointers_to_extents(struct bch_fs *c)
bbpos_cmp(end, BBPOS_MAX)) {
struct printbuf buf = PRINTBUF;
prt_str(&buf, "check_backointers_to_extents(): ");
prt_str(&buf, "check_backpointers_to_extents(): ");
bch2_bbpos_to_text(&buf, start);
prt_str(&buf, "-");
bch2_bbpos_to_text(&buf, end);

View File

@ -1320,6 +1320,20 @@ void bch2_path_put(struct btree_trans *trans, struct btree_path *path, bool inte
__bch2_path_free(trans, path);
}
static void bch2_path_put_nokeep(struct btree_trans *trans, struct btree_path *path,
bool intent)
{
struct btree_path *dup;
EBUG_ON(trans->paths + path->idx != path);
EBUG_ON(!path->ref);
if (!__btree_path_put(path, intent))
return;
__bch2_path_free(trans, path);
}
void bch2_trans_updates_to_text(struct printbuf *buf, struct btree_trans *trans)
{
struct btree_insert_entry *i;
@ -1952,8 +1966,8 @@ struct bkey_s_c bch2_btree_iter_peek_upto(struct btree_iter *iter, struct bpos e
EBUG_ON(iter->flags & BTREE_ITER_ALL_LEVELS);
if (iter->update_path) {
bch2_path_put(trans, iter->update_path,
iter->flags & BTREE_ITER_INTENT);
bch2_path_put_nokeep(trans, iter->update_path,
iter->flags & BTREE_ITER_INTENT);
iter->update_path = NULL;
}
@ -1984,8 +1998,8 @@ struct bkey_s_c bch2_btree_iter_peek_upto(struct btree_iter *iter, struct bpos e
if (iter->update_path &&
bkey_cmp(iter->update_path->pos, k.k->p)) {
bch2_path_put(trans, iter->update_path,
iter->flags & BTREE_ITER_INTENT);
bch2_path_put_nokeep(trans, iter->update_path,
iter->flags & BTREE_ITER_INTENT);
iter->update_path = NULL;
}
@ -2233,7 +2247,7 @@ struct bkey_s_c bch2_btree_iter_peek_prev(struct btree_iter *iter)
* that candidate
*/
if (saved_path && bkey_cmp(k.k->p, saved_k.p)) {
bch2_path_put(trans, iter->path,
bch2_path_put_nokeep(trans, iter->path,
iter->flags & BTREE_ITER_INTENT);
iter->path = saved_path;
saved_path = NULL;
@ -2246,7 +2260,7 @@ struct bkey_s_c bch2_btree_iter_peek_prev(struct btree_iter *iter)
iter->snapshot,
k.k->p.snapshot)) {
if (saved_path)
bch2_path_put(trans, saved_path,
bch2_path_put_nokeep(trans, saved_path,
iter->flags & BTREE_ITER_INTENT);
saved_path = btree_path_clone(trans, iter->path,
iter->flags & BTREE_ITER_INTENT);
@ -2290,7 +2304,7 @@ got_key:
btree_path_set_should_be_locked(iter->path);
out_no_locked:
if (saved_path)
bch2_path_put(trans, saved_path, iter->flags & BTREE_ITER_INTENT);
bch2_path_put_nokeep(trans, saved_path, iter->flags & BTREE_ITER_INTENT);
bch2_btree_iter_verify_entry_exit(iter);
bch2_btree_iter_verify(iter);
@ -2578,7 +2592,7 @@ void bch2_trans_iter_exit(struct btree_trans *trans, struct btree_iter *iter)
bch2_path_put(trans, iter->path,
iter->flags & BTREE_ITER_INTENT);
if (iter->update_path)
bch2_path_put(trans, iter->update_path,
bch2_path_put_nokeep(trans, iter->update_path,
iter->flags & BTREE_ITER_INTENT);
if (iter->key_cache_path)
bch2_path_put(trans, iter->key_cache_path,

View File

@ -1623,7 +1623,7 @@ int bch2_btree_delete_range_trans(struct btree_trans *trans, enum btree_id id,
int ret = 0;
bch2_trans_iter_init(trans, &iter, id, start, BTREE_ITER_INTENT);
while ((k = bch2_btree_iter_peek_upto(&iter, bpos_predecessor(end))).k) {
while ((k = bch2_btree_iter_peek(&iter)).k) {
struct disk_reservation disk_res =
bch2_disk_reservation_init(trans->c, 0);
struct bkey_i delete;
@ -1632,6 +1632,9 @@ int bch2_btree_delete_range_trans(struct btree_trans *trans, enum btree_id id,
if (ret)
goto err;
if (bkey_cmp(iter.pos, end) >= 0)
break;
bkey_init(&delete.k);
/*

View File

@ -575,7 +575,7 @@ int bch2_mark_alloc(struct btree_trans *trans,
if ((flags & BTREE_TRIGGER_BUCKET_INVALIDATE) &&
old_a.cached_sectors) {
ret = update_cached_sectors(c, new, ca->dev_idx,
-old_a.cached_sectors,
-((s64) old_a.cached_sectors),
journal_seq, gc);
if (ret) {
bch2_fs_fatal_error(c, "bch2_mark_alloc(): no replicas entry while updating cached sectors");

View File

@ -48,6 +48,7 @@ void si_meminfo(struct sysinfo *val)
FILE *f;
memset(val, 0, sizeof(*val));
val->mem_unit = 1;
f = fopen("/proc/meminfo", "r");
if (!f)