mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-23 00:00:02 +03:00
Update bcachefs sources to a1b6677dca57 bcachefs: Fix looping around bch2_propagate_key_to_snapshot_leaves()
This commit is contained in:
parent
1e358401ec
commit
5e215654da
@ -1 +1 @@
|
|||||||
1336a995cbc3a575002ed517c4d27c847ecb6496
|
a1b6677dca574a8bf904d9eea2b108474dc378d1
|
||||||
|
@ -293,9 +293,17 @@ do { \
|
|||||||
printk_ratelimited(KERN_ERR bch2_fmt_inum_offset(c, _inum, _offset, fmt), ##__VA_ARGS__)
|
printk_ratelimited(KERN_ERR bch2_fmt_inum_offset(c, _inum, _offset, fmt), ##__VA_ARGS__)
|
||||||
|
|
||||||
#define bch_err_fn(_c, _ret) \
|
#define bch_err_fn(_c, _ret) \
|
||||||
bch_err(_c, "%s(): error %s", __func__, bch2_err_str(_ret))
|
do { \
|
||||||
|
if (_ret && !bch2_err_matches(_ret, BCH_ERR_transaction_restart))\
|
||||||
|
bch_err(_c, "%s(): error %s", __func__, bch2_err_str(_ret));\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define bch_err_msg(_c, _ret, _msg, ...) \
|
#define bch_err_msg(_c, _ret, _msg, ...) \
|
||||||
bch_err(_c, "%s(): error " _msg " %s", __func__, ##__VA_ARGS__, bch2_err_str(_ret))
|
do { \
|
||||||
|
if (_ret && !bch2_err_matches(_ret, BCH_ERR_transaction_restart))\
|
||||||
|
bch_err(_c, "%s(): error " _msg " %s", __func__, \
|
||||||
|
##__VA_ARGS__, bch2_err_str(_ret)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define bch_verbose(c, fmt, ...) \
|
#define bch_verbose(c, fmt, ...) \
|
||||||
do { \
|
do { \
|
||||||
|
@ -126,8 +126,7 @@ static int lookup_first_inode(struct btree_trans *trans, u64 inode_nr,
|
|||||||
|
|
||||||
ret = bch2_inode_unpack(k, inode);
|
ret = bch2_inode_unpack(k, inode);
|
||||||
err:
|
err:
|
||||||
if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart))
|
bch_err_msg(trans->c, ret, "fetching inode %llu", inode_nr);
|
||||||
bch_err_msg(trans->c, ret, "fetching inode %llu", inode_nr);
|
|
||||||
bch2_trans_iter_exit(trans, &iter);
|
bch2_trans_iter_exit(trans, &iter);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -152,8 +151,7 @@ static int __lookup_inode(struct btree_trans *trans, u64 inode_nr,
|
|||||||
if (!ret)
|
if (!ret)
|
||||||
*snapshot = iter.pos.snapshot;
|
*snapshot = iter.pos.snapshot;
|
||||||
err:
|
err:
|
||||||
if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart))
|
bch_err_msg(trans->c, ret, "fetching inode %llu:%u", inode_nr, *snapshot);
|
||||||
bch_err_msg(trans->c, ret, "fetching inode %llu:%u", inode_nr, *snapshot);
|
|
||||||
bch2_trans_iter_exit(trans, &iter);
|
bch2_trans_iter_exit(trans, &iter);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -238,8 +236,7 @@ static int __remove_dirent(struct btree_trans *trans, struct bpos pos)
|
|||||||
BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE);
|
BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE);
|
||||||
bch2_trans_iter_exit(trans, &iter);
|
bch2_trans_iter_exit(trans, &iter);
|
||||||
err:
|
err:
|
||||||
if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart))
|
bch_err_fn(c, ret);
|
||||||
bch_err_fn(c, ret);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,8 +271,7 @@ static int lookup_lostfound(struct btree_trans *trans, u32 subvol,
|
|||||||
goto create_lostfound;
|
goto create_lostfound;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart))
|
bch_err_fn(c, ret);
|
||||||
bch_err_fn(c, ret);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@ -297,8 +293,7 @@ create_lostfound:
|
|||||||
lostfound, &lostfound_str,
|
lostfound, &lostfound_str,
|
||||||
0, 0, S_IFDIR|0700, 0, NULL, NULL,
|
0, 0, S_IFDIR|0700, 0, NULL, NULL,
|
||||||
(subvol_inum) { }, 0);
|
(subvol_inum) { }, 0);
|
||||||
if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart))
|
bch_err_msg(c, ret, "creating lost+found");
|
||||||
bch_err_msg(c, ret, "creating lost+found");
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,11 +356,7 @@ static int reattach_inode(struct btree_trans *trans,
|
|||||||
BTREE_INSERT_LAZY_RW|
|
BTREE_INSERT_LAZY_RW|
|
||||||
BTREE_INSERT_NOFAIL,
|
BTREE_INSERT_NOFAIL,
|
||||||
__reattach_inode(trans, inode, inode_snapshot));
|
__reattach_inode(trans, inode, inode_snapshot));
|
||||||
if (ret) {
|
bch_err_msg(trans->c, ret, "reattaching inode %llu", inode->bi_inum);
|
||||||
bch_err_msg(trans->c, ret, "reattaching inode %llu", inode->bi_inum);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -821,8 +812,7 @@ bad_hash:
|
|||||||
(printbuf_reset(&buf),
|
(printbuf_reset(&buf),
|
||||||
bch2_bkey_val_to_text(&buf, c, hash_k), buf.buf))) {
|
bch2_bkey_val_to_text(&buf, c, hash_k), buf.buf))) {
|
||||||
ret = hash_redo_key(trans, desc, hash_info, k_iter, hash_k);
|
ret = hash_redo_key(trans, desc, hash_info, k_iter, hash_k);
|
||||||
if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart))
|
bch_err_fn(c, ret);
|
||||||
bch_err_fn(c, ret);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
ret = -BCH_ERR_transaction_restart_nested;
|
ret = -BCH_ERR_transaction_restart_nested;
|
||||||
@ -885,11 +875,9 @@ static int check_inode(struct btree_trans *trans,
|
|||||||
u.bi_flags &= ~BCH_INODE_I_SIZE_DIRTY|BCH_INODE_UNLINKED;
|
u.bi_flags &= ~BCH_INODE_I_SIZE_DIRTY|BCH_INODE_UNLINKED;
|
||||||
|
|
||||||
ret = __write_inode(trans, &u, iter->pos.snapshot);
|
ret = __write_inode(trans, &u, iter->pos.snapshot);
|
||||||
if (ret) {
|
bch_err_msg(c, ret, "in fsck updating inode");
|
||||||
if (!bch2_err_matches(ret, BCH_ERR_transaction_restart))
|
if (ret)
|
||||||
bch_err_msg(c, ret, "in fsck updating inode");
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
|
||||||
|
|
||||||
if (!bpos_eq(new_min_pos, POS_MIN))
|
if (!bpos_eq(new_min_pos, POS_MIN))
|
||||||
bch2_btree_iter_set_pos(iter, bpos_predecessor(new_min_pos));
|
bch2_btree_iter_set_pos(iter, bpos_predecessor(new_min_pos));
|
||||||
@ -904,8 +892,7 @@ static int check_inode(struct btree_trans *trans,
|
|||||||
bch2_fs_lazy_rw(c);
|
bch2_fs_lazy_rw(c);
|
||||||
|
|
||||||
ret = bch2_inode_rm_snapshot(trans, u.bi_inum, iter->pos.snapshot);
|
ret = bch2_inode_rm_snapshot(trans, u.bi_inum, iter->pos.snapshot);
|
||||||
if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart))
|
bch_err_msg(c, ret, "in fsck deleting inode");
|
||||||
bch_err_msg(c, ret, "in fsck deleting inode");
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -927,8 +914,7 @@ static int check_inode(struct btree_trans *trans,
|
|||||||
iter->pos.snapshot),
|
iter->pos.snapshot),
|
||||||
POS(u.bi_inum, U64_MAX),
|
POS(u.bi_inum, U64_MAX),
|
||||||
0, NULL);
|
0, NULL);
|
||||||
if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart))
|
bch_err_msg(c, ret, "in fsck truncating inode");
|
||||||
bch_err_msg(c, ret, "in fsck truncating inode");
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@ -953,7 +939,7 @@ static int check_inode(struct btree_trans *trans,
|
|||||||
|
|
||||||
sectors = bch2_count_inode_sectors(trans, u.bi_inum, iter->pos.snapshot);
|
sectors = bch2_count_inode_sectors(trans, u.bi_inum, iter->pos.snapshot);
|
||||||
if (sectors < 0) {
|
if (sectors < 0) {
|
||||||
bch_err_msg(c, sectors, "fsck recounting inode sectors");
|
bch_err_msg(c, sectors, "in fsck recounting inode sectors");
|
||||||
return sectors;
|
return sectors;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -971,15 +957,13 @@ static int check_inode(struct btree_trans *trans,
|
|||||||
|
|
||||||
if (do_update) {
|
if (do_update) {
|
||||||
ret = __write_inode(trans, &u, iter->pos.snapshot);
|
ret = __write_inode(trans, &u, iter->pos.snapshot);
|
||||||
if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart))
|
bch_err_msg(c, ret, "in fsck updating inode");
|
||||||
bch_err_msg(c, ret, "in fsck updating inode");
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
err:
|
err:
|
||||||
fsck_err:
|
fsck_err:
|
||||||
if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart))
|
bch_err_fn(c, ret);
|
||||||
bch_err_fn(c, ret);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1004,8 +988,7 @@ int bch2_check_inodes(struct bch_fs *c)
|
|||||||
|
|
||||||
snapshots_seen_exit(&s);
|
snapshots_seen_exit(&s);
|
||||||
bch2_trans_put(trans);
|
bch2_trans_put(trans);
|
||||||
if (ret)
|
bch_err_fn(c, ret);
|
||||||
bch_err_fn(c, ret);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1084,8 +1067,7 @@ static int check_i_sectors(struct btree_trans *trans, struct inode_walker *w)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fsck_err:
|
fsck_err:
|
||||||
if (ret)
|
bch_err_fn(c, ret);
|
||||||
bch_err_fn(c, ret);
|
|
||||||
return ret ?: trans_was_restarted(trans, restart_count);
|
return ret ?: trans_was_restarted(trans, restart_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1419,9 +1401,7 @@ out:
|
|||||||
err:
|
err:
|
||||||
fsck_err:
|
fsck_err:
|
||||||
printbuf_exit(&buf);
|
printbuf_exit(&buf);
|
||||||
|
bch_err_fn(c, ret);
|
||||||
if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart))
|
|
||||||
bch_err_fn(c, ret);
|
|
||||||
return ret;
|
return ret;
|
||||||
delete:
|
delete:
|
||||||
ret = bch2_btree_delete_at(trans, iter, BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE);
|
ret = bch2_btree_delete_at(trans, iter, BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE);
|
||||||
@ -1462,8 +1442,7 @@ int bch2_check_extents(struct bch_fs *c)
|
|||||||
snapshots_seen_exit(&s);
|
snapshots_seen_exit(&s);
|
||||||
bch2_trans_put(trans);
|
bch2_trans_put(trans);
|
||||||
|
|
||||||
if (ret)
|
bch_err_fn(c, ret);
|
||||||
bch_err_fn(c, ret);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1501,8 +1480,7 @@ static int check_subdir_count(struct btree_trans *trans, struct inode_walker *w)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fsck_err:
|
fsck_err:
|
||||||
if (ret)
|
bch_err_fn(c, ret);
|
||||||
bch_err_fn(c, ret);
|
|
||||||
return ret ?: trans_was_restarted(trans, restart_count);
|
return ret ?: trans_was_restarted(trans, restart_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1619,9 +1597,7 @@ out:
|
|||||||
err:
|
err:
|
||||||
fsck_err:
|
fsck_err:
|
||||||
printbuf_exit(&buf);
|
printbuf_exit(&buf);
|
||||||
|
bch_err_fn(c, ret);
|
||||||
if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart))
|
|
||||||
bch_err_fn(c, ret);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1785,9 +1761,7 @@ out:
|
|||||||
err:
|
err:
|
||||||
fsck_err:
|
fsck_err:
|
||||||
printbuf_exit(&buf);
|
printbuf_exit(&buf);
|
||||||
|
bch_err_fn(c, ret);
|
||||||
if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart))
|
|
||||||
bch_err_fn(c, ret);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1820,9 +1794,7 @@ int bch2_check_dirents(struct bch_fs *c)
|
|||||||
snapshots_seen_exit(&s);
|
snapshots_seen_exit(&s);
|
||||||
inode_walker_exit(&dir);
|
inode_walker_exit(&dir);
|
||||||
inode_walker_exit(&target);
|
inode_walker_exit(&target);
|
||||||
|
bch_err_fn(c, ret);
|
||||||
if (ret)
|
|
||||||
bch_err_fn(c, ret);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1858,8 +1830,7 @@ static int check_xattr(struct btree_trans *trans, struct btree_iter *iter,
|
|||||||
|
|
||||||
ret = hash_check_key(trans, bch2_xattr_hash_desc, hash_info, iter, k);
|
ret = hash_check_key(trans, bch2_xattr_hash_desc, hash_info, iter, k);
|
||||||
fsck_err:
|
fsck_err:
|
||||||
if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart))
|
bch_err_fn(c, ret);
|
||||||
bch_err_fn(c, ret);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1882,8 +1853,7 @@ int bch2_check_xattrs(struct bch_fs *c)
|
|||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
BTREE_INSERT_LAZY_RW|BTREE_INSERT_NOFAIL,
|
BTREE_INSERT_LAZY_RW|BTREE_INSERT_NOFAIL,
|
||||||
check_xattr(trans, &iter, k, &hash_info, &inode)));
|
check_xattr(trans, &iter, k, &hash_info, &inode)));
|
||||||
if (ret)
|
bch_err_fn(c, ret);
|
||||||
bch_err_fn(c, ret);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1915,10 +1885,9 @@ static int check_root_trans(struct btree_trans *trans)
|
|||||||
BTREE_INSERT_LAZY_RW,
|
BTREE_INSERT_LAZY_RW,
|
||||||
bch2_btree_insert_trans(trans, BTREE_ID_subvolumes,
|
bch2_btree_insert_trans(trans, BTREE_ID_subvolumes,
|
||||||
&root_subvol.k_i, 0));
|
&root_subvol.k_i, 0));
|
||||||
if (ret) {
|
bch_err_msg(c, ret, "writing root subvol");
|
||||||
bch_err_msg(c, ret, "writing root subvol");
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1934,8 +1903,7 @@ static int check_root_trans(struct btree_trans *trans)
|
|||||||
root_inode.bi_inum = inum;
|
root_inode.bi_inum = inum;
|
||||||
|
|
||||||
ret = __write_inode(trans, &root_inode, snapshot);
|
ret = __write_inode(trans, &root_inode, snapshot);
|
||||||
if (ret)
|
bch_err_msg(c, ret, "writing root inode");
|
||||||
bch_err_msg(c, ret, "writing root inode");
|
|
||||||
}
|
}
|
||||||
err:
|
err:
|
||||||
fsck_err:
|
fsck_err:
|
||||||
@ -1951,9 +1919,7 @@ int bch2_check_root(struct bch_fs *c)
|
|||||||
BTREE_INSERT_NOFAIL|
|
BTREE_INSERT_NOFAIL|
|
||||||
BTREE_INSERT_LAZY_RW,
|
BTREE_INSERT_LAZY_RW,
|
||||||
check_root_trans(trans));
|
check_root_trans(trans));
|
||||||
|
bch_err_fn(c, ret);
|
||||||
if (ret)
|
|
||||||
bch_err_fn(c, ret);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2090,8 +2056,7 @@ static int check_path(struct btree_trans *trans,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fsck_err:
|
fsck_err:
|
||||||
if (ret)
|
bch_err_fn(c, ret);
|
||||||
bch_err_fn(c, ret);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2133,9 +2098,7 @@ int bch2_check_directory_structure(struct bch_fs *c)
|
|||||||
bch2_trans_iter_exit(trans, &iter);
|
bch2_trans_iter_exit(trans, &iter);
|
||||||
bch2_trans_put(trans);
|
bch2_trans_put(trans);
|
||||||
darray_exit(&path);
|
darray_exit(&path);
|
||||||
|
bch_err_fn(c, ret);
|
||||||
if (ret)
|
|
||||||
bch_err_fn(c, ret);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2402,9 +2365,7 @@ int bch2_check_nlinks(struct bch_fs *c)
|
|||||||
} while (next_iter_range_start != U64_MAX);
|
} while (next_iter_range_start != U64_MAX);
|
||||||
|
|
||||||
kvfree(links.d);
|
kvfree(links.d);
|
||||||
|
bch_err_fn(c, ret);
|
||||||
if (ret)
|
|
||||||
bch_err_fn(c, ret);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2451,7 +2412,6 @@ int bch2_fix_reflink_p(struct bch_fs *c)
|
|||||||
BTREE_ITER_ALL_SNAPSHOTS, k,
|
BTREE_ITER_ALL_SNAPSHOTS, k,
|
||||||
NULL, NULL, BTREE_INSERT_NOFAIL|BTREE_INSERT_LAZY_RW,
|
NULL, NULL, BTREE_INSERT_NOFAIL|BTREE_INSERT_LAZY_RW,
|
||||||
fix_reflink_p_key(trans, &iter, k)));
|
fix_reflink_p_key(trans, &iter, k)));
|
||||||
if (ret)
|
bch_err_fn(c, ret);
|
||||||
bch_err_fn(c, ret);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -357,9 +357,7 @@ int bch2_inode_peek(struct btree_trans *trans,
|
|||||||
subvol_inum inum, unsigned flags)
|
subvol_inum inum, unsigned flags)
|
||||||
{
|
{
|
||||||
int ret = bch2_inode_peek_nowarn(trans, iter, inode, inum, flags);
|
int ret = bch2_inode_peek_nowarn(trans, iter, inode, inum, flags);
|
||||||
|
bch_err_msg(trans->c, ret, "looking up inum %u:%llu:", inum.subvol, inum.inum);
|
||||||
if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart))
|
|
||||||
bch_err_msg(trans->c, ret, "looking up inum %u:%llu:", inum.subvol, inum.inum);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1636,9 +1636,15 @@ int bch2_propagate_key_to_snapshot_leaves(struct btree_trans *trans,
|
|||||||
if (!bch2_snapshot_is_ancestor(c, id, k.k->p.snapshot) ||
|
if (!bch2_snapshot_is_ancestor(c, id, k.k->p.snapshot) ||
|
||||||
!bch2_snapshot_is_leaf(c, id))
|
!bch2_snapshot_is_leaf(c, id))
|
||||||
continue;
|
continue;
|
||||||
|
again:
|
||||||
|
ret = btree_trans_too_many_iters(trans) ?:
|
||||||
|
bch2_propagate_key_to_snapshot_leaf(trans, btree, k, id, new_min_pos) ?:
|
||||||
|
bch2_trans_commit(trans, NULL, NULL, 0);
|
||||||
|
if (ret && bch2_err_matches(ret, BCH_ERR_transaction_restart)) {
|
||||||
|
bch2_trans_begin(trans);
|
||||||
|
goto again;
|
||||||
|
}
|
||||||
|
|
||||||
ret = commit_do(trans, NULL, NULL, 0,
|
|
||||||
bch2_propagate_key_to_snapshot_leaf(trans, btree, k, id, new_min_pos));
|
|
||||||
if (ret)
|
if (ret)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -45,28 +45,25 @@ static int test_delete(struct bch_fs *c, u64 nr)
|
|||||||
ret = commit_do(trans, NULL, NULL, 0,
|
ret = commit_do(trans, NULL, NULL, 0,
|
||||||
bch2_btree_iter_traverse(&iter) ?:
|
bch2_btree_iter_traverse(&iter) ?:
|
||||||
bch2_trans_update(trans, &iter, &k.k_i, 0));
|
bch2_trans_update(trans, &iter, &k.k_i, 0));
|
||||||
if (ret) {
|
bch_err_msg(c, ret, "update error");
|
||||||
bch_err_msg(c, ret, "update error");
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
|
||||||
|
|
||||||
pr_info("deleting once");
|
pr_info("deleting once");
|
||||||
ret = commit_do(trans, NULL, NULL, 0,
|
ret = commit_do(trans, NULL, NULL, 0,
|
||||||
bch2_btree_iter_traverse(&iter) ?:
|
bch2_btree_iter_traverse(&iter) ?:
|
||||||
bch2_btree_delete_at(trans, &iter, 0));
|
bch2_btree_delete_at(trans, &iter, 0));
|
||||||
if (ret) {
|
bch_err_msg(c, ret, "delete error (first)");
|
||||||
bch_err_msg(c, ret, "delete error (first)");
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
|
||||||
|
|
||||||
pr_info("deleting twice");
|
pr_info("deleting twice");
|
||||||
ret = commit_do(trans, NULL, NULL, 0,
|
ret = commit_do(trans, NULL, NULL, 0,
|
||||||
bch2_btree_iter_traverse(&iter) ?:
|
bch2_btree_iter_traverse(&iter) ?:
|
||||||
bch2_btree_delete_at(trans, &iter, 0));
|
bch2_btree_delete_at(trans, &iter, 0));
|
||||||
if (ret) {
|
bch_err_msg(c, ret, "delete error (second)");
|
||||||
bch_err_msg(c, ret, "delete error (second)");
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
|
||||||
err:
|
err:
|
||||||
bch2_trans_iter_exit(trans, &iter);
|
bch2_trans_iter_exit(trans, &iter);
|
||||||
bch2_trans_put(trans);
|
bch2_trans_put(trans);
|
||||||
@ -89,10 +86,9 @@ static int test_delete_written(struct bch_fs *c, u64 nr)
|
|||||||
ret = commit_do(trans, NULL, NULL, 0,
|
ret = commit_do(trans, NULL, NULL, 0,
|
||||||
bch2_btree_iter_traverse(&iter) ?:
|
bch2_btree_iter_traverse(&iter) ?:
|
||||||
bch2_trans_update(trans, &iter, &k.k_i, 0));
|
bch2_trans_update(trans, &iter, &k.k_i, 0));
|
||||||
if (ret) {
|
bch_err_msg(c, ret, "update error");
|
||||||
bch_err_msg(c, ret, "update error");
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
|
||||||
|
|
||||||
bch2_trans_unlock(trans);
|
bch2_trans_unlock(trans);
|
||||||
bch2_journal_flush_all_pins(&c->journal);
|
bch2_journal_flush_all_pins(&c->journal);
|
||||||
@ -100,10 +96,9 @@ static int test_delete_written(struct bch_fs *c, u64 nr)
|
|||||||
ret = commit_do(trans, NULL, NULL, 0,
|
ret = commit_do(trans, NULL, NULL, 0,
|
||||||
bch2_btree_iter_traverse(&iter) ?:
|
bch2_btree_iter_traverse(&iter) ?:
|
||||||
bch2_btree_delete_at(trans, &iter, 0));
|
bch2_btree_delete_at(trans, &iter, 0));
|
||||||
if (ret) {
|
bch_err_msg(c, ret, "delete error");
|
||||||
bch_err_msg(c, ret, "delete error");
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
|
||||||
err:
|
err:
|
||||||
bch2_trans_iter_exit(trans, &iter);
|
bch2_trans_iter_exit(trans, &iter);
|
||||||
bch2_trans_put(trans);
|
bch2_trans_put(trans);
|
||||||
@ -130,10 +125,9 @@ static int test_iterate(struct bch_fs *c, u64 nr)
|
|||||||
ck.k.p.snapshot = U32_MAX;
|
ck.k.p.snapshot = U32_MAX;
|
||||||
|
|
||||||
ret = bch2_btree_insert(c, BTREE_ID_xattrs, &ck.k_i, NULL, 0);
|
ret = bch2_btree_insert(c, BTREE_ID_xattrs, &ck.k_i, NULL, 0);
|
||||||
if (ret) {
|
bch_err_msg(c, ret, "insert error");
|
||||||
bch_err_msg(c, ret, "insert error");
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pr_info("iterating forwards");
|
pr_info("iterating forwards");
|
||||||
@ -146,10 +140,9 @@ static int test_iterate(struct bch_fs *c, u64 nr)
|
|||||||
BUG_ON(k.k->p.offset != i++);
|
BUG_ON(k.k->p.offset != i++);
|
||||||
0;
|
0;
|
||||||
}));
|
}));
|
||||||
if (ret) {
|
bch_err_msg(c, ret, "error iterating forwards");
|
||||||
bch_err_msg(c, ret, "error iterating forwards");
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
|
||||||
|
|
||||||
BUG_ON(i != nr);
|
BUG_ON(i != nr);
|
||||||
|
|
||||||
@ -161,10 +154,9 @@ static int test_iterate(struct bch_fs *c, u64 nr)
|
|||||||
BUG_ON(k.k->p.offset != --i);
|
BUG_ON(k.k->p.offset != --i);
|
||||||
0;
|
0;
|
||||||
}));
|
}));
|
||||||
if (ret) {
|
bch_err_msg(c, ret, "error iterating backwards");
|
||||||
bch_err_msg(c, ret, "error iterating backwards");
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
|
||||||
|
|
||||||
BUG_ON(i);
|
BUG_ON(i);
|
||||||
err:
|
err:
|
||||||
@ -194,10 +186,9 @@ static int test_iterate_extents(struct bch_fs *c, u64 nr)
|
|||||||
ck.k.size = 8;
|
ck.k.size = 8;
|
||||||
|
|
||||||
ret = bch2_btree_insert(c, BTREE_ID_extents, &ck.k_i, NULL, 0);
|
ret = bch2_btree_insert(c, BTREE_ID_extents, &ck.k_i, NULL, 0);
|
||||||
if (ret) {
|
bch_err_msg(c, ret, "insert error");
|
||||||
bch_err_msg(c, ret, "insert error");
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pr_info("iterating forwards");
|
pr_info("iterating forwards");
|
||||||
@ -211,10 +202,9 @@ static int test_iterate_extents(struct bch_fs *c, u64 nr)
|
|||||||
i = k.k->p.offset;
|
i = k.k->p.offset;
|
||||||
0;
|
0;
|
||||||
}));
|
}));
|
||||||
if (ret) {
|
bch_err_msg(c, ret, "error iterating forwards");
|
||||||
bch_err_msg(c, ret, "error iterating forwards");
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
|
||||||
|
|
||||||
BUG_ON(i != nr);
|
BUG_ON(i != nr);
|
||||||
|
|
||||||
@ -227,10 +217,9 @@ static int test_iterate_extents(struct bch_fs *c, u64 nr)
|
|||||||
i = bkey_start_offset(k.k);
|
i = bkey_start_offset(k.k);
|
||||||
0;
|
0;
|
||||||
}));
|
}));
|
||||||
if (ret) {
|
bch_err_msg(c, ret, "error iterating backwards");
|
||||||
bch_err_msg(c, ret, "error iterating backwards");
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
|
||||||
|
|
||||||
BUG_ON(i);
|
BUG_ON(i);
|
||||||
err:
|
err:
|
||||||
@ -259,10 +248,9 @@ static int test_iterate_slots(struct bch_fs *c, u64 nr)
|
|||||||
ck.k.p.snapshot = U32_MAX;
|
ck.k.p.snapshot = U32_MAX;
|
||||||
|
|
||||||
ret = bch2_btree_insert(c, BTREE_ID_xattrs, &ck.k_i, NULL, 0);
|
ret = bch2_btree_insert(c, BTREE_ID_xattrs, &ck.k_i, NULL, 0);
|
||||||
if (ret) {
|
bch_err_msg(c, ret, "insert error");
|
||||||
bch_err_msg(c, ret, "insert error");
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pr_info("iterating forwards");
|
pr_info("iterating forwards");
|
||||||
@ -276,10 +264,9 @@ static int test_iterate_slots(struct bch_fs *c, u64 nr)
|
|||||||
i += 2;
|
i += 2;
|
||||||
0;
|
0;
|
||||||
}));
|
}));
|
||||||
if (ret) {
|
bch_err_msg(c, ret, "error iterating forwards");
|
||||||
bch_err_msg(c, ret, "error iterating forwards");
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
|
||||||
|
|
||||||
BUG_ON(i != nr * 2);
|
BUG_ON(i != nr * 2);
|
||||||
|
|
||||||
@ -330,10 +317,9 @@ static int test_iterate_slots_extents(struct bch_fs *c, u64 nr)
|
|||||||
ck.k.size = 8;
|
ck.k.size = 8;
|
||||||
|
|
||||||
ret = bch2_btree_insert(c, BTREE_ID_extents, &ck.k_i, NULL, 0);
|
ret = bch2_btree_insert(c, BTREE_ID_extents, &ck.k_i, NULL, 0);
|
||||||
if (ret) {
|
bch_err_msg(c, ret, "insert error");
|
||||||
bch_err_msg(c, ret, "insert error");
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pr_info("iterating forwards");
|
pr_info("iterating forwards");
|
||||||
@ -348,10 +334,9 @@ static int test_iterate_slots_extents(struct bch_fs *c, u64 nr)
|
|||||||
i += 16;
|
i += 16;
|
||||||
0;
|
0;
|
||||||
}));
|
}));
|
||||||
if (ret) {
|
bch_err_msg(c, ret, "error iterating forwards");
|
||||||
bch_err_msg(c, ret, "error iterating forwards");
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
|
||||||
|
|
||||||
BUG_ON(i != nr);
|
BUG_ON(i != nr);
|
||||||
|
|
||||||
@ -371,10 +356,9 @@ static int test_iterate_slots_extents(struct bch_fs *c, u64 nr)
|
|||||||
i = k.k->p.offset;
|
i = k.k->p.offset;
|
||||||
0;
|
0;
|
||||||
}));
|
}));
|
||||||
if (ret) {
|
bch_err_msg(c, ret, "error iterating forwards by slots");
|
||||||
bch_err_msg(c, ret, "error iterating forwards by slots");
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
err:
|
err:
|
||||||
bch2_trans_put(trans);
|
bch2_trans_put(trans);
|
||||||
@ -442,8 +426,7 @@ static int insert_test_extent(struct bch_fs *c,
|
|||||||
k.k_i.k.version.lo = test_version++;
|
k.k_i.k.version.lo = test_version++;
|
||||||
|
|
||||||
ret = bch2_btree_insert(c, BTREE_ID_extents, &k.k_i, NULL, 0);
|
ret = bch2_btree_insert(c, BTREE_ID_extents, &k.k_i, NULL, 0);
|
||||||
if (ret)
|
bch_err_fn(c, ret);
|
||||||
bch_err_fn(c, ret);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -499,8 +482,7 @@ static int insert_test_overlapping_extent(struct bch_fs *c, u64 inum, u64 start,
|
|||||||
ret = bch2_trans_do(c, NULL, NULL, 0,
|
ret = bch2_trans_do(c, NULL, NULL, 0,
|
||||||
bch2_btree_insert_nonextent(trans, BTREE_ID_extents, &k.k_i,
|
bch2_btree_insert_nonextent(trans, BTREE_ID_extents, &k.k_i,
|
||||||
BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE));
|
BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE));
|
||||||
if (ret)
|
bch_err_fn(c, ret);
|
||||||
bch_err_fn(c, ret);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -569,12 +551,8 @@ static int test_snapshots(struct bch_fs *c, u64 nr)
|
|||||||
swap(snapids[0], snapids[1]);
|
swap(snapids[0], snapids[1]);
|
||||||
|
|
||||||
ret = test_snapshot_filter(c, snapids[0], snapids[1]);
|
ret = test_snapshot_filter(c, snapids[0], snapids[1]);
|
||||||
if (ret) {
|
bch_err_msg(c, ret, "from test_snapshot_filter");
|
||||||
bch_err_msg(c, ret, "from test_snapshot_filter");
|
return ret;
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* perf tests */
|
/* perf tests */
|
||||||
@ -678,8 +656,7 @@ static int rand_mixed_trans(struct btree_trans *trans,
|
|||||||
|
|
||||||
k = bch2_btree_iter_peek(iter);
|
k = bch2_btree_iter_peek(iter);
|
||||||
ret = bkey_err(k);
|
ret = bkey_err(k);
|
||||||
if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart))
|
bch_err_msg(trans->c, ret, "lookup error");
|
||||||
bch_err_msg(trans->c, ret, "lookup error");
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user