linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Fasheh <mfasheh@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: chris.mason@oracle.com, Mark Fasheh <mfasheh@suse.com>
Subject: [PATCH 3/7] btrfs: Don't BUG_ON alloc_path errors in btrfs_truncate_inode_items
Date: Thu, 21 Jul 2011 12:48:29 -0700	[thread overview]
Message-ID: <1311277713-7747-4-git-send-email-mfasheh@suse.com> (raw)
In-Reply-To: <1311277713-7747-3-git-send-email-mfasheh@suse.com>

I moved the path allocation up a few lines to the top of the function so
that we couldn't get into the state where we've dropped delayed items and
the extent cache but fail due to -ENOMEM.

Signed-off-by: Mark Fasheh <mfasheh@suse.com>
---
 fs/btrfs/inode.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 8be7d7a..a0faf7d 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3172,6 +3172,11 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
 
 	BUG_ON(new_size > 0 && min_type != BTRFS_EXTENT_DATA_KEY);
 
+	path = btrfs_alloc_path();
+	if (!path)
+		return -ENOMEM;
+	path->reada = -1;
+
 	if (root->ref_cows || root == root->fs_info->tree_root)
 		btrfs_drop_extent_cache(inode, new_size & (~mask), (u64)-1, 0);
 
@@ -3184,10 +3189,6 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
 	if (min_type == 0 && root == BTRFS_I(inode)->root)
 		btrfs_kill_delayed_inode_items(inode);
 
-	path = btrfs_alloc_path();
-	BUG_ON(!path);
-	path->reada = -1;
-
 	key.objectid = ino;
 	key.offset = (u64)-1;
 	key.type = (u8)-1;
-- 
1.7.5.3


  reply	other threads:[~2011-07-21 19:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-21 19:48 [PATCH 0/7] btrfs: don't BUG_ON btrfs_alloc_path errors v2 Mark Fasheh
2011-07-21 19:48 ` [PATCH 1/7] btrfs: don't BUG_ON btrfs_alloc_path() errors Mark Fasheh
2011-07-21 19:48   ` [PATCH 2/7] btrfs: Don't BUG_ON alloc_path errors in replay_one_buffer() Mark Fasheh
2011-07-21 19:48     ` Mark Fasheh [this message]
2011-07-21 19:48       ` [PATCH 4/7] btrfs: Don't BUG_ON alloc_path errors in btrfs_read_locked_inode Mark Fasheh
2011-07-21 19:48         ` [PATCH 5/7] btrfs: Don't BUG_ON alloc_path errors in btrfs_balance() Mark Fasheh
2011-07-21 19:48           ` [PATCH 6/7] btrfs: Don't BUG_ON alloc_path errors in find_next_chunk Mark Fasheh
2011-07-21 19:48             ` [PATCH 7/7] btrfs: don't BUG_ON allocation errors in btrfs_drop_snapshot Mark Fasheh
2011-07-22  0:45               ` Tsutomu Itoh
2011-07-25 21:10                 ` Mark Fasheh
2011-07-26 13:14                   ` Justin Ossevoort
2011-07-22  0:56             ` [PATCH 6/7] btrfs: Don't BUG_ON alloc_path errors in find_next_chunk Tsutomu Itoh
2011-07-25 21:37               ` Mark Fasheh
  -- strict thread matches above, loose matches on Subject: below --
2011-07-14 22:14 [PATCH 0/7] btrfs: don't BUG_ON btrfs_alloc_path errors Mark Fasheh
2011-07-14 22:14 ` [PATCH 1/7] btrfs: don't BUG_ON btrfs_alloc_path() errors Mark Fasheh
2011-07-14 22:14   ` [PATCH 2/7] btrfs: Don't BUG_ON alloc_path errors in replay_one_buffer() Mark Fasheh
2011-07-14 22:14     ` [PATCH 3/7] btrfs: Don't BUG_ON alloc_path errors in btrfs_truncate_inode_items Mark Fasheh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1311277713-7747-4-git-send-email-mfasheh@suse.com \
    --to=mfasheh@suse.com \
    --cc=chris.mason@oracle.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).