aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2009-06-16 20:24:53 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2009-06-16 20:24:53 -0400
commit492b057c426e4aa747484958e18e9da29003985d (patch)
tree34e08c24618688d8bcc190523028b5f94cce0c0b /fs/btrfs
parent313485175da221c388f6a8ecf4c30062ba9bea17 (diff)
parent300df7dc89cc276377fc020704e34875d5c473b6 (diff)
Merge commit 'origin/master' into next
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/disk-io.c26
-rw-r--r--fs/btrfs/transaction.c12
2 files changed, 27 insertions, 11 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 0d50d49d990a..d28d29c95f7c 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -42,6 +42,8 @@
42static struct extent_io_ops btree_extent_io_ops; 42static struct extent_io_ops btree_extent_io_ops;
43static void end_workqueue_fn(struct btrfs_work *work); 43static void end_workqueue_fn(struct btrfs_work *work);
44 44
45static atomic_t btrfs_bdi_num = ATOMIC_INIT(0);
46
45/* 47/*
46 * end_io_wq structs are used to do processing in task context when an IO is 48 * end_io_wq structs are used to do processing in task context when an IO is
47 * complete. This is used during reads to verify checksums, and it is used 49 * complete. This is used during reads to verify checksums, and it is used
@@ -1342,12 +1344,25 @@ static void btrfs_unplug_io_fn(struct backing_dev_info *bdi, struct page *page)
1342 free_extent_map(em); 1344 free_extent_map(em);
1343} 1345}
1344 1346
1347/*
1348 * If this fails, caller must call bdi_destroy() to get rid of the
1349 * bdi again.
1350 */
1345static int setup_bdi(struct btrfs_fs_info *info, struct backing_dev_info *bdi) 1351static int setup_bdi(struct btrfs_fs_info *info, struct backing_dev_info *bdi)
1346{ 1352{
1347 bdi_init(bdi); 1353 int err;
1354
1355 bdi->capabilities = BDI_CAP_MAP_COPY;
1356 err = bdi_init(bdi);
1357 if (err)
1358 return err;
1359
1360 err = bdi_register(bdi, NULL, "btrfs-%d",
1361 atomic_inc_return(&btrfs_bdi_num));
1362 if (err)
1363 return err;
1364
1348 bdi->ra_pages = default_backing_dev_info.ra_pages; 1365 bdi->ra_pages = default_backing_dev_info.ra_pages;
1349 bdi->state = 0;
1350 bdi->capabilities = default_backing_dev_info.capabilities;
1351 bdi->unplug_io_fn = btrfs_unplug_io_fn; 1366 bdi->unplug_io_fn = btrfs_unplug_io_fn;
1352 bdi->unplug_io_data = info; 1367 bdi->unplug_io_data = info;
1353 bdi->congested_fn = btrfs_congested_fn; 1368 bdi->congested_fn = btrfs_congested_fn;
@@ -1569,7 +1584,8 @@ struct btrfs_root *open_ctree(struct super_block *sb,
1569 fs_info->sb = sb; 1584 fs_info->sb = sb;
1570 fs_info->max_extent = (u64)-1; 1585 fs_info->max_extent = (u64)-1;
1571 fs_info->max_inline = 8192 * 1024; 1586 fs_info->max_inline = 8192 * 1024;
1572 setup_bdi(fs_info, &fs_info->bdi); 1587 if (setup_bdi(fs_info, &fs_info->bdi))
1588 goto fail_bdi;
1573 fs_info->btree_inode = new_inode(sb); 1589 fs_info->btree_inode = new_inode(sb);
1574 fs_info->btree_inode->i_ino = 1; 1590 fs_info->btree_inode->i_ino = 1;
1575 fs_info->btree_inode->i_nlink = 1; 1591 fs_info->btree_inode->i_nlink = 1;
@@ -1946,8 +1962,8 @@ fail_iput:
1946 1962
1947 btrfs_close_devices(fs_info->fs_devices); 1963 btrfs_close_devices(fs_info->fs_devices);
1948 btrfs_mapping_tree_free(&fs_info->mapping_tree); 1964 btrfs_mapping_tree_free(&fs_info->mapping_tree);
1965fail_bdi:
1949 bdi_destroy(&fs_info->bdi); 1966 bdi_destroy(&fs_info->bdi);
1950
1951fail: 1967fail:
1952 kfree(extent_root); 1968 kfree(extent_root);
1953 kfree(tree_root); 1969 kfree(tree_root);
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 2e177d7f4bb9..4e83457ea253 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -543,13 +543,13 @@ static noinline int commit_fs_roots(struct btrfs_trans_handle *trans,
543 btrfs_free_log(trans, root); 543 btrfs_free_log(trans, root);
544 btrfs_update_reloc_root(trans, root); 544 btrfs_update_reloc_root(trans, root);
545 545
546 if (root->commit_root == root->node) 546 if (root->commit_root != root->node) {
547 continue; 547 free_extent_buffer(root->commit_root);
548 548 root->commit_root = btrfs_root_node(root);
549 free_extent_buffer(root->commit_root); 549 btrfs_set_root_node(&root->root_item,
550 root->commit_root = btrfs_root_node(root); 550 root->node);
551 }
551 552
552 btrfs_set_root_node(&root->root_item, root->node);
553 err = btrfs_update_root(trans, fs_info->tree_root, 553 err = btrfs_update_root(trans, fs_info->tree_root,
554 &root->root_key, 554 &root->root_key,
555 &root->root_item); 555 &root->root_item);