diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-09-11 15:38:25 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-09-11 15:38:25 -0400 |
commit | e91eb6204fb826116453e43d4f5cf0f666bf46fe (patch) | |
tree | e688157b2ac689e32bacbdba8c8d185431d7f7e2 | |
parent | e013f74b60bbd37ee8c3a55214eb351ea3101c15 (diff) | |
parent | 527afb4493c2892ce89fb74648e72a30b68ba120 (diff) |
Merge branch 'for-linus-4.3' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs
Pull btrfs cleanups and fixes from Chris Mason:
"These are small cleanups, and also some fixes for our async worker
thread initialization.
I was having some trouble testing these, but it ended up being a
combination of changing around my test servers and a shiny new
schedule while atomic from the new start/finish_plug in
writeback_sb_inodes().
That one only hits on btrfs raid5/6 or MD raid10, and if I wasn't
changing a bunch of things in my test setup at once it would have been
really clear. Fix for writeback_sb_inodes() on the way as well"
* 'for-linus-4.3' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs:
Btrfs: cleanup: remove unnecessary check before btrfs_free_path is called
btrfs: async_thread: Fix workqueue 'max_active' value when initializing
btrfs: Add raid56 support for updating num_tolerated_disk_barrier_failures in btrfs_balance
btrfs: Cleanup for btrfs_calc_num_tolerated_disk_barrier_failures
btrfs: Remove noused chunk_tree and chunk_objectid from scrub_enumerate_chunks and scrub_chunk
btrfs: Update out-of-date "skip parity stripe" comment
-rw-r--r-- | fs/btrfs/async-thread.c | 57 | ||||
-rw-r--r-- | fs/btrfs/async-thread.h | 2 | ||||
-rw-r--r-- | fs/btrfs/dev-replace.c | 3 | ||||
-rw-r--r-- | fs/btrfs/disk-io.c | 76 | ||||
-rw-r--r-- | fs/btrfs/disk-io.h | 1 | ||||
-rw-r--r-- | fs/btrfs/inode.c | 3 | ||||
-rw-r--r-- | fs/btrfs/scrub.c | 12 | ||||
-rw-r--r-- | fs/btrfs/tree-defrag.c | 3 | ||||
-rw-r--r-- | fs/btrfs/volumes.c | 21 |
9 files changed, 82 insertions, 96 deletions
diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c index 1ce06c849a86..3e36e4adc4a3 100644 --- a/fs/btrfs/async-thread.c +++ b/fs/btrfs/async-thread.c | |||
@@ -42,8 +42,14 @@ struct __btrfs_workqueue { | |||
42 | 42 | ||
43 | /* Thresholding related variants */ | 43 | /* Thresholding related variants */ |
44 | atomic_t pending; | 44 | atomic_t pending; |
45 | int max_active; | 45 | |
46 | int current_max; | 46 | /* Up limit of concurrency workers */ |
47 | int limit_active; | ||
48 | |||
49 | /* Current number of concurrency workers */ | ||
50 | int current_active; | ||
51 | |||
52 | /* Threshold to change current_active */ | ||
47 | int thresh; | 53 | int thresh; |
48 | unsigned int count; | 54 | unsigned int count; |
49 | spinlock_t thres_lock; | 55 | spinlock_t thres_lock; |
@@ -88,7 +94,7 @@ BTRFS_WORK_HELPER(scrubnc_helper); | |||
88 | BTRFS_WORK_HELPER(scrubparity_helper); | 94 | BTRFS_WORK_HELPER(scrubparity_helper); |
89 | 95 | ||
90 | static struct __btrfs_workqueue * | 96 | static struct __btrfs_workqueue * |
91 | __btrfs_alloc_workqueue(const char *name, unsigned int flags, int max_active, | 97 | __btrfs_alloc_workqueue(const char *name, unsigned int flags, int limit_active, |
92 | int thresh) | 98 | int thresh) |
93 | { | 99 | { |
94 | struct __btrfs_workqueue *ret = kzalloc(sizeof(*ret), GFP_NOFS); | 100 | struct __btrfs_workqueue *ret = kzalloc(sizeof(*ret), GFP_NOFS); |
@@ -96,26 +102,31 @@ __btrfs_alloc_workqueue(const char *name, unsigned int flags, int max_active, | |||
96 | if (!ret) | 102 | if (!ret) |
97 | return NULL; | 103 | return NULL; |
98 | 104 | ||
99 | ret->max_active = max_active; | 105 | ret->limit_active = limit_active; |
100 | atomic_set(&ret->pending, 0); | 106 | atomic_set(&ret->pending, 0); |
101 | if (thresh == 0) | 107 | if (thresh == 0) |
102 | thresh = DFT_THRESHOLD; | 108 | thresh = DFT_THRESHOLD; |
103 | /* For low threshold, disabling threshold is a better choice */ | 109 | /* For low threshold, disabling threshold is a better choice */ |
104 | if (thresh < DFT_THRESHOLD) { | 110 | if (thresh < DFT_THRESHOLD) { |
105 | ret->current_max = max_active; | 111 | ret->current_active = limit_active; |
106 | ret->thresh = NO_THRESHOLD; | 112 | ret->thresh = NO_THRESHOLD; |
107 | } else { | 113 | } else { |
108 | ret->current_max = 1; | 114 | /* |
115 | * For threshold-able wq, let its concurrency grow on demand. | ||
116 | * Use minimal max_active at alloc time to reduce resource | ||
117 | * usage. | ||
118 | */ | ||
119 | ret->current_active = 1; | ||
109 | ret->thresh = thresh; | 120 | ret->thresh = thresh; |
110 | } | 121 | } |
111 | 122 | ||
112 | if (flags & WQ_HIGHPRI) | 123 | if (flags & WQ_HIGHPRI) |
113 | ret->normal_wq = alloc_workqueue("%s-%s-high", flags, | 124 | ret->normal_wq = alloc_workqueue("%s-%s-high", flags, |
114 | ret->max_active, | 125 | ret->current_active, "btrfs", |
115 | "btrfs", name); | 126 | name); |
116 | else | 127 | else |
117 | ret->normal_wq = alloc_workqueue("%s-%s", flags, | 128 | ret->normal_wq = alloc_workqueue("%s-%s", flags, |
118 | ret->max_active, "btrfs", | 129 | ret->current_active, "btrfs", |
119 | name); | 130 | name); |
120 | if (!ret->normal_wq) { | 131 | if (!ret->normal_wq) { |
121 | kfree(ret); | 132 | kfree(ret); |
@@ -134,7 +145,7 @@ __btrfs_destroy_workqueue(struct __btrfs_workqueue *wq); | |||
134 | 145 | ||
135 | struct btrfs_workqueue *btrfs_alloc_workqueue(const char *name, | 146 | struct btrfs_workqueue *btrfs_alloc_workqueue(const char *name, |
136 | unsigned int flags, | 147 | unsigned int flags, |
137 | int max_active, | 148 | int limit_active, |
138 | int thresh) | 149 | int thresh) |
139 | { | 150 | { |
140 | struct btrfs_workqueue *ret = kzalloc(sizeof(*ret), GFP_NOFS); | 151 | struct btrfs_workqueue *ret = kzalloc(sizeof(*ret), GFP_NOFS); |
@@ -143,14 +154,14 @@ struct btrfs_workqueue *btrfs_alloc_workqueue(const char *name, | |||
143 | return NULL; | 154 | return NULL; |
144 | 155 | ||
145 | ret->normal = __btrfs_alloc_workqueue(name, flags & ~WQ_HIGHPRI, | 156 | ret->normal = __btrfs_alloc_workqueue(name, flags & ~WQ_HIGHPRI, |
146 | max_active, thresh); | 157 | limit_active, thresh); |
147 | if (!ret->normal) { | 158 | if (!ret->normal) { |
148 | kfree(ret); | 159 | kfree(ret); |
149 | return NULL; | 160 | return NULL; |
150 | } | 161 | } |
151 | 162 | ||
152 | if (flags & WQ_HIGHPRI) { | 163 | if (flags & WQ_HIGHPRI) { |
153 | ret->high = __btrfs_alloc_workqueue(name, flags, max_active, | 164 | ret->high = __btrfs_alloc_workqueue(name, flags, limit_active, |
154 | thresh); | 165 | thresh); |
155 | if (!ret->high) { | 166 | if (!ret->high) { |
156 | __btrfs_destroy_workqueue(ret->normal); | 167 | __btrfs_destroy_workqueue(ret->normal); |
@@ -180,7 +191,7 @@ static inline void thresh_queue_hook(struct __btrfs_workqueue *wq) | |||
180 | */ | 191 | */ |
181 | static inline void thresh_exec_hook(struct __btrfs_workqueue *wq) | 192 | static inline void thresh_exec_hook(struct __btrfs_workqueue *wq) |
182 | { | 193 | { |
183 | int new_max_active; | 194 | int new_current_active; |
184 | long pending; | 195 | long pending; |
185 | int need_change = 0; | 196 | int need_change = 0; |
186 | 197 | ||
@@ -197,7 +208,7 @@ static inline void thresh_exec_hook(struct __btrfs_workqueue *wq) | |||
197 | wq->count %= (wq->thresh / 4); | 208 | wq->count %= (wq->thresh / 4); |
198 | if (!wq->count) | 209 | if (!wq->count) |
199 | goto out; | 210 | goto out; |
200 | new_max_active = wq->current_max; | 211 | new_current_active = wq->current_active; |
201 | 212 | ||
202 | /* | 213 | /* |
203 | * pending may be changed later, but it's OK since we really | 214 | * pending may be changed later, but it's OK since we really |
@@ -205,19 +216,19 @@ static inline void thresh_exec_hook(struct __btrfs_workqueue *wq) | |||
205 | */ | 216 | */ |
206 | pending = atomic_read(&wq->pending); | 217 | pending = atomic_read(&wq->pending); |
207 | if (pending > wq->thresh) | 218 | if (pending > wq->thresh) |
208 | new_max_active++; | 219 | new_current_active++; |
209 | if (pending < wq->thresh / 2) | 220 | if (pending < wq->thresh / 2) |
210 | new_max_active--; | 221 | new_current_active--; |
211 | new_max_active = clamp_val(new_max_active, 1, wq->max_active); | 222 | new_current_active = clamp_val(new_current_active, 1, wq->limit_active); |
212 | if (new_max_active != wq->current_max) { | 223 | if (new_current_active != wq->current_active) { |
213 | need_change = 1; | 224 | need_change = 1; |
214 | wq->current_max = new_max_active; | 225 | wq->current_active = new_current_active; |
215 | } | 226 | } |
216 | out: | 227 | out: |
217 | spin_unlock(&wq->thres_lock); | 228 | spin_unlock(&wq->thres_lock); |
218 | 229 | ||
219 | if (need_change) { | 230 | if (need_change) { |
220 | workqueue_set_max_active(wq->normal_wq, wq->current_max); | 231 | workqueue_set_max_active(wq->normal_wq, wq->current_active); |
221 | } | 232 | } |
222 | } | 233 | } |
223 | 234 | ||
@@ -351,13 +362,13 @@ void btrfs_destroy_workqueue(struct btrfs_workqueue *wq) | |||
351 | kfree(wq); | 362 | kfree(wq); |
352 | } | 363 | } |
353 | 364 | ||
354 | void btrfs_workqueue_set_max(struct btrfs_workqueue *wq, int max) | 365 | void btrfs_workqueue_set_max(struct btrfs_workqueue *wq, int limit_active) |
355 | { | 366 | { |
356 | if (!wq) | 367 | if (!wq) |
357 | return; | 368 | return; |
358 | wq->normal->max_active = max; | 369 | wq->normal->limit_active = limit_active; |
359 | if (wq->high) | 370 | if (wq->high) |
360 | wq->high->max_active = max; | 371 | wq->high->limit_active = limit_active; |
361 | } | 372 | } |
362 | 373 | ||
363 | void btrfs_set_work_high_priority(struct btrfs_work *work) | 374 | void btrfs_set_work_high_priority(struct btrfs_work *work) |
diff --git a/fs/btrfs/async-thread.h b/fs/btrfs/async-thread.h index b0b093b6afec..ad4d0647d1a6 100644 --- a/fs/btrfs/async-thread.h +++ b/fs/btrfs/async-thread.h | |||
@@ -69,7 +69,7 @@ BTRFS_WORK_HELPER_PROTO(scrubparity_helper); | |||
69 | 69 | ||
70 | struct btrfs_workqueue *btrfs_alloc_workqueue(const char *name, | 70 | struct btrfs_workqueue *btrfs_alloc_workqueue(const char *name, |
71 | unsigned int flags, | 71 | unsigned int flags, |
72 | int max_active, | 72 | int limit_active, |
73 | int thresh); | 73 | int thresh); |
74 | void btrfs_init_work(struct btrfs_work *work, btrfs_work_func_t helper, | 74 | void btrfs_init_work(struct btrfs_work *work, btrfs_work_func_t helper, |
75 | btrfs_func_t func, | 75 | btrfs_func_t func, |
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index 564a7de17d99..e54dd5905cee 100644 --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c | |||
@@ -183,8 +183,7 @@ no_valid_dev_replace_entry_found: | |||
183 | } | 183 | } |
184 | 184 | ||
185 | out: | 185 | out: |
186 | if (path) | 186 | btrfs_free_path(path); |
187 | btrfs_free_path(path); | ||
188 | return ret; | 187 | return ret; |
189 | } | 188 | } |
190 | 189 | ||
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 9ebd34f1c677..0d98aee34fee 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -3443,6 +3443,26 @@ static int barrier_all_devices(struct btrfs_fs_info *info) | |||
3443 | return 0; | 3443 | return 0; |
3444 | } | 3444 | } |
3445 | 3445 | ||
3446 | int btrfs_get_num_tolerated_disk_barrier_failures(u64 flags) | ||
3447 | { | ||
3448 | if ((flags & (BTRFS_BLOCK_GROUP_DUP | | ||
3449 | BTRFS_BLOCK_GROUP_RAID0 | | ||
3450 | BTRFS_AVAIL_ALLOC_BIT_SINGLE)) || | ||
3451 | ((flags & BTRFS_BLOCK_GROUP_PROFILE_MASK) == 0)) | ||
3452 | return 0; | ||
3453 | |||
3454 | if (flags & (BTRFS_BLOCK_GROUP_RAID1 | | ||
3455 | BTRFS_BLOCK_GROUP_RAID5 | | ||
3456 | BTRFS_BLOCK_GROUP_RAID10)) | ||
3457 | return 1; | ||
3458 | |||
3459 | if (flags & BTRFS_BLOCK_GROUP_RAID6) | ||
3460 | return 2; | ||
3461 | |||
3462 | pr_warn("BTRFS: unknown raid type: %llu\n", flags); | ||
3463 | return 0; | ||
3464 | } | ||
3465 | |||
3446 | int btrfs_calc_num_tolerated_disk_barrier_failures( | 3466 | int btrfs_calc_num_tolerated_disk_barrier_failures( |
3447 | struct btrfs_fs_info *fs_info) | 3467 | struct btrfs_fs_info *fs_info) |
3448 | { | 3468 | { |
@@ -3452,13 +3472,12 @@ int btrfs_calc_num_tolerated_disk_barrier_failures( | |||
3452 | BTRFS_BLOCK_GROUP_SYSTEM, | 3472 | BTRFS_BLOCK_GROUP_SYSTEM, |
3453 | BTRFS_BLOCK_GROUP_METADATA, | 3473 | BTRFS_BLOCK_GROUP_METADATA, |
3454 | BTRFS_BLOCK_GROUP_DATA | BTRFS_BLOCK_GROUP_METADATA}; | 3474 | BTRFS_BLOCK_GROUP_DATA | BTRFS_BLOCK_GROUP_METADATA}; |
3455 | int num_types = 4; | ||
3456 | int i; | 3475 | int i; |
3457 | int c; | 3476 | int c; |
3458 | int num_tolerated_disk_barrier_failures = | 3477 | int num_tolerated_disk_barrier_failures = |
3459 | (int)fs_info->fs_devices->num_devices; | 3478 | (int)fs_info->fs_devices->num_devices; |
3460 | 3479 | ||
3461 | for (i = 0; i < num_types; i++) { | 3480 | for (i = 0; i < ARRAY_SIZE(types); i++) { |
3462 | struct btrfs_space_info *tmp; | 3481 | struct btrfs_space_info *tmp; |
3463 | 3482 | ||
3464 | sinfo = NULL; | 3483 | sinfo = NULL; |
@@ -3476,44 +3495,21 @@ int btrfs_calc_num_tolerated_disk_barrier_failures( | |||
3476 | 3495 | ||
3477 | down_read(&sinfo->groups_sem); | 3496 | down_read(&sinfo->groups_sem); |
3478 | for (c = 0; c < BTRFS_NR_RAID_TYPES; c++) { | 3497 | for (c = 0; c < BTRFS_NR_RAID_TYPES; c++) { |
3479 | if (!list_empty(&sinfo->block_groups[c])) { | 3498 | u64 flags; |
3480 | u64 flags; | 3499 | |
3481 | 3500 | if (list_empty(&sinfo->block_groups[c])) | |
3482 | btrfs_get_block_group_info( | 3501 | continue; |
3483 | &sinfo->block_groups[c], &space); | 3502 | |
3484 | if (space.total_bytes == 0 || | 3503 | btrfs_get_block_group_info(&sinfo->block_groups[c], |
3485 | space.used_bytes == 0) | 3504 | &space); |
3486 | continue; | 3505 | if (space.total_bytes == 0 || space.used_bytes == 0) |
3487 | flags = space.flags; | 3506 | continue; |
3488 | /* | 3507 | flags = space.flags; |
3489 | * return | 3508 | |
3490 | * 0: if dup, single or RAID0 is configured for | 3509 | num_tolerated_disk_barrier_failures = min( |
3491 | * any of metadata, system or data, else | 3510 | num_tolerated_disk_barrier_failures, |
3492 | * 1: if RAID5 is configured, or if RAID1 or | 3511 | btrfs_get_num_tolerated_disk_barrier_failures( |
3493 | * RAID10 is configured and only two mirrors | 3512 | flags)); |
3494 | * are used, else | ||
3495 | * 2: if RAID6 is configured, else | ||
3496 | * num_mirrors - 1: if RAID1 or RAID10 is | ||
3497 | * configured and more than | ||
3498 | * 2 mirrors are used. | ||
3499 | */ | ||
3500 | if (num_tolerated_disk_barrier_failures > 0 && | ||
3501 | ((flags & (BTRFS_BLOCK_GROUP_DUP | | ||
3502 | BTRFS_BLOCK_GROUP_RAID0)) || | ||
3503 | ((flags & BTRFS_BLOCK_GROUP_PROFILE_MASK) | ||
3504 | == 0))) | ||
3505 | num_tolerated_disk_barrier_failures = 0; | ||
3506 | else if (num_tolerated_disk_barrier_failures > 1) { | ||
3507 | if (flags & (BTRFS_BLOCK_GROUP_RAID1 | | ||
3508 | BTRFS_BLOCK_GROUP_RAID5 | | ||
3509 | BTRFS_BLOCK_GROUP_RAID10)) { | ||
3510 | num_tolerated_disk_barrier_failures = 1; | ||
3511 | } else if (flags & | ||
3512 | BTRFS_BLOCK_GROUP_RAID6) { | ||
3513 | num_tolerated_disk_barrier_failures = 2; | ||
3514 | } | ||
3515 | } | ||
3516 | } | ||
3517 | } | 3513 | } |
3518 | up_read(&sinfo->groups_sem); | 3514 | up_read(&sinfo->groups_sem); |
3519 | } | 3515 | } |
diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h index d4cbfeeeedd4..bdfb479ea859 100644 --- a/fs/btrfs/disk-io.h +++ b/fs/btrfs/disk-io.h | |||
@@ -139,6 +139,7 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans, | |||
139 | u64 objectid); | 139 | u64 objectid); |
140 | int btree_lock_page_hook(struct page *page, void *data, | 140 | int btree_lock_page_hook(struct page *page, void *data, |
141 | void (*flush_fn)(void *)); | 141 | void (*flush_fn)(void *)); |
142 | int btrfs_get_num_tolerated_disk_barrier_failures(u64 flags); | ||
142 | int btrfs_calc_num_tolerated_disk_barrier_failures( | 143 | int btrfs_calc_num_tolerated_disk_barrier_failures( |
143 | struct btrfs_fs_info *fs_info); | 144 | struct btrfs_fs_info *fs_info); |
144 | int __init btrfs_end_io_wq_init(void); | 145 | int __init btrfs_end_io_wq_init(void); |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 237da012f7d0..a0fa7253a2d7 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -6909,8 +6909,7 @@ out: | |||
6909 | 6909 | ||
6910 | trace_btrfs_get_extent(root, em); | 6910 | trace_btrfs_get_extent(root, em); |
6911 | 6911 | ||
6912 | if (path) | 6912 | btrfs_free_path(path); |
6913 | btrfs_free_path(path); | ||
6914 | if (trans) { | 6913 | if (trans) { |
6915 | ret = btrfs_end_transaction(trans, root); | 6914 | ret = btrfs_end_transaction(trans, root); |
6916 | if (!err) | 6915 | if (!err) |
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index 9a11db0c47ee..a39f5d1144e8 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c | |||
@@ -3267,13 +3267,13 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx, | |||
3267 | scrub_blocked_if_needed(fs_info); | 3267 | scrub_blocked_if_needed(fs_info); |
3268 | } | 3268 | } |
3269 | 3269 | ||
3270 | /* for raid56, we skip parity stripe */ | ||
3271 | if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) { | 3270 | if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) { |
3272 | ret = get_raid56_logic_offset(physical, num, map, | 3271 | ret = get_raid56_logic_offset(physical, num, map, |
3273 | &logical, | 3272 | &logical, |
3274 | &stripe_logical); | 3273 | &stripe_logical); |
3275 | logical += base; | 3274 | logical += base; |
3276 | if (ret) { | 3275 | if (ret) { |
3276 | /* it is parity strip */ | ||
3277 | stripe_logical += base; | 3277 | stripe_logical += base; |
3278 | stripe_end = stripe_logical + increment; | 3278 | stripe_end = stripe_logical + increment; |
3279 | ret = scrub_raid56_parity(sctx, map, scrub_dev, | 3279 | ret = scrub_raid56_parity(sctx, map, scrub_dev, |
@@ -3480,7 +3480,6 @@ out: | |||
3480 | 3480 | ||
3481 | static noinline_for_stack int scrub_chunk(struct scrub_ctx *sctx, | 3481 | static noinline_for_stack int scrub_chunk(struct scrub_ctx *sctx, |
3482 | struct btrfs_device *scrub_dev, | 3482 | struct btrfs_device *scrub_dev, |
3483 | u64 chunk_tree, u64 chunk_objectid, | ||
3484 | u64 chunk_offset, u64 length, | 3483 | u64 chunk_offset, u64 length, |
3485 | u64 dev_offset, int is_dev_replace) | 3484 | u64 dev_offset, int is_dev_replace) |
3486 | { | 3485 | { |
@@ -3531,8 +3530,6 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx, | |||
3531 | struct btrfs_root *root = sctx->dev_root; | 3530 | struct btrfs_root *root = sctx->dev_root; |
3532 | struct btrfs_fs_info *fs_info = root->fs_info; | 3531 | struct btrfs_fs_info *fs_info = root->fs_info; |
3533 | u64 length; | 3532 | u64 length; |
3534 | u64 chunk_tree; | ||
3535 | u64 chunk_objectid; | ||
3536 | u64 chunk_offset; | 3533 | u64 chunk_offset; |
3537 | int ret = 0; | 3534 | int ret = 0; |
3538 | int slot; | 3535 | int slot; |
@@ -3596,8 +3593,6 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx, | |||
3596 | if (found_key.offset + length <= start) | 3593 | if (found_key.offset + length <= start) |
3597 | goto skip; | 3594 | goto skip; |
3598 | 3595 | ||
3599 | chunk_tree = btrfs_dev_extent_chunk_tree(l, dev_extent); | ||
3600 | chunk_objectid = btrfs_dev_extent_chunk_objectid(l, dev_extent); | ||
3601 | chunk_offset = btrfs_dev_extent_chunk_offset(l, dev_extent); | 3596 | chunk_offset = btrfs_dev_extent_chunk_offset(l, dev_extent); |
3602 | 3597 | ||
3603 | /* | 3598 | /* |
@@ -3630,9 +3625,8 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx, | |||
3630 | dev_replace->cursor_right = found_key.offset + length; | 3625 | dev_replace->cursor_right = found_key.offset + length; |
3631 | dev_replace->cursor_left = found_key.offset; | 3626 | dev_replace->cursor_left = found_key.offset; |
3632 | dev_replace->item_needs_writeback = 1; | 3627 | dev_replace->item_needs_writeback = 1; |
3633 | ret = scrub_chunk(sctx, scrub_dev, chunk_tree, chunk_objectid, | 3628 | ret = scrub_chunk(sctx, scrub_dev, chunk_offset, length, |
3634 | chunk_offset, length, found_key.offset, | 3629 | found_key.offset, is_dev_replace); |
3635 | is_dev_replace); | ||
3636 | 3630 | ||
3637 | /* | 3631 | /* |
3638 | * flush, submit all pending read and write bios, afterwards | 3632 | * flush, submit all pending read and write bios, afterwards |
diff --git a/fs/btrfs/tree-defrag.c b/fs/btrfs/tree-defrag.c index a4b9c8b2d35a..f31db4325339 100644 --- a/fs/btrfs/tree-defrag.c +++ b/fs/btrfs/tree-defrag.c | |||
@@ -115,8 +115,7 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans, | |||
115 | ret = -EAGAIN; | 115 | ret = -EAGAIN; |
116 | } | 116 | } |
117 | out: | 117 | out: |
118 | if (path) | 118 | btrfs_free_path(path); |
119 | btrfs_free_path(path); | ||
120 | if (ret == -EAGAIN) { | 119 | if (ret == -EAGAIN) { |
121 | if (root->defrag_max.objectid > root->defrag_progress.objectid) | 120 | if (root->defrag_max.objectid > root->defrag_progress.objectid) |
122 | goto done; | 121 | goto done; |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 76201d6f6ce4..6fc735869c18 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -3585,23 +3585,10 @@ int btrfs_balance(struct btrfs_balance_control *bctl, | |||
3585 | } while (read_seqretry(&fs_info->profiles_lock, seq)); | 3585 | } while (read_seqretry(&fs_info->profiles_lock, seq)); |
3586 | 3586 | ||
3587 | if (bctl->sys.flags & BTRFS_BALANCE_ARGS_CONVERT) { | 3587 | if (bctl->sys.flags & BTRFS_BALANCE_ARGS_CONVERT) { |
3588 | int num_tolerated_disk_barrier_failures; | 3588 | fs_info->num_tolerated_disk_barrier_failures = min( |
3589 | u64 target = bctl->sys.target; | 3589 | btrfs_calc_num_tolerated_disk_barrier_failures(fs_info), |
3590 | 3590 | btrfs_get_num_tolerated_disk_barrier_failures( | |
3591 | num_tolerated_disk_barrier_failures = | 3591 | bctl->sys.target)); |
3592 | btrfs_calc_num_tolerated_disk_barrier_failures(fs_info); | ||
3593 | if (num_tolerated_disk_barrier_failures > 0 && | ||
3594 | (target & | ||
3595 | (BTRFS_BLOCK_GROUP_DUP | BTRFS_BLOCK_GROUP_RAID0 | | ||
3596 | BTRFS_AVAIL_ALLOC_BIT_SINGLE))) | ||
3597 | num_tolerated_disk_barrier_failures = 0; | ||
3598 | else if (num_tolerated_disk_barrier_failures > 1 && | ||
3599 | (target & | ||
3600 | (BTRFS_BLOCK_GROUP_RAID1 | BTRFS_BLOCK_GROUP_RAID10))) | ||
3601 | num_tolerated_disk_barrier_failures = 1; | ||
3602 | |||
3603 | fs_info->num_tolerated_disk_barrier_failures = | ||
3604 | num_tolerated_disk_barrier_failures; | ||
3605 | } | 3592 | } |
3606 | 3593 | ||
3607 | ret = insert_balance_item(fs_info->tree_root, bctl); | 3594 | ret = insert_balance_item(fs_info->tree_root, bctl); |