diff options
author | Sergei Trofimovich <slyfox@gentoo.org> | 2012-04-24 15:59:16 -0400 |
---|---|---|
committer | Josef Bacik <josef@redhat.com> | 2012-05-30 10:23:30 -0400 |
commit | 0d2450abfa359ff94a2bee64a7daeba68c346c81 (patch) | |
tree | b6b9f88d0d51fa325dfa059a203e7e40856fc36c /fs/btrfs/super.c | |
parent | 0885ef5b5601e9b007c383e77c172769b1f214fd (diff) |
btrfs: allow changing 'thread_pool' size at remount time
Changing 'mount -oremount,thread_pool=2 /' didn't make any effect:
maximum amount of worker threads is specified in 2 places:
- in 'strict btrfs_fs_info::thread_pool_size'
- in each worker struct: 'struct btrfs_workers::max_workers'
'mount -oremount' updated only 'btrfs_fs_info::thread_pool_size'.
Fix it by pushing new maximum value to all created worker structures
as well.
Cc: Josef Bacik <josef@redhat.com>
Cc: Chris Mason <chris.mason@oracle.com>
Reviewed-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r-- | fs/btrfs/super.c | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index bd6d143cea85..2cd32175753d 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -435,11 +435,8 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) | |||
435 | case Opt_thread_pool: | 435 | case Opt_thread_pool: |
436 | intarg = 0; | 436 | intarg = 0; |
437 | match_int(&args[0], &intarg); | 437 | match_int(&args[0], &intarg); |
438 | if (intarg) { | 438 | if (intarg) |
439 | info->thread_pool_size = intarg; | 439 | info->thread_pool_size = intarg; |
440 | printk(KERN_INFO "btrfs: thread pool %d\n", | ||
441 | info->thread_pool_size); | ||
442 | } | ||
443 | break; | 440 | break; |
444 | case Opt_max_inline: | 441 | case Opt_max_inline: |
445 | num = match_strdup(&args[0]); | 442 | num = match_strdup(&args[0]); |
@@ -1118,6 +1115,40 @@ error_fs_info: | |||
1118 | return ERR_PTR(error); | 1115 | return ERR_PTR(error); |
1119 | } | 1116 | } |
1120 | 1117 | ||
1118 | static void btrfs_set_max_workers(struct btrfs_workers *workers, int new_limit) | ||
1119 | { | ||
1120 | spin_lock_irq(&workers->lock); | ||
1121 | workers->max_workers = new_limit; | ||
1122 | spin_unlock_irq(&workers->lock); | ||
1123 | } | ||
1124 | |||
1125 | static void btrfs_resize_thread_pool(struct btrfs_fs_info *fs_info, | ||
1126 | int new_pool_size, int old_pool_size) | ||
1127 | { | ||
1128 | if (new_pool_size == old_pool_size) | ||
1129 | return; | ||
1130 | |||
1131 | fs_info->thread_pool_size = new_pool_size; | ||
1132 | |||
1133 | printk(KERN_INFO "btrfs: resize thread pool %d -> %d\n", | ||
1134 | old_pool_size, new_pool_size); | ||
1135 | |||
1136 | btrfs_set_max_workers(&fs_info->generic_worker, new_pool_size); | ||
1137 | btrfs_set_max_workers(&fs_info->workers, new_pool_size); | ||
1138 | btrfs_set_max_workers(&fs_info->delalloc_workers, new_pool_size); | ||
1139 | btrfs_set_max_workers(&fs_info->submit_workers, new_pool_size); | ||
1140 | btrfs_set_max_workers(&fs_info->caching_workers, new_pool_size); | ||
1141 | btrfs_set_max_workers(&fs_info->fixup_workers, new_pool_size); | ||
1142 | btrfs_set_max_workers(&fs_info->endio_workers, new_pool_size); | ||
1143 | btrfs_set_max_workers(&fs_info->endio_meta_workers, new_pool_size); | ||
1144 | btrfs_set_max_workers(&fs_info->endio_meta_write_workers, new_pool_size); | ||
1145 | btrfs_set_max_workers(&fs_info->endio_write_workers, new_pool_size); | ||
1146 | btrfs_set_max_workers(&fs_info->endio_freespace_worker, new_pool_size); | ||
1147 | btrfs_set_max_workers(&fs_info->delayed_workers, new_pool_size); | ||
1148 | btrfs_set_max_workers(&fs_info->readahead_workers, new_pool_size); | ||
1149 | btrfs_set_max_workers(&fs_info->scrub_workers, new_pool_size); | ||
1150 | } | ||
1151 | |||
1121 | static int btrfs_remount(struct super_block *sb, int *flags, char *data) | 1152 | static int btrfs_remount(struct super_block *sb, int *flags, char *data) |
1122 | { | 1153 | { |
1123 | struct btrfs_fs_info *fs_info = btrfs_sb(sb); | 1154 | struct btrfs_fs_info *fs_info = btrfs_sb(sb); |
@@ -1137,6 +1168,9 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data) | |||
1137 | goto restore; | 1168 | goto restore; |
1138 | } | 1169 | } |
1139 | 1170 | ||
1171 | btrfs_resize_thread_pool(fs_info, | ||
1172 | fs_info->thread_pool_size, old_thread_pool_size); | ||
1173 | |||
1140 | if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) | 1174 | if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) |
1141 | return 0; | 1175 | return 0; |
1142 | 1176 | ||
@@ -1180,7 +1214,8 @@ restore: | |||
1180 | fs_info->compress_type = old_compress_type; | 1214 | fs_info->compress_type = old_compress_type; |
1181 | fs_info->max_inline = old_max_inline; | 1215 | fs_info->max_inline = old_max_inline; |
1182 | fs_info->alloc_start = old_alloc_start; | 1216 | fs_info->alloc_start = old_alloc_start; |
1183 | fs_info->thread_pool_size = old_thread_pool_size; | 1217 | btrfs_resize_thread_pool(fs_info, |
1218 | old_thread_pool_size, fs_info->thread_pool_size); | ||
1184 | fs_info->metadata_ratio = old_metadata_ratio; | 1219 | fs_info->metadata_ratio = old_metadata_ratio; |
1185 | return ret; | 1220 | return ret; |
1186 | } | 1221 | } |