From patchwork Fri Jul 12 01:00:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zheng Liu X-Patchwork-Id: 258672 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 1C5FE2C009A for ; Fri, 12 Jul 2013 10:42:22 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932137Ab3GLAmV (ORCPT ); Thu, 11 Jul 2013 20:42:21 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:63213 "EHLO mail-pb0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932110Ab3GLAmU (ORCPT ); Thu, 11 Jul 2013 20:42:20 -0400 Received: by mail-pb0-f45.google.com with SMTP id mc8so8395784pbc.18 for ; Thu, 11 Jul 2013 17:42:20 -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:x-mailer; bh=+m9J305NKP3C2FTX3ovlrbnZ6FE5OVi9e3I1fqPYGDQ=; b=MW0tUDQ9j5oqhVAoN8aF9+EuqfbXqYLNCOTgdpeN6zJAHC1YhJJBSfzeH7OoSmTDxQ 1BCj3tqaJe8EDiJGtdISfOt44LdnvR0xVr8ZrOLbhcbeFnpZdapREsA/qZckloq6s8r6 hxZBhpeky8ZrQgWMBWEpWJKuNwUSwXvEsqhNvolURreQEG6QMvjE7AeaYXfffHg9+fGt xVC2yvE7PXnPeeU5yf+aOOIawxYSbsEPoXjGOR37B54EtTq4NmDCGpL+Peuwx83viTEJ iuE9ZOOMzhSt1o2ftVt0F0ltgCWZL0r1ntlIMZHVVuvJQA1LZQ/QmIfEnxXklK7ie5KM ocPw== X-Received: by 10.68.17.230 with SMTP id r6mr38909691pbd.112.1373589740090; Thu, 11 Jul 2013 17:42:20 -0700 (PDT) Received: from lz-desktop.taobao.ali.com ([182.92.247.2]) by mx.google.com with ESMTPSA id xe9sm42134472pbc.21.2013.07.11.17.42.16 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 11 Jul 2013 17:42:19 -0700 (PDT) From: Zheng Liu To: linux-ext4@vger.kernel.org Cc: "Theodore Ts'o" , Zheng Liu Subject: [PATCH v2] ext4: add WARN_ON to check the length of allocated blocks Date: Fri, 12 Jul 2013 09:00:52 +0800 Message-Id: <1373590852-29544-1-git-send-email-wenqing.lz@taobao.com> X-Mailer: git-send-email 1.7.9.7 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Zheng Liu In this commit (921f266b) a sanity check is added in map_blocks to make sure 'retval == map->m_len'. But we'd better enable this check all the time because it can help us to dig some bugs that is hard to be hitted. Cc: "Theodore Ts'o" Signed-off-by: Zheng Liu --- changelog: v2 <- v1: * print more details to help us to dig some bugs that is hard to be hitted v1: http://patchwork.ozlabs.org/patch/230406/ Hi Ted, This patch sleeps on my own tree for a very long time so that I almost forgot it. Sorry about that. - Zheng fs/ext4/inode.c | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 19a1643..95bad70 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -556,14 +556,13 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode, int ret; unsigned long long status; -#ifdef ES_AGGRESSIVE_TEST - if (retval != map->m_len) { - printk("ES len assertation failed for inode: %lu " - "retval %d != map->m_len %d " - "in %s (lookup)\n", inode->i_ino, retval, - map->m_len, __func__); + if (unlikely(retval != map->m_len)) { + ext4_warning(inode->i_sb, + "ES len assertation failed for inode: " + "%lu retval %d != map->m_len %d\n", + inode->i_ino, retval, map->m_len); + WARN_ON(1); } -#endif status = map->m_flags & EXT4_MAP_UNWRITTEN ? EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN; @@ -657,14 +656,13 @@ found: int ret; unsigned long long status; -#ifdef ES_AGGRESSIVE_TEST - if (retval != map->m_len) { - printk("ES len assertation failed for inode: %lu " - "retval %d != map->m_len %d " - "in %s (allocation)\n", inode->i_ino, retval, - map->m_len, __func__); + if (unlikely(retval != map->m_len)) { + ext4_warning(inode->i_sb, + "ES len assertation failed for inode: " + "%lu retval %d != map->m_len %d\n", + inode->i_ino, retval, map->m_len); + WARN_ON(1); } -#endif /* * If the extent has been zeroed out, we don't need to update @@ -1640,14 +1638,13 @@ add_delayed: int ret; unsigned long long status; -#ifdef ES_AGGRESSIVE_TEST - if (retval != map->m_len) { - printk("ES len assertation failed for inode: %lu " - "retval %d != map->m_len %d " - "in %s (lookup)\n", inode->i_ino, retval, - map->m_len, __func__); + if (unlikely(retval != map->m_len)) { + ext4_warning(inode->i_sb, + "ES len assertation failed for inode: " + "%lu retval %d != map->m_len %d\n", + inode->i_ino, retval, map->m_len); + WARN_ON(1); } -#endif status = map->m_flags & EXT4_MAP_UNWRITTEN ? EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN;