From patchwork Tue Sep 18 05:52:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miao Xie X-Patchwork-Id: 1470691 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id B65BB3FCFC for ; Tue, 18 Sep 2012 05:52:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755406Ab2IRFwn (ORCPT ); Tue, 18 Sep 2012 01:52:43 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:7349 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1754613Ab2IRFwm (ORCPT ); Tue, 18 Sep 2012 01:52:42 -0400 X-IronPort-AV: E=Sophos;i="4.80,441,1344182400"; d="scan'208";a="5862448" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 18 Sep 2012 13:51:24 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id q8I5qemW029605; Tue, 18 Sep 2012 13:52:40 +0800 Received: from [10.167.225.199] ([10.167.225.199]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2012091813525760-900876 ; Tue, 18 Sep 2012 13:52:57 +0800 Message-ID: <50580C26.5030803@cn.fujitsu.com> Date: Tue, 18 Sep 2012 13:52:38 +0800 From: Miao Xie Reply-To: miaox@cn.fujitsu.com User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0 MIME-Version: 1.0 To: Linux Btrfs CC: David Sterba Subject: [PATCH] Btrfs: fix the missing error information in create_pending_snapshot() X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2012/09/18 13:52:57, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2012/09/18 13:52:58, Serialize complete at 2012/09/18 13:52:58 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org The macro btrfs_abort_transaction() can get the line number of the code where the problem happens, so we should invoke it in the place that the error occurs, or we will lose the line number. Reported-by: David Sterba Signed-off-by: Miao Xie --- fs/btrfs/transaction.c | 57 +++++++++++++++++++++++++++++------------------ 1 files changed, 35 insertions(+), 22 deletions(-) diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 7d3fc93..cf98dbc 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -1042,7 +1042,8 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, goto fail; } else if (IS_ERR(dir_item)) { ret = PTR_ERR(dir_item); - goto abort_trans; + btrfs_abort_transaction(trans, root, ret); + goto fail; } btrfs_release_path(path); @@ -1053,8 +1054,10 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, * snapshot */ ret = btrfs_run_delayed_items(trans, root); - if (ret) /* Transaction aborted */ - goto abort_trans; + if (ret) { /* Transaction aborted */ + btrfs_abort_transaction(trans, root, ret); + goto fail; + } record_root_in_trans(trans, root); btrfs_set_root_last_snapshot(&root->root_item, trans->transid); @@ -1087,7 +1090,8 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, if (ret) { btrfs_tree_unlock(old); free_extent_buffer(old); - goto abort_trans; + btrfs_abort_transaction(trans, root, ret); + goto fail; } btrfs_set_lock_blocking(old); @@ -1096,8 +1100,10 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, /* clean up in any case */ btrfs_tree_unlock(old); free_extent_buffer(old); - if (ret) - goto abort_trans; + if (ret) { + btrfs_abort_transaction(trans, root, ret); + goto fail; + } /* see comments in should_cow_block() */ root->force_cow = 1; @@ -1109,8 +1115,10 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, ret = btrfs_insert_root(trans, tree_root, &key, new_root_item); btrfs_tree_unlock(tmp); free_extent_buffer(tmp); - if (ret) - goto abort_trans; + if (ret) { + btrfs_abort_transaction(trans, root, ret); + goto fail; + } /* * insert root back/forward references @@ -1119,23 +1127,30 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, parent_root->root_key.objectid, btrfs_ino(parent_inode), index, dentry->d_name.name, dentry->d_name.len); - if (ret) - goto abort_trans; + if (ret) { + btrfs_abort_transaction(trans, root, ret); + goto fail; + } key.offset = (u64)-1; pending->snap = btrfs_read_fs_root_no_name(root->fs_info, &key); if (IS_ERR(pending->snap)) { ret = PTR_ERR(pending->snap); - goto abort_trans; + btrfs_abort_transaction(trans, root, ret); + goto fail; } ret = btrfs_reloc_post_snapshot(trans, pending); - if (ret) - goto abort_trans; + if (ret) { + btrfs_abort_transaction(trans, root, ret); + goto fail; + } ret = btrfs_run_delayed_refs(trans, root, (unsigned long)-1); - if (ret) - goto abort_trans; + if (ret) { + btrfs_abort_transaction(trans, root, ret); + goto fail; + } ret = btrfs_insert_dir_item(trans, parent_root, dentry->d_name.name, dentry->d_name.len, @@ -1143,15 +1158,17 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, BTRFS_FT_DIR, index); /* We have check then name at the beginning, so it is impossible. */ BUG_ON(ret == -EEXIST); - if (ret) - goto abort_trans; + if (ret) { + btrfs_abort_transaction(trans, root, ret); + goto fail; + } btrfs_i_size_write(parent_inode, parent_inode->i_size + dentry->d_name.len * 2); parent_inode->i_mtime = parent_inode->i_ctime = CURRENT_TIME; ret = btrfs_update_inode(trans, parent_root, parent_inode); if (ret) - goto abort_trans; + btrfs_abort_transaction(trans, root, ret); fail: dput(parent); trans->block_rsv = rsv; @@ -1162,10 +1179,6 @@ root_item_alloc_fail: path_alloc_fail: btrfs_block_rsv_release(root, &pending->block_rsv, (u64)-1); return ret; - -abort_trans: - btrfs_abort_transaction(trans, root, ret); - goto fail; } /*