2 * Copyright (C) 2007 Oracle. All rights reserved.
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.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 * Boston, MA 021110-1307, USA.
20 #include <linux/sched.h>
21 #include <linux/writeback.h>
22 #include <linux/pagemap.h>
25 #include "transaction.h"
27 #include "ref-cache.h"
29 static int total_trans = 0;
30 extern struct kmem_cache *btrfs_trans_handle_cachep;
31 extern struct kmem_cache *btrfs_transaction_cachep;
33 #define BTRFS_ROOT_TRANS_TAG 0
35 static noinline void put_transaction(struct btrfs_transaction *transaction)
37 WARN_ON(transaction->use_count == 0);
38 transaction->use_count--;
39 if (transaction->use_count == 0) {
40 WARN_ON(total_trans == 0);
42 list_del_init(&transaction->list);
43 memset(transaction, 0, sizeof(*transaction));
44 kmem_cache_free(btrfs_transaction_cachep, transaction);
48 static noinline int join_transaction(struct btrfs_root *root)
50 struct btrfs_transaction *cur_trans;
51 cur_trans = root->fs_info->running_transaction;
53 cur_trans = kmem_cache_alloc(btrfs_transaction_cachep,
57 root->fs_info->generation++;
58 root->fs_info->last_alloc = 0;
59 root->fs_info->last_data_alloc = 0;
60 cur_trans->num_writers = 1;
61 cur_trans->num_joined = 0;
62 cur_trans->transid = root->fs_info->generation;
63 init_waitqueue_head(&cur_trans->writer_wait);
64 init_waitqueue_head(&cur_trans->commit_wait);
65 cur_trans->in_commit = 0;
66 cur_trans->blocked = 0;
67 cur_trans->use_count = 1;
68 cur_trans->commit_done = 0;
69 cur_trans->start_time = get_seconds();
70 INIT_LIST_HEAD(&cur_trans->pending_snapshots);
71 list_add_tail(&cur_trans->list, &root->fs_info->trans_list);
72 extent_io_tree_init(&cur_trans->dirty_pages,
73 root->fs_info->btree_inode->i_mapping,
75 spin_lock(&root->fs_info->new_trans_lock);
76 root->fs_info->running_transaction = cur_trans;
77 spin_unlock(&root->fs_info->new_trans_lock);
79 cur_trans->num_writers++;
80 cur_trans->num_joined++;
86 static noinline int record_root_in_trans(struct btrfs_root *root)
88 struct btrfs_dirty_root *dirty;
89 u64 running_trans_id = root->fs_info->running_transaction->transid;
90 if (root->ref_cows && root->last_trans < running_trans_id) {
91 WARN_ON(root == root->fs_info->extent_root);
92 if (root->root_item.refs != 0) {
93 radix_tree_tag_set(&root->fs_info->fs_roots_radix,
94 (unsigned long)root->root_key.objectid,
95 BTRFS_ROOT_TRANS_TAG);
97 dirty = kmalloc(sizeof(*dirty), GFP_NOFS);
99 dirty->root = kmalloc(sizeof(*dirty->root), GFP_NOFS);
100 BUG_ON(!dirty->root);
101 dirty->latest_root = root;
102 INIT_LIST_HEAD(&dirty->list);
104 root->commit_root = btrfs_root_node(root);
106 memcpy(dirty->root, root, sizeof(*root));
107 spin_lock_init(&dirty->root->node_lock);
108 spin_lock_init(&dirty->root->list_lock);
109 mutex_init(&dirty->root->objectid_mutex);
110 INIT_LIST_HEAD(&dirty->root->dead_list);
111 dirty->root->node = root->commit_root;
112 dirty->root->commit_root = NULL;
114 spin_lock(&root->list_lock);
115 list_add(&dirty->root->dead_list, &root->dead_list);
116 spin_unlock(&root->list_lock);
118 root->dirty_root = dirty;
122 root->last_trans = running_trans_id;
127 static void wait_current_trans(struct btrfs_root *root)
129 struct btrfs_transaction *cur_trans;
131 cur_trans = root->fs_info->running_transaction;
132 if (cur_trans && cur_trans->blocked) {
134 cur_trans->use_count++;
136 prepare_to_wait(&root->fs_info->transaction_wait, &wait,
137 TASK_UNINTERRUPTIBLE);
138 if (cur_trans->blocked) {
139 mutex_unlock(&root->fs_info->trans_mutex);
141 mutex_lock(&root->fs_info->trans_mutex);
142 finish_wait(&root->fs_info->transaction_wait,
145 finish_wait(&root->fs_info->transaction_wait,
150 put_transaction(cur_trans);
154 struct btrfs_trans_handle *start_transaction(struct btrfs_root *root,
155 int num_blocks, int wait)
157 struct btrfs_trans_handle *h =
158 kmem_cache_alloc(btrfs_trans_handle_cachep, GFP_NOFS);
161 mutex_lock(&root->fs_info->trans_mutex);
162 if ((wait == 1 && !root->fs_info->open_ioctl_trans) || wait == 2)
163 wait_current_trans(root);
164 ret = join_transaction(root);
167 record_root_in_trans(root);
168 h->transid = root->fs_info->running_transaction->transid;
169 h->transaction = root->fs_info->running_transaction;
170 h->blocks_reserved = num_blocks;
172 h->block_group = NULL;
173 h->alloc_exclude_nr = 0;
174 h->alloc_exclude_start = 0;
175 root->fs_info->running_transaction->use_count++;
176 mutex_unlock(&root->fs_info->trans_mutex);
180 struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root,
183 return start_transaction(root, num_blocks, 1);
185 struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root,
188 return start_transaction(root, num_blocks, 0);
191 struct btrfs_trans_handle *btrfs_start_ioctl_transaction(struct btrfs_root *r,
194 return start_transaction(r, num_blocks, 2);
198 static noinline int wait_for_commit(struct btrfs_root *root,
199 struct btrfs_transaction *commit)
202 mutex_lock(&root->fs_info->trans_mutex);
203 while(!commit->commit_done) {
204 prepare_to_wait(&commit->commit_wait, &wait,
205 TASK_UNINTERRUPTIBLE);
206 if (commit->commit_done)
208 mutex_unlock(&root->fs_info->trans_mutex);
210 mutex_lock(&root->fs_info->trans_mutex);
212 mutex_unlock(&root->fs_info->trans_mutex);
213 finish_wait(&commit->commit_wait, &wait);
217 static void throttle_on_drops(struct btrfs_root *root)
219 struct btrfs_fs_info *info = root->fs_info;
220 int harder_count = 0;
223 if (atomic_read(&info->throttles)) {
226 thr = atomic_read(&info->throttle_gen);
229 prepare_to_wait(&info->transaction_throttle,
230 &wait, TASK_UNINTERRUPTIBLE);
231 if (!atomic_read(&info->throttles)) {
232 finish_wait(&info->transaction_throttle, &wait);
236 finish_wait(&info->transaction_throttle, &wait);
237 } while (thr == atomic_read(&info->throttle_gen));
240 if (root->fs_info->total_ref_cache_size > 1 * 1024 * 1024 &&
244 if (root->fs_info->total_ref_cache_size > 5 * 1024 * 1024 &&
248 if (root->fs_info->total_ref_cache_size > 10 * 1024 * 1024 &&
254 void btrfs_throttle(struct btrfs_root *root)
256 mutex_lock(&root->fs_info->trans_mutex);
257 if (!root->fs_info->open_ioctl_trans)
258 wait_current_trans(root);
259 mutex_unlock(&root->fs_info->trans_mutex);
261 throttle_on_drops(root);
264 static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
265 struct btrfs_root *root, int throttle)
267 struct btrfs_transaction *cur_trans;
268 struct btrfs_fs_info *info = root->fs_info;
270 mutex_lock(&info->trans_mutex);
271 cur_trans = info->running_transaction;
272 WARN_ON(cur_trans != trans->transaction);
273 WARN_ON(cur_trans->num_writers < 1);
274 cur_trans->num_writers--;
276 if (waitqueue_active(&cur_trans->writer_wait))
277 wake_up(&cur_trans->writer_wait);
278 put_transaction(cur_trans);
279 mutex_unlock(&info->trans_mutex);
280 memset(trans, 0, sizeof(*trans));
281 kmem_cache_free(btrfs_trans_handle_cachep, trans);
284 throttle_on_drops(root);
289 int btrfs_end_transaction(struct btrfs_trans_handle *trans,
290 struct btrfs_root *root)
292 return __btrfs_end_transaction(trans, root, 0);
295 int btrfs_end_transaction_throttle(struct btrfs_trans_handle *trans,
296 struct btrfs_root *root)
298 return __btrfs_end_transaction(trans, root, 1);
302 int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans,
303 struct btrfs_root *root)
308 struct extent_io_tree *dirty_pages;
310 struct inode *btree_inode = root->fs_info->btree_inode;
315 if (!trans || !trans->transaction) {
316 return filemap_write_and_wait(btree_inode->i_mapping);
318 dirty_pages = &trans->transaction->dirty_pages;
320 ret = find_first_extent_bit(dirty_pages, 0, &start, &end,
324 clear_extent_dirty(dirty_pages, start, end, GFP_NOFS);
325 while(start <= end) {
326 index = start >> PAGE_CACHE_SHIFT;
327 start = (u64)(index + 1) << PAGE_CACHE_SHIFT;
328 page = find_lock_page(btree_inode->i_mapping, index);
331 if (PageWriteback(page)) {
333 wait_on_page_writeback(page);
336 page_cache_release(page);
340 err = write_one_page(page, 0);
343 page_cache_release(page);
346 err = filemap_fdatawait(btree_inode->i_mapping);
352 static int update_cowonly_root(struct btrfs_trans_handle *trans,
353 struct btrfs_root *root)
357 struct btrfs_root *tree_root = root->fs_info->tree_root;
359 btrfs_write_dirty_block_groups(trans, root);
361 old_root_bytenr = btrfs_root_bytenr(&root->root_item);
362 if (old_root_bytenr == root->node->start)
364 btrfs_set_root_bytenr(&root->root_item,
366 btrfs_set_root_level(&root->root_item,
367 btrfs_header_level(root->node));
368 ret = btrfs_update_root(trans, tree_root,
372 btrfs_write_dirty_block_groups(trans, root);
377 int btrfs_commit_tree_roots(struct btrfs_trans_handle *trans,
378 struct btrfs_root *root)
380 struct btrfs_fs_info *fs_info = root->fs_info;
381 struct list_head *next;
383 while(!list_empty(&fs_info->dirty_cowonly_roots)) {
384 next = fs_info->dirty_cowonly_roots.next;
386 root = list_entry(next, struct btrfs_root, dirty_list);
387 update_cowonly_root(trans, root);
392 int btrfs_add_dead_root(struct btrfs_root *root,
393 struct btrfs_root *latest,
394 struct list_head *dead_list)
396 struct btrfs_dirty_root *dirty;
398 dirty = kmalloc(sizeof(*dirty), GFP_NOFS);
402 dirty->latest_root = latest;
403 list_add(&dirty->list, dead_list);
407 static noinline int add_dirty_roots(struct btrfs_trans_handle *trans,
408 struct radix_tree_root *radix,
409 struct list_head *list)
411 struct btrfs_dirty_root *dirty;
412 struct btrfs_root *gang[8];
413 struct btrfs_root *root;
420 ret = radix_tree_gang_lookup_tag(radix, (void **)gang, 0,
422 BTRFS_ROOT_TRANS_TAG);
425 for (i = 0; i < ret; i++) {
427 radix_tree_tag_clear(radix,
428 (unsigned long)root->root_key.objectid,
429 BTRFS_ROOT_TRANS_TAG);
431 BUG_ON(!root->ref_tree);
432 dirty = root->dirty_root;
434 if (root->commit_root == root->node) {
435 WARN_ON(root->node->start !=
436 btrfs_root_bytenr(&root->root_item));
438 free_extent_buffer(root->commit_root);
439 root->commit_root = NULL;
441 spin_lock(&root->list_lock);
442 list_del_init(&dirty->root->dead_list);
443 spin_unlock(&root->list_lock);
448 /* make sure to update the root on disk
449 * so we get any updates to the block used
452 err = btrfs_update_root(trans,
453 root->fs_info->tree_root,
459 memset(&root->root_item.drop_progress, 0,
460 sizeof(struct btrfs_disk_key));
461 root->root_item.drop_level = 0;
462 root->commit_root = NULL;
463 root->root_key.offset = root->fs_info->generation;
464 btrfs_set_root_bytenr(&root->root_item,
466 btrfs_set_root_level(&root->root_item,
467 btrfs_header_level(root->node));
468 err = btrfs_insert_root(trans, root->fs_info->tree_root,
474 refs = btrfs_root_refs(&dirty->root->root_item);
475 btrfs_set_root_refs(&dirty->root->root_item, refs - 1);
476 err = btrfs_update_root(trans, root->fs_info->tree_root,
477 &dirty->root->root_key,
478 &dirty->root->root_item);
482 list_add(&dirty->list, list);
485 free_extent_buffer(dirty->root->node);
494 int btrfs_defrag_root(struct btrfs_root *root, int cacheonly)
496 struct btrfs_fs_info *info = root->fs_info;
498 struct btrfs_trans_handle *trans;
502 if (root->defrag_running)
504 trans = btrfs_start_transaction(root, 1);
506 root->defrag_running = 1;
507 ret = btrfs_defrag_leaves(trans, root, cacheonly);
508 nr = trans->blocks_used;
509 btrfs_end_transaction(trans, root);
510 btrfs_btree_balance_dirty(info->tree_root, nr);
513 trans = btrfs_start_transaction(root, 1);
514 if (root->fs_info->closing || ret != -EAGAIN)
517 root->defrag_running = 0;
519 btrfs_end_transaction(trans, root);
523 static noinline int drop_dirty_roots(struct btrfs_root *tree_root,
524 struct list_head *list)
526 struct btrfs_dirty_root *dirty;
527 struct btrfs_trans_handle *trans;
535 while(!list_empty(list)) {
536 struct btrfs_root *root;
538 dirty = list_entry(list->prev, struct btrfs_dirty_root, list);
539 list_del_init(&dirty->list);
541 num_bytes = btrfs_root_used(&dirty->root->root_item);
542 root = dirty->latest_root;
543 atomic_inc(&root->fs_info->throttles);
545 mutex_lock(&root->fs_info->drop_mutex);
547 trans = btrfs_start_transaction(tree_root, 1);
548 ret = btrfs_drop_snapshot(trans, dirty->root);
549 if (ret != -EAGAIN) {
553 err = btrfs_update_root(trans,
555 &dirty->root->root_key,
556 &dirty->root->root_item);
559 nr = trans->blocks_used;
560 ret = btrfs_end_transaction(trans, tree_root);
563 mutex_unlock(&root->fs_info->drop_mutex);
564 btrfs_btree_balance_dirty(tree_root, nr);
566 mutex_lock(&root->fs_info->drop_mutex);
569 atomic_dec(&root->fs_info->throttles);
570 wake_up(&root->fs_info->transaction_throttle);
572 mutex_lock(&root->fs_info->alloc_mutex);
573 num_bytes -= btrfs_root_used(&dirty->root->root_item);
574 bytes_used = btrfs_root_used(&root->root_item);
576 record_root_in_trans(root);
577 btrfs_set_root_used(&root->root_item,
578 bytes_used - num_bytes);
580 mutex_unlock(&root->fs_info->alloc_mutex);
582 ret = btrfs_del_root(trans, tree_root, &dirty->root->root_key);
587 mutex_unlock(&root->fs_info->drop_mutex);
589 spin_lock(&root->list_lock);
590 list_del_init(&dirty->root->dead_list);
591 if (!list_empty(&root->dead_list)) {
592 struct btrfs_root *oldest;
593 oldest = list_entry(root->dead_list.prev,
594 struct btrfs_root, dead_list);
595 max_useless = oldest->root_key.offset - 1;
597 max_useless = root->root_key.offset - 1;
599 spin_unlock(&root->list_lock);
601 nr = trans->blocks_used;
602 ret = btrfs_end_transaction(trans, tree_root);
605 ret = btrfs_remove_leaf_refs(root, max_useless);
608 free_extent_buffer(dirty->root->node);
612 btrfs_btree_balance_dirty(tree_root, nr);
618 static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
619 struct btrfs_fs_info *fs_info,
620 struct btrfs_pending_snapshot *pending)
622 struct btrfs_key key;
623 struct btrfs_root_item *new_root_item;
624 struct btrfs_root *tree_root = fs_info->tree_root;
625 struct btrfs_root *root = pending->root;
626 struct extent_buffer *tmp;
627 struct extent_buffer *old;
632 new_root_item = kmalloc(sizeof(*new_root_item), GFP_NOFS);
633 if (!new_root_item) {
637 ret = btrfs_find_free_objectid(trans, tree_root, 0, &objectid);
641 memcpy(new_root_item, &root->root_item, sizeof(*new_root_item));
643 key.objectid = objectid;
645 btrfs_set_key_type(&key, BTRFS_ROOT_ITEM_KEY);
647 old = btrfs_lock_root_node(root);
648 btrfs_cow_block(trans, root, old, NULL, 0, &old, 0);
650 btrfs_copy_root(trans, root, old, &tmp, objectid);
651 btrfs_tree_unlock(old);
652 free_extent_buffer(old);
654 btrfs_set_root_bytenr(new_root_item, tmp->start);
655 btrfs_set_root_level(new_root_item, btrfs_header_level(tmp));
656 ret = btrfs_insert_root(trans, root->fs_info->tree_root, &key,
658 btrfs_tree_unlock(tmp);
659 free_extent_buffer(tmp);
664 * insert the directory item
666 key.offset = (u64)-1;
667 namelen = strlen(pending->name);
668 ret = btrfs_insert_dir_item(trans, root->fs_info->tree_root,
669 pending->name, namelen,
670 root->fs_info->sb->s_root->d_inode->i_ino,
671 &key, BTRFS_FT_DIR, 0);
676 ret = btrfs_insert_inode_ref(trans, root->fs_info->tree_root,
677 pending->name, strlen(pending->name), objectid,
678 root->fs_info->sb->s_root->d_inode->i_ino, 0);
680 /* Invalidate existing dcache entry for new snapshot. */
681 btrfs_invalidate_dcache_root(root, pending->name, namelen);
684 kfree(new_root_item);
688 static noinline int create_pending_snapshots(struct btrfs_trans_handle *trans,
689 struct btrfs_fs_info *fs_info)
691 struct btrfs_pending_snapshot *pending;
692 struct list_head *head = &trans->transaction->pending_snapshots;
695 while(!list_empty(head)) {
696 pending = list_entry(head->next,
697 struct btrfs_pending_snapshot, list);
698 ret = create_pending_snapshot(trans, fs_info, pending);
700 list_del(&pending->list);
701 kfree(pending->name);
707 int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
708 struct btrfs_root *root)
710 unsigned long joined = 0;
711 unsigned long timeout = 1;
712 struct btrfs_transaction *cur_trans;
713 struct btrfs_transaction *prev_trans = NULL;
714 struct btrfs_root *chunk_root = root->fs_info->chunk_root;
715 struct list_head dirty_fs_roots;
716 struct extent_io_tree *pinned_copy;
720 INIT_LIST_HEAD(&dirty_fs_roots);
722 mutex_lock(&root->fs_info->trans_mutex);
723 if (trans->transaction->in_commit) {
724 cur_trans = trans->transaction;
725 trans->transaction->use_count++;
726 mutex_unlock(&root->fs_info->trans_mutex);
727 btrfs_end_transaction(trans, root);
729 ret = wait_for_commit(root, cur_trans);
732 mutex_lock(&root->fs_info->trans_mutex);
733 put_transaction(cur_trans);
734 mutex_unlock(&root->fs_info->trans_mutex);
739 pinned_copy = kmalloc(sizeof(*pinned_copy), GFP_NOFS);
743 extent_io_tree_init(pinned_copy,
744 root->fs_info->btree_inode->i_mapping, GFP_NOFS);
746 trans->transaction->in_commit = 1;
747 trans->transaction->blocked = 1;
748 cur_trans = trans->transaction;
749 if (cur_trans->list.prev != &root->fs_info->trans_list) {
750 prev_trans = list_entry(cur_trans->list.prev,
751 struct btrfs_transaction, list);
752 if (!prev_trans->commit_done) {
753 prev_trans->use_count++;
754 mutex_unlock(&root->fs_info->trans_mutex);
756 wait_for_commit(root, prev_trans);
758 mutex_lock(&root->fs_info->trans_mutex);
759 put_transaction(prev_trans);
764 joined = cur_trans->num_joined;
765 WARN_ON(cur_trans != trans->transaction);
766 prepare_to_wait(&cur_trans->writer_wait, &wait,
767 TASK_UNINTERRUPTIBLE);
769 if (cur_trans->num_writers > 1)
770 timeout = MAX_SCHEDULE_TIMEOUT;
774 mutex_unlock(&root->fs_info->trans_mutex);
776 schedule_timeout(timeout);
778 mutex_lock(&root->fs_info->trans_mutex);
779 finish_wait(&cur_trans->writer_wait, &wait);
780 } while (cur_trans->num_writers > 1 ||
781 (cur_trans->num_joined != joined));
783 ret = create_pending_snapshots(trans, root->fs_info);
786 WARN_ON(cur_trans != trans->transaction);
788 ret = add_dirty_roots(trans, &root->fs_info->fs_roots_radix,
792 ret = btrfs_commit_tree_roots(trans, root);
795 cur_trans = root->fs_info->running_transaction;
796 spin_lock(&root->fs_info->new_trans_lock);
797 root->fs_info->running_transaction = NULL;
798 spin_unlock(&root->fs_info->new_trans_lock);
799 btrfs_set_super_generation(&root->fs_info->super_copy,
801 btrfs_set_super_root(&root->fs_info->super_copy,
802 root->fs_info->tree_root->node->start);
803 btrfs_set_super_root_level(&root->fs_info->super_copy,
804 btrfs_header_level(root->fs_info->tree_root->node));
806 btrfs_set_super_chunk_root(&root->fs_info->super_copy,
807 chunk_root->node->start);
808 btrfs_set_super_chunk_root_level(&root->fs_info->super_copy,
809 btrfs_header_level(chunk_root->node));
810 memcpy(&root->fs_info->super_for_commit, &root->fs_info->super_copy,
811 sizeof(root->fs_info->super_copy));
813 btrfs_copy_pinned(root, pinned_copy);
815 trans->transaction->blocked = 0;
816 wake_up(&root->fs_info->transaction_throttle);
817 wake_up(&root->fs_info->transaction_wait);
819 mutex_unlock(&root->fs_info->trans_mutex);
820 ret = btrfs_write_and_wait_transaction(trans, root);
822 write_ctree_super(trans, root);
824 btrfs_finish_extent_commit(trans, root, pinned_copy);
825 mutex_lock(&root->fs_info->trans_mutex);
829 cur_trans->commit_done = 1;
830 root->fs_info->last_trans_committed = cur_trans->transid;
831 wake_up(&cur_trans->commit_wait);
832 put_transaction(cur_trans);
833 put_transaction(cur_trans);
835 list_splice_init(&dirty_fs_roots, &root->fs_info->dead_roots);
836 if (root->fs_info->closing)
837 list_splice_init(&root->fs_info->dead_roots, &dirty_fs_roots);
839 mutex_unlock(&root->fs_info->trans_mutex);
840 kmem_cache_free(btrfs_trans_handle_cachep, trans);
842 if (root->fs_info->closing) {
843 drop_dirty_roots(root->fs_info->tree_root, &dirty_fs_roots);
848 int btrfs_clean_old_snapshots(struct btrfs_root *root)
850 struct list_head dirty_roots;
851 INIT_LIST_HEAD(&dirty_roots);
853 mutex_lock(&root->fs_info->trans_mutex);
854 list_splice_init(&root->fs_info->dead_roots, &dirty_roots);
855 mutex_unlock(&root->fs_info->trans_mutex);
857 if (!list_empty(&dirty_roots)) {
858 drop_dirty_roots(root, &dirty_roots);