extent-tree.c (9f3a074d108810139ad4af49a29d347a4cf41e9a) | extent-tree.c (b02441999efcc6152b87cd58e7970bb7843f76cf) |
---|---|
1/* 2 * Copyright (C) 2007 Oracle. All rights reserved. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public 6 * License v2 as published by the Free Software Foundation. 7 * 8 * This program is distributed in the hope that it will be useful, --- 4004 unchanged lines hidden (view full) --- 4013 * We needn't worry the filesystem going from r/w to r/o though 4014 * we don't acquire ->s_umount mutex, because the filesystem 4015 * should guarantee the delalloc inodes list be empty after 4016 * the filesystem is readonly(all dirty pages are written to 4017 * the disk). 4018 */ 4019 btrfs_start_all_delalloc_inodes(root->fs_info, 0); 4020 if (!current->journal_info) | 1/* 2 * Copyright (C) 2007 Oracle. All rights reserved. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public 6 * License v2 as published by the Free Software Foundation. 7 * 8 * This program is distributed in the hope that it will be useful, --- 4004 unchanged lines hidden (view full) --- 4013 * We needn't worry the filesystem going from r/w to r/o though 4014 * we don't acquire ->s_umount mutex, because the filesystem 4015 * should guarantee the delalloc inodes list be empty after 4016 * the filesystem is readonly(all dirty pages are written to 4017 * the disk). 4018 */ 4019 btrfs_start_all_delalloc_inodes(root->fs_info, 0); 4020 if (!current->journal_info) |
4021 btrfs_wait_all_ordered_extents(root->fs_info); | 4021 btrfs_wait_ordered_roots(root->fs_info, -1); |
4022 } 4023} 4024 4025static inline int calc_reclaim_items_nr(struct btrfs_root *root, u64 to_reclaim) 4026{ 4027 u64 bytes; 4028 int nr; 4029 --- 15 unchanged lines hidden (view full) --- 4045 struct btrfs_block_rsv *block_rsv; 4046 struct btrfs_space_info *space_info; 4047 struct btrfs_trans_handle *trans; 4048 u64 delalloc_bytes; 4049 u64 max_reclaim; 4050 long time_left; 4051 unsigned long nr_pages; 4052 int loops; | 4022 } 4023} 4024 4025static inline int calc_reclaim_items_nr(struct btrfs_root *root, u64 to_reclaim) 4026{ 4027 u64 bytes; 4028 int nr; 4029 --- 15 unchanged lines hidden (view full) --- 4045 struct btrfs_block_rsv *block_rsv; 4046 struct btrfs_space_info *space_info; 4047 struct btrfs_trans_handle *trans; 4048 u64 delalloc_bytes; 4049 u64 max_reclaim; 4050 long time_left; 4051 unsigned long nr_pages; 4052 int loops; |
4053 int items; |
|
4053 enum btrfs_reserve_flush_enum flush; 4054 4055 /* Calc the number of the pages we need flush for space reservation */ | 4054 enum btrfs_reserve_flush_enum flush; 4055 4056 /* Calc the number of the pages we need flush for space reservation */ |
4056 to_reclaim = calc_reclaim_items_nr(root, to_reclaim); 4057 to_reclaim *= EXTENT_SIZE_PER_ITEM; | 4057 items = calc_reclaim_items_nr(root, to_reclaim); 4058 to_reclaim = items * EXTENT_SIZE_PER_ITEM; |
4058 4059 trans = (struct btrfs_trans_handle *)current->journal_info; 4060 block_rsv = &root->fs_info->delalloc_block_rsv; 4061 space_info = block_rsv->space_info; 4062 4063 delalloc_bytes = percpu_counter_sum_positive( 4064 &root->fs_info->delalloc_bytes); 4065 if (delalloc_bytes == 0) { 4066 if (trans) 4067 return; 4068 if (wait_ordered) | 4059 4060 trans = (struct btrfs_trans_handle *)current->journal_info; 4061 block_rsv = &root->fs_info->delalloc_block_rsv; 4062 space_info = block_rsv->space_info; 4063 4064 delalloc_bytes = percpu_counter_sum_positive( 4065 &root->fs_info->delalloc_bytes); 4066 if (delalloc_bytes == 0) { 4067 if (trans) 4068 return; 4069 if (wait_ordered) |
4069 btrfs_wait_all_ordered_extents(root->fs_info); | 4070 btrfs_wait_ordered_roots(root->fs_info, items); |
4070 return; 4071 } 4072 4073 loops = 0; 4074 while (delalloc_bytes && loops < 3) { 4075 max_reclaim = min(delalloc_bytes, to_reclaim); 4076 nr_pages = max_reclaim >> PAGE_CACHE_SHIFT; 4077 btrfs_writeback_inodes_sb_nr(root, nr_pages); --- 22 unchanged lines hidden (view full) --- 4100 if (can_overcommit(root, space_info, orig, flush)) { 4101 spin_unlock(&space_info->lock); 4102 break; 4103 } 4104 spin_unlock(&space_info->lock); 4105 4106 loops++; 4107 if (wait_ordered && !trans) { | 4071 return; 4072 } 4073 4074 loops = 0; 4075 while (delalloc_bytes && loops < 3) { 4076 max_reclaim = min(delalloc_bytes, to_reclaim); 4077 nr_pages = max_reclaim >> PAGE_CACHE_SHIFT; 4078 btrfs_writeback_inodes_sb_nr(root, nr_pages); --- 22 unchanged lines hidden (view full) --- 4101 if (can_overcommit(root, space_info, orig, flush)) { 4102 spin_unlock(&space_info->lock); 4103 break; 4104 } 4105 spin_unlock(&space_info->lock); 4106 4107 loops++; 4108 if (wait_ordered && !trans) { |
4108 btrfs_wait_all_ordered_extents(root->fs_info); | 4109 btrfs_wait_ordered_roots(root->fs_info, items); |
4109 } else { 4110 time_left = schedule_timeout_killable(1); 4111 if (time_left) 4112 break; 4113 } 4114 delalloc_bytes = percpu_counter_sum_positive( 4115 &root->fs_info->delalloc_bytes); 4116 } --- 4827 unchanged lines hidden --- | 4110 } else { 4111 time_left = schedule_timeout_killable(1); 4112 if (time_left) 4113 break; 4114 } 4115 delalloc_bytes = percpu_counter_sum_positive( 4116 &root->fs_info->delalloc_bytes); 4117 } --- 4827 unchanged lines hidden --- |