Btrfs: use a lock to protect incompat/compat flag of the super block
[linux-2.6-block.git] / fs / btrfs / volumes.c
index 2854c824ab6443d04eac19cf0b540f79c257cfa0..76ded9eb77a7ba7ae467ca3911ddbc9d5e1857a8 100644 (file)
@@ -717,9 +717,9 @@ static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
                if (!device->name)
                        continue;
 
-               ret = btrfs_get_bdev_and_sb(device->name->str, flags, holder, 1,
-                                           &bdev, &bh);
-               if (ret)
+               /* Just open everything we can; ignore failures here */
+               if (btrfs_get_bdev_and_sb(device->name->str, flags, holder, 1,
+                                           &bdev, &bh))
                        continue;
 
                disk_super = (struct btrfs_super_block *)bh->b_data;
@@ -3674,18 +3674,10 @@ static u32 find_raid56_stripe_len(u32 data_devices, u32 dev_stripe_target)
 
 static void check_raid56_incompat_flag(struct btrfs_fs_info *info, u64 type)
 {
-       u64 features;
-
        if (!(type & (BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6)))
                return;
 
-       features = btrfs_super_incompat_flags(info->super_copy);
-       if (features & BTRFS_FEATURE_INCOMPAT_RAID56)
-               return;
-
-       features |= BTRFS_FEATURE_INCOMPAT_RAID56;
-       btrfs_set_super_incompat_flags(info->super_copy, features);
-       printk(KERN_INFO "btrfs: setting RAID5/6 feature flag\n");
+       btrfs_set_fs_incompat(info, RAID56);
 }
 
 static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
@@ -3932,7 +3924,7 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
 
        em_tree = &extent_root->fs_info->mapping_tree.map_tree;
        write_lock(&em_tree->lock);
-       ret = add_extent_mapping(em_tree, em);
+       ret = add_extent_mapping(em_tree, em, 0);
        write_unlock(&em_tree->lock);
        if (ret) {
                free_extent_map(em);
@@ -4411,9 +4403,9 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
        read_unlock(&em_tree->lock);
 
        if (!em) {
-               printk(KERN_CRIT "btrfs: unable to find logical %llu len %llu\n",
-                      (unsigned long long)logical,
-                      (unsigned long long)*length);
+               btrfs_crit(fs_info, "unable to find logical %llu len %llu",
+                       (unsigned long long)logical,
+                       (unsigned long long)*length);
                BUG();
        }
 
@@ -5308,10 +5300,10 @@ int btrfs_map_bio(struct btrfs_root *root, int rw, struct bio *bio,
        }
 
        if (map_length < length) {
-               printk(KERN_CRIT "btrfs: mapping failed logical %llu bio len %llu "
-                      "len %llu\n", (unsigned long long)logical,
-                      (unsigned long long)length,
-                      (unsigned long long)map_length);
+               btrfs_crit(root->fs_info, "mapping failed logical %llu bio len %llu len %llu",
+                       (unsigned long long)logical,
+                       (unsigned long long)length,
+                       (unsigned long long)map_length);
                BUG();
        }
 
@@ -5476,7 +5468,7 @@ static int read_one_chunk(struct btrfs_root *root, struct btrfs_key *key,
        }
 
        write_lock(&map_tree->map_tree.lock);
-       ret = add_extent_mapping(&map_tree->map_tree, em);
+       ret = add_extent_mapping(&map_tree->map_tree, em, 0);
        write_unlock(&map_tree->map_tree.lock);
        BUG_ON(ret); /* Tree corruption */
        free_extent_map(em);
@@ -5583,8 +5575,8 @@ static int read_one_dev(struct btrfs_root *root,
                        return -EIO;
 
                if (!device) {
-                       printk(KERN_WARNING "warning devid %llu missing\n",
-                              (unsigned long long)devid);
+                       btrfs_warn(root->fs_info, "devid %llu missing",
+                               (unsigned long long)devid);
                        device = add_missing_dev(root, devid, dev_uuid);
                        if (!device)
                                return -ENOMEM;