aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-09-11 15:53:37 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:07 -0400
commit3a5f1d458ad1610a06e38f0be2fbc6ac215439c0 (patch)
tree00fc015c5b494c7307d5dcae61b2d5d5ed6bf587 /fs/btrfs
parent49eb7e46d47ea72a9bd2a5f8cedb04f5159cc277 (diff)
Btrfs: Optimize btree walking while logging inodes
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/disk-io.c2
-rw-r--r--fs/btrfs/tree-log.c25
2 files changed, 20 insertions, 7 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index ecb74b720262..7c06eb4ecfdd 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1497,7 +1497,7 @@ struct btrfs_root *open_ctree(struct super_block *sb,
1497 * low idle thresh 1497 * low idle thresh
1498 */ 1498 */
1499 fs_info->endio_workers.idle_thresh = 4; 1499 fs_info->endio_workers.idle_thresh = 4;
1500 fs_info->endio_write_workers.idle_thresh = 4; 1500 fs_info->endio_write_workers.idle_thresh = 64;
1501 1501
1502 btrfs_start_workers(&fs_info->workers, 1); 1502 btrfs_start_workers(&fs_info->workers, 1);
1503 btrfs_start_workers(&fs_info->submit_workers, 1); 1503 btrfs_start_workers(&fs_info->submit_workers, 1);
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 5d49a701bdcd..f43ee33ec2dc 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -1982,7 +1982,6 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
1982 DEFINE_WAIT(wait); 1982 DEFINE_WAIT(wait);
1983 prepare_to_wait(&log->fs_info->tree_log_wait, &wait, 1983 prepare_to_wait(&log->fs_info->tree_log_wait, &wait,
1984 TASK_UNINTERRUPTIBLE); 1984 TASK_UNINTERRUPTIBLE);
1985 batch = log->fs_info->tree_log_batch;
1986 mutex_unlock(&log->fs_info->tree_log_mutex); 1985 mutex_unlock(&log->fs_info->tree_log_mutex);
1987 if (atomic_read(&log->fs_info->tree_log_writers)) 1986 if (atomic_read(&log->fs_info->tree_log_writers))
1988 schedule(); 1987 schedule();
@@ -2024,8 +2023,7 @@ out:
2024 2023
2025} 2024}
2026 2025
2027/* 2026/* * free all the extents used by the tree log. This should be called
2028 * free all the extents used by the tree log. This should be called
2029 * at commit time of the full transaction 2027 * at commit time of the full transaction
2030 */ 2028 */
2031int btrfs_free_log(struct btrfs_trans_handle *trans, struct btrfs_root *root) 2029int btrfs_free_log(struct btrfs_trans_handle *trans, struct btrfs_root *root)
@@ -2107,6 +2105,9 @@ int btrfs_del_dir_entries_in_log(struct btrfs_trans_handle *trans,
2107 int ret; 2105 int ret;
2108 int bytes_del = 0; 2106 int bytes_del = 0;
2109 2107
2108 if (BTRFS_I(dir)->logged_trans < trans->transid)
2109 return 0;
2110
2110 ret = join_running_log_trans(root); 2111 ret = join_running_log_trans(root);
2111 if (ret) 2112 if (ret)
2112 return 0; 2113 return 0;
@@ -2178,6 +2179,9 @@ int btrfs_del_inode_ref_in_log(struct btrfs_trans_handle *trans,
2178 u64 index; 2179 u64 index;
2179 int ret; 2180 int ret;
2180 2181
2182 if (BTRFS_I(inode)->logged_trans < trans->transid)
2183 return 0;
2184
2181 ret = join_running_log_trans(root); 2185 ret = join_running_log_trans(root);
2182 if (ret) 2186 if (ret)
2183 return 0; 2187 return 0;
@@ -2484,6 +2488,7 @@ static int __btrfs_log_inode(struct btrfs_trans_handle *trans,
2484 struct btrfs_inode_item *inode_item; 2488 struct btrfs_inode_item *inode_item;
2485 u32 size; 2489 u32 size;
2486 int ret; 2490 int ret;
2491 int nritems;
2487 2492
2488 log = root->log_root; 2493 log = root->log_root;
2489 2494
@@ -2541,12 +2546,11 @@ static int __btrfs_log_inode(struct btrfs_trans_handle *trans,
2541 path, 0, trans->transid); 2546 path, 0, trans->transid);
2542 if (ret != 0) 2547 if (ret != 0)
2543 break; 2548 break;
2544 2549again:
2545 if (min_key.objectid != inode->i_ino) 2550 if (min_key.objectid != inode->i_ino)
2546 break; 2551 break;
2547 if (min_key.type > max_key.type) 2552 if (min_key.type > max_key.type)
2548 break; 2553 break;
2549
2550 src = path->nodes[0]; 2554 src = path->nodes[0];
2551 size = btrfs_item_size_nr(src, path->slots[0]); 2555 size = btrfs_item_size_nr(src, path->slots[0]);
2552 ret = btrfs_insert_empty_item(trans, log, dst_path, &min_key, 2556 ret = btrfs_insert_empty_item(trans, log, dst_path, &min_key,
@@ -2606,9 +2610,17 @@ static int __btrfs_log_inode(struct btrfs_trans_handle *trans,
2606 } 2610 }
2607 2611
2608 btrfs_mark_buffer_dirty(dst_path->nodes[0]); 2612 btrfs_mark_buffer_dirty(dst_path->nodes[0]);
2609 btrfs_release_path(root, path);
2610 btrfs_release_path(log, dst_path); 2613 btrfs_release_path(log, dst_path);
2611 2614
2615 nritems = btrfs_header_nritems(path->nodes[0]);
2616 path->slots[0]++;
2617 if (path->slots[0] < nritems) {
2618 btrfs_item_key_to_cpu(path->nodes[0], &min_key,
2619 path->slots[0]);
2620 goto again;
2621 }
2622 btrfs_release_path(root, path);
2623
2612 if (min_key.offset < (u64)-1) 2624 if (min_key.offset < (u64)-1)
2613 min_key.offset++; 2625 min_key.offset++;
2614 else if (min_key.type < (u8)-1) 2626 else if (min_key.type < (u8)-1)
@@ -2626,6 +2638,7 @@ static int __btrfs_log_inode(struct btrfs_trans_handle *trans,
2626 ret = log_directory_changes(trans, root, inode, path, dst_path); 2638 ret = log_directory_changes(trans, root, inode, path, dst_path);
2627 BUG_ON(ret); 2639 BUG_ON(ret);
2628 } 2640 }
2641 BTRFS_I(inode)->logged_trans = trans->transid;
2629 mutex_unlock(&BTRFS_I(inode)->log_mutex); 2642 mutex_unlock(&BTRFS_I(inode)->log_mutex);
2630 2643
2631 btrfs_free_path(path); 2644 btrfs_free_path(path);