1 // SPDX-License-Identifier: GPL-2.0
4 #include "btree_key_cache.h"
5 #include "btree_update.h"
10 #include "subvolume.h"
12 #include <linux/random.h>
14 static int bch2_subvolume_delete(struct btree_trans *, u32);
16 static struct bpos subvolume_children_pos(struct bkey_s_c k)
18 if (k.k->type != KEY_TYPE_subvolume)
21 struct bkey_s_c_subvolume s = bkey_s_c_to_subvolume(k);
22 if (!s.v->fs_path_parent)
24 return POS(le32_to_cpu(s.v->fs_path_parent), s.k->p.offset);
27 static int check_subvol(struct btree_trans *trans,
28 struct btree_iter *iter,
31 struct bch_fs *c = trans->c;
32 struct bkey_s_c_subvolume subvol;
33 struct btree_iter subvol_children_iter = {};
34 struct bch_snapshot snapshot;
35 struct printbuf buf = PRINTBUF;
39 if (k.k->type != KEY_TYPE_subvolume)
42 subvol = bkey_s_c_to_subvolume(k);
43 snapid = le32_to_cpu(subvol.v->snapshot);
44 ret = bch2_snapshot_lookup(trans, snapid, &snapshot);
46 if (bch2_err_matches(ret, ENOENT))
47 bch_err(c, "subvolume %llu points to nonexistent snapshot %u",
48 k.k->p.offset, snapid);
52 if (BCH_SUBVOLUME_UNLINKED(subvol.v)) {
53 ret = bch2_subvolume_delete(trans, iter->pos.offset);
54 bch_err_msg(c, ret, "deleting subvolume %llu", iter->pos.offset);
55 return ret ?: -BCH_ERR_transaction_restart_nested;
58 if (fsck_err_on(subvol.k->p.offset == BCACHEFS_ROOT_SUBVOL &&
59 subvol.v->fs_path_parent,
60 trans, subvol_root_fs_path_parent_nonzero,
61 "root subvolume has nonzero fs_path_parent\n%s",
62 (bch2_bkey_val_to_text(&buf, c, k), buf.buf))) {
63 struct bkey_i_subvolume *n =
64 bch2_bkey_make_mut_typed(trans, iter, &subvol.s_c, 0, subvolume);
65 ret = PTR_ERR_OR_ZERO(n);
69 n->v.fs_path_parent = 0;
72 if (subvol.v->fs_path_parent) {
73 struct bpos pos = subvolume_children_pos(k);
75 struct bkey_s_c subvol_children_k =
76 bch2_bkey_get_iter(trans, &subvol_children_iter,
77 BTREE_ID_subvolume_children, pos, 0);
78 ret = bkey_err(subvol_children_k);
82 if (fsck_err_on(subvol_children_k.k->type != KEY_TYPE_set,
83 trans, subvol_children_not_set,
84 "subvolume not set in subvolume_children btree at %llu:%llu\n%s",
85 pos.inode, pos.offset,
86 (printbuf_reset(&buf),
87 bch2_bkey_val_to_text(&buf, c, k), buf.buf))) {
88 ret = bch2_btree_bit_mod(trans, BTREE_ID_subvolume_children, pos, true);
94 struct bch_inode_unpacked inode;
95 ret = bch2_inode_find_by_inum_nowarn_trans(trans,
96 (subvol_inum) { k.k->p.offset, le64_to_cpu(subvol.v->inode) },
99 if (fsck_err_on(inode.bi_subvol != subvol.k->p.offset,
100 trans, subvol_root_wrong_bi_subvol,
101 "subvol root %llu:%u has wrong bi_subvol field: got %u, should be %llu",
102 inode.bi_inum, inode.bi_snapshot,
103 inode.bi_subvol, subvol.k->p.offset)) {
104 inode.bi_subvol = subvol.k->p.offset;
105 inode.bi_snapshot = le32_to_cpu(subvol.v->snapshot);
106 ret = __bch2_fsck_write_inode(trans, &inode);
110 } else if (bch2_err_matches(ret, ENOENT)) {
111 if (fsck_err(trans, subvol_to_missing_root,
112 "subvolume %llu points to missing subvolume root %llu:%u",
113 k.k->p.offset, le64_to_cpu(subvol.v->inode),
114 le32_to_cpu(subvol.v->snapshot))) {
115 ret = bch2_subvolume_delete(trans, iter->pos.offset);
116 bch_err_msg(c, ret, "deleting subvolume %llu", iter->pos.offset);
117 ret = ret ?: -BCH_ERR_transaction_restart_nested;
124 if (!BCH_SUBVOLUME_SNAP(subvol.v)) {
125 u32 snapshot_root = bch2_snapshot_root(c, le32_to_cpu(subvol.v->snapshot));
127 struct bch_snapshot_tree st;
130 snapshot_tree = snapshot_t(c, snapshot_root)->tree;
133 ret = bch2_snapshot_tree_lookup(trans, snapshot_tree, &st);
135 bch2_fs_inconsistent_on(bch2_err_matches(ret, ENOENT), c,
136 "%s: snapshot tree %u not found", __func__, snapshot_tree);
141 if (fsck_err_on(le32_to_cpu(st.master_subvol) != subvol.k->p.offset,
142 trans, subvol_not_master_and_not_snapshot,
143 "subvolume %llu is not set as snapshot but is not master subvolume",
145 struct bkey_i_subvolume *s =
146 bch2_bkey_make_mut_typed(trans, iter, &subvol.s_c, 0, subvolume);
147 ret = PTR_ERR_OR_ZERO(s);
151 SET_BCH_SUBVOLUME_SNAP(&s->v, true);
156 bch2_trans_iter_exit(trans, &subvol_children_iter);
161 int bch2_check_subvols(struct bch_fs *c)
163 int ret = bch2_trans_run(c,
164 for_each_btree_key_commit(trans, iter,
165 BTREE_ID_subvolumes, POS_MIN, BTREE_ITER_prefetch, k,
166 NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
167 check_subvol(trans, &iter, k)));
172 static int check_subvol_child(struct btree_trans *trans,
173 struct btree_iter *child_iter,
174 struct bkey_s_c child_k)
176 struct bch_subvolume s;
177 int ret = bch2_bkey_get_val_typed(trans, BTREE_ID_subvolumes, POS(0, child_k.k->p.offset),
179 if (ret && !bch2_err_matches(ret, ENOENT))
182 if (fsck_err_on(ret ||
183 le32_to_cpu(s.fs_path_parent) != child_k.k->p.inode,
184 trans, subvol_children_bad,
185 "incorrect entry in subvolume_children btree %llu:%llu",
186 child_k.k->p.inode, child_k.k->p.offset)) {
187 ret = bch2_btree_delete_at(trans, child_iter, 0);
196 int bch2_check_subvol_children(struct bch_fs *c)
198 int ret = bch2_trans_run(c,
199 for_each_btree_key_commit(trans, iter,
200 BTREE_ID_subvolume_children, POS_MIN, BTREE_ITER_prefetch, k,
201 NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
202 check_subvol_child(trans, &iter, k)));
209 int bch2_subvolume_validate(struct bch_fs *c, struct bkey_s_c k,
210 struct bkey_validate_context from)
212 struct bkey_s_c_subvolume subvol = bkey_s_c_to_subvolume(k);
215 bkey_fsck_err_on(bkey_lt(k.k->p, SUBVOL_POS_MIN) ||
216 bkey_gt(k.k->p, SUBVOL_POS_MAX),
220 bkey_fsck_err_on(!subvol.v->snapshot,
221 c, subvol_snapshot_bad,
224 bkey_fsck_err_on(!subvol.v->inode,
231 void bch2_subvolume_to_text(struct printbuf *out, struct bch_fs *c,
234 struct bkey_s_c_subvolume s = bkey_s_c_to_subvolume(k);
236 prt_printf(out, "root %llu snapshot id %u",
237 le64_to_cpu(s.v->inode),
238 le32_to_cpu(s.v->snapshot));
240 if (bkey_val_bytes(s.k) > offsetof(struct bch_subvolume, creation_parent)) {
241 prt_printf(out, " creation_parent %u", le32_to_cpu(s.v->creation_parent));
242 prt_printf(out, " fs_parent %u", le32_to_cpu(s.v->fs_path_parent));
246 static int subvolume_children_mod(struct btree_trans *trans, struct bpos pos, bool set)
248 return !bpos_eq(pos, POS_MIN)
249 ? bch2_btree_bit_mod(trans, BTREE_ID_subvolume_children, pos, set)
253 int bch2_subvolume_trigger(struct btree_trans *trans,
254 enum btree_id btree_id, unsigned level,
255 struct bkey_s_c old, struct bkey_s new,
256 enum btree_iter_update_trigger_flags flags)
258 if (flags & BTREE_TRIGGER_transactional) {
259 struct bpos children_pos_old = subvolume_children_pos(old);
260 struct bpos children_pos_new = subvolume_children_pos(new.s_c);
262 if (!bpos_eq(children_pos_old, children_pos_new)) {
263 int ret = subvolume_children_mod(trans, children_pos_old, false) ?:
264 subvolume_children_mod(trans, children_pos_new, true);
273 int bch2_subvol_has_children(struct btree_trans *trans, u32 subvol)
275 struct btree_iter iter;
277 bch2_trans_iter_init(trans, &iter, BTREE_ID_subvolume_children, POS(subvol, 0), 0);
278 struct bkey_s_c k = bch2_btree_iter_peek(&iter);
279 bch2_trans_iter_exit(trans, &iter);
281 return bkey_err(k) ?: k.k && k.k->p.inode == subvol
282 ? -BCH_ERR_ENOTEMPTY_subvol_not_empty
286 static __always_inline int
287 bch2_subvolume_get_inlined(struct btree_trans *trans, unsigned subvol,
288 bool inconsistent_if_not_found,
289 struct bch_subvolume *s)
291 int ret = bch2_bkey_get_val_typed(trans, BTREE_ID_subvolumes, POS(0, subvol),
293 BTREE_ITER_with_updates, subvolume, s);
294 bch2_fs_inconsistent_on(bch2_err_matches(ret, ENOENT) &&
295 inconsistent_if_not_found,
296 trans->c, "missing subvolume %u", subvol);
300 int bch2_subvolume_get(struct btree_trans *trans, unsigned subvol,
301 bool inconsistent_if_not_found,
302 struct bch_subvolume *s)
304 return bch2_subvolume_get_inlined(trans, subvol, inconsistent_if_not_found, s);
307 int bch2_subvol_is_ro_trans(struct btree_trans *trans, u32 subvol)
309 struct bch_subvolume s;
310 int ret = bch2_subvolume_get_inlined(trans, subvol, true, &s);
314 if (BCH_SUBVOLUME_RO(&s))
319 int bch2_subvol_is_ro(struct bch_fs *c, u32 subvol)
321 return bch2_trans_do(c, bch2_subvol_is_ro_trans(trans, subvol));
324 int bch2_snapshot_get_subvol(struct btree_trans *trans, u32 snapshot,
325 struct bch_subvolume *subvol)
327 struct bch_snapshot snap;
329 return bch2_snapshot_lookup(trans, snapshot, &snap) ?:
330 bch2_subvolume_get(trans, le32_to_cpu(snap.subvol), true, subvol);
333 int __bch2_subvolume_get_snapshot(struct btree_trans *trans, u32 subvolid,
334 u32 *snapid, bool warn)
336 struct btree_iter iter;
337 struct bkey_s_c_subvolume subvol;
340 subvol = bch2_bkey_get_iter_typed(trans, &iter,
341 BTREE_ID_subvolumes, POS(0, subvolid),
342 BTREE_ITER_cached|BTREE_ITER_with_updates,
344 ret = bkey_err(subvol);
346 bch2_fs_inconsistent_on(warn && bch2_err_matches(ret, ENOENT), trans->c,
347 "missing subvolume %u", subvolid);
350 *snapid = le32_to_cpu(subvol.v->snapshot);
351 bch2_trans_iter_exit(trans, &iter);
355 int bch2_subvolume_get_snapshot(struct btree_trans *trans, u32 subvolid,
358 return __bch2_subvolume_get_snapshot(trans, subvolid, snapid, true);
361 static int bch2_subvolume_reparent(struct btree_trans *trans,
362 struct btree_iter *iter,
364 u32 old_parent, u32 new_parent)
366 struct bkey_i_subvolume *s;
369 if (k.k->type != KEY_TYPE_subvolume)
372 if (bkey_val_bytes(k.k) > offsetof(struct bch_subvolume, creation_parent) &&
373 le32_to_cpu(bkey_s_c_to_subvolume(k).v->creation_parent) != old_parent)
376 s = bch2_bkey_make_mut_typed(trans, iter, &k, 0, subvolume);
377 ret = PTR_ERR_OR_ZERO(s);
381 s->v.creation_parent = cpu_to_le32(new_parent);
386 * Separate from the snapshot tree in the snapshots btree, we record the tree
387 * structure of how snapshot subvolumes were created - the parent subvolume of
388 * each snapshot subvolume.
390 * When a subvolume is deleted, we scan for child subvolumes and reparant them,
391 * to avoid dangling references:
393 static int bch2_subvolumes_reparent(struct btree_trans *trans, u32 subvolid_to_delete)
395 struct bch_subvolume s;
397 return lockrestart_do(trans,
398 bch2_subvolume_get(trans, subvolid_to_delete, true, &s)) ?:
399 for_each_btree_key_commit(trans, iter,
400 BTREE_ID_subvolumes, POS_MIN, BTREE_ITER_prefetch, k,
401 NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
402 bch2_subvolume_reparent(trans, &iter, k,
403 subvolid_to_delete, le32_to_cpu(s.creation_parent)));
407 * Delete subvolume, mark snapshot ID as deleted, queue up snapshot
410 static int __bch2_subvolume_delete(struct btree_trans *trans, u32 subvolid)
412 struct btree_iter subvol_iter = {}, snapshot_iter = {}, snapshot_tree_iter = {};
414 struct bkey_s_c_subvolume subvol =
415 bch2_bkey_get_iter_typed(trans, &subvol_iter,
416 BTREE_ID_subvolumes, POS(0, subvolid),
417 BTREE_ITER_cached|BTREE_ITER_intent,
419 int ret = bkey_err(subvol);
420 bch2_fs_inconsistent_on(bch2_err_matches(ret, ENOENT), trans->c,
421 "missing subvolume %u", subvolid);
425 u32 snapid = le32_to_cpu(subvol.v->snapshot);
427 struct bkey_s_c_snapshot snapshot =
428 bch2_bkey_get_iter_typed(trans, &snapshot_iter,
429 BTREE_ID_snapshots, POS(0, snapid),
431 ret = bkey_err(snapshot);
432 bch2_fs_inconsistent_on(bch2_err_matches(ret, ENOENT), trans->c,
433 "missing snapshot %u", snapid);
437 u32 treeid = le32_to_cpu(snapshot.v->tree);
439 struct bkey_s_c_snapshot_tree snapshot_tree =
440 bch2_bkey_get_iter_typed(trans, &snapshot_tree_iter,
441 BTREE_ID_snapshot_trees, POS(0, treeid),
443 ret = bkey_err(snapshot_tree);
444 bch2_fs_inconsistent_on(bch2_err_matches(ret, ENOENT), trans->c,
445 "missing snapshot tree %u", treeid);
449 if (le32_to_cpu(snapshot_tree.v->master_subvol) == subvolid) {
450 struct bkey_i_snapshot_tree *snapshot_tree_mut =
451 bch2_bkey_make_mut_typed(trans, &snapshot_tree_iter,
454 ret = PTR_ERR_OR_ZERO(snapshot_tree_mut);
458 snapshot_tree_mut->v.master_subvol = 0;
461 ret = bch2_btree_delete_at(trans, &subvol_iter, 0) ?:
462 bch2_snapshot_node_set_deleted(trans, snapid);
464 bch2_trans_iter_exit(trans, &snapshot_tree_iter);
465 bch2_trans_iter_exit(trans, &snapshot_iter);
466 bch2_trans_iter_exit(trans, &subvol_iter);
470 static int bch2_subvolume_delete(struct btree_trans *trans, u32 subvolid)
472 return bch2_subvolumes_reparent(trans, subvolid) ?:
473 commit_do(trans, NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
474 __bch2_subvolume_delete(trans, subvolid));
477 static void bch2_subvolume_wait_for_pagecache_and_delete(struct work_struct *work)
479 struct bch_fs *c = container_of(work, struct bch_fs,
480 snapshot_wait_for_pagecache_and_delete_work);
486 mutex_lock(&c->snapshots_unlinked_lock);
487 s = c->snapshots_unlinked;
488 darray_init(&c->snapshots_unlinked);
489 mutex_unlock(&c->snapshots_unlinked_lock);
494 bch2_evict_subvolume_inodes(c, &s);
496 for (id = s.data; id < s.data + s.nr; id++) {
497 ret = bch2_trans_run(c, bch2_subvolume_delete(trans, *id));
498 bch_err_msg(c, ret, "deleting subvolume %u", *id);
506 bch2_write_ref_put(c, BCH_WRITE_REF_snapshot_delete_pagecache);
509 struct subvolume_unlink_hook {
510 struct btree_trans_commit_hook h;
514 static int bch2_subvolume_wait_for_pagecache_and_delete_hook(struct btree_trans *trans,
515 struct btree_trans_commit_hook *_h)
517 struct subvolume_unlink_hook *h = container_of(_h, struct subvolume_unlink_hook, h);
518 struct bch_fs *c = trans->c;
521 mutex_lock(&c->snapshots_unlinked_lock);
522 if (!snapshot_list_has_id(&c->snapshots_unlinked, h->subvol))
523 ret = snapshot_list_add(c, &c->snapshots_unlinked, h->subvol);
524 mutex_unlock(&c->snapshots_unlinked_lock);
529 if (!bch2_write_ref_tryget(c, BCH_WRITE_REF_snapshot_delete_pagecache))
532 if (!queue_work(c->write_ref_wq, &c->snapshot_wait_for_pagecache_and_delete_work))
533 bch2_write_ref_put(c, BCH_WRITE_REF_snapshot_delete_pagecache);
537 int bch2_subvolume_unlink(struct btree_trans *trans, u32 subvolid)
539 struct btree_iter iter;
540 struct bkey_i_subvolume *n;
541 struct subvolume_unlink_hook *h;
544 h = bch2_trans_kmalloc(trans, sizeof(*h));
545 ret = PTR_ERR_OR_ZERO(h);
549 h->h.fn = bch2_subvolume_wait_for_pagecache_and_delete_hook;
550 h->subvol = subvolid;
551 bch2_trans_commit_hook(trans, &h->h);
553 n = bch2_bkey_get_mut_typed(trans, &iter,
554 BTREE_ID_subvolumes, POS(0, subvolid),
555 BTREE_ITER_cached, subvolume);
556 ret = PTR_ERR_OR_ZERO(n);
558 bch2_fs_inconsistent_on(bch2_err_matches(ret, ENOENT), trans->c,
559 "missing subvolume %u", subvolid);
563 SET_BCH_SUBVOLUME_UNLINKED(&n->v, true);
564 bch2_trans_iter_exit(trans, &iter);
568 int bch2_subvolume_create(struct btree_trans *trans, u64 inode,
575 struct bch_fs *c = trans->c;
576 struct btree_iter dst_iter, src_iter = (struct btree_iter) { NULL };
577 struct bkey_i_subvolume *new_subvol = NULL;
578 struct bkey_i_subvolume *src_subvol = NULL;
579 u32 parent = 0, new_nodes[2], snapshot_subvols[2];
582 ret = bch2_bkey_get_empty_slot(trans, &dst_iter,
583 BTREE_ID_subvolumes, POS(0, U32_MAX));
584 if (ret == -BCH_ERR_ENOSPC_btree_slot)
585 ret = -BCH_ERR_ENOSPC_subvolume_create;
589 snapshot_subvols[0] = dst_iter.pos.offset;
590 snapshot_subvols[1] = src_subvolid;
593 /* Creating a snapshot: */
595 src_subvol = bch2_bkey_get_mut_typed(trans, &src_iter,
596 BTREE_ID_subvolumes, POS(0, src_subvolid),
597 BTREE_ITER_cached, subvolume);
598 ret = PTR_ERR_OR_ZERO(src_subvol);
600 bch2_fs_inconsistent_on(bch2_err_matches(ret, ENOENT), c,
601 "subvolume %u not found", src_subvolid);
605 parent = le32_to_cpu(src_subvol->v.snapshot);
608 ret = bch2_snapshot_node_create(trans, parent, new_nodes,
610 src_subvolid ? 2 : 1);
615 src_subvol->v.snapshot = cpu_to_le32(new_nodes[1]);
616 ret = bch2_trans_update(trans, &src_iter, &src_subvol->k_i, 0);
621 new_subvol = bch2_bkey_alloc(trans, &dst_iter, 0, subvolume);
622 ret = PTR_ERR_OR_ZERO(new_subvol);
626 new_subvol->v.flags = 0;
627 new_subvol->v.snapshot = cpu_to_le32(new_nodes[0]);
628 new_subvol->v.inode = cpu_to_le64(inode);
629 new_subvol->v.creation_parent = cpu_to_le32(src_subvolid);
630 new_subvol->v.fs_path_parent = cpu_to_le32(parent_subvolid);
631 new_subvol->v.otime.lo = cpu_to_le64(bch2_current_time(c));
632 new_subvol->v.otime.hi = 0;
634 SET_BCH_SUBVOLUME_RO(&new_subvol->v, ro);
635 SET_BCH_SUBVOLUME_SNAP(&new_subvol->v, src_subvolid != 0);
637 *new_subvolid = new_subvol->k.p.offset;
638 *new_snapshotid = new_nodes[0];
640 bch2_trans_iter_exit(trans, &src_iter);
641 bch2_trans_iter_exit(trans, &dst_iter);
645 int bch2_initialize_subvolumes(struct bch_fs *c)
647 struct bkey_i_snapshot_tree root_tree;
648 struct bkey_i_snapshot root_snapshot;
649 struct bkey_i_subvolume root_volume;
652 bkey_snapshot_tree_init(&root_tree.k_i);
653 root_tree.k.p.offset = 1;
654 root_tree.v.master_subvol = cpu_to_le32(1);
655 root_tree.v.root_snapshot = cpu_to_le32(U32_MAX);
657 bkey_snapshot_init(&root_snapshot.k_i);
658 root_snapshot.k.p.offset = U32_MAX;
659 root_snapshot.v.flags = 0;
660 root_snapshot.v.parent = 0;
661 root_snapshot.v.subvol = cpu_to_le32(BCACHEFS_ROOT_SUBVOL);
662 root_snapshot.v.tree = cpu_to_le32(1);
663 SET_BCH_SNAPSHOT_SUBVOL(&root_snapshot.v, true);
665 bkey_subvolume_init(&root_volume.k_i);
666 root_volume.k.p.offset = BCACHEFS_ROOT_SUBVOL;
667 root_volume.v.flags = 0;
668 root_volume.v.snapshot = cpu_to_le32(U32_MAX);
669 root_volume.v.inode = cpu_to_le64(BCACHEFS_ROOT_INO);
671 ret = bch2_btree_insert(c, BTREE_ID_snapshot_trees, &root_tree.k_i, NULL, 0, 0) ?:
672 bch2_btree_insert(c, BTREE_ID_snapshots, &root_snapshot.k_i, NULL, 0, 0) ?:
673 bch2_btree_insert(c, BTREE_ID_subvolumes, &root_volume.k_i, NULL, 0, 0);
678 static int __bch2_fs_upgrade_for_subvolumes(struct btree_trans *trans)
680 struct btree_iter iter;
682 struct bch_inode_unpacked inode;
685 k = bch2_bkey_get_iter(trans, &iter, BTREE_ID_inodes,
686 SPOS(0, BCACHEFS_ROOT_INO, U32_MAX), 0);
691 if (!bkey_is_inode(k.k)) {
692 bch_err(trans->c, "root inode not found");
693 ret = -BCH_ERR_ENOENT_inode;
697 ret = bch2_inode_unpack(k, &inode);
700 inode.bi_subvol = BCACHEFS_ROOT_SUBVOL;
702 ret = bch2_inode_write(trans, &iter, &inode);
704 bch2_trans_iter_exit(trans, &iter);
708 /* set bi_subvol on root inode */
709 int bch2_fs_upgrade_for_subvolumes(struct bch_fs *c)
711 int ret = bch2_trans_commit_do(c, NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
712 __bch2_fs_upgrade_for_subvolumes(trans));
717 int bch2_fs_subvolumes_init(struct bch_fs *c)
719 INIT_WORK(&c->snapshot_delete_work, bch2_delete_dead_snapshots_work);
720 INIT_WORK(&c->snapshot_wait_for_pagecache_and_delete_work,
721 bch2_subvolume_wait_for_pagecache_and_delete);
722 mutex_init(&c->snapshots_unlinked_lock);