mirror of https://gitee.com/openkylin/linux.git
Merge branch 'misc-for-4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux into for-linus-4.5
This commit is contained in:
commit
326f784281
|
@ -1583,8 +1583,23 @@ int btrfs_init_fs_root(struct btrfs_root *root)
|
||||||
ret = get_anon_bdev(&root->anon_dev);
|
ret = get_anon_bdev(&root->anon_dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto free_writers;
|
goto free_writers;
|
||||||
|
|
||||||
|
mutex_lock(&root->objectid_mutex);
|
||||||
|
ret = btrfs_find_highest_objectid(root,
|
||||||
|
&root->highest_objectid);
|
||||||
|
if (ret) {
|
||||||
|
mutex_unlock(&root->objectid_mutex);
|
||||||
|
goto free_root_dev;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT(root->highest_objectid <= BTRFS_LAST_FREE_OBJECTID);
|
||||||
|
|
||||||
|
mutex_unlock(&root->objectid_mutex);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
free_root_dev:
|
||||||
|
free_anon_bdev(root->anon_dev);
|
||||||
free_writers:
|
free_writers:
|
||||||
btrfs_free_subvolume_writers(root->subv_writers);
|
btrfs_free_subvolume_writers(root->subv_writers);
|
||||||
fail:
|
fail:
|
||||||
|
@ -2915,6 +2930,18 @@ int open_ctree(struct super_block *sb,
|
||||||
tree_root->commit_root = btrfs_root_node(tree_root);
|
tree_root->commit_root = btrfs_root_node(tree_root);
|
||||||
btrfs_set_root_refs(&tree_root->root_item, 1);
|
btrfs_set_root_refs(&tree_root->root_item, 1);
|
||||||
|
|
||||||
|
mutex_lock(&tree_root->objectid_mutex);
|
||||||
|
ret = btrfs_find_highest_objectid(tree_root,
|
||||||
|
&tree_root->highest_objectid);
|
||||||
|
if (ret) {
|
||||||
|
mutex_unlock(&tree_root->objectid_mutex);
|
||||||
|
goto recovery_tree_root;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT(tree_root->highest_objectid <= BTRFS_LAST_FREE_OBJECTID);
|
||||||
|
|
||||||
|
mutex_unlock(&tree_root->objectid_mutex);
|
||||||
|
|
||||||
ret = btrfs_read_roots(fs_info, tree_root);
|
ret = btrfs_read_roots(fs_info, tree_root);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto recovery_tree_root;
|
goto recovery_tree_root;
|
||||||
|
|
|
@ -515,7 +515,7 @@ int btrfs_save_ino_cache(struct btrfs_root *root,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int btrfs_find_highest_objectid(struct btrfs_root *root, u64 *objectid)
|
int btrfs_find_highest_objectid(struct btrfs_root *root, u64 *objectid)
|
||||||
{
|
{
|
||||||
struct btrfs_path *path;
|
struct btrfs_path *path;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -555,13 +555,6 @@ int btrfs_find_free_objectid(struct btrfs_root *root, u64 *objectid)
|
||||||
int ret;
|
int ret;
|
||||||
mutex_lock(&root->objectid_mutex);
|
mutex_lock(&root->objectid_mutex);
|
||||||
|
|
||||||
if (unlikely(root->highest_objectid < BTRFS_FIRST_FREE_OBJECTID)) {
|
|
||||||
ret = btrfs_find_highest_objectid(root,
|
|
||||||
&root->highest_objectid);
|
|
||||||
if (ret)
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (unlikely(root->highest_objectid >= BTRFS_LAST_FREE_OBJECTID)) {
|
if (unlikely(root->highest_objectid >= BTRFS_LAST_FREE_OBJECTID)) {
|
||||||
ret = -ENOSPC;
|
ret = -ENOSPC;
|
||||||
goto out;
|
goto out;
|
||||||
|
|
|
@ -9,5 +9,6 @@ int btrfs_save_ino_cache(struct btrfs_root *root,
|
||||||
struct btrfs_trans_handle *trans);
|
struct btrfs_trans_handle *trans);
|
||||||
|
|
||||||
int btrfs_find_free_objectid(struct btrfs_root *root, u64 *objectid);
|
int btrfs_find_free_objectid(struct btrfs_root *root, u64 *objectid);
|
||||||
|
int btrfs_find_highest_objectid(struct btrfs_root *root, u64 *objectid);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -568,6 +568,10 @@ static noinline int create_subvol(struct inode *dir,
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mutex_lock(&new_root->objectid_mutex);
|
||||||
|
new_root->highest_objectid = new_dirid;
|
||||||
|
mutex_unlock(&new_root->objectid_mutex);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* insert the directory item
|
* insert the directory item
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -383,6 +383,9 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
char *compress_type;
|
char *compress_type;
|
||||||
bool compress_force = false;
|
bool compress_force = false;
|
||||||
|
enum btrfs_compression_type saved_compress_type;
|
||||||
|
bool saved_compress_force;
|
||||||
|
int no_compress = 0;
|
||||||
|
|
||||||
cache_gen = btrfs_super_cache_generation(root->fs_info->super_copy);
|
cache_gen = btrfs_super_cache_generation(root->fs_info->super_copy);
|
||||||
if (btrfs_fs_compat_ro(root->fs_info, FREE_SPACE_TREE))
|
if (btrfs_fs_compat_ro(root->fs_info, FREE_SPACE_TREE))
|
||||||
|
@ -462,6 +465,10 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
|
||||||
/* Fallthrough */
|
/* Fallthrough */
|
||||||
case Opt_compress:
|
case Opt_compress:
|
||||||
case Opt_compress_type:
|
case Opt_compress_type:
|
||||||
|
saved_compress_type = btrfs_test_opt(root, COMPRESS) ?
|
||||||
|
info->compress_type : BTRFS_COMPRESS_NONE;
|
||||||
|
saved_compress_force =
|
||||||
|
btrfs_test_opt(root, FORCE_COMPRESS);
|
||||||
if (token == Opt_compress ||
|
if (token == Opt_compress ||
|
||||||
token == Opt_compress_force ||
|
token == Opt_compress_force ||
|
||||||
strcmp(args[0].from, "zlib") == 0) {
|
strcmp(args[0].from, "zlib") == 0) {
|
||||||
|
@ -470,6 +477,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
|
||||||
btrfs_set_opt(info->mount_opt, COMPRESS);
|
btrfs_set_opt(info->mount_opt, COMPRESS);
|
||||||
btrfs_clear_opt(info->mount_opt, NODATACOW);
|
btrfs_clear_opt(info->mount_opt, NODATACOW);
|
||||||
btrfs_clear_opt(info->mount_opt, NODATASUM);
|
btrfs_clear_opt(info->mount_opt, NODATASUM);
|
||||||
|
no_compress = 0;
|
||||||
} else if (strcmp(args[0].from, "lzo") == 0) {
|
} else if (strcmp(args[0].from, "lzo") == 0) {
|
||||||
compress_type = "lzo";
|
compress_type = "lzo";
|
||||||
info->compress_type = BTRFS_COMPRESS_LZO;
|
info->compress_type = BTRFS_COMPRESS_LZO;
|
||||||
|
@ -477,25 +485,21 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
|
||||||
btrfs_clear_opt(info->mount_opt, NODATACOW);
|
btrfs_clear_opt(info->mount_opt, NODATACOW);
|
||||||
btrfs_clear_opt(info->mount_opt, NODATASUM);
|
btrfs_clear_opt(info->mount_opt, NODATASUM);
|
||||||
btrfs_set_fs_incompat(info, COMPRESS_LZO);
|
btrfs_set_fs_incompat(info, COMPRESS_LZO);
|
||||||
|
no_compress = 0;
|
||||||
} else if (strncmp(args[0].from, "no", 2) == 0) {
|
} else if (strncmp(args[0].from, "no", 2) == 0) {
|
||||||
compress_type = "no";
|
compress_type = "no";
|
||||||
btrfs_clear_opt(info->mount_opt, COMPRESS);
|
btrfs_clear_opt(info->mount_opt, COMPRESS);
|
||||||
btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS);
|
btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS);
|
||||||
compress_force = false;
|
compress_force = false;
|
||||||
|
no_compress++;
|
||||||
} else {
|
} else {
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compress_force) {
|
if (compress_force) {
|
||||||
btrfs_set_and_info(root, FORCE_COMPRESS,
|
btrfs_set_opt(info->mount_opt, FORCE_COMPRESS);
|
||||||
"force %s compression",
|
|
||||||
compress_type);
|
|
||||||
} else {
|
} else {
|
||||||
if (!btrfs_test_opt(root, COMPRESS))
|
|
||||||
btrfs_info(root->fs_info,
|
|
||||||
"btrfs: use %s compression",
|
|
||||||
compress_type);
|
|
||||||
/*
|
/*
|
||||||
* If we remount from compress-force=xxx to
|
* If we remount from compress-force=xxx to
|
||||||
* compress=xxx, we need clear FORCE_COMPRESS
|
* compress=xxx, we need clear FORCE_COMPRESS
|
||||||
|
@ -504,6 +508,17 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
|
||||||
*/
|
*/
|
||||||
btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS);
|
btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS);
|
||||||
}
|
}
|
||||||
|
if ((btrfs_test_opt(root, COMPRESS) &&
|
||||||
|
(info->compress_type != saved_compress_type ||
|
||||||
|
compress_force != saved_compress_force)) ||
|
||||||
|
(!btrfs_test_opt(root, COMPRESS) &&
|
||||||
|
no_compress == 1)) {
|
||||||
|
btrfs_info(root->fs_info,
|
||||||
|
"%s %s compression",
|
||||||
|
(compress_force) ? "force" : "use",
|
||||||
|
compress_type);
|
||||||
|
}
|
||||||
|
compress_force = false;
|
||||||
break;
|
break;
|
||||||
case Opt_ssd:
|
case Opt_ssd:
|
||||||
btrfs_set_and_info(root, SSD,
|
btrfs_set_and_info(root, SSD,
|
||||||
|
|
|
@ -233,6 +233,7 @@ static struct btrfs_device *__alloc_device(void)
|
||||||
spin_lock_init(&dev->reada_lock);
|
spin_lock_init(&dev->reada_lock);
|
||||||
atomic_set(&dev->reada_in_flight, 0);
|
atomic_set(&dev->reada_in_flight, 0);
|
||||||
atomic_set(&dev->dev_stats_ccnt, 0);
|
atomic_set(&dev->dev_stats_ccnt, 0);
|
||||||
|
btrfs_device_data_ordered_init(dev);
|
||||||
INIT_RADIX_TREE(&dev->reada_zones, GFP_NOFS & ~__GFP_DIRECT_RECLAIM);
|
INIT_RADIX_TREE(&dev->reada_zones, GFP_NOFS & ~__GFP_DIRECT_RECLAIM);
|
||||||
INIT_RADIX_TREE(&dev->reada_extents, GFP_NOFS & ~__GFP_DIRECT_RECLAIM);
|
INIT_RADIX_TREE(&dev->reada_extents, GFP_NOFS & ~__GFP_DIRECT_RECLAIM);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue