From patchwork Sat May 14 00:06:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Bo X-Patchwork-Id: 9094271 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1DE4EBF29F for ; Sat, 14 May 2016 00:05:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 43E162021A for ; Sat, 14 May 2016 00:05:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 67EB12017E for ; Sat, 14 May 2016 00:05:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932385AbcENAF0 (ORCPT ); Fri, 13 May 2016 20:05:26 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:19190 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932339AbcENAFZ (ORCPT ); Fri, 13 May 2016 20:05:25 -0400 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u4E05OxP028127 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 14 May 2016 00:05:24 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id u4E05N4t032742 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 14 May 2016 00:05:24 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u4E05Nbw008373 for ; Sat, 14 May 2016 00:05:23 GMT Received: from localhost.us.oracle.com (/10.211.47.181) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 13 May 2016 17:05:23 -0700 From: Liu Bo To: linux-btrfs@vger.kernel.org Subject: [PATCH 2/7] Btrfs: replace BUG_ON with WARN_ONCE in cow_file_range Date: Fri, 13 May 2016 17:06:57 -0700 Message-Id: <1463184422-13584-2-git-send-email-bo.li.liu@oracle.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1463184422-13584-1-git-send-email-bo.li.liu@oracle.com> References: <1463184422-13584-1-git-send-email-bo.li.liu@oracle.com> X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 This BUG_ON is more like a warning since an invalid btrfs_super_total_bytes() doesn't affect other stuff. Thus, use WARN_ONCE for warning purpose and don't leave a possible kernel panic here. Signed-off-by: Liu Bo --- fs/btrfs/inode.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 2aaba58..5874562 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -974,8 +974,11 @@ static noinline int cow_file_range(struct inode *inode, } } - BUG_ON(disk_num_bytes > - btrfs_super_total_bytes(root->fs_info->super_copy)); + WARN_ONCE(disk_num_bytes > + btrfs_super_total_bytes(root->fs_info->super_copy), + KERN_WARNING "disk_num_bytes(%llu) > btrfs_super_total_bytes(%llu)\n", + disk_num_bytes, + btrfs_super_total_bytes(root->fs_info->super_copy)); alloc_hint = get_extent_allocation_hint(inode, start, num_bytes); btrfs_drop_extent_cache(inode, start, start + num_bytes - 1, 0);