diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2006-02-21 07:51:39 -0500 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2006-02-21 07:51:39 -0500 |
commit | f55ab26a8f92a23988c3e6da28dae4741933a4e2 (patch) | |
tree | b6f9e89ce1b2ccde8d81314aeea06f6a02f882f7 | |
parent | 5c4e9e036678fae65c9288e1c00a6f33cd447283 (diff) |
[GFS2] Use mutices rather than semaphores
As well as a number of minor bug fixes, this patch changes GFS
to use mutices rather than semaphores. This results in better
information in case there are any locking problems.
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
-rw-r--r-- | fs/gfs2/glock.c | 8 | ||||
-rw-r--r-- | fs/gfs2/incore.h | 22 | ||||
-rw-r--r-- | fs/gfs2/inode.c | 12 | ||||
-rw-r--r-- | fs/gfs2/log.c | 54 | ||||
-rw-r--r-- | fs/gfs2/log.h | 3 | ||||
-rw-r--r-- | fs/gfs2/lops.c | 36 | ||||
-rw-r--r-- | fs/gfs2/meta_io.c | 2 | ||||
-rw-r--r-- | fs/gfs2/ops_address.c | 1 | ||||
-rw-r--r-- | fs/gfs2/ops_file.c | 10 | ||||
-rw-r--r-- | fs/gfs2/ops_fstype.c | 18 | ||||
-rw-r--r-- | fs/gfs2/ops_super.c | 4 | ||||
-rw-r--r-- | fs/gfs2/quota.c | 16 | ||||
-rw-r--r-- | fs/gfs2/rgrp.c | 18 | ||||
-rw-r--r-- | fs/gfs2/super.c | 20 | ||||
-rw-r--r-- | fs/gfs2/sys.c | 4 | ||||
-rw-r--r-- | fs/gfs2/trans.c | 4 | ||||
-rw-r--r-- | fs/gfs2/unlinked.c | 4 |
17 files changed, 118 insertions, 118 deletions
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 321945fde12d..4df78ecfeeb3 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c | |||
@@ -149,7 +149,7 @@ int gfs2_glock_put(struct gfs2_glock *gl) | |||
149 | struct gfs2_gl_hash_bucket *bucket = gl->gl_bucket; | 149 | struct gfs2_gl_hash_bucket *bucket = gl->gl_bucket; |
150 | int rv = 0; | 150 | int rv = 0; |
151 | 151 | ||
152 | down(&sdp->sd_invalidate_inodes_mutex); | 152 | mutex_lock(&sdp->sd_invalidate_inodes_mutex); |
153 | 153 | ||
154 | write_lock(&bucket->hb_lock); | 154 | write_lock(&bucket->hb_lock); |
155 | if (kref_put(&gl->gl_ref, kill_glock)) { | 155 | if (kref_put(&gl->gl_ref, kill_glock)) { |
@@ -161,7 +161,7 @@ int gfs2_glock_put(struct gfs2_glock *gl) | |||
161 | } | 161 | } |
162 | write_unlock(&bucket->hb_lock); | 162 | write_unlock(&bucket->hb_lock); |
163 | out: | 163 | out: |
164 | up(&sdp->sd_invalidate_inodes_mutex); | 164 | mutex_unlock(&sdp->sd_invalidate_inodes_mutex); |
165 | return rv; | 165 | return rv; |
166 | } | 166 | } |
167 | 167 | ||
@@ -2312,9 +2312,9 @@ void gfs2_gl_hash_clear(struct gfs2_sbd *sdp, int wait) | |||
2312 | invalidate_inodes_mutex prevents glock_put()'s during | 2312 | invalidate_inodes_mutex prevents glock_put()'s during |
2313 | an invalidate_inodes() */ | 2313 | an invalidate_inodes() */ |
2314 | 2314 | ||
2315 | down(&sdp->sd_invalidate_inodes_mutex); | 2315 | mutex_lock(&sdp->sd_invalidate_inodes_mutex); |
2316 | invalidate_inodes(sdp->sd_vfs); | 2316 | invalidate_inodes(sdp->sd_vfs); |
2317 | up(&sdp->sd_invalidate_inodes_mutex); | 2317 | mutex_unlock(&sdp->sd_invalidate_inodes_mutex); |
2318 | yield(); | 2318 | yield(); |
2319 | } | 2319 | } |
2320 | } | 2320 | } |
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index e43a0475d0d8..7fe422537ff0 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h | |||
@@ -88,7 +88,7 @@ struct gfs2_rgrpd { | |||
88 | uint64_t rd_rg_vn; | 88 | uint64_t rd_rg_vn; |
89 | struct gfs2_bitmap *rd_bits; | 89 | struct gfs2_bitmap *rd_bits; |
90 | unsigned int rd_bh_count; | 90 | unsigned int rd_bh_count; |
91 | struct semaphore rd_mutex; | 91 | struct mutex rd_mutex; |
92 | uint32_t rd_free_clone; | 92 | uint32_t rd_free_clone; |
93 | struct gfs2_log_element rd_le; | 93 | struct gfs2_log_element rd_le; |
94 | uint32_t rd_last_alloc_data; | 94 | uint32_t rd_last_alloc_data; |
@@ -277,7 +277,7 @@ enum { | |||
277 | struct gfs2_file { | 277 | struct gfs2_file { |
278 | unsigned long f_flags; /* GFF_... */ | 278 | unsigned long f_flags; /* GFF_... */ |
279 | 279 | ||
280 | struct semaphore f_fl_mutex; | 280 | struct mutex f_fl_mutex; |
281 | struct gfs2_holder f_fl_gh; | 281 | struct gfs2_holder f_fl_gh; |
282 | 282 | ||
283 | struct gfs2_inode *f_inode; | 283 | struct gfs2_inode *f_inode; |
@@ -510,7 +510,7 @@ struct gfs2_sbd { | |||
510 | struct gfs2_holder sd_live_gh; | 510 | struct gfs2_holder sd_live_gh; |
511 | struct gfs2_glock *sd_rename_gl; | 511 | struct gfs2_glock *sd_rename_gl; |
512 | struct gfs2_glock *sd_trans_gl; | 512 | struct gfs2_glock *sd_trans_gl; |
513 | struct semaphore sd_invalidate_inodes_mutex; | 513 | struct mutex sd_invalidate_inodes_mutex; |
514 | 514 | ||
515 | /* Inode Stuff */ | 515 | /* Inode Stuff */ |
516 | 516 | ||
@@ -528,12 +528,12 @@ struct gfs2_sbd { | |||
528 | 528 | ||
529 | /* Inum stuff */ | 529 | /* Inum stuff */ |
530 | 530 | ||
531 | struct semaphore sd_inum_mutex; | 531 | struct mutex sd_inum_mutex; |
532 | 532 | ||
533 | /* StatFS stuff */ | 533 | /* StatFS stuff */ |
534 | 534 | ||
535 | spinlock_t sd_statfs_spin; | 535 | spinlock_t sd_statfs_spin; |
536 | struct semaphore sd_statfs_mutex; | 536 | struct mutex sd_statfs_mutex; |
537 | struct gfs2_statfs_change sd_statfs_master; | 537 | struct gfs2_statfs_change sd_statfs_master; |
538 | struct gfs2_statfs_change sd_statfs_local; | 538 | struct gfs2_statfs_change sd_statfs_local; |
539 | unsigned long sd_statfs_sync_time; | 539 | unsigned long sd_statfs_sync_time; |
@@ -542,7 +542,7 @@ struct gfs2_sbd { | |||
542 | 542 | ||
543 | uint64_t sd_rindex_vn; | 543 | uint64_t sd_rindex_vn; |
544 | spinlock_t sd_rindex_spin; | 544 | spinlock_t sd_rindex_spin; |
545 | struct semaphore sd_rindex_mutex; | 545 | struct mutex sd_rindex_mutex; |
546 | struct list_head sd_rindex_list; | 546 | struct list_head sd_rindex_list; |
547 | struct list_head sd_rindex_mru_list; | 547 | struct list_head sd_rindex_mru_list; |
548 | struct list_head sd_rindex_recent_list; | 548 | struct list_head sd_rindex_recent_list; |
@@ -553,7 +553,7 @@ struct gfs2_sbd { | |||
553 | 553 | ||
554 | struct list_head sd_jindex_list; | 554 | struct list_head sd_jindex_list; |
555 | spinlock_t sd_jindex_spin; | 555 | spinlock_t sd_jindex_spin; |
556 | struct semaphore sd_jindex_mutex; | 556 | struct mutex sd_jindex_mutex; |
557 | unsigned int sd_journals; | 557 | unsigned int sd_journals; |
558 | unsigned long sd_jindex_refresh_time; | 558 | unsigned long sd_jindex_refresh_time; |
559 | 559 | ||
@@ -581,7 +581,7 @@ struct gfs2_sbd { | |||
581 | struct list_head sd_unlinked_list; | 581 | struct list_head sd_unlinked_list; |
582 | atomic_t sd_unlinked_count; | 582 | atomic_t sd_unlinked_count; |
583 | spinlock_t sd_unlinked_spin; | 583 | spinlock_t sd_unlinked_spin; |
584 | struct semaphore sd_unlinked_mutex; | 584 | struct mutex sd_unlinked_mutex; |
585 | 585 | ||
586 | unsigned int sd_unlinked_slots; | 586 | unsigned int sd_unlinked_slots; |
587 | unsigned int sd_unlinked_chunks; | 587 | unsigned int sd_unlinked_chunks; |
@@ -592,7 +592,7 @@ struct gfs2_sbd { | |||
592 | struct list_head sd_quota_list; | 592 | struct list_head sd_quota_list; |
593 | atomic_t sd_quota_count; | 593 | atomic_t sd_quota_count; |
594 | spinlock_t sd_quota_spin; | 594 | spinlock_t sd_quota_spin; |
595 | struct semaphore sd_quota_mutex; | 595 | struct mutex sd_quota_mutex; |
596 | 596 | ||
597 | unsigned int sd_quota_slots; | 597 | unsigned int sd_quota_slots; |
598 | unsigned int sd_quota_chunks; | 598 | unsigned int sd_quota_chunks; |
@@ -637,7 +637,7 @@ struct gfs2_sbd { | |||
637 | int sd_log_idle; | 637 | int sd_log_idle; |
638 | 638 | ||
639 | unsigned long sd_log_flush_time; | 639 | unsigned long sd_log_flush_time; |
640 | struct semaphore sd_log_flush_lock; | 640 | struct mutex sd_log_flush_lock; |
641 | struct list_head sd_log_flush_list; | 641 | struct list_head sd_log_flush_list; |
642 | 642 | ||
643 | unsigned int sd_log_flush_head; | 643 | unsigned int sd_log_flush_head; |
@@ -659,7 +659,7 @@ struct gfs2_sbd { | |||
659 | /* For quiescing the filesystem */ | 659 | /* For quiescing the filesystem */ |
660 | 660 | ||
661 | struct gfs2_holder sd_freeze_gh; | 661 | struct gfs2_holder sd_freeze_gh; |
662 | struct semaphore sd_freeze_lock; | 662 | struct mutex sd_freeze_lock; |
663 | unsigned int sd_freeze_count; | 663 | unsigned int sd_freeze_count; |
664 | 664 | ||
665 | /* Counters */ | 665 | /* Counters */ |
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 2a00b96eac01..30ca82a1addf 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c | |||
@@ -782,11 +782,11 @@ static int pick_formal_ino_1(struct gfs2_sbd *sdp, uint64_t *formal_ino) | |||
782 | error = gfs2_trans_begin(sdp, RES_DINODE, 0); | 782 | error = gfs2_trans_begin(sdp, RES_DINODE, 0); |
783 | if (error) | 783 | if (error) |
784 | return error; | 784 | return error; |
785 | down(&sdp->sd_inum_mutex); | 785 | mutex_lock(&sdp->sd_inum_mutex); |
786 | 786 | ||
787 | error = gfs2_meta_inode_buffer(ip, &bh); | 787 | error = gfs2_meta_inode_buffer(ip, &bh); |
788 | if (error) { | 788 | if (error) { |
789 | up(&sdp->sd_inum_mutex); | 789 | mutex_unlock(&sdp->sd_inum_mutex); |
790 | gfs2_trans_end(sdp); | 790 | gfs2_trans_end(sdp); |
791 | return error; | 791 | return error; |
792 | } | 792 | } |
@@ -800,14 +800,14 @@ static int pick_formal_ino_1(struct gfs2_sbd *sdp, uint64_t *formal_ino) | |||
800 | gfs2_inum_range_out(&ir, | 800 | gfs2_inum_range_out(&ir, |
801 | bh->b_data + sizeof(struct gfs2_dinode)); | 801 | bh->b_data + sizeof(struct gfs2_dinode)); |
802 | brelse(bh); | 802 | brelse(bh); |
803 | up(&sdp->sd_inum_mutex); | 803 | mutex_unlock(&sdp->sd_inum_mutex); |
804 | gfs2_trans_end(sdp); | 804 | gfs2_trans_end(sdp); |
805 | return 0; | 805 | return 0; |
806 | } | 806 | } |
807 | 807 | ||
808 | brelse(bh); | 808 | brelse(bh); |
809 | 809 | ||
810 | up(&sdp->sd_inum_mutex); | 810 | mutex_unlock(&sdp->sd_inum_mutex); |
811 | gfs2_trans_end(sdp); | 811 | gfs2_trans_end(sdp); |
812 | 812 | ||
813 | return 1; | 813 | return 1; |
@@ -829,7 +829,7 @@ static int pick_formal_ino_2(struct gfs2_sbd *sdp, uint64_t *formal_ino) | |||
829 | error = gfs2_trans_begin(sdp, 2 * RES_DINODE, 0); | 829 | error = gfs2_trans_begin(sdp, 2 * RES_DINODE, 0); |
830 | if (error) | 830 | if (error) |
831 | goto out; | 831 | goto out; |
832 | down(&sdp->sd_inum_mutex); | 832 | mutex_lock(&sdp->sd_inum_mutex); |
833 | 833 | ||
834 | error = gfs2_meta_inode_buffer(ip, &bh); | 834 | error = gfs2_meta_inode_buffer(ip, &bh); |
835 | if (error) | 835 | if (error) |
@@ -869,7 +869,7 @@ static int pick_formal_ino_2(struct gfs2_sbd *sdp, uint64_t *formal_ino) | |||
869 | brelse(bh); | 869 | brelse(bh); |
870 | 870 | ||
871 | out_end_trans: | 871 | out_end_trans: |
872 | up(&sdp->sd_inum_mutex); | 872 | mutex_unlock(&sdp->sd_inum_mutex); |
873 | gfs2_trans_end(sdp); | 873 | gfs2_trans_end(sdp); |
874 | 874 | ||
875 | out: | 875 | out: |
diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c index 49190a29dd4f..e6acb41332e7 100644 --- a/fs/gfs2/log.c +++ b/fs/gfs2/log.c | |||
@@ -23,29 +23,16 @@ | |||
23 | 23 | ||
24 | #define PULL 1 | 24 | #define PULL 1 |
25 | 25 | ||
26 | static inline int is_done(struct gfs2_sbd *sdp, atomic_t *a) | ||
27 | { | ||
28 | int done; | ||
29 | gfs2_log_lock(sdp); | ||
30 | done = atomic_read(a) ? 0 : 1; | ||
31 | gfs2_log_unlock(sdp); | ||
32 | return done; | ||
33 | } | ||
34 | |||
35 | static void do_lock_wait(struct gfs2_sbd *sdp, wait_queue_head_t *wq, | 26 | static void do_lock_wait(struct gfs2_sbd *sdp, wait_queue_head_t *wq, |
36 | atomic_t *a) | 27 | atomic_t *a) |
37 | { | 28 | { |
38 | gfs2_log_unlock(sdp); | 29 | wait_event(*wq, atomic_read(a) ? 0 : 1); |
39 | wait_event(*wq, is_done(sdp, a)); | ||
40 | gfs2_log_lock(sdp); | ||
41 | } | 30 | } |
42 | 31 | ||
43 | static void lock_for_trans(struct gfs2_sbd *sdp) | 32 | static void lock_for_trans(struct gfs2_sbd *sdp) |
44 | { | 33 | { |
45 | gfs2_log_lock(sdp); | ||
46 | do_lock_wait(sdp, &sdp->sd_log_trans_wq, &sdp->sd_log_flush_count); | 34 | do_lock_wait(sdp, &sdp->sd_log_trans_wq, &sdp->sd_log_flush_count); |
47 | atomic_inc(&sdp->sd_log_trans_count); | 35 | atomic_inc(&sdp->sd_log_trans_count); |
48 | gfs2_log_unlock(sdp); | ||
49 | } | 36 | } |
50 | 37 | ||
51 | static void unlock_from_trans(struct gfs2_sbd *sdp) | 38 | static void unlock_from_trans(struct gfs2_sbd *sdp) |
@@ -55,15 +42,13 @@ static void unlock_from_trans(struct gfs2_sbd *sdp) | |||
55 | wake_up(&sdp->sd_log_flush_wq); | 42 | wake_up(&sdp->sd_log_flush_wq); |
56 | } | 43 | } |
57 | 44 | ||
58 | void gfs2_lock_for_flush(struct gfs2_sbd *sdp) | 45 | static void gfs2_lock_for_flush(struct gfs2_sbd *sdp) |
59 | { | 46 | { |
60 | gfs2_log_lock(sdp); | ||
61 | atomic_inc(&sdp->sd_log_flush_count); | 47 | atomic_inc(&sdp->sd_log_flush_count); |
62 | do_lock_wait(sdp, &sdp->sd_log_flush_wq, &sdp->sd_log_trans_count); | 48 | do_lock_wait(sdp, &sdp->sd_log_flush_wq, &sdp->sd_log_trans_count); |
63 | gfs2_log_unlock(sdp); | ||
64 | } | 49 | } |
65 | 50 | ||
66 | void gfs2_unlock_from_flush(struct gfs2_sbd *sdp) | 51 | static void gfs2_unlock_from_flush(struct gfs2_sbd *sdp) |
67 | { | 52 | { |
68 | gfs2_assert_warn(sdp, atomic_read(&sdp->sd_log_flush_count)); | 53 | gfs2_assert_warn(sdp, atomic_read(&sdp->sd_log_flush_count)); |
69 | if (atomic_dec_and_test(&sdp->sd_log_flush_count)) | 54 | if (atomic_dec_and_test(&sdp->sd_log_flush_count)) |
@@ -209,7 +194,6 @@ int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks) | |||
209 | 194 | ||
210 | for (;;) { | 195 | for (;;) { |
211 | gfs2_log_lock(sdp); | 196 | gfs2_log_lock(sdp); |
212 | |||
213 | if (list_empty(&list)) { | 197 | if (list_empty(&list)) { |
214 | list_add_tail(&list, &sdp->sd_log_blks_list); | 198 | list_add_tail(&list, &sdp->sd_log_blks_list); |
215 | while (sdp->sd_log_blks_list.next != &list) { | 199 | while (sdp->sd_log_blks_list.next != &list) { |
@@ -225,7 +209,6 @@ int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks) | |||
225 | set_current_state(TASK_RUNNING); | 209 | set_current_state(TASK_RUNNING); |
226 | } | 210 | } |
227 | } | 211 | } |
228 | |||
229 | /* Never give away the last block so we can | 212 | /* Never give away the last block so we can |
230 | always pull the tail if we need to. */ | 213 | always pull the tail if we need to. */ |
231 | if (sdp->sd_log_blks_free > blks) { | 214 | if (sdp->sd_log_blks_free > blks) { |
@@ -237,14 +220,12 @@ int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks) | |||
237 | } | 220 | } |
238 | 221 | ||
239 | gfs2_log_unlock(sdp); | 222 | gfs2_log_unlock(sdp); |
240 | |||
241 | gfs2_ail1_empty(sdp, 0); | 223 | gfs2_ail1_empty(sdp, 0); |
242 | gfs2_log_flush(sdp); | 224 | gfs2_log_flush(sdp); |
243 | 225 | ||
244 | if (try++) | 226 | if (try++) |
245 | gfs2_ail1_start(sdp, 0); | 227 | gfs2_ail1_start(sdp, 0); |
246 | } | 228 | } |
247 | |||
248 | lock_for_trans(sdp); | 229 | lock_for_trans(sdp); |
249 | 230 | ||
250 | return 0; | 231 | return 0; |
@@ -512,22 +493,26 @@ void gfs2_log_flush_i(struct gfs2_sbd *sdp, struct gfs2_glock *gl) | |||
512 | ai = kzalloc(sizeof(struct gfs2_ail), GFP_NOFS | __GFP_NOFAIL); | 493 | ai = kzalloc(sizeof(struct gfs2_ail), GFP_NOFS | __GFP_NOFAIL); |
513 | INIT_LIST_HEAD(&ai->ai_ail1_list); | 494 | INIT_LIST_HEAD(&ai->ai_ail1_list); |
514 | INIT_LIST_HEAD(&ai->ai_ail2_list); | 495 | INIT_LIST_HEAD(&ai->ai_ail2_list); |
515 | |||
516 | gfs2_lock_for_flush(sdp); | 496 | gfs2_lock_for_flush(sdp); |
517 | down(&sdp->sd_log_flush_lock); | 497 | |
498 | if (gl) { | ||
499 | gfs2_log_lock(sdp); | ||
500 | if (list_empty(&gl->gl_le.le_list)) { | ||
501 | gfs2_log_unlock(sdp); | ||
502 | gfs2_unlock_from_flush(sdp); | ||
503 | kfree(ai); | ||
504 | return; | ||
505 | } | ||
506 | gfs2_log_unlock(sdp); | ||
507 | } | ||
508 | |||
509 | mutex_lock(&sdp->sd_log_flush_lock); | ||
518 | 510 | ||
519 | gfs2_assert_withdraw(sdp, | 511 | gfs2_assert_withdraw(sdp, |
520 | sdp->sd_log_num_buf == sdp->sd_log_commited_buf); | 512 | sdp->sd_log_num_buf == sdp->sd_log_commited_buf); |
521 | gfs2_assert_withdraw(sdp, | 513 | gfs2_assert_withdraw(sdp, |
522 | sdp->sd_log_num_revoke == sdp->sd_log_commited_revoke); | 514 | sdp->sd_log_num_revoke == sdp->sd_log_commited_revoke); |
523 | 515 | ||
524 | if (gl && list_empty(&gl->gl_le.le_list)) { | ||
525 | up(&sdp->sd_log_flush_lock); | ||
526 | gfs2_unlock_from_flush(sdp); | ||
527 | kfree(ai); | ||
528 | return; | ||
529 | } | ||
530 | |||
531 | sdp->sd_log_flush_head = sdp->sd_log_head; | 516 | sdp->sd_log_flush_head = sdp->sd_log_head; |
532 | sdp->sd_log_flush_wrapped = 0; | 517 | sdp->sd_log_flush_wrapped = 0; |
533 | ai->ai_first = sdp->sd_log_flush_head; | 518 | ai->ai_first = sdp->sd_log_flush_head; |
@@ -538,7 +523,6 @@ void gfs2_log_flush_i(struct gfs2_sbd *sdp, struct gfs2_glock *gl) | |||
538 | else if (sdp->sd_log_tail != current_tail(sdp) && !sdp->sd_log_idle) | 523 | else if (sdp->sd_log_tail != current_tail(sdp) && !sdp->sd_log_idle) |
539 | log_write_header(sdp, 0, PULL); | 524 | log_write_header(sdp, 0, PULL); |
540 | lops_after_commit(sdp, ai); | 525 | lops_after_commit(sdp, ai); |
541 | |||
542 | sdp->sd_log_head = sdp->sd_log_flush_head; | 526 | sdp->sd_log_head = sdp->sd_log_flush_head; |
543 | if (sdp->sd_log_flush_wrapped) | 527 | if (sdp->sd_log_flush_wrapped) |
544 | sdp->sd_log_wraps++; | 528 | sdp->sd_log_wraps++; |
@@ -554,7 +538,7 @@ void gfs2_log_flush_i(struct gfs2_sbd *sdp, struct gfs2_glock *gl) | |||
554 | } | 538 | } |
555 | gfs2_log_unlock(sdp); | 539 | gfs2_log_unlock(sdp); |
556 | 540 | ||
557 | up(&sdp->sd_log_flush_lock); | 541 | mutex_unlock(&sdp->sd_log_flush_lock); |
558 | sdp->sd_vfs->s_dirt = 0; | 542 | sdp->sd_vfs->s_dirt = 0; |
559 | gfs2_unlock_from_flush(sdp); | 543 | gfs2_unlock_from_flush(sdp); |
560 | 544 | ||
@@ -627,7 +611,7 @@ void gfs2_log_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr) | |||
627 | 611 | ||
628 | void gfs2_log_shutdown(struct gfs2_sbd *sdp) | 612 | void gfs2_log_shutdown(struct gfs2_sbd *sdp) |
629 | { | 613 | { |
630 | down(&sdp->sd_log_flush_lock); | 614 | mutex_lock(&sdp->sd_log_flush_lock); |
631 | 615 | ||
632 | gfs2_assert_withdraw(sdp, !atomic_read(&sdp->sd_log_trans_count)); | 616 | gfs2_assert_withdraw(sdp, !atomic_read(&sdp->sd_log_trans_count)); |
633 | gfs2_assert_withdraw(sdp, !sdp->sd_log_blks_reserved); | 617 | gfs2_assert_withdraw(sdp, !sdp->sd_log_blks_reserved); |
@@ -654,6 +638,6 @@ void gfs2_log_shutdown(struct gfs2_sbd *sdp) | |||
654 | sdp->sd_log_wraps++; | 638 | sdp->sd_log_wraps++; |
655 | sdp->sd_log_tail = sdp->sd_log_head; | 639 | sdp->sd_log_tail = sdp->sd_log_head; |
656 | 640 | ||
657 | up(&sdp->sd_log_flush_lock); | 641 | mutex_unlock(&sdp->sd_log_flush_lock); |
658 | } | 642 | } |
659 | 643 | ||
diff --git a/fs/gfs2/log.h b/fs/gfs2/log.h index 4413cda81154..e7a6a65c530f 100644 --- a/fs/gfs2/log.h +++ b/fs/gfs2/log.h | |||
@@ -42,9 +42,6 @@ static inline void gfs2_log_pointers_init(struct gfs2_sbd *sdp, | |||
42 | sdp->sd_log_head = sdp->sd_log_tail = value; | 42 | sdp->sd_log_head = sdp->sd_log_tail = value; |
43 | } | 43 | } |
44 | 44 | ||
45 | void gfs2_lock_for_flush(struct gfs2_sbd *sdp); | ||
46 | void gfs2_unlock_from_flush(struct gfs2_sbd *sdp); | ||
47 | |||
48 | unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct, | 45 | unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct, |
49 | unsigned int ssize); | 46 | unsigned int ssize); |
50 | 47 | ||
diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c index 23be00141901..5e7e7d91fc5e 100644 --- a/fs/gfs2/lops.c +++ b/fs/gfs2/lops.c | |||
@@ -502,7 +502,8 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp) | |||
502 | unsigned int total_dbuf = sdp->sd_log_num_databuf; | 502 | unsigned int total_dbuf = sdp->sd_log_num_databuf; |
503 | unsigned int total_jdata = sdp->sd_log_num_jdata; | 503 | unsigned int total_jdata = sdp->sd_log_num_jdata; |
504 | unsigned int num, n; | 504 | unsigned int num, n; |
505 | __be64 *ptr; | 505 | __be64 *ptr = NULL; |
506 | unsigned i; | ||
506 | 507 | ||
507 | offset += (2*sizeof(__be64) - 1); | 508 | offset += (2*sizeof(__be64) - 1); |
508 | offset &= ~(2*sizeof(__be64) - 1); | 509 | offset &= ~(2*sizeof(__be64) - 1); |
@@ -513,14 +514,17 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp) | |||
513 | * Start writing ordered buffers, write journaled buffers | 514 | * Start writing ordered buffers, write journaled buffers |
514 | * into the log along with a header | 515 | * into the log along with a header |
515 | */ | 516 | */ |
517 | gfs2_log_lock(sdp); | ||
518 | /* printk(KERN_INFO "locked in lops databuf_before_commit\n"); */ | ||
516 | bd2 = bd1 = list_prepare_entry(bd1, &sdp->sd_log_le_databuf, bd_le.le_list); | 519 | bd2 = bd1 = list_prepare_entry(bd1, &sdp->sd_log_le_databuf, bd_le.le_list); |
517 | while(total_dbuf) { | 520 | while(total_dbuf) { |
518 | num = total_jdata; | 521 | num = total_jdata; |
519 | if (num > limit) | 522 | if (num > limit) |
520 | num = limit; | 523 | num = limit; |
524 | /* printk(KERN_INFO "total_dbuf=%u num=%u\n", total_dbuf, num); */ | ||
521 | n = 0; | 525 | n = 0; |
526 | i = 0; | ||
522 | list_for_each_entry_safe_continue(bd1, bdt, &sdp->sd_log_le_databuf, bd_le.le_list) { | 527 | list_for_each_entry_safe_continue(bd1, bdt, &sdp->sd_log_le_databuf, bd_le.le_list) { |
523 | gfs2_log_lock(sdp); | ||
524 | /* An ordered write buffer */ | 528 | /* An ordered write buffer */ |
525 | if (bd1->bd_bh && !buffer_pinned(bd1->bd_bh)) { | 529 | if (bd1->bd_bh && !buffer_pinned(bd1->bd_bh)) { |
526 | list_move(&bd1->bd_le.le_list, &started); | 530 | list_move(&bd1->bd_le.le_list, &started); |
@@ -531,20 +535,28 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp) | |||
531 | total_dbuf--; | 535 | total_dbuf--; |
532 | if (bd1->bd_bh) { | 536 | if (bd1->bd_bh) { |
533 | get_bh(bd1->bd_bh); | 537 | get_bh(bd1->bd_bh); |
534 | gfs2_log_unlock(sdp); | ||
535 | if (buffer_dirty(bd1->bd_bh)) { | 538 | if (buffer_dirty(bd1->bd_bh)) { |
539 | gfs2_log_unlock(sdp); | ||
536 | wait_on_buffer(bd1->bd_bh); | 540 | wait_on_buffer(bd1->bd_bh); |
537 | ll_rw_block(WRITE, 1, &bd1->bd_bh); | 541 | ll_rw_block(WRITE, 1, &bd1->bd_bh); |
542 | gfs2_log_lock(sdp); | ||
538 | } | 543 | } |
539 | brelse(bd1->bd_bh); | 544 | brelse(bd1->bd_bh); |
545 | /* printk(KERN_INFO "db write %p\n", bd1); */ | ||
546 | if (++i > 100000) { | ||
547 | printk(KERN_INFO "looping bd1=%p bdt=%p eol=%p started=%p\n", bd1, bdt, &sdp->sd_log_le_databuf, &started); | ||
548 | dump_stack(); | ||
549 | BUG(); | ||
550 | } | ||
540 | continue; | 551 | continue; |
541 | } | 552 | } |
542 | gfs2_log_unlock(sdp); | 553 | /* printk(KERN_INFO "db skip\n"); */ |
543 | continue; | 554 | continue; |
544 | } else if (bd1->bd_bh) { /* A journaled buffer */ | 555 | } else if (bd1->bd_bh) { /* A journaled buffer */ |
545 | int magic; | 556 | int magic; |
546 | gfs2_log_unlock(sdp); | 557 | gfs2_log_unlock(sdp); |
547 | /* printk(KERN_INFO "journaled buffer\n"); */ | 558 | printk(KERN_INFO "journaled buffer %p\n", bd1->bd_bh); |
559 | printk(KERN_INFO "%lu %u %p %p\n", bd1->bd_bh->b_blocknr, bd1->bd_bh->b_size, bd1->bd_bh->b_data, bd1->bd_bh->b_page); | ||
548 | if (!bh) { | 560 | if (!bh) { |
549 | bh = gfs2_log_get_buf(sdp); | 561 | bh = gfs2_log_get_buf(sdp); |
550 | ld = (struct gfs2_log_descriptor *)bh->b_data; | 562 | ld = (struct gfs2_log_descriptor *)bh->b_data; |
@@ -558,16 +570,21 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp) | |||
558 | ld->ld_data2 = cpu_to_be32(0); | 570 | ld->ld_data2 = cpu_to_be32(0); |
559 | memset(ld->ld_reserved, 0, sizeof(ld->ld_reserved)); | 571 | memset(ld->ld_reserved, 0, sizeof(ld->ld_reserved)); |
560 | } | 572 | } |
573 | /* printk(KERN_INFO "check_magic\n"); */ | ||
561 | magic = gfs2_check_magic(bd1->bd_bh); | 574 | magic = gfs2_check_magic(bd1->bd_bh); |
575 | /* printk(KERN_INFO "write data\n"); */ | ||
562 | *ptr++ = cpu_to_be64(bd1->bd_bh->b_blocknr); | 576 | *ptr++ = cpu_to_be64(bd1->bd_bh->b_blocknr); |
563 | *ptr++ = cpu_to_be64((__u64)magic); | 577 | *ptr++ = cpu_to_be64((__u64)magic); |
578 | /* printk(KERN_INFO "mark escaped or not\n"); */ | ||
564 | clear_buffer_escaped(bd1->bd_bh); | 579 | clear_buffer_escaped(bd1->bd_bh); |
565 | if (unlikely(magic != 0)) | 580 | if (unlikely(magic != 0)) |
566 | set_buffer_escaped(bd1->bd_bh); | 581 | set_buffer_escaped(bd1->bd_bh); |
582 | gfs2_log_lock(sdp); | ||
567 | if (n++ > num) | 583 | if (n++ > num) |
568 | break; | 584 | break; |
569 | } | 585 | } |
570 | } | 586 | } |
587 | gfs2_log_unlock(sdp); | ||
571 | if (bh) { | 588 | if (bh) { |
572 | set_buffer_dirty(bh); | 589 | set_buffer_dirty(bh); |
573 | ll_rw_block(WRITE, 1, &bh); | 590 | ll_rw_block(WRITE, 1, &bh); |
@@ -575,10 +592,12 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp) | |||
575 | } | 592 | } |
576 | n = 0; | 593 | n = 0; |
577 | /* printk(KERN_INFO "totals2: jdata=%u dbuf=%u\n", total_jdata, total_dbuf); */ | 594 | /* printk(KERN_INFO "totals2: jdata=%u dbuf=%u\n", total_jdata, total_dbuf); */ |
595 | gfs2_log_lock(sdp); | ||
578 | list_for_each_entry_continue(bd2, &sdp->sd_log_le_databuf, bd_le.le_list) { | 596 | list_for_each_entry_continue(bd2, &sdp->sd_log_le_databuf, bd_le.le_list) { |
579 | if (!bd2->bd_bh) | 597 | if (!bd2->bd_bh) |
580 | continue; | 598 | continue; |
581 | /* copy buffer if it needs escaping */ | 599 | /* copy buffer if it needs escaping */ |
600 | gfs2_log_unlock(sdp); | ||
582 | if (unlikely(buffer_escaped(bd2->bd_bh))) { | 601 | if (unlikely(buffer_escaped(bd2->bd_bh))) { |
583 | void *kaddr; | 602 | void *kaddr; |
584 | struct page *page = bd2->bd_bh->b_page; | 603 | struct page *page = bd2->bd_bh->b_page; |
@@ -592,6 +611,7 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp) | |||
592 | } | 611 | } |
593 | set_buffer_dirty(bh); | 612 | set_buffer_dirty(bh); |
594 | ll_rw_block(WRITE, 1, &bh); | 613 | ll_rw_block(WRITE, 1, &bh); |
614 | gfs2_log_lock(sdp); | ||
595 | if (++n >= num) | 615 | if (++n >= num) |
596 | break; | 616 | break; |
597 | } | 617 | } |
@@ -599,6 +619,8 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp) | |||
599 | total_dbuf -= num; | 619 | total_dbuf -= num; |
600 | total_jdata -= num; | 620 | total_jdata -= num; |
601 | } | 621 | } |
622 | gfs2_log_unlock(sdp); | ||
623 | |||
602 | /* printk(KERN_INFO "wait on ordered data buffers\n"); */ | 624 | /* printk(KERN_INFO "wait on ordered data buffers\n"); */ |
603 | /* Wait on all ordered buffers */ | 625 | /* Wait on all ordered buffers */ |
604 | while (!list_empty(&started)) { | 626 | while (!list_empty(&started)) { |
@@ -701,12 +723,10 @@ static void databuf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai) | |||
701 | 723 | ||
702 | while (!list_empty(head)) { | 724 | while (!list_empty(head)) { |
703 | bd = list_entry(head->next, struct gfs2_bufdata, bd_le.le_list); | 725 | bd = list_entry(head->next, struct gfs2_bufdata, bd_le.le_list); |
704 | list_del_init(&bd->bd_le.le_list); | 726 | list_del(&bd->bd_le.le_list); |
705 | sdp->sd_log_num_databuf--; | 727 | sdp->sd_log_num_databuf--; |
706 | sdp->sd_log_num_jdata--; | 728 | sdp->sd_log_num_jdata--; |
707 | gfs2_unpin(sdp, bd->bd_bh, ai); | 729 | gfs2_unpin(sdp, bd->bd_bh, ai); |
708 | brelse(bd->bd_bh); | ||
709 | kfree(bd); | ||
710 | } | 730 | } |
711 | gfs2_assert_warn(sdp, !sdp->sd_log_num_databuf); | 731 | gfs2_assert_warn(sdp, !sdp->sd_log_num_databuf); |
712 | gfs2_assert_warn(sdp, !sdp->sd_log_num_jdata); | 732 | gfs2_assert_warn(sdp, !sdp->sd_log_num_jdata); |
diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c index ef58d43b67ee..8fba84306755 100644 --- a/fs/gfs2/meta_io.c +++ b/fs/gfs2/meta_io.c | |||
@@ -556,7 +556,7 @@ void gfs2_attach_bufdata(struct gfs2_glock *gl, struct buffer_head *bh, int meta | |||
556 | return; | 556 | return; |
557 | } | 557 | } |
558 | 558 | ||
559 | bd = kmem_cache_alloc(gfs2_bufdata_cachep, GFP_KERNEL | __GFP_NOFAIL), | 559 | bd = kmem_cache_alloc(gfs2_bufdata_cachep, GFP_NOFS | __GFP_NOFAIL), |
560 | atomic_inc(&gl->gl_sbd->sd_bufdata_count); | 560 | atomic_inc(&gl->gl_sbd->sd_bufdata_count); |
561 | 561 | ||
562 | memset(bd, 0, sizeof(struct gfs2_bufdata)); | 562 | memset(bd, 0, sizeof(struct gfs2_bufdata)); |
diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c index 1ccc26426821..c719a2a40698 100644 --- a/fs/gfs2/ops_address.c +++ b/fs/gfs2/ops_address.c | |||
@@ -189,7 +189,6 @@ static int gfs2_writepage(struct page *page, struct writeback_control *wbc) | |||
189 | gfs2_page_add_databufs(ip, page, 0, sdp->sd_vfs->s_blocksize-1); | 189 | gfs2_page_add_databufs(ip, page, 0, sdp->sd_vfs->s_blocksize-1); |
190 | done_trans = 1; | 190 | done_trans = 1; |
191 | } | 191 | } |
192 | |||
193 | error = block_write_full_page(page, get_block_noalloc, wbc); | 192 | error = block_write_full_page(page, get_block_noalloc, wbc); |
194 | if (done_trans) | 193 | if (done_trans) |
195 | gfs2_trans_end(sdp); | 194 | gfs2_trans_end(sdp); |
diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c index b86037832299..cf2e26e07245 100644 --- a/fs/gfs2/ops_file.c +++ b/fs/gfs2/ops_file.c | |||
@@ -688,7 +688,7 @@ static int gfs2_open(struct inode *inode, struct file *file) | |||
688 | if (!fp) | 688 | if (!fp) |
689 | return -ENOMEM; | 689 | return -ENOMEM; |
690 | 690 | ||
691 | init_MUTEX(&fp->f_fl_mutex); | 691 | mutex_init(&fp->f_fl_mutex); |
692 | 692 | ||
693 | fp->f_inode = ip; | 693 | fp->f_inode = ip; |
694 | fp->f_vfile = file; | 694 | fp->f_vfile = file; |
@@ -858,7 +858,7 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl) | |||
858 | state = (fl->fl_type == F_WRLCK) ? LM_ST_EXCLUSIVE : LM_ST_SHARED; | 858 | state = (fl->fl_type == F_WRLCK) ? LM_ST_EXCLUSIVE : LM_ST_SHARED; |
859 | flags = ((IS_SETLKW(cmd)) ? 0 : LM_FLAG_TRY) | GL_EXACT | GL_NOCACHE; | 859 | flags = ((IS_SETLKW(cmd)) ? 0 : LM_FLAG_TRY) | GL_EXACT | GL_NOCACHE; |
860 | 860 | ||
861 | down(&fp->f_fl_mutex); | 861 | mutex_lock(&fp->f_fl_mutex); |
862 | 862 | ||
863 | gl = fl_gh->gh_gl; | 863 | gl = fl_gh->gh_gl; |
864 | if (gl) { | 864 | if (gl) { |
@@ -890,7 +890,7 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl) | |||
890 | } | 890 | } |
891 | 891 | ||
892 | out: | 892 | out: |
893 | up(&fp->f_fl_mutex); | 893 | mutex_unlock(&fp->f_fl_mutex); |
894 | 894 | ||
895 | return error; | 895 | return error; |
896 | } | 896 | } |
@@ -900,11 +900,11 @@ static void do_unflock(struct file *file, struct file_lock *fl) | |||
900 | struct gfs2_file *fp = get_v2fp(file); | 900 | struct gfs2_file *fp = get_v2fp(file); |
901 | struct gfs2_holder *fl_gh = &fp->f_fl_gh; | 901 | struct gfs2_holder *fl_gh = &fp->f_fl_gh; |
902 | 902 | ||
903 | down(&fp->f_fl_mutex); | 903 | mutex_lock(&fp->f_fl_mutex); |
904 | flock_lock_file_wait(file, fl); | 904 | flock_lock_file_wait(file, fl); |
905 | if (fl_gh->gh_gl) | 905 | if (fl_gh->gh_gl) |
906 | gfs2_glock_dq_uninit(fl_gh); | 906 | gfs2_glock_dq_uninit(fl_gh); |
907 | up(&fp->f_fl_mutex); | 907 | mutex_unlock(&fp->f_fl_mutex); |
908 | } | 908 | } |
909 | 909 | ||
910 | /** | 910 | /** |
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index 80d5582d9d9b..751178ab497c 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c | |||
@@ -59,29 +59,29 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb) | |||
59 | INIT_LIST_HEAD(&sdp->sd_reclaim_list); | 59 | INIT_LIST_HEAD(&sdp->sd_reclaim_list); |
60 | spin_lock_init(&sdp->sd_reclaim_lock); | 60 | spin_lock_init(&sdp->sd_reclaim_lock); |
61 | init_waitqueue_head(&sdp->sd_reclaim_wq); | 61 | init_waitqueue_head(&sdp->sd_reclaim_wq); |
62 | init_MUTEX(&sdp->sd_invalidate_inodes_mutex); | 62 | mutex_init(&sdp->sd_invalidate_inodes_mutex); |
63 | 63 | ||
64 | init_MUTEX(&sdp->sd_inum_mutex); | 64 | mutex_init(&sdp->sd_inum_mutex); |
65 | spin_lock_init(&sdp->sd_statfs_spin); | 65 | spin_lock_init(&sdp->sd_statfs_spin); |
66 | init_MUTEX(&sdp->sd_statfs_mutex); | 66 | mutex_init(&sdp->sd_statfs_mutex); |
67 | 67 | ||
68 | spin_lock_init(&sdp->sd_rindex_spin); | 68 | spin_lock_init(&sdp->sd_rindex_spin); |
69 | init_MUTEX(&sdp->sd_rindex_mutex); | 69 | mutex_init(&sdp->sd_rindex_mutex); |
70 | INIT_LIST_HEAD(&sdp->sd_rindex_list); | 70 | INIT_LIST_HEAD(&sdp->sd_rindex_list); |
71 | INIT_LIST_HEAD(&sdp->sd_rindex_mru_list); | 71 | INIT_LIST_HEAD(&sdp->sd_rindex_mru_list); |
72 | INIT_LIST_HEAD(&sdp->sd_rindex_recent_list); | 72 | INIT_LIST_HEAD(&sdp->sd_rindex_recent_list); |
73 | 73 | ||
74 | INIT_LIST_HEAD(&sdp->sd_jindex_list); | 74 | INIT_LIST_HEAD(&sdp->sd_jindex_list); |
75 | spin_lock_init(&sdp->sd_jindex_spin); | 75 | spin_lock_init(&sdp->sd_jindex_spin); |
76 | init_MUTEX(&sdp->sd_jindex_mutex); | 76 | mutex_init(&sdp->sd_jindex_mutex); |
77 | 77 | ||
78 | INIT_LIST_HEAD(&sdp->sd_unlinked_list); | 78 | INIT_LIST_HEAD(&sdp->sd_unlinked_list); |
79 | spin_lock_init(&sdp->sd_unlinked_spin); | 79 | spin_lock_init(&sdp->sd_unlinked_spin); |
80 | init_MUTEX(&sdp->sd_unlinked_mutex); | 80 | mutex_init(&sdp->sd_unlinked_mutex); |
81 | 81 | ||
82 | INIT_LIST_HEAD(&sdp->sd_quota_list); | 82 | INIT_LIST_HEAD(&sdp->sd_quota_list); |
83 | spin_lock_init(&sdp->sd_quota_spin); | 83 | spin_lock_init(&sdp->sd_quota_spin); |
84 | init_MUTEX(&sdp->sd_quota_mutex); | 84 | mutex_init(&sdp->sd_quota_mutex); |
85 | 85 | ||
86 | spin_lock_init(&sdp->sd_log_lock); | 86 | spin_lock_init(&sdp->sd_log_lock); |
87 | init_waitqueue_head(&sdp->sd_log_trans_wq); | 87 | init_waitqueue_head(&sdp->sd_log_trans_wq); |
@@ -99,12 +99,12 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb) | |||
99 | INIT_LIST_HEAD(&sdp->sd_ail1_list); | 99 | INIT_LIST_HEAD(&sdp->sd_ail1_list); |
100 | INIT_LIST_HEAD(&sdp->sd_ail2_list); | 100 | INIT_LIST_HEAD(&sdp->sd_ail2_list); |
101 | 101 | ||
102 | init_MUTEX(&sdp->sd_log_flush_lock); | 102 | mutex_init(&sdp->sd_log_flush_lock); |
103 | INIT_LIST_HEAD(&sdp->sd_log_flush_list); | 103 | INIT_LIST_HEAD(&sdp->sd_log_flush_list); |
104 | 104 | ||
105 | INIT_LIST_HEAD(&sdp->sd_revoke_list); | 105 | INIT_LIST_HEAD(&sdp->sd_revoke_list); |
106 | 106 | ||
107 | init_MUTEX(&sdp->sd_freeze_lock); | 107 | mutex_init(&sdp->sd_freeze_lock); |
108 | 108 | ||
109 | return sdp; | 109 | return sdp; |
110 | } | 110 | } |
diff --git a/fs/gfs2/ops_super.c b/fs/gfs2/ops_super.c index e06ef8dbd4d3..9130d0d0df3c 100644 --- a/fs/gfs2/ops_super.c +++ b/fs/gfs2/ops_super.c | |||
@@ -74,10 +74,10 @@ static void gfs2_put_super(struct super_block *sb) | |||
74 | 74 | ||
75 | /* Unfreeze the filesystem, if we need to */ | 75 | /* Unfreeze the filesystem, if we need to */ |
76 | 76 | ||
77 | down(&sdp->sd_freeze_lock); | 77 | mutex_lock(&sdp->sd_freeze_lock); |
78 | if (sdp->sd_freeze_count) | 78 | if (sdp->sd_freeze_count) |
79 | gfs2_glock_dq_uninit(&sdp->sd_freeze_gh); | 79 | gfs2_glock_dq_uninit(&sdp->sd_freeze_gh); |
80 | up(&sdp->sd_freeze_lock); | 80 | mutex_unlock(&sdp->sd_freeze_lock); |
81 | 81 | ||
82 | kthread_stop(sdp->sd_inoded_process); | 82 | kthread_stop(sdp->sd_inoded_process); |
83 | kthread_stop(sdp->sd_quotad_process); | 83 | kthread_stop(sdp->sd_quotad_process); |
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index 7b5573946f19..c0352cf330a3 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c | |||
@@ -251,10 +251,10 @@ static int bh_get(struct gfs2_quota_data *qd) | |||
251 | struct buffer_head *bh; | 251 | struct buffer_head *bh; |
252 | int error; | 252 | int error; |
253 | 253 | ||
254 | down(&sdp->sd_quota_mutex); | 254 | mutex_lock(&sdp->sd_quota_mutex); |
255 | 255 | ||
256 | if (qd->qd_bh_count++) { | 256 | if (qd->qd_bh_count++) { |
257 | up(&sdp->sd_quota_mutex); | 257 | mutex_unlock(&sdp->sd_quota_mutex); |
258 | return 0; | 258 | return 0; |
259 | } | 259 | } |
260 | 260 | ||
@@ -276,7 +276,7 @@ static int bh_get(struct gfs2_quota_data *qd) | |||
276 | (bh->b_data + sizeof(struct gfs2_meta_header) + | 276 | (bh->b_data + sizeof(struct gfs2_meta_header) + |
277 | offset * sizeof(struct gfs2_quota_change)); | 277 | offset * sizeof(struct gfs2_quota_change)); |
278 | 278 | ||
279 | up(&sdp->sd_quota_mutex); | 279 | mutex_lock(&sdp->sd_quota_mutex); |
280 | 280 | ||
281 | return 0; | 281 | return 0; |
282 | 282 | ||
@@ -285,7 +285,7 @@ static int bh_get(struct gfs2_quota_data *qd) | |||
285 | 285 | ||
286 | fail: | 286 | fail: |
287 | qd->qd_bh_count--; | 287 | qd->qd_bh_count--; |
288 | up(&sdp->sd_quota_mutex); | 288 | mutex_unlock(&sdp->sd_quota_mutex); |
289 | return error; | 289 | return error; |
290 | } | 290 | } |
291 | 291 | ||
@@ -293,14 +293,14 @@ static void bh_put(struct gfs2_quota_data *qd) | |||
293 | { | 293 | { |
294 | struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd; | 294 | struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd; |
295 | 295 | ||
296 | down(&sdp->sd_quota_mutex); | 296 | mutex_lock(&sdp->sd_quota_mutex); |
297 | gfs2_assert(sdp, qd->qd_bh_count); | 297 | gfs2_assert(sdp, qd->qd_bh_count); |
298 | if (!--qd->qd_bh_count) { | 298 | if (!--qd->qd_bh_count) { |
299 | brelse(qd->qd_bh); | 299 | brelse(qd->qd_bh); |
300 | qd->qd_bh = NULL; | 300 | qd->qd_bh = NULL; |
301 | qd->qd_bh_qc = NULL; | 301 | qd->qd_bh_qc = NULL; |
302 | } | 302 | } |
303 | up(&sdp->sd_quota_mutex); | 303 | mutex_unlock(&sdp->sd_quota_mutex); |
304 | } | 304 | } |
305 | 305 | ||
306 | static int qd_fish(struct gfs2_sbd *sdp, struct gfs2_quota_data **qdp) | 306 | static int qd_fish(struct gfs2_sbd *sdp, struct gfs2_quota_data **qdp) |
@@ -529,7 +529,7 @@ static void do_qc(struct gfs2_quota_data *qd, int64_t change) | |||
529 | struct gfs2_quota_change *qc = qd->qd_bh_qc; | 529 | struct gfs2_quota_change *qc = qd->qd_bh_qc; |
530 | int64_t x; | 530 | int64_t x; |
531 | 531 | ||
532 | down(&sdp->sd_quota_mutex); | 532 | mutex_lock(&sdp->sd_quota_mutex); |
533 | gfs2_trans_add_bh(ip->i_gl, qd->qd_bh, 1); | 533 | gfs2_trans_add_bh(ip->i_gl, qd->qd_bh, 1); |
534 | 534 | ||
535 | if (!test_bit(QDF_CHANGE, &qd->qd_flags)) { | 535 | if (!test_bit(QDF_CHANGE, &qd->qd_flags)) { |
@@ -560,7 +560,7 @@ static void do_qc(struct gfs2_quota_data *qd, int64_t change) | |||
560 | slot_hold(qd); | 560 | slot_hold(qd); |
561 | } | 561 | } |
562 | 562 | ||
563 | up(&sdp->sd_quota_mutex); | 563 | mutex_unlock(&sdp->sd_quota_mutex); |
564 | } | 564 | } |
565 | 565 | ||
566 | /** | 566 | /** |
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 758cc565813a..2e69e5cda967 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c | |||
@@ -182,9 +182,9 @@ static void clear_rgrpdi(struct gfs2_sbd *sdp) | |||
182 | 182 | ||
183 | void gfs2_clear_rgrpd(struct gfs2_sbd *sdp) | 183 | void gfs2_clear_rgrpd(struct gfs2_sbd *sdp) |
184 | { | 184 | { |
185 | down(&sdp->sd_rindex_mutex); | 185 | mutex_lock(&sdp->sd_rindex_mutex); |
186 | clear_rgrpdi(sdp); | 186 | clear_rgrpdi(sdp); |
187 | up(&sdp->sd_rindex_mutex); | 187 | mutex_unlock(&sdp->sd_rindex_mutex); |
188 | } | 188 | } |
189 | 189 | ||
190 | /** | 190 | /** |
@@ -301,7 +301,7 @@ static int gfs2_ri_update(struct gfs2_inode *ip) | |||
301 | if (!rgd) | 301 | if (!rgd) |
302 | goto fail; | 302 | goto fail; |
303 | 303 | ||
304 | init_MUTEX(&rgd->rd_mutex); | 304 | mutex_init(&rgd->rd_mutex); |
305 | lops_init_le(&rgd->rd_le, &gfs2_rg_lops); | 305 | lops_init_le(&rgd->rd_le, &gfs2_rg_lops); |
306 | rgd->rd_sbd = sdp; | 306 | rgd->rd_sbd = sdp; |
307 | 307 | ||
@@ -363,13 +363,13 @@ int gfs2_rindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ri_gh) | |||
363 | 363 | ||
364 | /* Read new copy from disk if we don't have the latest */ | 364 | /* Read new copy from disk if we don't have the latest */ |
365 | if (sdp->sd_rindex_vn != gl->gl_vn) { | 365 | if (sdp->sd_rindex_vn != gl->gl_vn) { |
366 | down(&sdp->sd_rindex_mutex); | 366 | mutex_lock(&sdp->sd_rindex_mutex); |
367 | if (sdp->sd_rindex_vn != gl->gl_vn) { | 367 | if (sdp->sd_rindex_vn != gl->gl_vn) { |
368 | error = gfs2_ri_update(ip); | 368 | error = gfs2_ri_update(ip); |
369 | if (error) | 369 | if (error) |
370 | gfs2_glock_dq_uninit(ri_gh); | 370 | gfs2_glock_dq_uninit(ri_gh); |
371 | } | 371 | } |
372 | up(&sdp->sd_rindex_mutex); | 372 | mutex_unlock(&sdp->sd_rindex_mutex); |
373 | } | 373 | } |
374 | 374 | ||
375 | return error; | 375 | return error; |
@@ -394,13 +394,13 @@ int gfs2_rgrp_bh_get(struct gfs2_rgrpd *rgd) | |||
394 | unsigned int x, y; | 394 | unsigned int x, y; |
395 | int error; | 395 | int error; |
396 | 396 | ||
397 | down(&rgd->rd_mutex); | 397 | mutex_lock(&rgd->rd_mutex); |
398 | 398 | ||
399 | spin_lock(&sdp->sd_rindex_spin); | 399 | spin_lock(&sdp->sd_rindex_spin); |
400 | if (rgd->rd_bh_count) { | 400 | if (rgd->rd_bh_count) { |
401 | rgd->rd_bh_count++; | 401 | rgd->rd_bh_count++; |
402 | spin_unlock(&sdp->sd_rindex_spin); | 402 | spin_unlock(&sdp->sd_rindex_spin); |
403 | up(&rgd->rd_mutex); | 403 | mutex_unlock(&rgd->rd_mutex); |
404 | return 0; | 404 | return 0; |
405 | } | 405 | } |
406 | spin_unlock(&sdp->sd_rindex_spin); | 406 | spin_unlock(&sdp->sd_rindex_spin); |
@@ -436,7 +436,7 @@ int gfs2_rgrp_bh_get(struct gfs2_rgrpd *rgd) | |||
436 | rgd->rd_bh_count++; | 436 | rgd->rd_bh_count++; |
437 | spin_unlock(&sdp->sd_rindex_spin); | 437 | spin_unlock(&sdp->sd_rindex_spin); |
438 | 438 | ||
439 | up(&rgd->rd_mutex); | 439 | mutex_unlock(&rgd->rd_mutex); |
440 | 440 | ||
441 | return 0; | 441 | return 0; |
442 | 442 | ||
@@ -447,7 +447,7 @@ int gfs2_rgrp_bh_get(struct gfs2_rgrpd *rgd) | |||
447 | bi->bi_bh = NULL; | 447 | bi->bi_bh = NULL; |
448 | gfs2_assert_warn(sdp, !bi->bi_clone); | 448 | gfs2_assert_warn(sdp, !bi->bi_clone); |
449 | } | 449 | } |
450 | up(&rgd->rd_mutex); | 450 | mutex_unlock(&rgd->rd_mutex); |
451 | 451 | ||
452 | return error; | 452 | return error; |
453 | } | 453 | } |
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index 9b5c31952c5d..be80771c414d 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c | |||
@@ -279,7 +279,7 @@ int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh) | |||
279 | 279 | ||
280 | name.name = buf; | 280 | name.name = buf; |
281 | 281 | ||
282 | down(&sdp->sd_jindex_mutex); | 282 | mutex_lock(&sdp->sd_jindex_mutex); |
283 | 283 | ||
284 | for (;;) { | 284 | for (;;) { |
285 | error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED, | 285 | error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED, |
@@ -317,7 +317,7 @@ int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh) | |||
317 | spin_unlock(&sdp->sd_jindex_spin); | 317 | spin_unlock(&sdp->sd_jindex_spin); |
318 | } | 318 | } |
319 | 319 | ||
320 | up(&sdp->sd_jindex_mutex); | 320 | mutex_unlock(&sdp->sd_jindex_mutex); |
321 | 321 | ||
322 | return error; | 322 | return error; |
323 | } | 323 | } |
@@ -608,9 +608,9 @@ void gfs2_statfs_change(struct gfs2_sbd *sdp, int64_t total, int64_t free, | |||
608 | if (error) | 608 | if (error) |
609 | return; | 609 | return; |
610 | 610 | ||
611 | down(&sdp->sd_statfs_mutex); | 611 | mutex_lock(&sdp->sd_statfs_mutex); |
612 | gfs2_trans_add_bh(l_ip->i_gl, l_bh, 1); | 612 | gfs2_trans_add_bh(l_ip->i_gl, l_bh, 1); |
613 | up(&sdp->sd_statfs_mutex); | 613 | mutex_unlock(&sdp->sd_statfs_mutex); |
614 | 614 | ||
615 | spin_lock(&sdp->sd_statfs_spin); | 615 | spin_lock(&sdp->sd_statfs_spin); |
616 | l_sc->sc_total += total; | 616 | l_sc->sc_total += total; |
@@ -659,9 +659,9 @@ int gfs2_statfs_sync(struct gfs2_sbd *sdp) | |||
659 | if (error) | 659 | if (error) |
660 | goto out_bh2; | 660 | goto out_bh2; |
661 | 661 | ||
662 | down(&sdp->sd_statfs_mutex); | 662 | mutex_lock(&sdp->sd_statfs_mutex); |
663 | gfs2_trans_add_bh(l_ip->i_gl, l_bh, 1); | 663 | gfs2_trans_add_bh(l_ip->i_gl, l_bh, 1); |
664 | up(&sdp->sd_statfs_mutex); | 664 | mutex_unlock(&sdp->sd_statfs_mutex); |
665 | 665 | ||
666 | spin_lock(&sdp->sd_statfs_spin); | 666 | spin_lock(&sdp->sd_statfs_spin); |
667 | m_sc->sc_total += l_sc->sc_total; | 667 | m_sc->sc_total += l_sc->sc_total; |
@@ -910,7 +910,7 @@ int gfs2_freeze_fs(struct gfs2_sbd *sdp) | |||
910 | { | 910 | { |
911 | int error = 0; | 911 | int error = 0; |
912 | 912 | ||
913 | down(&sdp->sd_freeze_lock); | 913 | mutex_lock(&sdp->sd_freeze_lock); |
914 | 914 | ||
915 | if (!sdp->sd_freeze_count++) { | 915 | if (!sdp->sd_freeze_count++) { |
916 | error = gfs2_lock_fs_check_clean(sdp, &sdp->sd_freeze_gh); | 916 | error = gfs2_lock_fs_check_clean(sdp, &sdp->sd_freeze_gh); |
@@ -918,7 +918,7 @@ int gfs2_freeze_fs(struct gfs2_sbd *sdp) | |||
918 | sdp->sd_freeze_count--; | 918 | sdp->sd_freeze_count--; |
919 | } | 919 | } |
920 | 920 | ||
921 | up(&sdp->sd_freeze_lock); | 921 | mutex_unlock(&sdp->sd_freeze_lock); |
922 | 922 | ||
923 | return error; | 923 | return error; |
924 | } | 924 | } |
@@ -935,11 +935,11 @@ int gfs2_freeze_fs(struct gfs2_sbd *sdp) | |||
935 | 935 | ||
936 | void gfs2_unfreeze_fs(struct gfs2_sbd *sdp) | 936 | void gfs2_unfreeze_fs(struct gfs2_sbd *sdp) |
937 | { | 937 | { |
938 | down(&sdp->sd_freeze_lock); | 938 | mutex_lock(&sdp->sd_freeze_lock); |
939 | 939 | ||
940 | if (sdp->sd_freeze_count && !--sdp->sd_freeze_count) | 940 | if (sdp->sd_freeze_count && !--sdp->sd_freeze_count) |
941 | gfs2_glock_dq_uninit(&sdp->sd_freeze_gh); | 941 | gfs2_glock_dq_uninit(&sdp->sd_freeze_gh); |
942 | 942 | ||
943 | up(&sdp->sd_freeze_lock); | 943 | mutex_unlock(&sdp->sd_freeze_lock); |
944 | } | 944 | } |
945 | 945 | ||
diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c index 75e9a3231b8f..c5984351e4d8 100644 --- a/fs/gfs2/sys.c +++ b/fs/gfs2/sys.c | |||
@@ -41,9 +41,9 @@ static ssize_t freeze_show(struct gfs2_sbd *sdp, char *buf) | |||
41 | { | 41 | { |
42 | unsigned int count; | 42 | unsigned int count; |
43 | 43 | ||
44 | down(&sdp->sd_freeze_lock); | 44 | mutex_lock(&sdp->sd_freeze_lock); |
45 | count = sdp->sd_freeze_count; | 45 | count = sdp->sd_freeze_count; |
46 | up(&sdp->sd_freeze_lock); | 46 | mutex_unlock(&sdp->sd_freeze_lock); |
47 | 47 | ||
48 | return sprintf(buf, "%u\n", count); | 48 | return sprintf(buf, "%u\n", count); |
49 | } | 49 | } |
diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c index 104e664fa182..0a0ea70eac4c 100644 --- a/fs/gfs2/trans.c +++ b/fs/gfs2/trans.c | |||
@@ -33,7 +33,7 @@ int gfs2_trans_begin_i(struct gfs2_sbd *sdp, unsigned int blocks, | |||
33 | return -EINVAL; | 33 | return -EINVAL; |
34 | } | 34 | } |
35 | 35 | ||
36 | tr = kzalloc(sizeof(struct gfs2_trans), GFP_KERNEL); | 36 | tr = kzalloc(sizeof(struct gfs2_trans), GFP_NOFS); |
37 | if (!tr) | 37 | if (!tr) |
38 | return -ENOMEM; | 38 | return -ENOMEM; |
39 | 39 | ||
@@ -51,7 +51,7 @@ int gfs2_trans_begin_i(struct gfs2_sbd *sdp, unsigned int blocks, | |||
51 | 51 | ||
52 | error = -ENOMEM; | 52 | error = -ENOMEM; |
53 | tr->tr_t_gh = gfs2_holder_get(sdp->sd_trans_gl, LM_ST_SHARED, | 53 | tr->tr_t_gh = gfs2_holder_get(sdp->sd_trans_gl, LM_ST_SHARED, |
54 | GL_NEVER_RECURSE, GFP_KERNEL); | 54 | GL_NEVER_RECURSE, GFP_NOFS); |
55 | if (!tr->tr_t_gh) | 55 | if (!tr->tr_t_gh) |
56 | goto fail; | 56 | goto fail; |
57 | 57 | ||
diff --git a/fs/gfs2/unlinked.c b/fs/gfs2/unlinked.c index 405b91b0295d..e92a3a11815b 100644 --- a/fs/gfs2/unlinked.c +++ b/fs/gfs2/unlinked.c | |||
@@ -46,12 +46,12 @@ static int munge_ondisk(struct gfs2_sbd *sdp, unsigned int slot, | |||
46 | goto out; | 46 | goto out; |
47 | } | 47 | } |
48 | 48 | ||
49 | down(&sdp->sd_unlinked_mutex); | 49 | mutex_lock(&sdp->sd_unlinked_mutex); |
50 | gfs2_trans_add_bh(ip->i_gl, bh, 1); | 50 | gfs2_trans_add_bh(ip->i_gl, bh, 1); |
51 | gfs2_unlinked_tag_out(ut, bh->b_data + | 51 | gfs2_unlinked_tag_out(ut, bh->b_data + |
52 | sizeof(struct gfs2_meta_header) + | 52 | sizeof(struct gfs2_meta_header) + |
53 | offset * sizeof(struct gfs2_unlinked_tag)); | 53 | offset * sizeof(struct gfs2_unlinked_tag)); |
54 | up(&sdp->sd_unlinked_mutex); | 54 | mutex_unlock(&sdp->sd_unlinked_mutex); |
55 | 55 | ||
56 | out: | 56 | out: |
57 | brelse(bh); | 57 | brelse(bh); |