1 jbd2: save some atomic ops in __JI_COMMIT_RUNNING handling
3 From: Jan Kara <jack@suse.cz>
5 Currently we used atomic bit operations to manipulate
6 __JI_COMMIT_RUNNING bit. However this is unnecessary as i_flags are
7 always written and read under j_list_lock. So just change the operations
8 to standard bit operations.
10 Signed-off-by: Jan Kara <jack@suse.cz>
11 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
13 fs/jbd2/commit.c | 12 ++++++------
14 fs/jbd2/journal.c | 2 +-
15 2 files changed, 7 insertions(+), 7 deletions(-)
17 diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
18 index ae832cd44dd8..517f2de784cf 100644
19 --- a/fs/jbd2/commit.c
20 +++ b/fs/jbd2/commit.c
21 @@ -220,7 +220,7 @@ static int journal_submit_data_buffers(journal_t *journal,
22 spin_lock(&journal->j_list_lock);
23 list_for_each_entry(jinode, &commit_transaction->t_inode_list, i_list) {
24 mapping = jinode->i_vfs_inode->i_mapping;
25 - set_bit(__JI_COMMIT_RUNNING, &jinode->i_flags);
26 + jinode->i_flags |= JI_COMMIT_RUNNING;
27 spin_unlock(&journal->j_list_lock);
29 * submit the inode data buffers. We use writepage
30 @@ -234,8 +234,8 @@ static int journal_submit_data_buffers(journal_t *journal,
32 spin_lock(&journal->j_list_lock);
33 J_ASSERT(jinode->i_transaction == commit_transaction);
34 - clear_bit(__JI_COMMIT_RUNNING, &jinode->i_flags);
35 - smp_mb__after_atomic();
36 + jinode->i_flags &= ~JI_COMMIT_RUNNING;
38 wake_up_bit(&jinode->i_flags, __JI_COMMIT_RUNNING);
40 spin_unlock(&journal->j_list_lock);
41 @@ -256,7 +256,7 @@ static int journal_finish_inode_data_buffers(journal_t *journal,
42 /* For locking, see the comment in journal_submit_data_buffers() */
43 spin_lock(&journal->j_list_lock);
44 list_for_each_entry(jinode, &commit_transaction->t_inode_list, i_list) {
45 - set_bit(__JI_COMMIT_RUNNING, &jinode->i_flags);
46 + jinode->i_flags |= JI_COMMIT_RUNNING;
47 spin_unlock(&journal->j_list_lock);
48 err = filemap_fdatawait(jinode->i_vfs_inode->i_mapping);
50 @@ -272,8 +272,8 @@ static int journal_finish_inode_data_buffers(journal_t *journal,
53 spin_lock(&journal->j_list_lock);
54 - clear_bit(__JI_COMMIT_RUNNING, &jinode->i_flags);
55 - smp_mb__after_atomic();
56 + jinode->i_flags &= ~JI_COMMIT_RUNNING;
58 wake_up_bit(&jinode->i_flags, __JI_COMMIT_RUNNING);
61 diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
62 index defa962a8e15..7bf1683e81af 100644
63 --- a/fs/jbd2/journal.c
64 +++ b/fs/jbd2/journal.c
65 @@ -2587,7 +2587,7 @@ void jbd2_journal_release_jbd_inode(journal_t *journal,
67 spin_lock(&journal->j_list_lock);
68 /* Is commit writing out inode - we have to wait */
69 - if (test_bit(__JI_COMMIT_RUNNING, &jinode->i_flags)) {
70 + if (jinode->i_flags & JI_COMMIT_RUNNING) {
71 wait_queue_head_t *wq;
72 DEFINE_WAIT_BIT(wait, &jinode->i_flags, __JI_COMMIT_RUNNING);
73 wq = bit_waitqueue(&jinode->i_flags, __JI_COMMIT_RUNNING);