From patchwork Wed Apr 9 14:37:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 3955431 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B3670BFF02 for ; Wed, 9 Apr 2014 13:38:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D6A3F20511 for ; Wed, 9 Apr 2014 13:38:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1F24E2050E for ; Wed, 9 Apr 2014 13:38:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933213AbaDINiA (ORCPT ); Wed, 9 Apr 2014 09:38:00 -0400 Received: from mail-we0-f171.google.com ([74.125.82.171]:48221 "EHLO mail-we0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932807AbaDINh7 (ORCPT ); Wed, 9 Apr 2014 09:37:59 -0400 Received: by mail-we0-f171.google.com with SMTP id t61so2492703wes.30 for ; Wed, 09 Apr 2014 06:37:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=l2Y+PB+qn/mLE0MUhiRHBikDXVpw/JCyrDEF0nhD9so=; b=HEZHdGXMhVmSMuBugJpTdOAJ05d5Mq0fAn/ProrBW0WspuybqJX3mRr27tp6CkNdQy h4LLbTyfK95wbqpgNtpfUvrkSYv7K5dhxy93ZfqVNHl89Z71FymOmM4EkH83ii7QKQts w3tgFQH9mVVWvIwFgmS6ilaZhWPVueaFV2+gSG/r5qHlU4PisbIJ8ZJrtDfqfAJz221T vRgngcdvm0Yugxodw5XEBmQr2w6gwg3po/ggbK9Z4ZNHwOxIcInbXEJiHvnWdo3ADi/D vnNk8fMWdqV0lM6eArEbyyo7P9f1oSGdqY4KNCcQaygR4X3MD5Ojer/so8txZnQ+Tsaj isdQ== X-Received: by 10.180.94.196 with SMTP id de4mr10239860wib.16.1397050678474; Wed, 09 Apr 2014 06:37:58 -0700 (PDT) Received: from debian-vm3.lan (bl13-136-121.dsl.telepac.pt. [85.246.136.121]) by mx.google.com with ESMTPSA id ea8sm4457540wib.11.2014.04.09.06.37.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 09 Apr 2014 06:37:56 -0700 (PDT) From: Filipe David Borba Manana To: linux-btrfs@vger.kernel.org Cc: Filipe David Borba Manana Subject: [PATCH] Btrfs: check if items are ordered when a leaf is marked dirty Date: Wed, 9 Apr 2014 15:37:06 +0100 Message-Id: <1397054226-17950-1-git-send-email-fdmanana@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: David Sterba --- fs/btrfs/disk-io.c | 6 ++++++ 1 file changed, 6 insertions(+) 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,