diff mbox

Btrfs: check if items are ordered when a leaf is marked dirty

Message ID 1397054226-17950-1-git-send-email-fdmanana@gmail.com (mailing list archive)
State Accepted
Headers show

Commit Message

Filipe Manana April 9, 2014, 2:37 p.m. UTC
To ease finding bugs during development related to modifying btree leaves
in such a way that it makes its items not sorted by key anymore. Since this
is an expensive check, it's only enabled if CONFIG_BTRFS_FS_CHECK_INTEGRITY
is set, which isn't meant to be enabled for regular users.

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
---
 fs/btrfs/disk-io.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

David Sterba April 14, 2014, 4:51 p.m. UTC | #1
On Wed, Apr 09, 2014 at 03:37:06PM +0100, Filipe David Borba Manana wrote:
> To ease finding bugs during development related to modifying btree leaves
> in such a way that it makes its items not sorted by key anymore. Since this
> is an expensive check, it's only enabled if CONFIG_BTRFS_FS_CHECK_INTEGRITY
> is set, which isn't meant to be enabled for regular users.
> 
> Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Reviewed-by: David Sterba <dsterba@suse.cz>

> @@ -3695,6 +3695,12 @@ void btrfs_mark_buffer_dirty(struct extent_buffer *buf)
>  		__percpu_counter_add(&root->fs_info->dirty_metadata_bytes,
>  				     buf->len,
>  				     root->fs_info->dirty_metadata_batch);
> +#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY
> +	if (btrfs_header_level(buf) == 0 && check_leaf(root, buf)) {

You coud also add the 'level == 0' to check_leaf() itself.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index d9698fd..8bf6628 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3695,6 +3695,12 @@  void btrfs_mark_buffer_dirty(struct extent_buffer *buf)
 		__percpu_counter_add(&root->fs_info->dirty_metadata_bytes,
 				     buf->len,
 				     root->fs_info->dirty_metadata_batch);
+#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY
+	if (btrfs_header_level(buf) == 0 && check_leaf(root, buf)) {
+		btrfs_print_leaf(root, buf);
+		ASSERT(0);
+	}
+#endif
 }
 
 static void __btrfs_btree_balance_dirty(struct btrfs_root *root,