summaryrefslogtreecommitdiff
path: root/fs/bcachefs/fs-common.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-10-11 12:03:19 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:15 -0400
commit2027875bd8318171159495c948461eae2f84936d (patch)
tree891d2abcd3f50b2bd3bf9b3b60cd325aea5fad66 /fs/bcachefs/fs-common.c
parentf3b1e1937973624d3bc5f3ba0824e228ae256b88 (diff)
bcachefs: Add BCH_SUBVOLUME_UNLINKED
Snapshot deletion needs to become a multi step process, where we unlink, then tear down the page cache, then delete the subvolume - the deleting flag is equivalent to an inode with i_nlink = 0. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/fs-common.c')
-rw-r--r--fs/bcachefs/fs-common.c30
1 files changed, 7 insertions, 23 deletions
diff --git a/fs/bcachefs/fs-common.c b/fs/bcachefs/fs-common.c
index c49de741e1e3..5f3429e99115 100644
--- a/fs/bcachefs/fs-common.c
+++ b/fs/bcachefs/fs-common.c
@@ -239,7 +239,7 @@ int bch2_unlink_trans(struct btree_trans *trans,
struct bch_inode_unpacked *dir_u,
struct bch_inode_unpacked *inode_u,
const struct qstr *name,
- int deleting_snapshot)
+ bool deleting_snapshot)
{
struct bch_fs *c = trans->c;
struct btree_iter dir_iter = { NULL };
@@ -267,35 +267,19 @@ int bch2_unlink_trans(struct btree_trans *trans,
if (ret)
goto err;
- if (deleting_snapshot <= 0 && S_ISDIR(inode_u->bi_mode)) {
+ if (!deleting_snapshot && S_ISDIR(inode_u->bi_mode)) {
ret = bch2_empty_dir_trans(trans, inum);
if (ret)
goto err;
}
- if (deleting_snapshot < 0 &&
- inode_u->bi_subvol) {
- struct bch_subvolume s;
-
- ret = bch2_subvolume_get(trans, inode_u->bi_subvol, true,
- BTREE_ITER_CACHED|
- BTREE_ITER_WITH_UPDATES,
- &s);
- if (ret)
- goto err;
-
- if (BCH_SUBVOLUME_SNAP(&s))
- deleting_snapshot = 1;
+ if (deleting_snapshot && !inode_u->bi_subvol) {
+ ret = -ENOENT;
+ goto err;
}
- if (deleting_snapshot == 1) {
- if (!inode_u->bi_subvol) {
- ret = -ENOENT;
- goto err;
- }
-
- ret = bch2_subvolume_delete(trans, inode_u->bi_subvol,
- deleting_snapshot);
+ if (deleting_snapshot || inode_u->bi_subvol) {
+ ret = bch2_subvolume_unlink(trans, inode_u->bi_subvol);
if (ret)
goto err;