Update bcachefs sources to 259ff91605 bcachefs: Don't keep around btree_paths unnecessarily

This commit is contained in:
Kent Overstreet 2022-03-05 17:06:24 -05:00
parent 4568914cfb
commit b797b087a9
11 changed files with 65 additions and 70 deletions

View File

@ -1 +1 @@
b64d9b7b192a641ef4ea036d6e465e8cfe82e83c
259ff916050fb6a9ff742891fb8aa379924a187f

View File

@ -3016,6 +3016,14 @@ void bch2_trans_begin(struct btree_trans *trans)
trans_for_each_path(trans, path) {
path->should_be_locked = false;
/*
* If the transaction wasn't restarted, we're presuming to be
* doing something new: dont keep iterators excpt the ones that
* are in use - except for the subvolumes btree:
*/
if (!trans->restarted && path->btree_id != BTREE_ID_subvolumes)
path->preserve = false;
/*
* XXX: we probably shouldn't be doing this if the transaction
* was restarted, but currently we still overflow transaction

View File

@ -445,7 +445,10 @@ int bch2_opt_target_parse(struct bch_fs *c, const char *buf, u64 *v)
return -EINVAL;
}
void bch2_sb_target_to_text(struct printbuf *out, struct bch_sb *sb, u64 v)
void bch2_opt_target_to_text(struct printbuf *out,
struct bch_fs *c,
struct bch_sb *sb,
u64 v)
{
struct target t = target_decode(v);
@ -453,37 +456,8 @@ void bch2_sb_target_to_text(struct printbuf *out, struct bch_sb *sb, u64 v)
case TARGET_NULL:
pr_buf(out, "none");
break;
case TARGET_DEV: {
struct bch_sb_field_members *mi = bch2_sb_get_members(sb);
struct bch_member *m = mi->members + t.dev;
if (bch2_dev_exists(sb, mi, t.dev)) {
pr_buf(out, "Device ");
pr_uuid(out, m->uuid.b);
pr_buf(out, " (%u)", t.dev);
} else {
pr_buf(out, "Bad device %u", t.dev);
}
break;
}
case TARGET_GROUP:
bch2_disk_path_to_text(out, sb, t.group);
break;
default:
BUG();
}
}
void bch2_opt_target_to_text(struct printbuf *out, struct bch_fs *c, u64 v)
{
struct target t = target_decode(v);
switch (t.type) {
case TARGET_NULL:
pr_buf(out, "none");
break;
case TARGET_DEV: {
case TARGET_DEV:
if (c) {
struct bch_dev *ca;
rcu_read_lock();
@ -504,12 +478,27 @@ void bch2_opt_target_to_text(struct printbuf *out, struct bch_fs *c, u64 v)
}
rcu_read_unlock();
break;
} else {
struct bch_sb_field_members *mi = bch2_sb_get_members(sb);
struct bch_member *m = mi->members + t.dev;
if (bch2_dev_exists(sb, mi, t.dev)) {
pr_buf(out, "Device ");
pr_uuid(out, m->uuid.b);
pr_buf(out, " (%u)", t.dev);
} else {
pr_buf(out, "Bad device %u", t.dev);
}
}
break;
case TARGET_GROUP:
if (c) {
mutex_lock(&c->sb_lock);
bch2_disk_path_to_text(out, c->disk_sb.sb, t.group);
mutex_unlock(&c->sb_lock);
} else {
bch2_disk_path_to_text(out, sb, t.group);
}
break;
default:
BUG();

View File

@ -77,10 +77,8 @@ int bch2_disk_path_find_or_create(struct bch_sb_handle *, const char *);
void bch2_disk_path_to_text(struct printbuf *, struct bch_sb *, unsigned);
void bch2_sb_target_to_text(struct printbuf *, struct bch_sb *, u64);
int bch2_opt_target_parse(struct bch_fs *, const char *, u64 *);
void bch2_opt_target_to_text(struct printbuf *, struct bch_fs *, u64);
void bch2_opt_target_to_text(struct printbuf *, struct bch_fs *, struct bch_sb *, u64);
int bch2_sb_disk_groups_to_cpu(struct bch_fs *);

View File

@ -933,7 +933,8 @@ retry:
bch2_trans_iter_init(&trans, &iter, BTREE_ID_extents,
SPOS(ei->v.i_ino, start, snapshot), 0);
while ((k = bch2_btree_iter_peek(&iter)).k &&
while (!(ret = btree_trans_too_many_iters(&trans)) &&
(k = bch2_btree_iter_peek(&iter)).k &&
!(ret = bkey_err(k)) &&
bkey_cmp(iter.pos, end) < 0) {
enum btree_id data_btree = BTREE_ID_extents;
@ -980,9 +981,6 @@ retry:
bch2_btree_iter_set_pos(&iter,
POS(iter.pos.inode, iter.pos.offset + sectors));
if (btree_trans_too_many_iters(&trans))
goto retry;
}
start = iter.pos.offset;
bch2_trans_iter_exit(&trans, &iter);
@ -1691,7 +1689,7 @@ static int bch2_show_options(struct seq_file *seq, struct dentry *root)
continue;
printbuf_reset(&buf);
bch2_opt_to_text(&buf, c, opt, v,
bch2_opt_to_text(&buf, c, c->disk_sb.sb, opt, v,
OPT_SHOW_MOUNT_STYLE);
seq_putc(seq, ',');
seq_puts(seq, buf.buf);

View File

@ -290,7 +290,8 @@ int bch2_opt_parse(struct bch_fs *c, const char *msg,
return bch2_opt_validate(opt, msg, *res);
}
void bch2_opt_to_text(struct printbuf *out, struct bch_fs *c,
void bch2_opt_to_text(struct printbuf *out,
struct bch_fs *c, struct bch_sb *sb,
const struct bch_option *opt, u64 v,
unsigned flags)
{
@ -320,7 +321,7 @@ void bch2_opt_to_text(struct printbuf *out, struct bch_fs *c,
pr_buf(out, opt->choices[v]);
break;
case BCH_OPT_FN:
opt->to_text(out, c, v);
opt->to_text(out, c, sb, v);
break;
default:
BUG();

View File

@ -461,7 +461,7 @@ struct bch_option {
};
struct {
int (*parse)(struct bch_fs *, const char *, u64 *);
void (*to_text)(struct printbuf *, struct bch_fs *, u64);
void (*to_text)(struct printbuf *, struct bch_fs *, struct bch_sb *, u64);
};
};
@ -488,7 +488,7 @@ int bch2_opt_parse(struct bch_fs *, const char *, const struct bch_option *,
#define OPT_SHOW_FULL_LIST (1 << 0)
#define OPT_SHOW_MOUNT_STYLE (1 << 1)
void bch2_opt_to_text(struct printbuf *, struct bch_fs *,
void bch2_opt_to_text(struct printbuf *, struct bch_fs *, struct bch_sb *,
const struct bch_option *, u64, unsigned);
int bch2_opt_check_may_set(struct bch_fs *, int, u64);

View File

@ -1619,7 +1619,8 @@ void bch2_sb_to_text(struct printbuf *out, struct bch_sb *sb,
pr_buf(out, "%s:", opt->attr.name);
pr_tab(out);
bch2_opt_to_text(out, NULL, opt, v, OPT_HUMAN_READABLE|OPT_SHOW_FULL_LIST);
bch2_opt_to_text(out, NULL, sb, opt, v,
OPT_HUMAN_READABLE|OPT_SHOW_FULL_LIST);
pr_newline(out);
}
}

View File

@ -886,7 +886,7 @@ static void print_mount_opts(struct bch_fs *c)
if (!first)
pr_buf(&p, ",");
first = false;
bch2_opt_to_text(&p, c, opt, v, OPT_SHOW_MOUNT_STYLE);
bch2_opt_to_text(&p, c, c->disk_sb.sb, opt, v, OPT_SHOW_MOUNT_STYLE);
}
if (!p.pos)

View File

@ -597,7 +597,7 @@ SHOW(bch2_fs_opts_dir)
int id = opt - bch2_opt_table;
u64 v = bch2_opt_get_by_id(&c->opts, id);
bch2_opt_to_text(out, c, opt, v, OPT_SHOW_FULL_LIST);
bch2_opt_to_text(out, c, c->disk_sb.sb, opt, v, OPT_SHOW_FULL_LIST);
pr_char(out, '\n');
return 0;

View File

@ -448,7 +448,7 @@ static int __bch2_xattr_bcachefs_get(const struct xattr_handler *handler,
return -ENODATA;
v = bch2_opt_get_by_id(&opts, id);
bch2_opt_to_text(&out, c, opt, v, 0);
bch2_opt_to_text(&out, c, c->disk_sb.sb, opt, v, 0);
ret = out.pos;