From patchwork Wed Apr 24 20:50:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 2486281 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 3EF45DFE75 for ; Wed, 24 Apr 2013 20:51:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758260Ab3DXUu6 (ORCPT ); Wed, 24 Apr 2013 16:50:58 -0400 Received: from dkim2.fusionio.com ([66.114.96.54]:37789 "EHLO dkim2.fusionio.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758059Ab3DXUu4 (ORCPT ); Wed, 24 Apr 2013 16:50:56 -0400 Received: from mx2.fusionio.com (unknown [10.101.1.160]) by dkim2.fusionio.com (Postfix) with ESMTP id 958E39A068E for ; Wed, 24 Apr 2013 14:50:56 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fusionio.com; s=default; t=1366836656; bh=0/Izwtx1coidep0qCfSpF3O4J1na9eC5JyvnTIQ7irY=; h=From:To:Subject:Date; b=crsU8vmunfP9aZ+UlaozOjvUSzwm+a/JPo8zVEqoTaN+6hj+pn+gJF3rgQ9kDGdCC BqfanLsBxCJKA+2hHGm+4KW8Fli3+qzPBRPYI9hlKqMQXrlOVXP4ulGqiYwqe/FFd7 c/8bQiw63v92bY6rGASnyv+1XGSYGyz5kwLDIX9g= X-ASG-Debug-ID: 1366836655-0421b55bca4d540001-6jHSXT Received: from mail1.int.fusionio.com (mail1.int.fusionio.com [10.101.1.21]) by mx2.fusionio.com with ESMTP id 4ZNwrxRP31E3TW9x (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO) for ; Wed, 24 Apr 2013 14:50:55 -0600 (MDT) X-Barracuda-Envelope-From: JBacik@fusionio.com Received: from localhost (76.182.72.146) by mail.fusionio.com (10.101.1.19) with Microsoft SMTP Server (TLS) id 8.3.83.0; Wed, 24 Apr 2013 14:50:55 -0600 From: Josef Bacik To: Subject: [PATCH] Btrfs: check return value of commit when recovering log Date: Wed, 24 Apr 2013 16:50:54 -0400 X-ASG-Orig-Subj: [PATCH] Btrfs: check return value of commit when recovering log Message-ID: <1366836654-2065-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: 1366836655 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: http://10.101.1.181:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at fusionio.com X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global 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.129061 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 We need to check the return value of the commit in case something goes wrong, otherwise we could end up going down the line and doing more stuff (like orphan cleanup) before we notice we should have errored out. We need to do this before we free up the log_tree_root since the caller will handle all of that. Thanks, Signed-off-by: Josef Bacik --- fs/btrfs/tree-log.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 1fdc221..f50137a 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -4012,16 +4012,17 @@ again: btrfs_free_path(path); + /* step 4: commit the transaction, which also unpins the blocks */ + ret = btrfs_commit_transaction(trans, fs_info->tree_root); + if (ret) + return ret; + free_extent_buffer(log_root_tree->node); log_root_tree->log_root = NULL; fs_info->log_root_recovering = 0; - - /* step 4: commit the transaction, which also unpins the blocks */ - btrfs_commit_transaction(trans, fs_info->tree_root); - kfree(log_root_tree); - return 0; + return 0; error: btrfs_free_path(path); return ret;