diff options
author | Chris Mason <chris.mason@oracle.com> | 2008-12-16 13:51:01 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-12-16 13:51:01 -0500 |
commit | dcbdd4dcb9793b00b46ab023e9330922c8c7c54c (patch) | |
tree | ca599e975c92de75c98283756f80b2aa7a1879bb /fs/btrfs/file-item.c | |
parent | 75eff68ea6959efd999b125fc3dcf73931a3b30b (diff) |
Btrfs: delete checksum items before marking blocks free
Btrfs maintains a cache of blocks available for allocation in ram. The
code that frees extents was marking the extents free and then deleting
the checksum items.
This meant it was possible the extent would be reallocated before the
checksum item was actually deleted, leading to races and other
problems as the checksums were updated for the newly allocated extent.
The fix is to delete the checksum before marking the extent free.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/file-item.c')
-rw-r--r-- | fs/btrfs/file-item.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c index df0447632dbd..7acadf3b742a 100644 --- a/fs/btrfs/file-item.c +++ b/fs/btrfs/file-item.c | |||
@@ -537,6 +537,8 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans, | |||
537 | if (key.offset >= bytenr && csum_end <= end_byte) { | 537 | if (key.offset >= bytenr && csum_end <= end_byte) { |
538 | ret = btrfs_del_item(trans, root, path); | 538 | ret = btrfs_del_item(trans, root, path); |
539 | BUG_ON(ret); | 539 | BUG_ON(ret); |
540 | if (key.offset == bytenr) | ||
541 | break; | ||
540 | } else if (key.offset < bytenr && csum_end > end_byte) { | 542 | } else if (key.offset < bytenr && csum_end > end_byte) { |
541 | unsigned long offset; | 543 | unsigned long offset; |
542 | unsigned long shift_len; | 544 | unsigned long shift_len; |
@@ -583,6 +585,8 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans, | |||
583 | ret = truncate_one_csum(trans, root, path, | 585 | ret = truncate_one_csum(trans, root, path, |
584 | &key, bytenr, len); | 586 | &key, bytenr, len); |
585 | BUG_ON(ret); | 587 | BUG_ON(ret); |
588 | if (key.offset < bytenr) | ||
589 | break; | ||
586 | } | 590 | } |
587 | btrfs_release_path(root, path); | 591 | btrfs_release_path(root, path); |
588 | } | 592 | } |