--- zzzz-none-000/linux-3.10.107/fs/btrfs/tree-defrag.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/fs/btrfs/tree-defrag.c 2021-02-04 17:41:59.000000000 +0000 @@ -37,7 +37,6 @@ int ret = 0; int wret; int level; - int is_extent = 0; int next_key_ret = 0; u64 last_ret = 0; u64 min_trans = 0; @@ -50,10 +49,7 @@ goto out; } - if (root->ref_cows == 0 && !is_extent) - goto out; - - if (btrfs_test_opt(root, SSD)) + if (!test_bit(BTRFS_ROOT_REF_COWS, &root->state)) goto out; path = btrfs_alloc_path(); @@ -85,7 +81,7 @@ path->keep_locks = 1; - ret = btrfs_search_forward(root, &key, NULL, path, min_trans); + ret = btrfs_search_forward(root, &key, path, min_trans); if (ret < 0) goto out; if (ret > 0) { @@ -119,8 +115,7 @@ ret = -EAGAIN; } out: - if (path) - btrfs_free_path(path); + btrfs_free_path(path); if (ret == -EAGAIN) { if (root->defrag_max.objectid > root->defrag_progress.objectid) goto done;