Lines Matching full:trans
27 static int check_subvol(struct btree_trans *trans, in check_subvol() argument
31 struct bch_fs *c = trans->c; in check_subvol()
44 ret = bch2_snapshot_lookup(trans, snapid, &snapshot); in check_subvol()
53 ret = bch2_subvolume_delete(trans, iter->pos.offset); in check_subvol()
60 trans, subvol_root_fs_path_parent_nonzero, in check_subvol()
64 bch2_bkey_make_mut_typed(trans, iter, &subvol.s_c, 0, subvolume); in check_subvol()
76 bch2_bkey_get_iter(trans, &subvol_children_iter, in check_subvol()
83 trans, subvol_children_not_set, in check_subvol()
88 ret = bch2_btree_bit_mod(trans, BTREE_ID_subvolume_children, pos, true); in check_subvol()
95 ret = bch2_inode_find_by_inum_nowarn_trans(trans, in check_subvol()
100 trans, subvol_root_wrong_bi_subvol, in check_subvol()
106 ret = __bch2_fsck_write_inode(trans, &inode); in check_subvol()
111 if (fsck_err(trans, subvol_to_missing_root, in check_subvol()
115 ret = bch2_subvolume_delete(trans, iter->pos.offset); in check_subvol()
133 ret = bch2_snapshot_tree_lookup(trans, snapshot_tree, &st); in check_subvol()
142 trans, subvol_not_master_and_not_snapshot, in check_subvol()
146 bch2_bkey_make_mut_typed(trans, iter, &subvol.s_c, 0, subvolume); in check_subvol()
156 bch2_trans_iter_exit(trans, &subvol_children_iter); in check_subvol()
164 for_each_btree_key_commit(trans, iter, in bch2_check_subvols()
167 check_subvol(trans, &iter, k))); in bch2_check_subvols()
172 static int check_subvol_child(struct btree_trans *trans, in check_subvol_child() argument
177 int ret = bch2_bkey_get_val_typed(trans, BTREE_ID_subvolumes, POS(0, child_k.k->p.offset), in check_subvol_child()
184 trans, subvol_children_bad, in check_subvol_child()
187 ret = bch2_btree_delete_at(trans, child_iter, 0); in check_subvol_child()
199 for_each_btree_key_commit(trans, iter, in bch2_check_subvol_children()
202 check_subvol_child(trans, &iter, k))); in bch2_check_subvol_children()
246 static int subvolume_children_mod(struct btree_trans *trans, struct bpos pos, bool set) in subvolume_children_mod() argument
249 ? bch2_btree_bit_mod(trans, BTREE_ID_subvolume_children, pos, set) in subvolume_children_mod()
253 int bch2_subvolume_trigger(struct btree_trans *trans, in bch2_subvolume_trigger() argument
263 int ret = subvolume_children_mod(trans, children_pos_old, false) ?: in bch2_subvolume_trigger()
264 subvolume_children_mod(trans, children_pos_new, true); in bch2_subvolume_trigger()
273 int bch2_subvol_has_children(struct btree_trans *trans, u32 subvol) in bch2_subvol_has_children() argument
277 bch2_trans_iter_init(trans, &iter, BTREE_ID_subvolume_children, POS(subvol, 0), 0); in bch2_subvol_has_children()
279 bch2_trans_iter_exit(trans, &iter); in bch2_subvol_has_children()
287 bch2_subvolume_get_inlined(struct btree_trans *trans, unsigned subvol, in bch2_subvolume_get_inlined() argument
291 int ret = bch2_bkey_get_val_typed(trans, BTREE_ID_subvolumes, POS(0, subvol), in bch2_subvolume_get_inlined()
296 trans->c, "missing subvolume %u", subvol); in bch2_subvolume_get_inlined()
300 int bch2_subvolume_get(struct btree_trans *trans, unsigned subvol, in bch2_subvolume_get() argument
304 return bch2_subvolume_get_inlined(trans, subvol, inconsistent_if_not_found, s); in bch2_subvolume_get()
307 int bch2_subvol_is_ro_trans(struct btree_trans *trans, u32 subvol) in bch2_subvol_is_ro_trans() argument
310 int ret = bch2_subvolume_get_inlined(trans, subvol, true, &s); in bch2_subvol_is_ro_trans()
321 return bch2_trans_do(c, bch2_subvol_is_ro_trans(trans, subvol)); in bch2_subvol_is_ro()
324 int bch2_snapshot_get_subvol(struct btree_trans *trans, u32 snapshot, in bch2_snapshot_get_subvol() argument
329 return bch2_snapshot_lookup(trans, snapshot, &snap) ?: in bch2_snapshot_get_subvol()
330 bch2_subvolume_get(trans, le32_to_cpu(snap.subvol), true, subvol); in bch2_snapshot_get_subvol()
333 int __bch2_subvolume_get_snapshot(struct btree_trans *trans, u32 subvolid, in __bch2_subvolume_get_snapshot() argument
340 subvol = bch2_bkey_get_iter_typed(trans, &iter, in __bch2_subvolume_get_snapshot()
346 bch2_fs_inconsistent_on(warn && bch2_err_matches(ret, ENOENT), trans->c, in __bch2_subvolume_get_snapshot()
351 bch2_trans_iter_exit(trans, &iter); in __bch2_subvolume_get_snapshot()
355 int bch2_subvolume_get_snapshot(struct btree_trans *trans, u32 subvolid, in bch2_subvolume_get_snapshot() argument
358 return __bch2_subvolume_get_snapshot(trans, subvolid, snapid, true); in bch2_subvolume_get_snapshot()
361 static int bch2_subvolume_reparent(struct btree_trans *trans, in bch2_subvolume_reparent() argument
376 s = bch2_bkey_make_mut_typed(trans, iter, &k, 0, subvolume); in bch2_subvolume_reparent()
393 static int bch2_subvolumes_reparent(struct btree_trans *trans, u32 subvolid_to_delete) in bch2_subvolumes_reparent() argument
397 return lockrestart_do(trans, in bch2_subvolumes_reparent()
398 bch2_subvolume_get(trans, subvolid_to_delete, true, &s)) ?: in bch2_subvolumes_reparent()
399 for_each_btree_key_commit(trans, iter, in bch2_subvolumes_reparent()
402 bch2_subvolume_reparent(trans, &iter, k, in bch2_subvolumes_reparent()
410 static int __bch2_subvolume_delete(struct btree_trans *trans, u32 subvolid) in __bch2_subvolume_delete() argument
415 bch2_bkey_get_iter_typed(trans, &subvol_iter, in __bch2_subvolume_delete()
420 bch2_fs_inconsistent_on(bch2_err_matches(ret, ENOENT), trans->c, in __bch2_subvolume_delete()
428 bch2_bkey_get_iter_typed(trans, &snapshot_iter, in __bch2_subvolume_delete()
432 bch2_fs_inconsistent_on(bch2_err_matches(ret, ENOENT), trans->c, in __bch2_subvolume_delete()
440 bch2_bkey_get_iter_typed(trans, &snapshot_tree_iter, in __bch2_subvolume_delete()
444 bch2_fs_inconsistent_on(bch2_err_matches(ret, ENOENT), trans->c, in __bch2_subvolume_delete()
451 bch2_bkey_make_mut_typed(trans, &snapshot_tree_iter, in __bch2_subvolume_delete()
461 ret = bch2_btree_delete_at(trans, &subvol_iter, 0) ?: in __bch2_subvolume_delete()
462 bch2_snapshot_node_set_deleted(trans, snapid); in __bch2_subvolume_delete()
464 bch2_trans_iter_exit(trans, &snapshot_tree_iter); in __bch2_subvolume_delete()
465 bch2_trans_iter_exit(trans, &snapshot_iter); in __bch2_subvolume_delete()
466 bch2_trans_iter_exit(trans, &subvol_iter); in __bch2_subvolume_delete()
470 static int bch2_subvolume_delete(struct btree_trans *trans, u32 subvolid) in bch2_subvolume_delete() argument
472 return bch2_subvolumes_reparent(trans, subvolid) ?: in bch2_subvolume_delete()
473 commit_do(trans, NULL, NULL, BCH_TRANS_COMMIT_no_enospc, in bch2_subvolume_delete()
474 __bch2_subvolume_delete(trans, subvolid)); in bch2_subvolume_delete()
497 ret = bch2_trans_run(c, bch2_subvolume_delete(trans, *id)); in bch2_subvolume_wait_for_pagecache_and_delete()
514 static int bch2_subvolume_wait_for_pagecache_and_delete_hook(struct btree_trans *trans, in bch2_subvolume_wait_for_pagecache_and_delete_hook() argument
518 struct bch_fs *c = trans->c; in bch2_subvolume_wait_for_pagecache_and_delete_hook()
537 int bch2_subvolume_unlink(struct btree_trans *trans, u32 subvolid) in bch2_subvolume_unlink() argument
544 h = bch2_trans_kmalloc(trans, sizeof(*h)); in bch2_subvolume_unlink()
551 bch2_trans_commit_hook(trans, &h->h); in bch2_subvolume_unlink()
553 n = bch2_bkey_get_mut_typed(trans, &iter, in bch2_subvolume_unlink()
558 bch2_fs_inconsistent_on(bch2_err_matches(ret, ENOENT), trans->c, in bch2_subvolume_unlink()
564 bch2_trans_iter_exit(trans, &iter); in bch2_subvolume_unlink()
568 int bch2_subvolume_create(struct btree_trans *trans, u64 inode, in bch2_subvolume_create() argument
575 struct bch_fs *c = trans->c; in bch2_subvolume_create()
582 ret = bch2_bkey_get_empty_slot(trans, &dst_iter, in bch2_subvolume_create()
595 src_subvol = bch2_bkey_get_mut_typed(trans, &src_iter, in bch2_subvolume_create()
608 ret = bch2_snapshot_node_create(trans, parent, new_nodes, in bch2_subvolume_create()
616 ret = bch2_trans_update(trans, &src_iter, &src_subvol->k_i, 0); in bch2_subvolume_create()
621 new_subvol = bch2_bkey_alloc(trans, &dst_iter, 0, subvolume); in bch2_subvolume_create()
640 bch2_trans_iter_exit(trans, &src_iter); in bch2_subvolume_create()
641 bch2_trans_iter_exit(trans, &dst_iter); in bch2_subvolume_create()
678 static int __bch2_fs_upgrade_for_subvolumes(struct btree_trans *trans) in __bch2_fs_upgrade_for_subvolumes() argument
685 k = bch2_bkey_get_iter(trans, &iter, BTREE_ID_inodes, in __bch2_fs_upgrade_for_subvolumes()
692 bch_err(trans->c, "root inode not found"); in __bch2_fs_upgrade_for_subvolumes()
702 ret = bch2_inode_write(trans, &iter, &inode); in __bch2_fs_upgrade_for_subvolumes()
704 bch2_trans_iter_exit(trans, &iter); in __bch2_fs_upgrade_for_subvolumes()
712 __bch2_fs_upgrade_for_subvolumes(trans)); in bch2_fs_upgrade_for_subvolumes()