diff options
Diffstat (limited to 'fs/reiserfs/journal.c')
-rw-r--r-- | fs/reiserfs/journal.c | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c index e396b2fa4743..c8f60ee183b5 100644 --- a/fs/reiserfs/journal.c +++ b/fs/reiserfs/journal.c | |||
@@ -34,15 +34,10 @@ | |||
34 | ** from within kupdate, it will ignore the immediate flag | 34 | ** from within kupdate, it will ignore the immediate flag |
35 | */ | 35 | */ |
36 | 36 | ||
37 | #include <asm/uaccess.h> | ||
38 | #include <asm/system.h> | ||
39 | |||
40 | #include <linux/time.h> | 37 | #include <linux/time.h> |
41 | #include <linux/semaphore.h> | 38 | #include <linux/semaphore.h> |
42 | |||
43 | #include <linux/vmalloc.h> | 39 | #include <linux/vmalloc.h> |
44 | #include <linux/reiserfs_fs.h> | 40 | #include <linux/reiserfs_fs.h> |
45 | |||
46 | #include <linux/kernel.h> | 41 | #include <linux/kernel.h> |
47 | #include <linux/errno.h> | 42 | #include <linux/errno.h> |
48 | #include <linux/fcntl.h> | 43 | #include <linux/fcntl.h> |
@@ -54,6 +49,9 @@ | |||
54 | #include <linux/writeback.h> | 49 | #include <linux/writeback.h> |
55 | #include <linux/blkdev.h> | 50 | #include <linux/blkdev.h> |
56 | #include <linux/backing-dev.h> | 51 | #include <linux/backing-dev.h> |
52 | #include <linux/uaccess.h> | ||
53 | |||
54 | #include <asm/system.h> | ||
57 | 55 | ||
58 | /* gets a struct reiserfs_journal_list * from a list head */ | 56 | /* gets a struct reiserfs_journal_list * from a list head */ |
59 | #define JOURNAL_LIST_ENTRY(h) (list_entry((h), struct reiserfs_journal_list, \ | 57 | #define JOURNAL_LIST_ENTRY(h) (list_entry((h), struct reiserfs_journal_list, \ |
@@ -558,13 +556,13 @@ static inline void insert_journal_hash(struct reiserfs_journal_cnode **table, | |||
558 | static inline void lock_journal(struct super_block *p_s_sb) | 556 | static inline void lock_journal(struct super_block *p_s_sb) |
559 | { | 557 | { |
560 | PROC_INFO_INC(p_s_sb, journal.lock_journal); | 558 | PROC_INFO_INC(p_s_sb, journal.lock_journal); |
561 | down(&SB_JOURNAL(p_s_sb)->j_lock); | 559 | mutex_lock(&SB_JOURNAL(p_s_sb)->j_mutex); |
562 | } | 560 | } |
563 | 561 | ||
564 | /* unlock the current transaction */ | 562 | /* unlock the current transaction */ |
565 | static inline void unlock_journal(struct super_block *p_s_sb) | 563 | static inline void unlock_journal(struct super_block *p_s_sb) |
566 | { | 564 | { |
567 | up(&SB_JOURNAL(p_s_sb)->j_lock); | 565 | mutex_unlock(&SB_JOURNAL(p_s_sb)->j_mutex); |
568 | } | 566 | } |
569 | 567 | ||
570 | static inline void get_journal_list(struct reiserfs_journal_list *jl) | 568 | static inline void get_journal_list(struct reiserfs_journal_list *jl) |
@@ -1045,9 +1043,9 @@ static int flush_commit_list(struct super_block *s, | |||
1045 | } | 1043 | } |
1046 | 1044 | ||
1047 | /* make sure nobody is trying to flush this one at the same time */ | 1045 | /* make sure nobody is trying to flush this one at the same time */ |
1048 | down(&jl->j_commit_lock); | 1046 | mutex_lock(&jl->j_commit_mutex); |
1049 | if (!journal_list_still_alive(s, trans_id)) { | 1047 | if (!journal_list_still_alive(s, trans_id)) { |
1050 | up(&jl->j_commit_lock); | 1048 | mutex_unlock(&jl->j_commit_mutex); |
1051 | goto put_jl; | 1049 | goto put_jl; |
1052 | } | 1050 | } |
1053 | BUG_ON(jl->j_trans_id == 0); | 1051 | BUG_ON(jl->j_trans_id == 0); |
@@ -1057,7 +1055,7 @@ static int flush_commit_list(struct super_block *s, | |||
1057 | if (flushall) { | 1055 | if (flushall) { |
1058 | atomic_set(&(jl->j_older_commits_done), 1); | 1056 | atomic_set(&(jl->j_older_commits_done), 1); |
1059 | } | 1057 | } |
1060 | up(&jl->j_commit_lock); | 1058 | mutex_unlock(&jl->j_commit_mutex); |
1061 | goto put_jl; | 1059 | goto put_jl; |
1062 | } | 1060 | } |
1063 | 1061 | ||
@@ -1181,7 +1179,7 @@ static int flush_commit_list(struct super_block *s, | |||
1181 | if (flushall) { | 1179 | if (flushall) { |
1182 | atomic_set(&(jl->j_older_commits_done), 1); | 1180 | atomic_set(&(jl->j_older_commits_done), 1); |
1183 | } | 1181 | } |
1184 | up(&jl->j_commit_lock); | 1182 | mutex_unlock(&jl->j_commit_mutex); |
1185 | put_jl: | 1183 | put_jl: |
1186 | put_journal_list(s, jl); | 1184 | put_journal_list(s, jl); |
1187 | 1185 | ||
@@ -1411,8 +1409,8 @@ static int flush_journal_list(struct super_block *s, | |||
1411 | 1409 | ||
1412 | /* if flushall == 0, the lock is already held */ | 1410 | /* if flushall == 0, the lock is already held */ |
1413 | if (flushall) { | 1411 | if (flushall) { |
1414 | down(&journal->j_flush_sem); | 1412 | mutex_lock(&journal->j_flush_mutex); |
1415 | } else if (!down_trylock(&journal->j_flush_sem)) { | 1413 | } else if (mutex_trylock(&journal->j_flush_mutex)) { |
1416 | BUG(); | 1414 | BUG(); |
1417 | } | 1415 | } |
1418 | 1416 | ||
@@ -1642,7 +1640,7 @@ static int flush_journal_list(struct super_block *s, | |||
1642 | jl->j_state = 0; | 1640 | jl->j_state = 0; |
1643 | put_journal_list(s, jl); | 1641 | put_journal_list(s, jl); |
1644 | if (flushall) | 1642 | if (flushall) |
1645 | up(&journal->j_flush_sem); | 1643 | mutex_unlock(&journal->j_flush_mutex); |
1646 | put_fs_excl(); | 1644 | put_fs_excl(); |
1647 | return err; | 1645 | return err; |
1648 | } | 1646 | } |
@@ -1772,12 +1770,12 @@ static int kupdate_transactions(struct super_block *s, | |||
1772 | struct reiserfs_journal *journal = SB_JOURNAL(s); | 1770 | struct reiserfs_journal *journal = SB_JOURNAL(s); |
1773 | chunk.nr = 0; | 1771 | chunk.nr = 0; |
1774 | 1772 | ||
1775 | down(&journal->j_flush_sem); | 1773 | mutex_lock(&journal->j_flush_mutex); |
1776 | if (!journal_list_still_alive(s, orig_trans_id)) { | 1774 | if (!journal_list_still_alive(s, orig_trans_id)) { |
1777 | goto done; | 1775 | goto done; |
1778 | } | 1776 | } |
1779 | 1777 | ||
1780 | /* we've got j_flush_sem held, nobody is going to delete any | 1778 | /* we've got j_flush_mutex held, nobody is going to delete any |
1781 | * of these lists out from underneath us | 1779 | * of these lists out from underneath us |
1782 | */ | 1780 | */ |
1783 | while ((num_trans && transactions_flushed < num_trans) || | 1781 | while ((num_trans && transactions_flushed < num_trans) || |
@@ -1812,7 +1810,7 @@ static int kupdate_transactions(struct super_block *s, | |||
1812 | } | 1810 | } |
1813 | 1811 | ||
1814 | done: | 1812 | done: |
1815 | up(&journal->j_flush_sem); | 1813 | mutex_unlock(&journal->j_flush_mutex); |
1816 | return ret; | 1814 | return ret; |
1817 | } | 1815 | } |
1818 | 1816 | ||
@@ -2556,7 +2554,7 @@ static struct reiserfs_journal_list *alloc_journal_list(struct super_block *s) | |||
2556 | INIT_LIST_HEAD(&jl->j_working_list); | 2554 | INIT_LIST_HEAD(&jl->j_working_list); |
2557 | INIT_LIST_HEAD(&jl->j_tail_bh_list); | 2555 | INIT_LIST_HEAD(&jl->j_tail_bh_list); |
2558 | INIT_LIST_HEAD(&jl->j_bh_list); | 2556 | INIT_LIST_HEAD(&jl->j_bh_list); |
2559 | sema_init(&jl->j_commit_lock, 1); | 2557 | mutex_init(&jl->j_commit_mutex); |
2560 | SB_JOURNAL(s)->j_num_lists++; | 2558 | SB_JOURNAL(s)->j_num_lists++; |
2561 | get_journal_list(jl); | 2559 | get_journal_list(jl); |
2562 | return jl; | 2560 | return jl; |
@@ -2837,8 +2835,8 @@ int journal_init(struct super_block *p_s_sb, const char *j_dev_name, | |||
2837 | journal->j_last = NULL; | 2835 | journal->j_last = NULL; |
2838 | journal->j_first = NULL; | 2836 | journal->j_first = NULL; |
2839 | init_waitqueue_head(&(journal->j_join_wait)); | 2837 | init_waitqueue_head(&(journal->j_join_wait)); |
2840 | sema_init(&journal->j_lock, 1); | 2838 | mutex_init(&journal->j_mutex); |
2841 | sema_init(&journal->j_flush_sem, 1); | 2839 | mutex_init(&journal->j_flush_mutex); |
2842 | 2840 | ||
2843 | journal->j_trans_id = 10; | 2841 | journal->j_trans_id = 10; |
2844 | journal->j_mount_id = 10; | 2842 | journal->j_mount_id = 10; |
@@ -4030,7 +4028,7 @@ static int do_journal_end(struct reiserfs_transaction_handle *th, | |||
4030 | * the new transaction is fully setup, and we've already flushed the | 4028 | * the new transaction is fully setup, and we've already flushed the |
4031 | * ordered bh list | 4029 | * ordered bh list |
4032 | */ | 4030 | */ |
4033 | down(&jl->j_commit_lock); | 4031 | mutex_lock(&jl->j_commit_mutex); |
4034 | 4032 | ||
4035 | /* save the transaction id in case we need to commit it later */ | 4033 | /* save the transaction id in case we need to commit it later */ |
4036 | commit_trans_id = jl->j_trans_id; | 4034 | commit_trans_id = jl->j_trans_id; |
@@ -4196,7 +4194,7 @@ static int do_journal_end(struct reiserfs_transaction_handle *th, | |||
4196 | lock_kernel(); | 4194 | lock_kernel(); |
4197 | } | 4195 | } |
4198 | BUG_ON(!list_empty(&jl->j_tail_bh_list)); | 4196 | BUG_ON(!list_empty(&jl->j_tail_bh_list)); |
4199 | up(&jl->j_commit_lock); | 4197 | mutex_unlock(&jl->j_commit_mutex); |
4200 | 4198 | ||
4201 | /* honor the flush wishes from the caller, simple commits can | 4199 | /* honor the flush wishes from the caller, simple commits can |
4202 | ** be done outside the journal lock, they are done below | 4200 | ** be done outside the journal lock, they are done below |