From patchwork Mon Feb 7 05:12:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tsutomu Itoh X-Patchwork-Id: 537161 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p175DGMe018130 for ; Mon, 7 Feb 2011 05:13:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750879Ab1BGFNI (ORCPT ); Mon, 7 Feb 2011 00:13:08 -0500 Received: from fgwmail6.fujitsu.co.jp ([192.51.44.36]:36509 "EHLO fgwmail6.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750768Ab1BGFNG (ORCPT ); Mon, 7 Feb 2011 00:13:06 -0500 Received: from m4.gw.fujitsu.co.jp (unknown [10.0.50.74]) by fgwmail6.fujitsu.co.jp (Postfix) with ESMTP id DB73C3EE0B3 for ; Mon, 7 Feb 2011 14:13:03 +0900 (JST) Received: from smail (m4 [127.0.0.1]) by outgoing.m4.gw.fujitsu.co.jp (Postfix) with ESMTP id C3E4E45DE53 for ; Mon, 7 Feb 2011 14:13:03 +0900 (JST) Received: from s4.gw.fujitsu.co.jp (s4.gw.fujitsu.co.jp [10.0.50.94]) by m4.gw.fujitsu.co.jp (Postfix) with ESMTP id A9C4445DE51 for ; Mon, 7 Feb 2011 14:13:03 +0900 (JST) Received: from s4.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s4.gw.fujitsu.co.jp (Postfix) with ESMTP id 947C2EF8006 for ; Mon, 7 Feb 2011 14:13:03 +0900 (JST) Received: from ml14.s.css.fujitsu.com (ml14.s.css.fujitsu.com [10.249.87.104]) by s4.gw.fujitsu.co.jp (Postfix) with ESMTP id 54F3EEF8002 for ; Mon, 7 Feb 2011 14:13:03 +0900 (JST) Received: from ml14.css.fujitsu.com (ml14 [127.0.0.1]) by ml14.s.css.fujitsu.com (Postfix) with ESMTP id 29EF89F6D3C; Mon, 7 Feb 2011 14:13:03 +0900 (JST) Received: from T-ITOH1.jp.fujitsu.com (unknown [10.124.101.86]) by ml14.s.css.fujitsu.com (Postfix) with SMTP id C5F809F6D2C; Mon, 7 Feb 2011 14:13:02 +0900 (JST) X-SecurityPolicyCheck-FJ: OK by FujitsuOutboundMailChecker v1.4.0 Received: from T-ITOH1[10.124.101.86] by T-ITOH1 (FujitsuOutboundMailChecker v1.4.0/9992[10.124.101.86]); Mon, 07 Feb 2011 14:12:39 +0900 (JST) Message-Id: <201102070512.AA00007@T-ITOH1.jp.fujitsu.com> From: Tsutomu Itoh Date: Mon, 07 Feb 2011 14:12:16 +0900 To: linux-btrfs@vger.kernel.org Cc: chris.mason@oracle.com Subject: [PATCH v2] btrfs: fix return value check of btrfs_start_transaction() MIME-Version: 1.0 X-Mailer: AL-Mail32 Version 1.13 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 07 Feb 2011 05:13:22 +0000 (UTC) diff -urNp linux-2.6.38-rc3/fs/btrfs/extent-tree.c linux-2.6.38-rc3.new/fs/btrfs/extent-tree.c --- linux-2.6.38-rc3/fs/btrfs/extent-tree.c 2011-02-01 12:05:49.000000000 +0900 +++ linux-2.6.38-rc3.new/fs/btrfs/extent-tree.c 2011-02-07 11:53:34.000000000 +0900 @@ -6221,6 +6221,8 @@ int btrfs_drop_snapshot(struct btrfs_roo BUG_ON(!wc); trans = btrfs_start_transaction(tree_root, 0); + BUG_ON(IS_ERR(trans)); + if (block_rsv) trans->block_rsv = block_rsv; @@ -6318,6 +6320,7 @@ int btrfs_drop_snapshot(struct btrfs_roo btrfs_end_transaction_throttle(trans, tree_root); trans = btrfs_start_transaction(tree_root, 0); + BUG_ON(IS_ERR(trans)); if (block_rsv) trans->block_rsv = block_rsv; } @@ -7535,7 +7538,7 @@ int btrfs_cleanup_reloc_trees(struct btr if (found) { trans = btrfs_start_transaction(root, 1); - BUG_ON(!trans); + BUG_ON(IS_ERR(trans)); ret = btrfs_commit_transaction(trans, root); BUG_ON(ret); } @@ -7779,7 +7782,7 @@ static noinline int relocate_one_extent( trans = btrfs_start_transaction(extent_root, 1); - BUG_ON(!trans); + BUG_ON(IS_ERR(trans)); if (extent_key->objectid == 0) { ret = del_extent_zero(trans, extent_root, path, extent_key); diff -urNp linux-2.6.38-rc3/fs/btrfs/inode.c linux-2.6.38-rc3.new/fs/btrfs/inode.c --- linux-2.6.38-rc3/fs/btrfs/inode.c 2011-02-01 12:05:49.000000000 +0900 +++ linux-2.6.38-rc3.new/fs/btrfs/inode.c 2011-02-07 11:53:34.000000000 +0900 @@ -2354,6 +2354,7 @@ void btrfs_orphan_cleanup(struct btrfs_r */ if (is_bad_inode(inode)) { trans = btrfs_start_transaction(root, 0); + BUG_ON(IS_ERR(trans)); btrfs_orphan_del(trans, inode); btrfs_end_transaction(trans, root); iput(inode); diff -urNp linux-2.6.38-rc3/fs/btrfs/ioctl.c linux-2.6.38-rc3.new/fs/btrfs/ioctl.c --- linux-2.6.38-rc3/fs/btrfs/ioctl.c 2011-02-01 12:05:49.000000000 +0900 +++ linux-2.6.38-rc3.new/fs/btrfs/ioctl.c 2011-02-07 11:53:34.000000000 +0900 @@ -907,6 +907,10 @@ static noinline int btrfs_ioctl_resize(s if (new_size > old_size) { trans = btrfs_start_transaction(root, 0); + if (IS_ERR(trans)) { + ret = PTR_ERR(trans); + goto out_unlock; + } ret = btrfs_grow_device(trans, device, new_size); btrfs_commit_transaction(trans, root); } else { @@ -2138,9 +2142,9 @@ static long btrfs_ioctl_default_subvol(s path->leave_spinning = 1; trans = btrfs_start_transaction(root, 1); - if (!trans) { + if (IS_ERR(trans)) { btrfs_free_path(path); - return -ENOMEM; + return PTR_ERR(trans); } dir_id = btrfs_super_root_dir(&root->fs_info->super_copy); @@ -2334,6 +2338,8 @@ static noinline long btrfs_ioctl_start_s u64 transid; trans = btrfs_start_transaction(root, 0); + if (IS_ERR(trans)) + return PTR_ERR(trans); transid = trans->transid; btrfs_commit_transaction_async(trans, root, 0); diff -urNp linux-2.6.38-rc3/fs/btrfs/relocation.c linux-2.6.38-rc3.new/fs/btrfs/relocation.c --- linux-2.6.38-rc3/fs/btrfs/relocation.c 2011-02-01 12:05:49.000000000 +0900 +++ linux-2.6.38-rc3.new/fs/btrfs/relocation.c 2011-02-07 11:53:34.000000000 +0900 @@ -2028,6 +2028,7 @@ static noinline_for_stack int merge_relo while (1) { trans = btrfs_start_transaction(root, 0); + BUG_ON(IS_ERR(trans)); trans->block_rsv = rc->block_rsv; ret = btrfs_block_rsv_check(trans, root, rc->block_rsv, @@ -3657,6 +3658,7 @@ static noinline_for_stack int relocate_b while (1) { trans = btrfs_start_transaction(rc->extent_root, 0); + BUG_ON(IS_ERR(trans)); if (update_backref_cache(trans, &rc->backref_cache)) { btrfs_end_transaction(trans, rc->extent_root); @@ -4022,6 +4024,7 @@ static noinline_for_stack int mark_garba int ret; trans = btrfs_start_transaction(root->fs_info->tree_root, 0); + BUG_ON(IS_ERR(trans)); memset(&root->root_item.drop_progress, 0, sizeof(root->root_item.drop_progress)); diff -urNp linux-2.6.38-rc3/fs/btrfs/super.c linux-2.6.38-rc3.new/fs/btrfs/super.c --- linux-2.6.38-rc3/fs/btrfs/super.c 2011-02-01 12:05:49.000000000 +0900 +++ linux-2.6.38-rc3.new/fs/btrfs/super.c 2011-02-07 11:53:34.000000000 +0900 @@ -623,6 +623,8 @@ int btrfs_sync_fs(struct super_block *sb btrfs_wait_ordered_extents(root, 0, 0); trans = btrfs_start_transaction(root, 0); + if (IS_ERR(trans)) + return PTR_ERR(trans); ret = btrfs_commit_transaction(trans, root); return ret; } diff -urNp linux-2.6.38-rc3/fs/btrfs/tree-log.c linux-2.6.38-rc3.new/fs/btrfs/tree-log.c --- linux-2.6.38-rc3/fs/btrfs/tree-log.c 2011-02-01 12:05:49.000000000 +0900 +++ linux-2.6.38-rc3.new/fs/btrfs/tree-log.c 2011-02-07 11:53:34.000000000 +0900 @@ -3080,6 +3080,7 @@ int btrfs_recover_log_trees(struct btrfs BUG_ON(!path); trans = btrfs_start_transaction(fs_info->tree_root, 0); + BUG_ON(IS_ERR(trans)); wc.trans = trans; wc.pin = 1; diff -urNp linux-2.6.38-rc3/fs/btrfs/volumes.c linux-2.6.38-rc3.new/fs/btrfs/volumes.c --- linux-2.6.38-rc3/fs/btrfs/volumes.c 2011-02-01 12:05:49.000000000 +0900 +++ linux-2.6.38-rc3.new/fs/btrfs/volumes.c 2011-02-07 11:55:01.000000000 +0900 @@ -1213,6 +1213,10 @@ static int btrfs_rm_dev_item(struct btrf return -ENOMEM; trans = btrfs_start_transaction(root, 0); + if (IS_ERR(trans)) { + btrfs_free_path(path); + return PTR_ERR(trans); + } key.objectid = BTRFS_DEV_ITEMS_OBJECTID; key.type = BTRFS_DEV_ITEM_KEY; key.offset = device->devid; @@ -1606,6 +1610,13 @@ int btrfs_init_new_device(struct btrfs_r } trans = btrfs_start_transaction(root, 0); + if (IS_ERR(trans)) { + kfree(device->name); + kfree(device); + ret = PTR_ERR(trans); + goto error; + } + lock_chunks(root); device->writeable = 1; @@ -1873,7 +1884,7 @@ static int btrfs_relocate_chunk(struct b return ret; trans = btrfs_start_transaction(root, 0); - BUG_ON(!trans); + BUG_ON(IS_ERR(trans)); lock_chunks(root); @@ -2047,7 +2058,7 @@ int btrfs_balance(struct btrfs_root *dev BUG_ON(ret); trans = btrfs_start_transaction(dev_root, 0); - BUG_ON(!trans); + BUG_ON(IS_ERR(trans)); ret = btrfs_grow_device(trans, device, old_size); BUG_ON(ret); @@ -2213,6 +2224,11 @@ again: /* Shrinking succeeded, else we would be at "done". */ trans = btrfs_start_transaction(root, 0); + if (IS_ERR(trans)) { + ret = PTR_ERR(trans); + goto done; + } + lock_chunks(root); device->disk_total_bytes = new_size;