diff options
author | Josef Bacik <josef@redhat.com> | 2010-03-19 14:07:23 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2010-03-30 21:19:09 -0400 |
commit | 287a0ab91d25ca982f895a76402e5893b47ed7a6 (patch) | |
tree | fcbe35daef2b4cbdc2bfc0c6026e7c45faef0245 /fs | |
parent | 1b1d1f6625e517a08640ddb4b8f8a0e025243fe3 (diff) |
Btrfs: kill max_extent mount option
As Yan pointed out, theres not much reason for all this complicated math to
account for file extents being split up into max_extent chunks, since they are
likely to all end up in the same leaf anyway. Since there isn't much reason to
use max_extent, just remove the option altogether so we have one less thing we
need to test.
Signed-off-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/ctree.h | 1 | ||||
-rw-r--r-- | fs/btrfs/disk-io.c | 1 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 4 | ||||
-rw-r--r-- | fs/btrfs/inode.c | 59 | ||||
-rw-r--r-- | fs/btrfs/ordered-data.c | 6 | ||||
-rw-r--r-- | fs/btrfs/super.c | 23 |
6 files changed, 13 insertions, 81 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 11115847d875..ae8c40922c54 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -834,7 +834,6 @@ struct btrfs_fs_info { | |||
834 | u64 last_trans_log_full_commit; | 834 | u64 last_trans_log_full_commit; |
835 | u64 open_ioctl_trans; | 835 | u64 open_ioctl_trans; |
836 | unsigned long mount_opt; | 836 | unsigned long mount_opt; |
837 | u64 max_extent; | ||
838 | u64 max_inline; | 837 | u64 max_inline; |
839 | u64 alloc_start; | 838 | u64 alloc_start; |
840 | struct btrfs_transaction *running_transaction; | 839 | struct btrfs_transaction *running_transaction; |
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 5ae1c0fcfce0..6632e5c4c8bb 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -1634,7 +1634,6 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1634 | atomic_set(&fs_info->async_submit_draining, 0); | 1634 | atomic_set(&fs_info->async_submit_draining, 0); |
1635 | atomic_set(&fs_info->nr_async_bios, 0); | 1635 | atomic_set(&fs_info->nr_async_bios, 0); |
1636 | fs_info->sb = sb; | 1636 | fs_info->sb = sb; |
1637 | fs_info->max_extent = (u64)-1; | ||
1638 | fs_info->max_inline = 8192 * 1024; | 1637 | fs_info->max_inline = 8192 * 1024; |
1639 | fs_info->metadata_ratio = 0; | 1638 | fs_info->metadata_ratio = 0; |
1640 | 1639 | ||
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 4c910359c807..5f6bc283c0c8 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -2846,7 +2846,7 @@ int btrfs_unreserve_metadata_for_delalloc(struct btrfs_root *root, | |||
2846 | } | 2846 | } |
2847 | spin_unlock(&BTRFS_I(inode)->accounting_lock); | 2847 | spin_unlock(&BTRFS_I(inode)->accounting_lock); |
2848 | 2848 | ||
2849 | BTRFS_I(inode)->reserved_extents--; | 2849 | BTRFS_I(inode)->reserved_extents -= num_items; |
2850 | BUG_ON(BTRFS_I(inode)->reserved_extents < 0); | 2850 | BUG_ON(BTRFS_I(inode)->reserved_extents < 0); |
2851 | 2851 | ||
2852 | if (meta_sinfo->bytes_delalloc < num_bytes) { | 2852 | if (meta_sinfo->bytes_delalloc < num_bytes) { |
@@ -3111,7 +3111,7 @@ again: | |||
3111 | return -ENOSPC; | 3111 | return -ENOSPC; |
3112 | } | 3112 | } |
3113 | 3113 | ||
3114 | BTRFS_I(inode)->reserved_extents++; | 3114 | BTRFS_I(inode)->reserved_extents += num_items; |
3115 | check_force_delalloc(meta_sinfo); | 3115 | check_force_delalloc(meta_sinfo); |
3116 | spin_unlock(&meta_sinfo->lock); | 3116 | spin_unlock(&meta_sinfo->lock); |
3117 | 3117 | ||
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 2a337a09c650..a85b90c86cb0 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -796,7 +796,7 @@ static noinline int cow_file_range(struct inode *inode, | |||
796 | while (disk_num_bytes > 0) { | 796 | while (disk_num_bytes > 0) { |
797 | unsigned long op; | 797 | unsigned long op; |
798 | 798 | ||
799 | cur_alloc_size = min(disk_num_bytes, root->fs_info->max_extent); | 799 | cur_alloc_size = disk_num_bytes; |
800 | ret = btrfs_reserve_extent(trans, root, cur_alloc_size, | 800 | ret = btrfs_reserve_extent(trans, root, cur_alloc_size, |
801 | root->sectorsize, 0, alloc_hint, | 801 | root->sectorsize, 0, alloc_hint, |
802 | (u64)-1, &ins, 1); | 802 | (u64)-1, &ins, 1); |
@@ -1227,30 +1227,9 @@ static int run_delalloc_range(struct inode *inode, struct page *locked_page, | |||
1227 | static int btrfs_split_extent_hook(struct inode *inode, | 1227 | static int btrfs_split_extent_hook(struct inode *inode, |
1228 | struct extent_state *orig, u64 split) | 1228 | struct extent_state *orig, u64 split) |
1229 | { | 1229 | { |
1230 | struct btrfs_root *root = BTRFS_I(inode)->root; | ||
1231 | u64 size; | ||
1232 | |||
1233 | if (!(orig->state & EXTENT_DELALLOC)) | 1230 | if (!(orig->state & EXTENT_DELALLOC)) |
1234 | return 0; | 1231 | return 0; |
1235 | 1232 | ||
1236 | size = orig->end - orig->start + 1; | ||
1237 | if (size > root->fs_info->max_extent) { | ||
1238 | u64 num_extents; | ||
1239 | u64 new_size; | ||
1240 | |||
1241 | new_size = orig->end - split + 1; | ||
1242 | num_extents = div64_u64(size + root->fs_info->max_extent - 1, | ||
1243 | root->fs_info->max_extent); | ||
1244 | |||
1245 | /* | ||
1246 | * if we break a large extent up then leave oustanding_extents | ||
1247 | * be, since we've already accounted for the large extent. | ||
1248 | */ | ||
1249 | if (div64_u64(new_size + root->fs_info->max_extent - 1, | ||
1250 | root->fs_info->max_extent) < num_extents) | ||
1251 | return 0; | ||
1252 | } | ||
1253 | |||
1254 | spin_lock(&BTRFS_I(inode)->accounting_lock); | 1233 | spin_lock(&BTRFS_I(inode)->accounting_lock); |
1255 | BTRFS_I(inode)->outstanding_extents++; | 1234 | BTRFS_I(inode)->outstanding_extents++; |
1256 | spin_unlock(&BTRFS_I(inode)->accounting_lock); | 1235 | spin_unlock(&BTRFS_I(inode)->accounting_lock); |
@@ -1268,38 +1247,10 @@ static int btrfs_merge_extent_hook(struct inode *inode, | |||
1268 | struct extent_state *new, | 1247 | struct extent_state *new, |
1269 | struct extent_state *other) | 1248 | struct extent_state *other) |
1270 | { | 1249 | { |
1271 | struct btrfs_root *root = BTRFS_I(inode)->root; | ||
1272 | u64 new_size, old_size; | ||
1273 | u64 num_extents; | ||
1274 | |||
1275 | /* not delalloc, ignore it */ | 1250 | /* not delalloc, ignore it */ |
1276 | if (!(other->state & EXTENT_DELALLOC)) | 1251 | if (!(other->state & EXTENT_DELALLOC)) |
1277 | return 0; | 1252 | return 0; |
1278 | 1253 | ||
1279 | old_size = other->end - other->start + 1; | ||
1280 | if (new->start < other->start) | ||
1281 | new_size = other->end - new->start + 1; | ||
1282 | else | ||
1283 | new_size = new->end - other->start + 1; | ||
1284 | |||
1285 | /* we're not bigger than the max, unreserve the space and go */ | ||
1286 | if (new_size <= root->fs_info->max_extent) { | ||
1287 | spin_lock(&BTRFS_I(inode)->accounting_lock); | ||
1288 | BTRFS_I(inode)->outstanding_extents--; | ||
1289 | spin_unlock(&BTRFS_I(inode)->accounting_lock); | ||
1290 | return 0; | ||
1291 | } | ||
1292 | |||
1293 | /* | ||
1294 | * If we grew by another max_extent, just return, we want to keep that | ||
1295 | * reserved amount. | ||
1296 | */ | ||
1297 | num_extents = div64_u64(old_size + root->fs_info->max_extent - 1, | ||
1298 | root->fs_info->max_extent); | ||
1299 | if (div64_u64(new_size + root->fs_info->max_extent - 1, | ||
1300 | root->fs_info->max_extent) > num_extents) | ||
1301 | return 0; | ||
1302 | |||
1303 | spin_lock(&BTRFS_I(inode)->accounting_lock); | 1254 | spin_lock(&BTRFS_I(inode)->accounting_lock); |
1304 | BTRFS_I(inode)->outstanding_extents--; | 1255 | BTRFS_I(inode)->outstanding_extents--; |
1305 | spin_unlock(&BTRFS_I(inode)->accounting_lock); | 1256 | spin_unlock(&BTRFS_I(inode)->accounting_lock); |
@@ -1328,6 +1279,7 @@ static int btrfs_set_bit_hook(struct inode *inode, u64 start, u64 end, | |||
1328 | BTRFS_I(inode)->outstanding_extents++; | 1279 | BTRFS_I(inode)->outstanding_extents++; |
1329 | spin_unlock(&BTRFS_I(inode)->accounting_lock); | 1280 | spin_unlock(&BTRFS_I(inode)->accounting_lock); |
1330 | btrfs_delalloc_reserve_space(root, inode, end - start + 1); | 1281 | btrfs_delalloc_reserve_space(root, inode, end - start + 1); |
1282 | |||
1331 | spin_lock(&root->fs_info->delalloc_lock); | 1283 | spin_lock(&root->fs_info->delalloc_lock); |
1332 | BTRFS_I(inode)->delalloc_bytes += end - start + 1; | 1284 | BTRFS_I(inode)->delalloc_bytes += end - start + 1; |
1333 | root->fs_info->delalloc_bytes += end - start + 1; | 1285 | root->fs_info->delalloc_bytes += end - start + 1; |
@@ -1356,6 +1308,7 @@ static int btrfs_clear_bit_hook(struct inode *inode, | |||
1356 | 1308 | ||
1357 | if (bits & EXTENT_DO_ACCOUNTING) { | 1309 | if (bits & EXTENT_DO_ACCOUNTING) { |
1358 | spin_lock(&BTRFS_I(inode)->accounting_lock); | 1310 | spin_lock(&BTRFS_I(inode)->accounting_lock); |
1311 | WARN_ON(!BTRFS_I(inode)->outstanding_extents); | ||
1359 | BTRFS_I(inode)->outstanding_extents--; | 1312 | BTRFS_I(inode)->outstanding_extents--; |
1360 | spin_unlock(&BTRFS_I(inode)->accounting_lock); | 1313 | spin_unlock(&BTRFS_I(inode)->accounting_lock); |
1361 | btrfs_unreserve_metadata_for_delalloc(root, inode, 1); | 1314 | btrfs_unreserve_metadata_for_delalloc(root, inode, 1); |
@@ -5384,7 +5337,6 @@ free: | |||
5384 | void btrfs_drop_inode(struct inode *inode) | 5337 | void btrfs_drop_inode(struct inode *inode) |
5385 | { | 5338 | { |
5386 | struct btrfs_root *root = BTRFS_I(inode)->root; | 5339 | struct btrfs_root *root = BTRFS_I(inode)->root; |
5387 | |||
5388 | if (inode->i_nlink > 0 && btrfs_root_refs(&root->root_item) == 0) | 5340 | if (inode->i_nlink > 0 && btrfs_root_refs(&root->root_item) == 0) |
5389 | generic_delete_inode(inode); | 5341 | generic_delete_inode(inode); |
5390 | else | 5342 | else |
@@ -5788,18 +5740,15 @@ static int prealloc_file_range(struct inode *inode, u64 start, u64 end, | |||
5788 | struct btrfs_trans_handle *trans; | 5740 | struct btrfs_trans_handle *trans; |
5789 | struct btrfs_root *root = BTRFS_I(inode)->root; | 5741 | struct btrfs_root *root = BTRFS_I(inode)->root; |
5790 | struct btrfs_key ins; | 5742 | struct btrfs_key ins; |
5791 | u64 alloc_size; | ||
5792 | u64 cur_offset = start; | 5743 | u64 cur_offset = start; |
5793 | u64 num_bytes = end - start; | 5744 | u64 num_bytes = end - start; |
5794 | int ret = 0; | 5745 | int ret = 0; |
5795 | u64 i_size; | 5746 | u64 i_size; |
5796 | 5747 | ||
5797 | while (num_bytes > 0) { | 5748 | while (num_bytes > 0) { |
5798 | alloc_size = min(num_bytes, root->fs_info->max_extent); | ||
5799 | |||
5800 | trans = btrfs_start_transaction(root, 1); | 5749 | trans = btrfs_start_transaction(root, 1); |
5801 | 5750 | ||
5802 | ret = btrfs_reserve_extent(trans, root, alloc_size, | 5751 | ret = btrfs_reserve_extent(trans, root, num_bytes, |
5803 | root->sectorsize, 0, alloc_hint, | 5752 | root->sectorsize, 0, alloc_hint, |
5804 | (u64)-1, &ins, 1); | 5753 | (u64)-1, &ins, 1); |
5805 | if (ret) { | 5754 | if (ret) { |
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c index a8ffecd0b491..5c99882b9763 100644 --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c | |||
@@ -303,6 +303,7 @@ static int __btrfs_remove_ordered_extent(struct inode *inode, | |||
303 | struct btrfs_ordered_extent *entry) | 303 | struct btrfs_ordered_extent *entry) |
304 | { | 304 | { |
305 | struct btrfs_ordered_inode_tree *tree; | 305 | struct btrfs_ordered_inode_tree *tree; |
306 | struct btrfs_root *root = BTRFS_I(inode)->root; | ||
306 | struct rb_node *node; | 307 | struct rb_node *node; |
307 | 308 | ||
308 | tree = &BTRFS_I(inode)->ordered_tree; | 309 | tree = &BTRFS_I(inode)->ordered_tree; |
@@ -312,12 +313,13 @@ static int __btrfs_remove_ordered_extent(struct inode *inode, | |||
312 | set_bit(BTRFS_ORDERED_COMPLETE, &entry->flags); | 313 | set_bit(BTRFS_ORDERED_COMPLETE, &entry->flags); |
313 | 314 | ||
314 | spin_lock(&BTRFS_I(inode)->accounting_lock); | 315 | spin_lock(&BTRFS_I(inode)->accounting_lock); |
316 | WARN_ON(!BTRFS_I(inode)->outstanding_extents); | ||
315 | BTRFS_I(inode)->outstanding_extents--; | 317 | BTRFS_I(inode)->outstanding_extents--; |
316 | spin_unlock(&BTRFS_I(inode)->accounting_lock); | 318 | spin_unlock(&BTRFS_I(inode)->accounting_lock); |
317 | btrfs_unreserve_metadata_for_delalloc(BTRFS_I(inode)->root, | 319 | btrfs_unreserve_metadata_for_delalloc(BTRFS_I(inode)->root, |
318 | inode, 1); | 320 | inode, 1); |
319 | 321 | ||
320 | spin_lock(&BTRFS_I(inode)->root->fs_info->ordered_extent_lock); | 322 | spin_lock(&root->fs_info->ordered_extent_lock); |
321 | list_del_init(&entry->root_extent_list); | 323 | list_del_init(&entry->root_extent_list); |
322 | 324 | ||
323 | /* | 325 | /* |
@@ -329,7 +331,7 @@ static int __btrfs_remove_ordered_extent(struct inode *inode, | |||
329 | !mapping_tagged(inode->i_mapping, PAGECACHE_TAG_DIRTY)) { | 331 | !mapping_tagged(inode->i_mapping, PAGECACHE_TAG_DIRTY)) { |
330 | list_del_init(&BTRFS_I(inode)->ordered_operations); | 332 | list_del_init(&BTRFS_I(inode)->ordered_operations); |
331 | } | 333 | } |
332 | spin_unlock(&BTRFS_I(inode)->root->fs_info->ordered_extent_lock); | 334 | spin_unlock(&root->fs_info->ordered_extent_lock); |
333 | 335 | ||
334 | return 0; | 336 | return 0; |
335 | } | 337 | } |
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 9ac612e6ca60..d11b12fc086b 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -64,10 +64,9 @@ static void btrfs_put_super(struct super_block *sb) | |||
64 | 64 | ||
65 | enum { | 65 | enum { |
66 | Opt_degraded, Opt_subvol, Opt_subvolid, Opt_device, Opt_nodatasum, | 66 | Opt_degraded, Opt_subvol, Opt_subvolid, Opt_device, Opt_nodatasum, |
67 | Opt_nodatacow, Opt_max_extent, Opt_max_inline, Opt_alloc_start, | 67 | Opt_nodatacow, Opt_max_inline, Opt_alloc_start, Opt_nobarrier, Opt_ssd, |
68 | Opt_nobarrier, Opt_ssd, Opt_nossd, Opt_ssd_spread, Opt_thread_pool, | 68 | Opt_nossd, Opt_ssd_spread, Opt_thread_pool, Opt_noacl, Opt_compress, |
69 | Opt_noacl, Opt_compress, Opt_compress_force, Opt_notreelog, Opt_ratio, | 69 | Opt_compress_force, Opt_notreelog, Opt_ratio, Opt_flushoncommit, |
70 | Opt_flushoncommit, | ||
71 | Opt_discard, Opt_err, | 70 | Opt_discard, Opt_err, |
72 | }; | 71 | }; |
73 | 72 | ||
@@ -79,7 +78,6 @@ static match_table_t tokens = { | |||
79 | {Opt_nodatasum, "nodatasum"}, | 78 | {Opt_nodatasum, "nodatasum"}, |
80 | {Opt_nodatacow, "nodatacow"}, | 79 | {Opt_nodatacow, "nodatacow"}, |
81 | {Opt_nobarrier, "nobarrier"}, | 80 | {Opt_nobarrier, "nobarrier"}, |
82 | {Opt_max_extent, "max_extent=%s"}, | ||
83 | {Opt_max_inline, "max_inline=%s"}, | 81 | {Opt_max_inline, "max_inline=%s"}, |
84 | {Opt_alloc_start, "alloc_start=%s"}, | 82 | {Opt_alloc_start, "alloc_start=%s"}, |
85 | {Opt_thread_pool, "thread_pool=%d"}, | 83 | {Opt_thread_pool, "thread_pool=%d"}, |
@@ -188,18 +186,6 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) | |||
188 | info->thread_pool_size); | 186 | info->thread_pool_size); |
189 | } | 187 | } |
190 | break; | 188 | break; |
191 | case Opt_max_extent: | ||
192 | num = match_strdup(&args[0]); | ||
193 | if (num) { | ||
194 | info->max_extent = memparse(num, NULL); | ||
195 | kfree(num); | ||
196 | |||
197 | info->max_extent = max_t(u64, | ||
198 | info->max_extent, root->sectorsize); | ||
199 | printk(KERN_INFO "btrfs: max_extent at %llu\n", | ||
200 | (unsigned long long)info->max_extent); | ||
201 | } | ||
202 | break; | ||
203 | case Opt_max_inline: | 189 | case Opt_max_inline: |
204 | num = match_strdup(&args[0]); | 190 | num = match_strdup(&args[0]); |
205 | if (num) { | 191 | if (num) { |
@@ -529,9 +515,6 @@ static int btrfs_show_options(struct seq_file *seq, struct vfsmount *vfs) | |||
529 | seq_puts(seq, ",nodatacow"); | 515 | seq_puts(seq, ",nodatacow"); |
530 | if (btrfs_test_opt(root, NOBARRIER)) | 516 | if (btrfs_test_opt(root, NOBARRIER)) |
531 | seq_puts(seq, ",nobarrier"); | 517 | seq_puts(seq, ",nobarrier"); |
532 | if (info->max_extent != (u64)-1) | ||
533 | seq_printf(seq, ",max_extent=%llu", | ||
534 | (unsigned long long)info->max_extent); | ||
535 | if (info->max_inline != 8192 * 1024) | 518 | if (info->max_inline != 8192 * 1024) |
536 | seq_printf(seq, ",max_inline=%llu", | 519 | seq_printf(seq, ",max_inline=%llu", |
537 | (unsigned long long)info->max_inline); | 520 | (unsigned long long)info->max_inline); |