summaryrefslogtreecommitdiff
path: root/fs/bcachefs/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/bcachefs/inode.c')
-rw-r--r--fs/bcachefs/inode.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/fs/bcachefs/inode.c b/fs/bcachefs/inode.c
index 2b653ee03f4f..3b19dc6b9ddc 100644
--- a/fs/bcachefs/inode.c
+++ b/fs/bcachefs/inode.c
@@ -8,6 +8,7 @@
#include "extents.h"
#include "inode.h"
#include "str_hash.h"
+#include "subvolume.h"
#include "varint.h"
#include <linux/random.h>
@@ -340,8 +341,8 @@ int bch2_inode_write(struct btree_trans *trans,
const char *bch2_inode_invalid(const struct bch_fs *c, struct bkey_s_c k)
{
- struct bkey_s_c_inode inode = bkey_s_c_to_inode(k);
- struct bch_inode_unpacked unpacked;
+ struct bkey_s_c_inode inode = bkey_s_c_to_inode(k);
+ struct bch_inode_unpacked unpacked;
if (k.k->p.inode)
return "nonzero k.p.inode";
@@ -368,6 +369,9 @@ const char *bch2_inode_invalid(const struct bch_fs *c, struct bkey_s_c k)
unpacked.bi_nlink != 0)
return "flagged as unlinked but bi_nlink != 0";
+ if (unpacked.bi_subvol && !S_ISDIR(unpacked.bi_mode))
+ return "subvolume root but not a directory";
+
return NULL;
}
@@ -635,6 +639,13 @@ retry:
bch2_inode_unpack(bkey_s_c_to_inode(k), &inode_u);
+ /* Subvolume root? */
+ if (inode_u.bi_subvol) {
+ ret = bch2_subvolume_delete(&trans, inode_u.bi_subvol, -1);
+ if (ret)
+ goto err;
+ }
+
bkey_inode_generation_init(&delete.k_i);
delete.k.p = iter.pos;
delete.v.bi_generation = cpu_to_le32(inode_u.bi_generation + 1);