From patchwork Wed Aug 20 08:51:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Bo X-Patchwork-Id: 4748151 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 B0432C0338 for ; Wed, 20 Aug 2014 08:51:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E6DCB20155 for ; Wed, 20 Aug 2014 08:51:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 053F02011D for ; Wed, 20 Aug 2014 08:51:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750876AbaHTIvf (ORCPT ); Wed, 20 Aug 2014 04:51:35 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:49055 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750819AbaHTIvd (ORCPT ); Wed, 20 Aug 2014 04:51:33 -0400 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s7K8pW26028520 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 20 Aug 2014 08:51:33 GMT Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s7K8pVEX008095 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 20 Aug 2014 08:51:32 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s7K8pVjQ014193 for ; Wed, 20 Aug 2014 08:51:31 GMT Received: from localhost.localdomain.localdomain (/117.22.105.36) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 20 Aug 2014 01:51:30 -0700 From: Liu Bo To: linux-btrfs Subject: [PATCH v2] Btrfs: fix crash on endio of reading corrupted block Date: Wed, 20 Aug 2014 16:51:19 +0800 Message-Id: <1408524679-13583-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: ucsinet21.oracle.com [156.151.31.93] 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. 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. 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; } }