From patchwork Sat Dec 28 11:52:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Shilong X-Patchwork-Id: 3413661 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 C81E19F383 for ; Sat, 28 Dec 2013 11:53:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F0D212015D for ; Sat, 28 Dec 2013 11:53:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 05B5F2014A for ; Sat, 28 Dec 2013 11:53:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755232Ab3L1Lwq (ORCPT ); Sat, 28 Dec 2013 06:52:46 -0500 Received: from mail-pb0-f52.google.com ([209.85.160.52]:58765 "EHLO mail-pb0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753225Ab3L1Lwq (ORCPT ); Sat, 28 Dec 2013 06:52:46 -0500 Received: by mail-pb0-f52.google.com with SMTP id uo5so10108973pbc.11 for ; Sat, 28 Dec 2013 03:52:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id; bh=yLIJyvXWRYDZRbCbjgT53VqIgmqmqxsldk7WTArYY5o=; b=JR2lxhI91AVHNdbYW2XHsQAllAy11GYVL9Sslt2NxREF1RKxa1F8B1HSW7yfDC3iGW m2mqMmeg2QVW3lz7Nhj0Uyy/kL0ZRlXxSE5RiCYt+PC+dLLQ1zV654pe4dsva3kP/r9F LuQwu7LTxK/jgqKBjZMeCsCgeppb6idh09mx0q4cmKfxJ8D2AqH30BvTJbOFFbiPuL8a /DplsBkUHIhUZNFNvVmfujzzy4U4Vs4Qj5erk06ZCAQYo1HToE8nZFjsmKfpSx5qcsOV LptdcsVhMy8+T+f5mAt4lm4FMOUTe12JaCc951Z7I/Ul9qWuHmsc3sFh3x1zESe50s/E QTMQ== X-Received: by 10.68.232.37 with SMTP id tl5mr57055313pbc.86.1388231565397; Sat, 28 Dec 2013 03:52:45 -0800 (PST) Received: from linux-b0ol.localdomain ([223.65.188.73]) by mx.google.com with ESMTPSA id dq3sm68495815pbc.35.2013.12.28.03.52.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 Dec 2013 03:52:44 -0800 (PST) From: Wang Shilong To: linux-btrfs@vger.kernel.org Subject: [PATCH] Btrfs: fix an oops when we fail to relocate tree blocks Date: Sat, 28 Dec 2013 19:52:39 +0800 Message-Id: <1388231559-2463-1-git-send-email-wangshilong1991@gmail.com> X-Mailer: git-send-email 1.8.4 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.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 From: Wang Shilong During balance test, we hit an oops: [ 2013.841551] kernel BUG at fs/btrfs/relocation.c:1174! The problem is that if we fail to relocate tree blocks, we should update backref cache, otherwise, some pending nodes are not updated while snapshot check @cache->last_trans is within one transaction and won't update it and then oops happen. Signed-off-by: Wang Shilong --- fs/btrfs/relocation.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index b530ed9..4a3f0d9 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -4075,6 +4075,12 @@ restart: if (!RB_EMPTY_ROOT(&blocks)) { ret = relocate_tree_blocks(trans, rc, &blocks); if (ret < 0) { + /* + * if we fail to relocate tree blocks, force to update + * backref cache when committing transaction. + */ + rc->backref_cache.last_trans = trans->transid - 1; + if (ret != -EAGAIN) { err = ret; break;