From: "Liu Hui" <onlyflyer@gmail.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATH]Some fix for batching extent insert.
Date: Mon, 17 Nov 2008 23:48:26 +0800 [thread overview]
Message-ID: <2c3b11250811170748s508ec4ddlfce9ad80bb296d95@mail.gmail.com> (raw)
Hi,
When I review the code about batching extent insert, I found some code
could result in problems in some corner cases.
1)In finish_current_insert(), when it finds nothing to insert and it
has skipped some locked extents, it should try again to see if the
locked extent is unlocked. So, it will re-search the extent_ins
extent_io_tree by reseting 'search' to 0. There is one place forget to
reset the 'search' pointer to 0 which will lead BTRFS not to finish
*all* current insert.
2)In insert_extents(), when ret==1 and last is not zero, it should
check if the current inserted item is the last item in this batching
inserts. If so, it should just break from loop. If not, 'cur =
insert_list->next' will make no sense because the list is empty now,
and 'op' will point to an unexpectable place.
3)There are also some trivial fixs in this patch including one comment
typo error and deleting two redundant lines.
--
Thanks & Best Regards
Hui
--
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 8bb4524..0d0e2e7 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -3033,7 +3033,6 @@ int btrfs_insert_some_items(struct
btrfs_trans_handle *trans,
struct btrfs_item *item;
int ret = 0;
int slot;
- int slot_orig;
int i;
u32 nritems;
u32 total_data = 0;
@@ -3056,7 +3055,6 @@ int btrfs_insert_some_items(struct
btrfs_trans_handle *trans,
if (ret < 0)
goto out;
- slot_orig = path->slots[0];
leaf = path->nodes[0];
nritems = btrfs_header_nritems(leaf);
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index e785f0a..be5b376 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -783,7 +783,7 @@ static int noinline insert_extents(struct
btrfs_trans_handle *trans,
i = total - 1;
cur = insert_list->prev;
op = list_entry(cur, struct pending_extent_op, list);
- } else if (last) {
+ } else if (last && (i + ret < total)) {
/*
* ok we successfully inserted the last item on the
* list, lets reset everything
@@ -2145,6 +2145,7 @@ again:
if (ret) {
if (skipped && all && !num_inserts) {
skipped = 0;
+ search = 0;
continue;
}
mutex_unlock(&info->extent_ins_mutex);
@@ -2184,7 +2185,7 @@ again:
}
/*
- * process teh update list, clear the writeback bit for it, and if
+ * process the update list, clear the writeback bit for it, and if
* somebody marked this thing for deletion then just unlock it and be
* done, the free_extents will handle it
*/
next reply other threads:[~2008-11-17 15:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-17 15:48 Liu Hui [this message]
2008-11-18 12:17 ` [PATH]Some fix for batching extent insert Chris Mason
2008-11-18 12:30 ` Chris Mason
2008-11-18 14:35 ` yanhai zhu
2008-11-18 14:48 ` Chris Mason
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=2c3b11250811170748s508ec4ddlfce9ad80bb296d95@mail.gmail.com \
--to=onlyflyer@gmail.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