提交 3f1e3fa6 编写于 作者: M Miao Xie 提交者: Josef Bacik

Btrfs: remove unnecessary varient ->num_joined in btrfs_transaction structure

We used ->num_joined track if there were some writers which join the current
transaction when the committer was sleeping. If some writers joined the current
transaction, we has to continue the while loop to do some necessary stuff, such
as flush the ordered operations. But it is unnecessary because we will do it
after the while loop.

Besides that, tracking ->num_joined would make the committer drop into the while
loop when there are lots of internal writers(TRANS_JOIN).

So we remove ->num_joined and don't track if there are some writers which join
the current transaction when the committer is sleeping.
Signed-off-by: NMiao Xie <miaox@cn.fujitsu.com>
Signed-off-by: NJosef Bacik <jbacik@fusionio.com>
上级 82436617
...@@ -124,7 +124,6 @@ static noinline int join_transaction(struct btrfs_root *root, unsigned int type) ...@@ -124,7 +124,6 @@ static noinline int join_transaction(struct btrfs_root *root, unsigned int type)
atomic_inc(&cur_trans->use_count); atomic_inc(&cur_trans->use_count);
atomic_inc(&cur_trans->num_writers); atomic_inc(&cur_trans->num_writers);
extwriter_counter_inc(cur_trans, type); extwriter_counter_inc(cur_trans, type);
cur_trans->num_joined++;
spin_unlock(&fs_info->trans_lock); spin_unlock(&fs_info->trans_lock);
return 0; return 0;
} }
...@@ -157,7 +156,6 @@ static noinline int join_transaction(struct btrfs_root *root, unsigned int type) ...@@ -157,7 +156,6 @@ static noinline int join_transaction(struct btrfs_root *root, unsigned int type)
atomic_set(&cur_trans->num_writers, 1); atomic_set(&cur_trans->num_writers, 1);
extwriter_counter_init(cur_trans, type); extwriter_counter_init(cur_trans, type);
cur_trans->num_joined = 0;
init_waitqueue_head(&cur_trans->writer_wait); init_waitqueue_head(&cur_trans->writer_wait);
init_waitqueue_head(&cur_trans->commit_wait); init_waitqueue_head(&cur_trans->commit_wait);
cur_trans->in_commit = 0; cur_trans->in_commit = 0;
...@@ -1566,7 +1564,6 @@ static inline void btrfs_wait_delalloc_flush(struct btrfs_fs_info *fs_info) ...@@ -1566,7 +1564,6 @@ static inline void btrfs_wait_delalloc_flush(struct btrfs_fs_info *fs_info)
int btrfs_commit_transaction(struct btrfs_trans_handle *trans, int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
struct btrfs_root *root) struct btrfs_root *root)
{ {
unsigned long joined = 0;
struct btrfs_transaction *cur_trans = trans->transaction; struct btrfs_transaction *cur_trans = trans->transaction;
struct btrfs_transaction *prev_trans = NULL; struct btrfs_transaction *prev_trans = NULL;
DEFINE_WAIT(wait); DEFINE_WAIT(wait);
...@@ -1668,8 +1665,6 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, ...@@ -1668,8 +1665,6 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
should_grow = 1; should_grow = 1;
do { do {
joined = cur_trans->num_joined;
WARN_ON(cur_trans != trans->transaction); WARN_ON(cur_trans != trans->transaction);
ret = btrfs_flush_all_pending_stuffs(trans, root); ret = btrfs_flush_all_pending_stuffs(trans, root);
...@@ -1685,8 +1680,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, ...@@ -1685,8 +1680,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
schedule_timeout(1); schedule_timeout(1);
finish_wait(&cur_trans->writer_wait, &wait); finish_wait(&cur_trans->writer_wait, &wait);
} while (extwriter_counter_read(cur_trans) > 0 || } while (extwriter_counter_read(cur_trans) > 0);
(should_grow && cur_trans->num_joined != joined));
ret = btrfs_flush_all_pending_stuffs(trans, root); ret = btrfs_flush_all_pending_stuffs(trans, root);
if (ret) if (ret)
......
...@@ -37,8 +37,6 @@ struct btrfs_transaction { ...@@ -37,8 +37,6 @@ struct btrfs_transaction {
atomic_t num_writers; atomic_t num_writers;
atomic_t use_count; atomic_t use_count;
unsigned long num_joined;
spinlock_t commit_lock; spinlock_t commit_lock;
int in_commit; int in_commit;
int commit_done; int commit_done;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册