btrfs: remove stale newlines from log messages
[deliverable/linux.git] / fs / btrfs / volumes.c
index 8113f4567084407841e3e9b8a13b6aa33f7ca160..7d725a9ce6708d91b9c155157f915ea8737a3073 100644 (file)
@@ -1710,12 +1710,43 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
         * remove it from the devices list and zero out the old super
         */
        if (clear_super && disk_super) {
+               u64 bytenr;
+               int i;
+
                /* make sure this device isn't detected as part of
                 * the FS anymore
                 */
                memset(&disk_super->magic, 0, sizeof(disk_super->magic));
                set_buffer_dirty(bh);
                sync_dirty_buffer(bh);
+
+               /* clear the mirror copies of super block on the disk
+                * being removed, 0th copy is been taken care above and
+                * the below would take of the rest
+                */
+               for (i = 1; i < BTRFS_SUPER_MIRROR_MAX; i++) {
+                       bytenr = btrfs_sb_offset(i);
+                       if (bytenr + BTRFS_SUPER_INFO_SIZE >=
+                                       i_size_read(bdev->bd_inode))
+                               break;
+
+                       brelse(bh);
+                       bh = __bread(bdev, bytenr / 4096,
+                                       BTRFS_SUPER_INFO_SIZE);
+                       if (!bh)
+                               continue;
+
+                       disk_super = (struct btrfs_super_block *)bh->b_data;
+
+                       if (btrfs_super_bytenr(disk_super) != bytenr ||
+                               btrfs_super_magic(disk_super) != BTRFS_MAGIC) {
+                               continue;
+                       }
+                       memset(&disk_super->magic, 0,
+                                               sizeof(disk_super->magic));
+                       set_buffer_dirty(bh);
+                       sync_dirty_buffer(bh);
+               }
        }
 
        ret = 0;
@@ -1903,7 +1934,6 @@ static int btrfs_prepare_sprout(struct btrfs_root *root)
        fs_devices->seeding = 0;
        fs_devices->num_devices = 0;
        fs_devices->open_devices = 0;
-       fs_devices->total_devices = 0;
        fs_devices->seed = seed_devices;
 
        generate_random_uuid(fs_devices->fsid);
@@ -4103,7 +4133,7 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
                if (!devs_max)
                        devs_max = BTRFS_MAX_DEVS_SYS_CHUNK;
        } else {
-               btrfs_err(info, "invalid chunk type 0x%llx requested\n",
+               btrfs_err(info, "invalid chunk type 0x%llx requested",
                       type);
                BUG_ON(1);
        }
@@ -4351,7 +4381,7 @@ int btrfs_finish_chunk_alloc(struct btrfs_trans_handle *trans,
 
        if (em->start != chunk_offset || em->len != chunk_size) {
                btrfs_crit(extent_root->fs_info, "found a bad mapping, wanted"
-                         " %Lu-%Lu, found %Lu-%Lu\n", chunk_offset,
+                         " %Lu-%Lu, found %Lu-%Lu", chunk_offset,
                          chunk_size, em->start, em->len);
                free_extent_map(em);
                return -EINVAL;
@@ -4553,14 +4583,14 @@ int btrfs_num_copies(struct btrfs_fs_info *fs_info, u64 logical, u64 len)
         * and exit, so return 1 so the callers don't try to use other copies.
         */
        if (!em) {
-               btrfs_crit(fs_info, "No mapping for %Lu-%Lu\n", logical,
+               btrfs_crit(fs_info, "No mapping for %Lu-%Lu", logical,
                            logical+len);
                return 1;
        }
 
        if (em->start > logical || em->start + em->len < logical) {
                btrfs_crit(fs_info, "Invalid mapping for %Lu-%Lu, got "
-                           "%Lu-%Lu\n", logical, logical+len, em->start,
+                           "%Lu-%Lu", logical, logical+len, em->start,
                            em->start + em->len);
                free_extent_map(em);
                return 1;
@@ -4741,7 +4771,7 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
 
        if (em->start > logical || em->start + em->len < logical) {
                btrfs_crit(fs_info, "found a bad mapping, wanted %Lu, "
-                          "found %Lu-%Lu\n", logical, em->start,
+                          "found %Lu-%Lu", logical, em->start,
                           em->start + em->len);
                free_extent_map(em);
                return -EINVAL;
@@ -6115,10 +6145,14 @@ void btrfs_init_devices_late(struct btrfs_fs_info *fs_info)
        struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
        struct btrfs_device *device;
 
-       mutex_lock(&fs_devices->device_list_mutex);
-       list_for_each_entry(device, &fs_devices->devices, dev_list)
-               device->dev_root = fs_info->dev_root;
-       mutex_unlock(&fs_devices->device_list_mutex);
+       while (fs_devices) {
+               mutex_lock(&fs_devices->device_list_mutex);
+               list_for_each_entry(device, &fs_devices->devices, dev_list)
+                       device->dev_root = fs_info->dev_root;
+               mutex_unlock(&fs_devices->device_list_mutex);
+
+               fs_devices = fs_devices->seed;
+       }
 }
 
 static void __btrfs_reset_dev_stats(struct btrfs_device *dev)
This page took 0.031594 seconds and 5 git commands to generate.