diff options
Diffstat (limited to 'fs/btrfs/volumes.c')
| -rw-r--r-- | fs/btrfs/volumes.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index ecaad40e7ef4..e86ae04abe6a 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
| @@ -429,6 +429,7 @@ static struct btrfs_fs_devices *clone_fs_devices(struct btrfs_fs_devices *orig) | |||
| 429 | mutex_init(&fs_devices->device_list_mutex); | 429 | mutex_init(&fs_devices->device_list_mutex); |
| 430 | fs_devices->latest_devid = orig->latest_devid; | 430 | fs_devices->latest_devid = orig->latest_devid; |
| 431 | fs_devices->latest_trans = orig->latest_trans; | 431 | fs_devices->latest_trans = orig->latest_trans; |
| 432 | fs_devices->total_devices = orig->total_devices; | ||
| 432 | memcpy(fs_devices->fsid, orig->fsid, sizeof(fs_devices->fsid)); | 433 | memcpy(fs_devices->fsid, orig->fsid, sizeof(fs_devices->fsid)); |
| 433 | 434 | ||
| 434 | /* We have held the volume lock, it is safe to get the devices. */ | 435 | /* We have held the volume lock, it is safe to get the devices. */ |
| @@ -739,6 +740,7 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder, | |||
| 739 | int ret; | 740 | int ret; |
| 740 | u64 devid; | 741 | u64 devid; |
| 741 | u64 transid; | 742 | u64 transid; |
| 743 | u64 total_devices; | ||
| 742 | 744 | ||
| 743 | flags |= FMODE_EXCL; | 745 | flags |= FMODE_EXCL; |
| 744 | bdev = blkdev_get_by_path(path, flags, holder); | 746 | bdev = blkdev_get_by_path(path, flags, holder); |
| @@ -760,6 +762,7 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder, | |||
| 760 | disk_super = (struct btrfs_super_block *)bh->b_data; | 762 | disk_super = (struct btrfs_super_block *)bh->b_data; |
| 761 | devid = btrfs_stack_device_id(&disk_super->dev_item); | 763 | devid = btrfs_stack_device_id(&disk_super->dev_item); |
| 762 | transid = btrfs_super_generation(disk_super); | 764 | transid = btrfs_super_generation(disk_super); |
| 765 | total_devices = btrfs_super_num_devices(disk_super); | ||
| 763 | if (disk_super->label[0]) | 766 | if (disk_super->label[0]) |
| 764 | printk(KERN_INFO "device label %s ", disk_super->label); | 767 | printk(KERN_INFO "device label %s ", disk_super->label); |
| 765 | else | 768 | else |
| @@ -767,7 +770,8 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder, | |||
| 767 | printk(KERN_CONT "devid %llu transid %llu %s\n", | 770 | printk(KERN_CONT "devid %llu transid %llu %s\n", |
| 768 | (unsigned long long)devid, (unsigned long long)transid, path); | 771 | (unsigned long long)devid, (unsigned long long)transid, path); |
| 769 | ret = device_list_add(path, disk_super, devid, fs_devices_ret); | 772 | ret = device_list_add(path, disk_super, devid, fs_devices_ret); |
| 770 | 773 | if (!ret && fs_devices_ret) | |
| 774 | (*fs_devices_ret)->total_devices = total_devices; | ||
| 771 | brelse(bh); | 775 | brelse(bh); |
| 772 | error_close: | 776 | error_close: |
| 773 | mutex_unlock(&uuid_mutex); | 777 | mutex_unlock(&uuid_mutex); |
| @@ -1433,6 +1437,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) | |||
| 1433 | list_del_rcu(&device->dev_list); | 1437 | list_del_rcu(&device->dev_list); |
| 1434 | 1438 | ||
| 1435 | device->fs_devices->num_devices--; | 1439 | device->fs_devices->num_devices--; |
| 1440 | device->fs_devices->total_devices--; | ||
| 1436 | 1441 | ||
| 1437 | if (device->missing) | 1442 | if (device->missing) |
| 1438 | root->fs_info->fs_devices->missing_devices--; | 1443 | root->fs_info->fs_devices->missing_devices--; |
| @@ -1550,6 +1555,7 @@ static int btrfs_prepare_sprout(struct btrfs_root *root) | |||
| 1550 | fs_devices->seeding = 0; | 1555 | fs_devices->seeding = 0; |
| 1551 | fs_devices->num_devices = 0; | 1556 | fs_devices->num_devices = 0; |
| 1552 | fs_devices->open_devices = 0; | 1557 | fs_devices->open_devices = 0; |
| 1558 | fs_devices->total_devices = 0; | ||
| 1553 | fs_devices->seed = seed_devices; | 1559 | fs_devices->seed = seed_devices; |
| 1554 | 1560 | ||
| 1555 | generate_random_uuid(fs_devices->fsid); | 1561 | generate_random_uuid(fs_devices->fsid); |
| @@ -1738,10 +1744,6 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path) | |||
| 1738 | 1744 | ||
| 1739 | device->fs_devices = root->fs_info->fs_devices; | 1745 | device->fs_devices = root->fs_info->fs_devices; |
| 1740 | 1746 | ||
| 1741 | /* | ||
| 1742 | * we don't want write_supers to jump in here with our device | ||
| 1743 | * half setup | ||
| 1744 | */ | ||
| 1745 | mutex_lock(&root->fs_info->fs_devices->device_list_mutex); | 1747 | mutex_lock(&root->fs_info->fs_devices->device_list_mutex); |
| 1746 | list_add_rcu(&device->dev_list, &root->fs_info->fs_devices->devices); | 1748 | list_add_rcu(&device->dev_list, &root->fs_info->fs_devices->devices); |
| 1747 | list_add(&device->dev_alloc_list, | 1749 | list_add(&device->dev_alloc_list, |
| @@ -1749,6 +1751,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path) | |||
| 1749 | root->fs_info->fs_devices->num_devices++; | 1751 | root->fs_info->fs_devices->num_devices++; |
| 1750 | root->fs_info->fs_devices->open_devices++; | 1752 | root->fs_info->fs_devices->open_devices++; |
| 1751 | root->fs_info->fs_devices->rw_devices++; | 1753 | root->fs_info->fs_devices->rw_devices++; |
| 1754 | root->fs_info->fs_devices->total_devices++; | ||
| 1752 | if (device->can_discard) | 1755 | if (device->can_discard) |
| 1753 | root->fs_info->fs_devices->num_can_discard++; | 1756 | root->fs_info->fs_devices->num_can_discard++; |
| 1754 | root->fs_info->fs_devices->total_rw_bytes += device->total_bytes; | 1757 | root->fs_info->fs_devices->total_rw_bytes += device->total_bytes; |
| @@ -4736,9 +4739,6 @@ int btrfs_init_dev_stats(struct btrfs_fs_info *fs_info) | |||
| 4736 | key.offset = device->devid; | 4739 | key.offset = device->devid; |
| 4737 | ret = btrfs_search_slot(NULL, dev_root, &key, path, 0, 0); | 4740 | ret = btrfs_search_slot(NULL, dev_root, &key, path, 0, 0); |
| 4738 | if (ret) { | 4741 | if (ret) { |
| 4739 | printk_in_rcu(KERN_WARNING "btrfs: no dev_stats entry found for device %s (devid %llu) (OK on first mount after mkfs)\n", | ||
| 4740 | rcu_str_deref(device->name), | ||
| 4741 | (unsigned long long)device->devid); | ||
| 4742 | __btrfs_reset_dev_stats(device); | 4742 | __btrfs_reset_dev_stats(device); |
| 4743 | device->dev_stats_valid = 1; | 4743 | device->dev_stats_valid = 1; |
| 4744 | btrfs_release_path(path); | 4744 | btrfs_release_path(path); |
| @@ -4880,6 +4880,14 @@ void btrfs_dev_stat_print_on_error(struct btrfs_device *dev) | |||
| 4880 | 4880 | ||
| 4881 | static void btrfs_dev_stat_print_on_load(struct btrfs_device *dev) | 4881 | static void btrfs_dev_stat_print_on_load(struct btrfs_device *dev) |
| 4882 | { | 4882 | { |
| 4883 | int i; | ||
| 4884 | |||
| 4885 | for (i = 0; i < BTRFS_DEV_STAT_VALUES_MAX; i++) | ||
| 4886 | if (btrfs_dev_stat_read(dev, i) != 0) | ||
| 4887 | break; | ||
| 4888 | if (i == BTRFS_DEV_STAT_VALUES_MAX) | ||
| 4889 | return; /* all values == 0, suppress message */ | ||
| 4890 | |||
| 4883 | printk_in_rcu(KERN_INFO "btrfs: bdev %s errs: wr %u, rd %u, flush %u, corrupt %u, gen %u\n", | 4891 | printk_in_rcu(KERN_INFO "btrfs: bdev %s errs: wr %u, rd %u, flush %u, corrupt %u, gen %u\n", |
| 4884 | rcu_str_deref(dev->name), | 4892 | rcu_str_deref(dev->name), |
| 4885 | btrfs_dev_stat_read(dev, BTRFS_DEV_STAT_WRITE_ERRS), | 4893 | btrfs_dev_stat_read(dev, BTRFS_DEV_STAT_WRITE_ERRS), |
| @@ -4890,8 +4898,7 @@ static void btrfs_dev_stat_print_on_load(struct btrfs_device *dev) | |||
| 4890 | } | 4898 | } |
| 4891 | 4899 | ||
| 4892 | int btrfs_get_dev_stats(struct btrfs_root *root, | 4900 | int btrfs_get_dev_stats(struct btrfs_root *root, |
| 4893 | struct btrfs_ioctl_get_dev_stats *stats, | 4901 | struct btrfs_ioctl_get_dev_stats *stats) |
| 4894 | int reset_after_read) | ||
| 4895 | { | 4902 | { |
| 4896 | struct btrfs_device *dev; | 4903 | struct btrfs_device *dev; |
| 4897 | struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices; | 4904 | struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices; |
| @@ -4909,7 +4916,7 @@ int btrfs_get_dev_stats(struct btrfs_root *root, | |||
| 4909 | printk(KERN_WARNING | 4916 | printk(KERN_WARNING |
| 4910 | "btrfs: get dev_stats failed, not yet valid\n"); | 4917 | "btrfs: get dev_stats failed, not yet valid\n"); |
| 4911 | return -ENODEV; | 4918 | return -ENODEV; |
| 4912 | } else if (reset_after_read) { | 4919 | } else if (stats->flags & BTRFS_DEV_STATS_RESET) { |
| 4913 | for (i = 0; i < BTRFS_DEV_STAT_VALUES_MAX; i++) { | 4920 | for (i = 0; i < BTRFS_DEV_STAT_VALUES_MAX; i++) { |
| 4914 | if (stats->nr_items > i) | 4921 | if (stats->nr_items > i) |
| 4915 | stats->values[i] = | 4922 | stats->values[i] = |
