From patchwork Mon Apr 1 15:27:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 2371261 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id EEA8CE00D8 for ; Mon, 1 Apr 2013 15:27:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758818Ab3DAP1W (ORCPT ); Mon, 1 Apr 2013 11:27:22 -0400 Received: from dkim1.fusionio.com ([66.114.96.53]:48444 "EHLO dkim1.fusionio.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751552Ab3DAP1T (ORCPT ); Mon, 1 Apr 2013 11:27:19 -0400 Received: from mx1.fusionio.com (unknown [10.101.1.160]) by dkim1.fusionio.com (Postfix) with ESMTP id 644697C0425 for ; Mon, 1 Apr 2013 09:27:19 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fusionio.com; s=default; t=1364830039; bh=8BOqTg29Yp9Vsq3ZmSlpMsGDFZRkyoIFZ+Xh4hjDMWE=; h=From:To:Subject:Date; b=EES6jGm+r4D0DTpDgRa9tQ24Wt+P8d5hzn6fflv20Xd8nYhVV6rOo00d6YOQSbRE9 q3gxGQjIAjCQCHafKmUgUCjqGZS4grewAKqKg1Eg2bDM/Pp1w/pzhY9j0M4eBJlwHO RaKbzmbMHp7i+BnLgEcvjSE/zRH3BORUideh3GuQ= X-ASG-Debug-ID: 1364830038-03d6a52ac0179730001-6jHSXT Received: from mail1.int.fusionio.com (mail1.int.fusionio.com [10.101.1.21]) by mx1.fusionio.com with ESMTP id pU5u3pSeA5PxI5Kb (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO) for ; Mon, 01 Apr 2013 09:27:18 -0600 (MDT) X-Barracuda-Envelope-From: JBacik@fusionio.com Received: from localhost (98.26.82.158) by mail.fusionio.com (10.101.1.19) with Microsoft SMTP Server (TLS) id 8.3.83.0; Mon, 1 Apr 2013 09:27:17 -0600 From: Josef Bacik To: Subject: [PATCH] Btrfs: fix infinite loop when we abort on mount Date: Mon, 1 Apr 2013 11:27:16 -0400 X-ASG-Orig-Subj: [PATCH] Btrfs: fix infinite loop when we abort on mount Message-ID: <1364830036-1939-1-git-send-email-jbacik@fusionio.com> X-Mailer: git-send-email 1.7.7.6 MIME-Version: 1.0 X-Barracuda-Connect: mail1.int.fusionio.com[10.101.1.21] X-Barracuda-Start-Time: 1364830038 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: http://10.101.1.180:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at fusionio.com X-Barracuda-Bayes: INNOCENT GLOBAL 0.0000 1.0000 -2.0210 X-Barracuda-Spam-Score: -2.02 X-Barracuda-Spam-Status: No, SCORE=-2.02 using per-user scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.126876 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Testing my enospc log code I managed to abort a transaction during mount, which put me into an infinite loop. This is because of two things, first we don't reset trans_no_join if we abort during transaction commit, which will force anybody trying to start a transaction to just loop endlessly waiting for it to be set to 0. But this is still just a symptom, the second issue is we don't set the fs state to error during errors on mount. This is because we don't want to do the flip read only thing during mount, but we still really want to set the fs state to an error to keep us from even getting to the trans_no_join check. So fix both of these things, make sure to reset trans_no_join if we abort during a commit, and make sure we set the fs state to error no matter if we're mounting or not. This should keep us from getting into this infinite loop again. Thanks, Signed-off-by: Josef Bacik --- fs/btrfs/super.c | 5 ++--- fs/btrfs/transaction.c | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 984816f..d13d6b2 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -161,10 +161,9 @@ void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function, } /* Don't go through full error handling during mount */ - if (sb->s_flags & MS_BORN) { - save_error_info(fs_info); + save_error_info(fs_info); + if (sb->s_flags & MS_BORN) btrfs_handle_error(fs_info); - } } static const char * const logtypes[] = { diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 37f509f..e660ac0b 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -1488,6 +1488,10 @@ static void cleanup_transaction(struct btrfs_trans_handle *trans, current->journal_info = NULL; kmem_cache_free(btrfs_trans_handle_cachep, trans); + + spin_lock(&root->fs_info->trans_lock); + root->fs_info->trans_no_join = 0; + spin_unlock(&root->fs_info->trans_lock); } static int btrfs_flush_all_pending_stuffs(struct btrfs_trans_handle *trans,