aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/super.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r--fs/btrfs/super.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 0645ec428b4f..78de9d5d80c6 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -42,6 +42,7 @@
42#include "dev-replace.h" 42#include "dev-replace.h"
43#include "free-space-cache.h" 43#include "free-space-cache.h"
44#include "backref.h" 44#include "backref.h"
45#include "space-info.h"
45#include "tests/btrfs-tests.h" 46#include "tests/btrfs-tests.h"
46 47
47#include "qgroup.h" 48#include "qgroup.h"
@@ -1553,6 +1554,8 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type,
1553 } else { 1554 } else {
1554 snprintf(s->s_id, sizeof(s->s_id), "%pg", bdev); 1555 snprintf(s->s_id, sizeof(s->s_id), "%pg", bdev);
1555 btrfs_sb(s)->bdev_holder = fs_type; 1556 btrfs_sb(s)->bdev_holder = fs_type;
1557 if (!strstr(crc32c_impl(), "generic"))
1558 set_bit(BTRFS_FS_CSUM_IMPL_FAST, &fs_info->flags);
1556 error = btrfs_fill_super(s, fs_devices, data); 1559 error = btrfs_fill_super(s, fs_devices, data);
1557 } 1560 }
1558 if (!error) 1561 if (!error)
@@ -1601,14 +1604,10 @@ static struct dentry *btrfs_mount(struct file_system_type *fs_type, int flags,
1601{ 1604{
1602 struct vfsmount *mnt_root; 1605 struct vfsmount *mnt_root;
1603 struct dentry *root; 1606 struct dentry *root;
1604 fmode_t mode = FMODE_READ;
1605 char *subvol_name = NULL; 1607 char *subvol_name = NULL;
1606 u64 subvol_objectid = 0; 1608 u64 subvol_objectid = 0;
1607 int error = 0; 1609 int error = 0;
1608 1610
1609 if (!(flags & SB_RDONLY))
1610 mode |= FMODE_WRITE;
1611
1612 error = btrfs_parse_subvol_options(data, &subvol_name, 1611 error = btrfs_parse_subvol_options(data, &subvol_name,
1613 &subvol_objectid); 1612 &subvol_objectid);
1614 if (error) { 1613 if (error) {
@@ -1904,8 +1903,9 @@ static inline int btrfs_calc_avail_data_space(struct btrfs_fs_info *fs_info,
1904 u64 type; 1903 u64 type;
1905 u64 avail_space; 1904 u64 avail_space;
1906 u64 min_stripe_size; 1905 u64 min_stripe_size;
1907 int min_stripes = 1, num_stripes = 1; 1906 int min_stripes, num_stripes = 1;
1908 int i = 0, nr_devices; 1907 int i = 0, nr_devices;
1908 const struct btrfs_raid_attr *rattr;
1909 1909
1910 /* 1910 /*
1911 * We aren't under the device list lock, so this is racy-ish, but good 1911 * We aren't under the device list lock, so this is racy-ish, but good
@@ -1929,21 +1929,18 @@ static inline int btrfs_calc_avail_data_space(struct btrfs_fs_info *fs_info,
1929 1929
1930 /* calc min stripe number for data space allocation */ 1930 /* calc min stripe number for data space allocation */
1931 type = btrfs_data_alloc_profile(fs_info); 1931 type = btrfs_data_alloc_profile(fs_info);
1932 if (type & BTRFS_BLOCK_GROUP_RAID0) { 1932 rattr = &btrfs_raid_array[btrfs_bg_flags_to_raid_index(type)];
1933 min_stripes = 2; 1933 min_stripes = rattr->devs_min;
1934
1935 if (type & BTRFS_BLOCK_GROUP_RAID0)
1934 num_stripes = nr_devices; 1936 num_stripes = nr_devices;
1935 } else if (type & BTRFS_BLOCK_GROUP_RAID1) { 1937 else if (type & BTRFS_BLOCK_GROUP_RAID1)
1936 min_stripes = 2;
1937 num_stripes = 2; 1938 num_stripes = 2;
1938 } else if (type & BTRFS_BLOCK_GROUP_RAID10) { 1939 else if (type & BTRFS_BLOCK_GROUP_RAID10)
1939 min_stripes = 4;
1940 num_stripes = 4; 1940 num_stripes = 4;
1941 }
1942 1941
1943 if (type & BTRFS_BLOCK_GROUP_DUP) 1942 /* Adjust for more than 1 stripe per device */
1944 min_stripe_size = 2 * BTRFS_STRIPE_LEN; 1943 min_stripe_size = rattr->dev_stripes * BTRFS_STRIPE_LEN;
1945 else
1946 min_stripe_size = BTRFS_STRIPE_LEN;
1947 1944
1948 rcu_read_lock(); 1945 rcu_read_lock();
1949 list_for_each_entry_rcu(device, &fs_devices->devices, dev_list) { 1946 list_for_each_entry_rcu(device, &fs_devices->devices, dev_list) {
@@ -2466,3 +2463,4 @@ late_initcall(init_btrfs_fs);
2466module_exit(exit_btrfs_fs) 2463module_exit(exit_btrfs_fs)
2467 2464
2468MODULE_LICENSE("GPL"); 2465MODULE_LICENSE("GPL");
2466MODULE_SOFTDEP("pre: crc32c");