From patchwork Thu Dec 21 22:42:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Bo X-Patchwork-Id: 10128549 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 78E65603B5 for ; Thu, 21 Dec 2017 23:46:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BC0629E75 for ; Thu, 21 Dec 2017 23:46:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F7C329EDB; Thu, 21 Dec 2017 23:46:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0650929E75 for ; Thu, 21 Dec 2017 23:46:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755444AbdLUXqH (ORCPT ); Thu, 21 Dec 2017 18:46:07 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:57352 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755275AbdLUXpm (ORCPT ); Thu, 21 Dec 2017 18:45:42 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.21/8.16.0.21) with SMTP id vBLNfprl082990 for ; Thu, 21 Dec 2017 23:45:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=UyjNCmDu/35sUgxYW6cMkgfM04AJ44obydNA0BAmbyc=; b=MTPGxBH8mgpt2gdJKMZ3uX/FrodCz7N7v+rt0UVCrwes6SkKHgtomRZeFxiniwvRfyJG jhxoA/hYfo73k/KHmPgA2be0vrDkmSWPuGAOi2j+S3zo99UcckCTeHW4u32i62fvkCBT ucPOT8uVybs3ul/s3XbOtkC7/26cLAVvX4KIx1ESRDc4cqmI2UykbOoOo0wDshPAvr81 DF7E/l4CifvVB2cglhEvY0WPR1MOLBnNioX/OrZ4UKTL8aTDTKujk2LZfxY9YAkM7s+K a7ajIUNBzH1L78sS2lQaYMsNSgyRBCt6oh7D7uuhN80hFDKdaGAKVWqwAimaPSHw8rC3 fg== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2f0prs01b7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 21 Dec 2017 23:45:41 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id vBLNje36010775 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 21 Dec 2017 23:45:41 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 vBLNjeun008961 for ; Thu, 21 Dec 2017 23:45:40 GMT Received: from dhcp-10-211-47-181.usdhcp.oraclecorp.com.com (/10.211.47.181) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 21 Dec 2017 15:45:40 -0800 From: Liu Bo To: linux-btrfs@vger.kernel.org Subject: [PATCH 08/10] Btrfs: add WARN_ONCE to detect unexpected error from merge_extent_mapping Date: Thu, 21 Dec 2017 15:42:54 -0700 Message-Id: <20171221224256.18196-9-bo.li.liu@oracle.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20171221224256.18196-1-bo.li.liu@oracle.com> References: <20171221224256.18196-1-bo.li.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8752 signatures=668651 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=18 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=602 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1712210312 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is a subtle case, so in order to understand the problem, it'd be good to know the content of existing and em when any error occurs. Signed-off-by: Liu Bo --- fs/btrfs/extent_map.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c index d386cfb..a8b7e24 100644 --- a/fs/btrfs/extent_map.c +++ b/fs/btrfs/extent_map.c @@ -550,17 +550,23 @@ int btrfs_add_extent_mapping(struct extent_map_tree *em_tree, *em_in = existing; ret = 0; } else { + u64 orig_start = em->start; + u64 orig_len = em->len; + /* * The existing extent map is the one nearest to * the [start, start + len) range which overlaps */ ret = merge_extent_mapping(em_tree, existing, em, start, len); - free_extent_map(existing); if (ret) { free_extent_map(em); *em_in = NULL; + WARN_ONCE(ret, KERN_INFO "Unexpected error %d: merge existing(start %llu len %llu) with em(start %llu len %llu)\n", + ret, existing->start, existing->len, + orig_start, orig_len); } + free_extent_map(existing); } }