From: Zach Brown <zab@redhat.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 5/6] btrfs: add helper to get delayed item root
Date: Tue, 4 Jun 2013 15:17:59 -0700 [thread overview]
Message-ID: <1370384280-28652-6-git-send-email-zab@redhat.com> (raw)
In-Reply-To: <1370384280-28652-1-git-send-email-zab@redhat.com>
This just moves some duplicated code into a helper. I couldn't bring
myself to add another copy in an upcoming patch.
The delayed_root BUG() in __btrfs_remove_delayed_item() wasn't needed.
The pointer deref will oops later if its null.
And now the remaining BUG() is in one place! :)
Signed-off-by: Zach Brown <zab@redhat.com>
---
fs/btrfs/delayed-inode.c | 28 +++++++++++++---------------
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index 67e0f9f..fcce951 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -382,6 +382,16 @@ static struct btrfs_delayed_item *__btrfs_lookup_delayed_insertion_item(
return item;
}
+static struct rb_root *get_ins_del_root(struct btrfs_delayed_node *delayed_node,
+ int ins_del)
+{
+ if (ins_del == BTRFS_DELAYED_INSERTION_ITEM)
+ return &delayed_node->ins_root;
+ if (ins_del == BTRFS_DELAYED_DELETION_ITEM)
+ return &delayed_node->del_root;
+ BUG();
+}
+
static int __btrfs_add_delayed_item(struct btrfs_delayed_node *delayed_node,
struct btrfs_delayed_item *ins,
int action)
@@ -392,12 +402,7 @@ static int __btrfs_add_delayed_item(struct btrfs_delayed_node *delayed_node,
struct btrfs_delayed_item *item;
int cmp;
- if (action == BTRFS_DELAYED_INSERTION_ITEM)
- root = &delayed_node->ins_root;
- else if (action == BTRFS_DELAYED_DELETION_ITEM)
- root = &delayed_node->del_root;
- else
- BUG();
+ root = get_ins_del_root(delayed_node, action);
p = &root->rb_node;
node = &ins->rb_node;
@@ -460,15 +465,8 @@ static void __btrfs_remove_delayed_item(struct btrfs_delayed_item *delayed_item)
delayed_root = delayed_item->delayed_node->root->fs_info->delayed_root;
- BUG_ON(!delayed_root);
- BUG_ON(delayed_item->ins_or_del != BTRFS_DELAYED_DELETION_ITEM &&
- delayed_item->ins_or_del != BTRFS_DELAYED_INSERTION_ITEM);
-
- if (delayed_item->ins_or_del == BTRFS_DELAYED_INSERTION_ITEM)
- root = &delayed_item->delayed_node->ins_root;
- else
- root = &delayed_item->delayed_node->del_root;
-
+ root = get_ins_del_root(delayed_item->delayed_node,
+ delayed_item->ins_or_del);
rb_erase(&delayed_item->rb_node, root);
delayed_item->delayed_node->count--;
--
1.7.11.7
next prev parent reply other threads:[~2013-06-04 22:18 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-04 22:17 [PATCH 0/6] fix INT_MAX readdir hang, plus cleanups Zach Brown
2013-06-04 22:17 ` [PATCH 1/6] btrfs: set readdir f_pos only after filldir Zach Brown
2013-06-05 1:19 ` Miao Xie
2013-06-04 22:17 ` [PATCH 2/6] btrfs: fix readdir hang with offsets past INT_MAX Zach Brown
2013-06-04 22:17 ` [PATCH 3/6] btrfs: trivial delayed item readdir list cleanups Zach Brown
2013-06-04 22:17 ` [PATCH 4/6] btrfs: simplify finding next/prev delayed items Zach Brown
2013-06-04 22:17 ` Zach Brown [this message]
2013-06-04 22:18 ` [PATCH 6/6] btrfs: get fewer delayed item refs during readdir Zach Brown
2013-06-04 23:16 ` [PATCH 0/6] fix INT_MAX readdir hang, plus cleanups Chris Mason
2013-06-04 23:26 ` Zach Brown
2013-06-05 2:34 ` Miao Xie
2013-06-05 13:36 ` David Sterba
2013-06-06 1:35 ` Miao Xie
2013-06-06 13:55 ` David Sterba
2013-06-06 14:32 ` Chris Mason
2013-06-10 22:39 ` Zach Brown
2013-06-12 12:59 ` Chris Mason
2013-07-01 12:54 ` Josef Bacik
2013-07-01 13:18 ` Chris Mason
2013-07-01 16:10 ` Zach Brown
2013-07-01 17:18 ` Chris Mason
2013-07-11 23:19 ` Zach Brown
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=1370384280-28652-6-git-send-email-zab@redhat.com \
--to=zab@redhat.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).