diff options
author | Josef Bacik <josef@redhat.com> | 2012-01-10 10:31:31 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2012-01-16 15:29:43 -0500 |
commit | 8c2a3ca20f6233677ac3222c6506174010eb414f (patch) | |
tree | 88d1105c665d355b363929557ed0c5489795e348 /fs/btrfs/delayed-inode.c | |
parent | 90290e19820e3323ce6b9c2888eeb68bf29c278b (diff) |
Btrfs: space leak tracepoints
This in addition to a script in my btrfs-tracing tree will help track down space
leaks when we're getting space left over in block groups on umount. Thanks,
Signed-off-by: Josef Bacik <josef@redhat.com>
Diffstat (limited to 'fs/btrfs/delayed-inode.c')
-rw-r--r-- | fs/btrfs/delayed-inode.c | 45 |
1 files changed, 33 insertions, 12 deletions
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c index 9c1eccc2c503..fe4cd0f1cef1 100644 --- a/fs/btrfs/delayed-inode.c +++ b/fs/btrfs/delayed-inode.c | |||
@@ -595,8 +595,12 @@ static int btrfs_delayed_item_reserve_metadata(struct btrfs_trans_handle *trans, | |||
595 | 595 | ||
596 | num_bytes = btrfs_calc_trans_metadata_size(root, 1); | 596 | num_bytes = btrfs_calc_trans_metadata_size(root, 1); |
597 | ret = btrfs_block_rsv_migrate(src_rsv, dst_rsv, num_bytes); | 597 | ret = btrfs_block_rsv_migrate(src_rsv, dst_rsv, num_bytes); |
598 | if (!ret) | 598 | if (!ret) { |
599 | trace_btrfs_space_reservation(root->fs_info, "delayed_item", | ||
600 | item->key.objectid, | ||
601 | num_bytes, 1); | ||
599 | item->bytes_reserved = num_bytes; | 602 | item->bytes_reserved = num_bytes; |
603 | } | ||
600 | 604 | ||
601 | return ret; | 605 | return ret; |
602 | } | 606 | } |
@@ -610,6 +614,9 @@ static void btrfs_delayed_item_release_metadata(struct btrfs_root *root, | |||
610 | return; | 614 | return; |
611 | 615 | ||
612 | rsv = &root->fs_info->delayed_block_rsv; | 616 | rsv = &root->fs_info->delayed_block_rsv; |
617 | trace_btrfs_space_reservation(root->fs_info, "delayed_item", | ||
618 | item->key.objectid, item->bytes_reserved, | ||
619 | 0); | ||
613 | btrfs_block_rsv_release(root, rsv, | 620 | btrfs_block_rsv_release(root, rsv, |
614 | item->bytes_reserved); | 621 | item->bytes_reserved); |
615 | } | 622 | } |
@@ -624,7 +631,7 @@ static int btrfs_delayed_inode_reserve_metadata( | |||
624 | struct btrfs_block_rsv *dst_rsv; | 631 | struct btrfs_block_rsv *dst_rsv; |
625 | u64 num_bytes; | 632 | u64 num_bytes; |
626 | int ret; | 633 | int ret; |
627 | int release = false; | 634 | bool release = false; |
628 | 635 | ||
629 | src_rsv = trans->block_rsv; | 636 | src_rsv = trans->block_rsv; |
630 | dst_rsv = &root->fs_info->delayed_block_rsv; | 637 | dst_rsv = &root->fs_info->delayed_block_rsv; |
@@ -651,8 +658,13 @@ static int btrfs_delayed_inode_reserve_metadata( | |||
651 | */ | 658 | */ |
652 | if (ret == -EAGAIN) | 659 | if (ret == -EAGAIN) |
653 | ret = -ENOSPC; | 660 | ret = -ENOSPC; |
654 | if (!ret) | 661 | if (!ret) { |
655 | node->bytes_reserved = num_bytes; | 662 | node->bytes_reserved = num_bytes; |
663 | trace_btrfs_space_reservation(root->fs_info, | ||
664 | "delayed_inode", | ||
665 | btrfs_ino(inode), | ||
666 | num_bytes, 1); | ||
667 | } | ||
656 | return ret; | 668 | return ret; |
657 | } else if (src_rsv == &root->fs_info->delalloc_block_rsv) { | 669 | } else if (src_rsv == &root->fs_info->delalloc_block_rsv) { |
658 | spin_lock(&BTRFS_I(inode)->lock); | 670 | spin_lock(&BTRFS_I(inode)->lock); |
@@ -707,11 +719,17 @@ out: | |||
707 | * reservation here. I think it may be time for a documentation page on | 719 | * reservation here. I think it may be time for a documentation page on |
708 | * how block rsvs. work. | 720 | * how block rsvs. work. |
709 | */ | 721 | */ |
710 | if (!ret) | 722 | if (!ret) { |
723 | trace_btrfs_space_reservation(root->fs_info, "delayed_inode", | ||
724 | btrfs_ino(inode), num_bytes, 1); | ||
711 | node->bytes_reserved = num_bytes; | 725 | node->bytes_reserved = num_bytes; |
726 | } | ||
712 | 727 | ||
713 | if (release) | 728 | if (release) { |
729 | trace_btrfs_space_reservation(root->fs_info, "delalloc", | ||
730 | btrfs_ino(inode), num_bytes, 0); | ||
714 | btrfs_block_rsv_release(root, src_rsv, num_bytes); | 731 | btrfs_block_rsv_release(root, src_rsv, num_bytes); |
732 | } | ||
715 | 733 | ||
716 | return ret; | 734 | return ret; |
717 | } | 735 | } |
@@ -725,6 +743,8 @@ static void btrfs_delayed_inode_release_metadata(struct btrfs_root *root, | |||
725 | return; | 743 | return; |
726 | 744 | ||
727 | rsv = &root->fs_info->delayed_block_rsv; | 745 | rsv = &root->fs_info->delayed_block_rsv; |
746 | trace_btrfs_space_reservation(root->fs_info, "delayed_inode", | ||
747 | node->inode_id, node->bytes_reserved, 0); | ||
728 | btrfs_block_rsv_release(root, rsv, | 748 | btrfs_block_rsv_release(root, rsv, |
729 | node->bytes_reserved); | 749 | node->bytes_reserved); |
730 | node->bytes_reserved = 0; | 750 | node->bytes_reserved = 0; |
@@ -1372,13 +1392,6 @@ int btrfs_insert_delayed_dir_index(struct btrfs_trans_handle *trans, | |||
1372 | goto release_node; | 1392 | goto release_node; |
1373 | } | 1393 | } |
1374 | 1394 | ||
1375 | ret = btrfs_delayed_item_reserve_metadata(trans, root, delayed_item); | ||
1376 | /* | ||
1377 | * we have reserved enough space when we start a new transaction, | ||
1378 | * so reserving metadata failure is impossible | ||
1379 | */ | ||
1380 | BUG_ON(ret); | ||
1381 | |||
1382 | delayed_item->key.objectid = btrfs_ino(dir); | 1395 | delayed_item->key.objectid = btrfs_ino(dir); |
1383 | btrfs_set_key_type(&delayed_item->key, BTRFS_DIR_INDEX_KEY); | 1396 | btrfs_set_key_type(&delayed_item->key, BTRFS_DIR_INDEX_KEY); |
1384 | delayed_item->key.offset = index; | 1397 | delayed_item->key.offset = index; |
@@ -1391,6 +1404,14 @@ int btrfs_insert_delayed_dir_index(struct btrfs_trans_handle *trans, | |||
1391 | dir_item->type = type; | 1404 | dir_item->type = type; |
1392 | memcpy((char *)(dir_item + 1), name, name_len); | 1405 | memcpy((char *)(dir_item + 1), name, name_len); |
1393 | 1406 | ||
1407 | ret = btrfs_delayed_item_reserve_metadata(trans, root, delayed_item); | ||
1408 | /* | ||
1409 | * we have reserved enough space when we start a new transaction, | ||
1410 | * so reserving metadata failure is impossible | ||
1411 | */ | ||
1412 | BUG_ON(ret); | ||
1413 | |||
1414 | |||
1394 | mutex_lock(&delayed_node->mutex); | 1415 | mutex_lock(&delayed_node->mutex); |
1395 | ret = __btrfs_add_delayed_insertion_item(delayed_node, delayed_item); | 1416 | ret = __btrfs_add_delayed_insertion_item(delayed_node, delayed_item); |
1396 | if (unlikely(ret)) { | 1417 | if (unlikely(ret)) { |