From patchwork Sat Aug 23 04:00:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Bo X-Patchwork-Id: 4768441 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 250249F344 for ; Sat, 23 Aug 2014 04:00:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4A140200FF for ; Sat, 23 Aug 2014 04:00:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 205F52013A for ; Sat, 23 Aug 2014 04:00:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752180AbaHWEAm (ORCPT ); Sat, 23 Aug 2014 00:00:42 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:40583 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751376AbaHWEAl (ORCPT ); Sat, 23 Aug 2014 00:00:41 -0400 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s7N40aTx020134 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 23 Aug 2014 04:00:36 GMT Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s7N40Zji011553 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 23 Aug 2014 04:00:35 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userz7022.oracle.com (8.14.5+Sun/8.14.4) with ESMTP id s7N40XMa026731; Sat, 23 Aug 2014 04:00:34 GMT Received: from localhost.localdomain.com (/10.182.228.124) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 22 Aug 2014 21:00:33 -0700 From: Liu Bo To: linux-btrfs Cc: Eric Sandeen Subject: [PATCH v3] Btrfs: fix crash on endio of reading corrupted block Date: Sat, 23 Aug 2014 12:00:26 +0800 Message-Id: <1408766426-13271-1-git-send-email-bo.li.liu@oracle.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1408462393-3291-1-git-send-email-bo.li.liu@oracle.com> References: <1408462393-3291-1-git-send-email-bo.li.liu@oracle.com> X-Source-IP: acsinet21.oracle.com [141.146.126.237] 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.6 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 The crash is ------------[ cut here ]------------ kernel BUG at fs/btrfs/extent_io.c:2124! invalid opcode: 0000 [#1] SMP ... CPU: 3 PID: 88 Comm: kworker/u8:7 Not tainted 3.17.0-0.rc1.git0.1.fc22.x86_64 #1 Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 Workqueue: btrfs-endio normal_work_helper [btrfs] task: ffff8800d7152700 ti: ffff8800d729c000 task.ti: ffff8800d729c000 RIP: 0010:[] [] end_bio_extent_readpage+0xb45/0xcd0 [btrfs] Call Trace: [] ? __enqueue_entity+0x78/0x80 [] ? enqueue_entity+0x2e9/0x990 [] bio_endio+0x6b/0xa0 [] bio_endio_nodec+0x12/0x20 [] end_workqueue_fn+0x37/0x40 [btrfs] [] normal_work_helper+0xbd/0x280 [btrfs] [] process_one_work+0x17e/0x430 [] worker_thread+0x6b/0x4a0 [] ? rescuer_thread+0x2a0/0x2a0 [] kthread+0xea/0x100 [] ? kthread_create_on_node+0x1a0/0x1a0 [] ret_from_fork+0x7c/0xb0 [] ? kthread_create_on_node+0x1a0/0x1a0 This is in fact a regression introduced by commit facc8a2247340a9735fe8cc123c5da2102f5ef1b(Btrfs: don't cache the csum value into the extent state tree). It is because we forgot to increase @offset properly in reading corrupted block, so that the @offset remains unchanged, and it leads to checksum errors while reading left blocks queued up in the same bio, and then btrfs tries to iterate copies for those blocks in order to get good data, and hits the BUG_ON() which we set to avoid finding good copies for blocks without problems. Reported-by: Chris Murphy Signed-off-by: Liu Bo --- v2: - Improve the commit log to be clear, suggested by Eric. v3: - Show the commit that introduces this bug, I forgot to add this in the v2 version. fs/btrfs/extent_io.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 3af4966..be41e4d 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2602,6 +2602,7 @@ static void end_bio_extent_readpage(struct bio *bio, int err) test_bit(BIO_UPTODATE, &bio->bi_flags); if (err) uptodate = 0; + offset += len; continue; } }