aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/qgroup.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-10-11 08:03:52 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-10-11 08:03:52 -0400
commit90d0c376f5ee1927327b267faf15bf970476f09e (patch)
treeb4ed1266ac45a34133e0e93b739067d5f5b33703 /fs/btrfs/qgroup.c
parentac0c49396d5ed9a33f08ce661635ac1bff80bb4f (diff)
parenta43bb39b5c710e79e921fb76341bacc418cfde78 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs
Pull btrfs updates from Chris Mason: "The largest set of changes here come from Miao Xie. He's cleaning up and improving read recovery/repair for raid, and has a number of related fixes. I've merged another set of fsync fixes from Filipe, and he's also improved the way we handle metadata write errors to make sure we force the FS readonly if things go wrong. Otherwise we have a collection of fixes and cleanups. Dave Sterba gets a cookie for removing the most lines (thanks Dave)" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs: (139 commits) btrfs: Fix compile error when CONFIG_SECURITY is not set. Btrfs: fix compiles when CONFIG_BTRFS_FS_RUN_SANITY_TESTS is off btrfs: Make btrfs handle security mount options internally to avoid losing security label. Btrfs: send, don't delay dir move if there's a new parent inode btrfs: add more superblock checks Btrfs: fix race in WAIT_SYNC ioctl Btrfs: be aware of btree inode write errors to avoid fs corruption Btrfs: remove redundant btrfs_verify_qgroup_counts declaration. btrfs: fix shadow warning on cmp Btrfs: fix compilation errors under DEBUG Btrfs: fix crash of btrfs_release_extent_buffer_page Btrfs: add missing end_page_writeback on submit_extent_page failure btrfs: Fix the wrong condition judgment about subset extent map Btrfs: fix build_backref_tree issue with multiple shared blocks Btrfs: cleanup error handling in build_backref_tree btrfs: move checks for DUMMY_ROOT into a helper btrfs: new define for the inline extent data start btrfs: kill extent_buffer_page helper btrfs: drop constant param from btrfs_release_extent_buffer_page btrfs: hide typecast to definition of BTRFS_SEND_TRANS_STUB ...
Diffstat (limited to 'fs/btrfs/qgroup.c')
-rw-r--r--fs/btrfs/qgroup.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index ded5c601d916..48b60dbf807f 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -539,10 +539,9 @@ static int add_qgroup_item(struct btrfs_trans_handle *trans,
539 struct extent_buffer *leaf; 539 struct extent_buffer *leaf;
540 struct btrfs_key key; 540 struct btrfs_key key;
541 541
542#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS 542 if (btrfs_test_is_dummy_root(quota_root))
543 if (unlikely(test_bit(BTRFS_ROOT_DUMMY_ROOT, &quota_root->state)))
544 return 0; 543 return 0;
545#endif 544
546 path = btrfs_alloc_path(); 545 path = btrfs_alloc_path();
547 if (!path) 546 if (!path)
548 return -ENOMEM; 547 return -ENOMEM;
@@ -551,9 +550,15 @@ static int add_qgroup_item(struct btrfs_trans_handle *trans,
551 key.type = BTRFS_QGROUP_INFO_KEY; 550 key.type = BTRFS_QGROUP_INFO_KEY;
552 key.offset = qgroupid; 551 key.offset = qgroupid;
553 552
553 /*
554 * Avoid a transaction abort by catching -EEXIST here. In that
555 * case, we proceed by re-initializing the existing structure
556 * on disk.
557 */
558
554 ret = btrfs_insert_empty_item(trans, quota_root, path, &key, 559 ret = btrfs_insert_empty_item(trans, quota_root, path, &key,
555 sizeof(*qgroup_info)); 560 sizeof(*qgroup_info));
556 if (ret) 561 if (ret && ret != -EEXIST)
557 goto out; 562 goto out;
558 563
559 leaf = path->nodes[0]; 564 leaf = path->nodes[0];
@@ -572,7 +577,7 @@ static int add_qgroup_item(struct btrfs_trans_handle *trans,
572 key.type = BTRFS_QGROUP_LIMIT_KEY; 577 key.type = BTRFS_QGROUP_LIMIT_KEY;
573 ret = btrfs_insert_empty_item(trans, quota_root, path, &key, 578 ret = btrfs_insert_empty_item(trans, quota_root, path, &key,
574 sizeof(*qgroup_limit)); 579 sizeof(*qgroup_limit));
575 if (ret) 580 if (ret && ret != -EEXIST)
576 goto out; 581 goto out;
577 582
578 leaf = path->nodes[0]; 583 leaf = path->nodes[0];
@@ -692,10 +697,9 @@ static int update_qgroup_info_item(struct btrfs_trans_handle *trans,
692 int ret; 697 int ret;
693 int slot; 698 int slot;
694 699
695#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS 700 if (btrfs_test_is_dummy_root(root))
696 if (unlikely(test_bit(BTRFS_ROOT_DUMMY_ROOT, &root->state)))
697 return 0; 701 return 0;
698#endif 702
699 key.objectid = 0; 703 key.objectid = 0;
700 key.type = BTRFS_QGROUP_INFO_KEY; 704 key.type = BTRFS_QGROUP_INFO_KEY;
701 key.offset = qgroup->qgroupid; 705 key.offset = qgroup->qgroupid;
@@ -1335,6 +1339,8 @@ int btrfs_qgroup_record_ref(struct btrfs_trans_handle *trans,
1335 INIT_LIST_HEAD(&oper->elem.list); 1339 INIT_LIST_HEAD(&oper->elem.list);
1336 oper->elem.seq = 0; 1340 oper->elem.seq = 0;
1337 1341
1342 trace_btrfs_qgroup_record_ref(oper);
1343
1338 if (type == BTRFS_QGROUP_OPER_SUB_SUBTREE) { 1344 if (type == BTRFS_QGROUP_OPER_SUB_SUBTREE) {
1339 /* 1345 /*
1340 * If any operation for this bytenr/ref_root combo 1346 * If any operation for this bytenr/ref_root combo
@@ -2077,6 +2083,8 @@ static int btrfs_qgroup_account(struct btrfs_trans_handle *trans,
2077 2083
2078 ASSERT(is_fstree(oper->ref_root)); 2084 ASSERT(is_fstree(oper->ref_root));
2079 2085
2086 trace_btrfs_qgroup_account(oper);
2087
2080 switch (oper->type) { 2088 switch (oper->type) {
2081 case BTRFS_QGROUP_OPER_ADD_EXCL: 2089 case BTRFS_QGROUP_OPER_ADD_EXCL:
2082 case BTRFS_QGROUP_OPER_SUB_EXCL: 2090 case BTRFS_QGROUP_OPER_SUB_EXCL:
@@ -2237,7 +2245,6 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans,
2237 if (srcid) { 2245 if (srcid) {
2238 struct btrfs_root *srcroot; 2246 struct btrfs_root *srcroot;
2239 struct btrfs_key srckey; 2247 struct btrfs_key srckey;
2240 int srcroot_level;
2241 2248
2242 srckey.objectid = srcid; 2249 srckey.objectid = srcid;
2243 srckey.type = BTRFS_ROOT_ITEM_KEY; 2250 srckey.type = BTRFS_ROOT_ITEM_KEY;
@@ -2249,8 +2256,7 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans,
2249 } 2256 }
2250 2257
2251 rcu_read_lock(); 2258 rcu_read_lock();
2252 srcroot_level = btrfs_header_level(srcroot->node); 2259 level_size = srcroot->nodesize;
2253 level_size = btrfs_level_size(srcroot, srcroot_level);
2254 rcu_read_unlock(); 2260 rcu_read_unlock();
2255 } 2261 }
2256 2262
@@ -2566,7 +2572,7 @@ qgroup_rescan_leaf(struct btrfs_fs_info *fs_info, struct btrfs_path *path,
2566 found.type != BTRFS_METADATA_ITEM_KEY) 2572 found.type != BTRFS_METADATA_ITEM_KEY)
2567 continue; 2573 continue;
2568 if (found.type == BTRFS_METADATA_ITEM_KEY) 2574 if (found.type == BTRFS_METADATA_ITEM_KEY)
2569 num_bytes = fs_info->extent_root->leafsize; 2575 num_bytes = fs_info->extent_root->nodesize;
2570 else 2576 else
2571 num_bytes = found.offset; 2577 num_bytes = found.offset;
2572 2578