diff options
Diffstat (limited to 'fs/btrfs/qgroup.c')
-rw-r--r-- | fs/btrfs/qgroup.c | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index 4e6ef490619e..472302a2d745 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c | |||
@@ -301,16 +301,16 @@ int btrfs_read_qgroup_config(struct btrfs_fs_info *fs_info) | |||
301 | 301 | ||
302 | if (btrfs_qgroup_status_version(l, ptr) != | 302 | if (btrfs_qgroup_status_version(l, ptr) != |
303 | BTRFS_QGROUP_STATUS_VERSION) { | 303 | BTRFS_QGROUP_STATUS_VERSION) { |
304 | printk(KERN_ERR | 304 | btrfs_err(fs_info, |
305 | "btrfs: old qgroup version, quota disabled\n"); | 305 | "old qgroup version, quota disabled"); |
306 | goto out; | 306 | goto out; |
307 | } | 307 | } |
308 | if (btrfs_qgroup_status_generation(l, ptr) != | 308 | if (btrfs_qgroup_status_generation(l, ptr) != |
309 | fs_info->generation) { | 309 | fs_info->generation) { |
310 | flags |= BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT; | 310 | flags |= BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT; |
311 | printk(KERN_ERR | 311 | btrfs_err(fs_info, |
312 | "btrfs: qgroup generation mismatch, " | 312 | "qgroup generation mismatch, " |
313 | "marked as inconsistent\n"); | 313 | "marked as inconsistent"); |
314 | } | 314 | } |
315 | fs_info->qgroup_flags = btrfs_qgroup_status_flags(l, | 315 | fs_info->qgroup_flags = btrfs_qgroup_status_flags(l, |
316 | ptr); | 316 | ptr); |
@@ -325,7 +325,7 @@ int btrfs_read_qgroup_config(struct btrfs_fs_info *fs_info) | |||
325 | qgroup = find_qgroup_rb(fs_info, found_key.offset); | 325 | qgroup = find_qgroup_rb(fs_info, found_key.offset); |
326 | if ((qgroup && found_key.type == BTRFS_QGROUP_INFO_KEY) || | 326 | if ((qgroup && found_key.type == BTRFS_QGROUP_INFO_KEY) || |
327 | (!qgroup && found_key.type == BTRFS_QGROUP_LIMIT_KEY)) { | 327 | (!qgroup && found_key.type == BTRFS_QGROUP_LIMIT_KEY)) { |
328 | printk(KERN_ERR "btrfs: inconsitent qgroup config\n"); | 328 | btrfs_err(fs_info, "inconsitent qgroup config"); |
329 | flags |= BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT; | 329 | flags |= BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT; |
330 | } | 330 | } |
331 | if (!qgroup) { | 331 | if (!qgroup) { |
@@ -396,8 +396,8 @@ next1: | |||
396 | ret = add_relation_rb(fs_info, found_key.objectid, | 396 | ret = add_relation_rb(fs_info, found_key.objectid, |
397 | found_key.offset); | 397 | found_key.offset); |
398 | if (ret == -ENOENT) { | 398 | if (ret == -ENOENT) { |
399 | printk(KERN_WARNING | 399 | btrfs_warn(fs_info, |
400 | "btrfs: orphan qgroup relation 0x%llx->0x%llx\n", | 400 | "orphan qgroup relation 0x%llx->0x%llx", |
401 | found_key.objectid, found_key.offset); | 401 | found_key.objectid, found_key.offset); |
402 | ret = 0; /* ignore the error */ | 402 | ret = 0; /* ignore the error */ |
403 | } | 403 | } |
@@ -644,8 +644,7 @@ static int update_qgroup_limit_item(struct btrfs_trans_handle *trans, | |||
644 | 644 | ||
645 | l = path->nodes[0]; | 645 | l = path->nodes[0]; |
646 | slot = path->slots[0]; | 646 | slot = path->slots[0]; |
647 | qgroup_limit = btrfs_item_ptr(l, path->slots[0], | 647 | qgroup_limit = btrfs_item_ptr(l, slot, struct btrfs_qgroup_limit_item); |
648 | struct btrfs_qgroup_limit_item); | ||
649 | btrfs_set_qgroup_limit_flags(l, qgroup_limit, flags); | 648 | btrfs_set_qgroup_limit_flags(l, qgroup_limit, flags); |
650 | btrfs_set_qgroup_limit_max_rfer(l, qgroup_limit, max_rfer); | 649 | btrfs_set_qgroup_limit_max_rfer(l, qgroup_limit, max_rfer); |
651 | btrfs_set_qgroup_limit_max_excl(l, qgroup_limit, max_excl); | 650 | btrfs_set_qgroup_limit_max_excl(l, qgroup_limit, max_excl); |
@@ -687,8 +686,7 @@ static int update_qgroup_info_item(struct btrfs_trans_handle *trans, | |||
687 | 686 | ||
688 | l = path->nodes[0]; | 687 | l = path->nodes[0]; |
689 | slot = path->slots[0]; | 688 | slot = path->slots[0]; |
690 | qgroup_info = btrfs_item_ptr(l, path->slots[0], | 689 | qgroup_info = btrfs_item_ptr(l, slot, struct btrfs_qgroup_info_item); |
691 | struct btrfs_qgroup_info_item); | ||
692 | btrfs_set_qgroup_info_generation(l, qgroup_info, trans->transid); | 690 | btrfs_set_qgroup_info_generation(l, qgroup_info, trans->transid); |
693 | btrfs_set_qgroup_info_rfer(l, qgroup_info, qgroup->rfer); | 691 | btrfs_set_qgroup_info_rfer(l, qgroup_info, qgroup->rfer); |
694 | btrfs_set_qgroup_info_rfer_cmpr(l, qgroup_info, qgroup->rfer_cmpr); | 692 | btrfs_set_qgroup_info_rfer_cmpr(l, qgroup_info, qgroup->rfer_cmpr); |
@@ -1161,7 +1159,7 @@ int btrfs_limit_qgroup(struct btrfs_trans_handle *trans, | |||
1161 | limit->rsv_excl); | 1159 | limit->rsv_excl); |
1162 | if (ret) { | 1160 | if (ret) { |
1163 | fs_info->qgroup_flags |= BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT; | 1161 | fs_info->qgroup_flags |= BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT; |
1164 | printk(KERN_INFO "unable to update quota limit for %llu\n", | 1162 | btrfs_info(fs_info, "unable to update quota limit for %llu", |
1165 | qgroupid); | 1163 | qgroupid); |
1166 | } | 1164 | } |
1167 | 1165 | ||
@@ -1349,7 +1347,6 @@ int btrfs_qgroup_account_ref(struct btrfs_trans_handle *trans, | |||
1349 | struct btrfs_delayed_ref_node *node, | 1347 | struct btrfs_delayed_ref_node *node, |
1350 | struct btrfs_delayed_extent_op *extent_op) | 1348 | struct btrfs_delayed_extent_op *extent_op) |
1351 | { | 1349 | { |
1352 | struct btrfs_key ins; | ||
1353 | struct btrfs_root *quota_root; | 1350 | struct btrfs_root *quota_root; |
1354 | u64 ref_root; | 1351 | u64 ref_root; |
1355 | struct btrfs_qgroup *qgroup; | 1352 | struct btrfs_qgroup *qgroup; |
@@ -1363,10 +1360,6 @@ int btrfs_qgroup_account_ref(struct btrfs_trans_handle *trans, | |||
1363 | 1360 | ||
1364 | BUG_ON(!fs_info->quota_root); | 1361 | BUG_ON(!fs_info->quota_root); |
1365 | 1362 | ||
1366 | ins.objectid = node->bytenr; | ||
1367 | ins.offset = node->num_bytes; | ||
1368 | ins.type = BTRFS_EXTENT_ITEM_KEY; | ||
1369 | |||
1370 | if (node->type == BTRFS_TREE_BLOCK_REF_KEY || | 1363 | if (node->type == BTRFS_TREE_BLOCK_REF_KEY || |
1371 | node->type == BTRFS_SHARED_BLOCK_REF_KEY) { | 1364 | node->type == BTRFS_SHARED_BLOCK_REF_KEY) { |
1372 | struct btrfs_delayed_tree_ref *ref; | 1365 | struct btrfs_delayed_tree_ref *ref; |
@@ -1840,7 +1833,9 @@ void assert_qgroups_uptodate(struct btrfs_trans_handle *trans) | |||
1840 | { | 1833 | { |
1841 | if (list_empty(&trans->qgroup_ref_list) && !trans->delayed_ref_elem.seq) | 1834 | if (list_empty(&trans->qgroup_ref_list) && !trans->delayed_ref_elem.seq) |
1842 | return; | 1835 | return; |
1843 | pr_err("btrfs: qgroups not uptodate in trans handle %p: list is%s empty, seq is %#x.%x\n", | 1836 | btrfs_err(trans->root->fs_info, |
1837 | "qgroups not uptodate in trans handle %p: list is%s empty, " | ||
1838 | "seq is %#x.%x", | ||
1844 | trans, list_empty(&trans->qgroup_ref_list) ? "" : " not", | 1839 | trans, list_empty(&trans->qgroup_ref_list) ? "" : " not", |
1845 | (u32)(trans->delayed_ref_elem.seq >> 32), | 1840 | (u32)(trans->delayed_ref_elem.seq >> 32), |
1846 | (u32)trans->delayed_ref_elem.seq); | 1841 | (u32)trans->delayed_ref_elem.seq); |
@@ -1902,9 +1897,17 @@ qgroup_rescan_leaf(struct btrfs_fs_info *fs_info, struct btrfs_path *path, | |||
1902 | mutex_unlock(&fs_info->qgroup_rescan_lock); | 1897 | mutex_unlock(&fs_info->qgroup_rescan_lock); |
1903 | 1898 | ||
1904 | for (; slot < btrfs_header_nritems(scratch_leaf); ++slot) { | 1899 | for (; slot < btrfs_header_nritems(scratch_leaf); ++slot) { |
1900 | u64 num_bytes; | ||
1901 | |||
1905 | btrfs_item_key_to_cpu(scratch_leaf, &found, slot); | 1902 | btrfs_item_key_to_cpu(scratch_leaf, &found, slot); |
1906 | if (found.type != BTRFS_EXTENT_ITEM_KEY) | 1903 | if (found.type != BTRFS_EXTENT_ITEM_KEY && |
1904 | found.type != BTRFS_METADATA_ITEM_KEY) | ||
1907 | continue; | 1905 | continue; |
1906 | if (found.type == BTRFS_METADATA_ITEM_KEY) | ||
1907 | num_bytes = fs_info->extent_root->leafsize; | ||
1908 | else | ||
1909 | num_bytes = found.offset; | ||
1910 | |||
1908 | ret = btrfs_find_all_roots(trans, fs_info, found.objectid, | 1911 | ret = btrfs_find_all_roots(trans, fs_info, found.objectid, |
1909 | tree_mod_seq_elem.seq, &roots); | 1912 | tree_mod_seq_elem.seq, &roots); |
1910 | if (ret < 0) | 1913 | if (ret < 0) |
@@ -1949,12 +1952,12 @@ qgroup_rescan_leaf(struct btrfs_fs_info *fs_info, struct btrfs_path *path, | |||
1949 | struct btrfs_qgroup_list *glist; | 1952 | struct btrfs_qgroup_list *glist; |
1950 | 1953 | ||
1951 | qg = (struct btrfs_qgroup *)(uintptr_t) unode->aux; | 1954 | qg = (struct btrfs_qgroup *)(uintptr_t) unode->aux; |
1952 | qg->rfer += found.offset; | 1955 | qg->rfer += num_bytes; |
1953 | qg->rfer_cmpr += found.offset; | 1956 | qg->rfer_cmpr += num_bytes; |
1954 | WARN_ON(qg->tag >= seq); | 1957 | WARN_ON(qg->tag >= seq); |
1955 | if (qg->refcnt - seq == roots->nnodes) { | 1958 | if (qg->refcnt - seq == roots->nnodes) { |
1956 | qg->excl += found.offset; | 1959 | qg->excl += num_bytes; |
1957 | qg->excl_cmpr += found.offset; | 1960 | qg->excl_cmpr += num_bytes; |
1958 | } | 1961 | } |
1959 | qgroup_dirty(fs_info, qg); | 1962 | qgroup_dirty(fs_info, qg); |
1960 | 1963 | ||
@@ -2037,10 +2040,10 @@ out: | |||
2037 | mutex_unlock(&fs_info->qgroup_rescan_lock); | 2040 | mutex_unlock(&fs_info->qgroup_rescan_lock); |
2038 | 2041 | ||
2039 | if (err >= 0) { | 2042 | if (err >= 0) { |
2040 | pr_info("btrfs: qgroup scan completed%s\n", | 2043 | btrfs_info(fs_info, "qgroup scan completed%s", |
2041 | err == 2 ? " (inconsistency flag cleared)" : ""); | 2044 | err == 2 ? " (inconsistency flag cleared)" : ""); |
2042 | } else { | 2045 | } else { |
2043 | pr_err("btrfs: qgroup scan failed with %d\n", err); | 2046 | btrfs_err(fs_info, "qgroup scan failed with %d", err); |
2044 | } | 2047 | } |
2045 | 2048 | ||
2046 | complete_all(&fs_info->qgroup_rescan_completion); | 2049 | complete_all(&fs_info->qgroup_rescan_completion); |
@@ -2096,7 +2099,7 @@ qgroup_rescan_init(struct btrfs_fs_info *fs_info, u64 progress_objectid, | |||
2096 | 2099 | ||
2097 | if (ret) { | 2100 | if (ret) { |
2098 | err: | 2101 | err: |
2099 | pr_info("btrfs: qgroup_rescan_init failed with %d\n", ret); | 2102 | btrfs_info(fs_info, "qgroup_rescan_init failed with %d", ret); |
2100 | return ret; | 2103 | return ret; |
2101 | } | 2104 | } |
2102 | 2105 | ||