]> git.baikalelectronics.ru Git - kernel.git/commitdiff
btrfs: disable snapshot creation/deletion for extent tree v2
authorJosef Bacik <josef@toxicpanda.com>
Wed, 15 Dec 2021 20:40:03 +0000 (15:40 -0500)
committerDavid Sterba <dsterba@suse.com>
Mon, 14 Mar 2022 12:13:48 +0000 (13:13 +0100)
When we stop tracking metadata blocks all of snapshotting will break, so
disable it until I add the snapshot root and drop tree support.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/inode.c
fs/btrfs/ioctl.c

index 9e21fbcbac6d241f349ea2fa14e2335b091a3394..fc3e2f06cb026c1085ac9735f648a58fd24b8a69 100644 (file)
@@ -4583,14 +4583,21 @@ out_up_write:
 static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
 {
        struct inode *inode = d_inode(dentry);
+       struct btrfs_fs_info *fs_info = BTRFS_I(inode)->root->fs_info;
        int err = 0;
        struct btrfs_trans_handle *trans;
        u64 last_unlink_trans;
 
        if (inode->i_size > BTRFS_EMPTY_DIR_SIZE)
                return -ENOTEMPTY;
-       if (btrfs_ino(BTRFS_I(inode)) == BTRFS_FIRST_FREE_OBJECTID)
+       if (btrfs_ino(BTRFS_I(inode)) == BTRFS_FIRST_FREE_OBJECTID) {
+               if (unlikely(btrfs_fs_incompat(fs_info, EXTENT_TREE_V2))) {
+                       btrfs_err(fs_info,
+                       "extent tree v2 doesn't support snapshot deletion yet");
+                       return -EOPNOTSUPP;
+               }
                return btrfs_delete_subvolume(dir, dentry);
+       }
 
        trans = __unlink_start_trans(dir);
        if (IS_ERR(trans))
@@ -4629,7 +4636,7 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
        }
 out:
        btrfs_end_transaction(trans);
-       btrfs_btree_balance_dirty(BTRFS_I(dir)->root->fs_info);
+       btrfs_btree_balance_dirty(fs_info);
 
        return err;
 }
index ecf3e05104aaa6d0f0b11369321a7c6dc7c6c738..8b2538b7027de38ae70c6fab4df3c6155b6e4dca 100644 (file)
@@ -751,6 +751,13 @@ static int create_snapshot(struct btrfs_root *root, struct inode *dir,
        struct btrfs_trans_handle *trans;
        int ret;
 
+       /* We do not support snapshotting right now. */
+       if (btrfs_fs_incompat(fs_info, EXTENT_TREE_V2)) {
+               btrfs_warn(fs_info,
+                          "extent tree v2 doesn't support snapshotting yet");
+               return -EOPNOTSUPP;
+       }
+
        if (!test_bit(BTRFS_ROOT_SHAREABLE, &root->state))
                return -EINVAL;
 
@@ -3174,6 +3181,13 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
        int err = 0;
        bool destroy_parent = false;
 
+       /* We don't support snapshots with extent tree v2 yet. */
+       if (btrfs_fs_incompat(fs_info, EXTENT_TREE_V2)) {
+               btrfs_err(fs_info,
+                         "extent tree v2 doesn't support snapshot deletion yet");
+               return -EOPNOTSUPP;
+       }
+
        if (destroy_v2) {
                vol_args2 = memdup_user(arg, sizeof(*vol_args2));
                if (IS_ERR(vol_args2))