aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2006-04-21 15:10:46 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2006-04-21 15:10:46 -0400
commita74604bee27da7c9506114e5710f91f388e98296 (patch)
treebfd1c8b14c03022894396c788bf8b0377c5afe49 /fs/gfs2
parenta748422ee45725e04e1d3792fa19dfa90ddfd116 (diff)
[GFS2] sem -> mutex conversion in locking.c
Convert a semaphore to a mutex in locking.c and also tidy up one or two loose ends. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2')
-rw-r--r--fs/gfs2/locking.c34
-rw-r--r--fs/gfs2/log.c7
-rw-r--r--fs/gfs2/util.h1
3 files changed, 20 insertions, 22 deletions
diff --git a/fs/gfs2/locking.c b/fs/gfs2/locking.c
index 0f4c50ebcbad..6a78aacb26af 100644
--- a/fs/gfs2/locking.c
+++ b/fs/gfs2/locking.c
@@ -28,7 +28,7 @@ struct lmh_wrapper {
28 of them by name at mount time, e.g. lock_nolock, lock_dlm. */ 28 of them by name at mount time, e.g. lock_nolock, lock_dlm. */
29 29
30static struct list_head lmh_list; 30static struct list_head lmh_list;
31static struct semaphore lmh_lock; 31static struct mutex lmh_lock;
32 32
33/** 33/**
34 * gfs_register_lockproto - Register a low-level locking protocol 34 * gfs_register_lockproto - Register a low-level locking protocol
@@ -41,11 +41,11 @@ int gfs_register_lockproto(struct lm_lockops *proto)
41{ 41{
42 struct lmh_wrapper *lw; 42 struct lmh_wrapper *lw;
43 43
44 down(&lmh_lock); 44 mutex_lock(&lmh_lock);
45 45
46 list_for_each_entry(lw, &lmh_list, lw_list) { 46 list_for_each_entry(lw, &lmh_list, lw_list) {
47 if (!strcmp(lw->lw_ops->lm_proto_name, proto->lm_proto_name)) { 47 if (!strcmp(lw->lw_ops->lm_proto_name, proto->lm_proto_name)) {
48 up(&lmh_lock); 48 mutex_unlock(&lmh_lock);
49 printk(KERN_INFO "GFS2: protocol %s already exists\n", 49 printk(KERN_INFO "GFS2: protocol %s already exists\n",
50 proto->lm_proto_name); 50 proto->lm_proto_name);
51 return -EEXIST; 51 return -EEXIST;
@@ -54,14 +54,14 @@ int gfs_register_lockproto(struct lm_lockops *proto)
54 54
55 lw = kzalloc(sizeof(struct lmh_wrapper), GFP_KERNEL); 55 lw = kzalloc(sizeof(struct lmh_wrapper), GFP_KERNEL);
56 if (!lw) { 56 if (!lw) {
57 up(&lmh_lock); 57 mutex_unlock(&lmh_lock);
58 return -ENOMEM; 58 return -ENOMEM;
59 } 59 }
60 60
61 lw->lw_ops = proto; 61 lw->lw_ops = proto;
62 list_add(&lw->lw_list, &lmh_list); 62 list_add(&lw->lw_list, &lmh_list);
63 63
64 up(&lmh_lock); 64 mutex_unlock(&lmh_lock);
65 65
66 return 0; 66 return 0;
67} 67}
@@ -76,18 +76,18 @@ void gfs_unregister_lockproto(struct lm_lockops *proto)
76{ 76{
77 struct lmh_wrapper *lw; 77 struct lmh_wrapper *lw;
78 78
79 down(&lmh_lock); 79 mutex_lock(&lmh_lock);
80 80
81 list_for_each_entry(lw, &lmh_list, lw_list) { 81 list_for_each_entry(lw, &lmh_list, lw_list) {
82 if (!strcmp(lw->lw_ops->lm_proto_name, proto->lm_proto_name)) { 82 if (!strcmp(lw->lw_ops->lm_proto_name, proto->lm_proto_name)) {
83 list_del(&lw->lw_list); 83 list_del(&lw->lw_list);
84 up(&lmh_lock); 84 mutex_unlock(&lmh_lock);
85 kfree(lw); 85 kfree(lw);
86 return; 86 return;
87 } 87 }
88 } 88 }
89 89
90 up(&lmh_lock); 90 mutex_unlock(&lmh_lock);
91 91
92 printk(KERN_WARNING "GFS2: can't unregister lock protocol %s\n", 92 printk(KERN_WARNING "GFS2: can't unregister lock protocol %s\n",
93 proto->lm_proto_name); 93 proto->lm_proto_name);
@@ -118,7 +118,7 @@ int gfs2_mount_lockproto(char *proto_name, char *table_name, char *host_data,
118 int error, found; 118 int error, found;
119 119
120 retry: 120 retry:
121 down(&lmh_lock); 121 mutex_lock(&lmh_lock);
122 122
123 found = 0; 123 found = 0;
124 list_for_each_entry(lw, &lmh_list, lw_list) { 124 list_for_each_entry(lw, &lmh_list, lw_list) {
@@ -131,7 +131,7 @@ int gfs2_mount_lockproto(char *proto_name, char *table_name, char *host_data,
131 if (!found) { 131 if (!found) {
132 if (!try && capable(CAP_SYS_MODULE)) { 132 if (!try && capable(CAP_SYS_MODULE)) {
133 try = 1; 133 try = 1;
134 up(&lmh_lock); 134 mutex_unlock(&lmh_lock);
135 request_module(proto_name); 135 request_module(proto_name);
136 goto retry; 136 goto retry;
137 } 137 }
@@ -142,7 +142,7 @@ int gfs2_mount_lockproto(char *proto_name, char *table_name, char *host_data,
142 142
143 if (!try_module_get(lw->lw_ops->lm_owner)) { 143 if (!try_module_get(lw->lw_ops->lm_owner)) {
144 try = 0; 144 try = 0;
145 up(&lmh_lock); 145 mutex_unlock(&lmh_lock);
146 msleep(1000); 146 msleep(1000);
147 goto retry; 147 goto retry;
148 } 148 }
@@ -152,17 +152,17 @@ int gfs2_mount_lockproto(char *proto_name, char *table_name, char *host_data,
152 if (error) 152 if (error)
153 module_put(lw->lw_ops->lm_owner); 153 module_put(lw->lw_ops->lm_owner);
154 out: 154 out:
155 up(&lmh_lock); 155 mutex_unlock(&lmh_lock);
156 return error; 156 return error;
157} 157}
158 158
159void gfs2_unmount_lockproto(struct lm_lockstruct *lockstruct) 159void gfs2_unmount_lockproto(struct lm_lockstruct *lockstruct)
160{ 160{
161 down(&lmh_lock); 161 mutex_lock(&lmh_lock);
162 lockstruct->ls_ops->lm_unmount(lockstruct->ls_lockspace); 162 lockstruct->ls_ops->lm_unmount(lockstruct->ls_lockspace);
163 if (lockstruct->ls_ops->lm_owner) 163 if (lockstruct->ls_ops->lm_owner)
164 module_put(lockstruct->ls_ops->lm_owner); 164 module_put(lockstruct->ls_ops->lm_owner);
165 up(&lmh_lock); 165 mutex_unlock(&lmh_lock);
166} 166}
167 167
168/** 168/**
@@ -173,16 +173,16 @@ void gfs2_unmount_lockproto(struct lm_lockstruct *lockstruct)
173 173
174void gfs2_withdraw_lockproto(struct lm_lockstruct *lockstruct) 174void gfs2_withdraw_lockproto(struct lm_lockstruct *lockstruct)
175{ 175{
176 down(&lmh_lock); 176 mutex_lock(&lmh_lock);
177 lockstruct->ls_ops->lm_withdraw(lockstruct->ls_lockspace); 177 lockstruct->ls_ops->lm_withdraw(lockstruct->ls_lockspace);
178 if (lockstruct->ls_ops->lm_owner) 178 if (lockstruct->ls_ops->lm_owner)
179 module_put(lockstruct->ls_ops->lm_owner); 179 module_put(lockstruct->ls_ops->lm_owner);
180 up(&lmh_lock); 180 mutex_unlock(&lmh_lock);
181} 181}
182 182
183void __init gfs2_init_lmh(void) 183void __init gfs2_init_lmh(void)
184{ 184{
185 init_MUTEX(&lmh_lock); 185 mutex_init(&lmh_lock);
186 INIT_LIST_HEAD(&lmh_list); 186 INIT_LIST_HEAD(&lmh_list);
187} 187}
188 188
diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index 9e32e0faaf20..134fc57e21d3 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -587,10 +587,9 @@ void gfs2_log_shutdown(struct gfs2_sbd *sdp)
587 log_write_header(sdp, GFS2_LOG_HEAD_UNMOUNT, 0); 587 log_write_header(sdp, GFS2_LOG_HEAD_UNMOUNT, 0);
588 588
589 /* printk(KERN_INFO "sd_log_blks_free %u, sd_jdesc->jd_blocks %u\n", sdp->sd_log_blks_free, sdp->sd_jdesc->jd_blocks); */ 589 /* printk(KERN_INFO "sd_log_blks_free %u, sd_jdesc->jd_blocks %u\n", sdp->sd_log_blks_free, sdp->sd_jdesc->jd_blocks); */
590 gfs2_assert_withdraw(sdp, sdp->sd_log_blks_free == 590 gfs2_assert_warn(sdp, sdp->sd_log_blks_free == sdp->sd_jdesc->jd_blocks);
591 sdp->sd_jdesc->jd_blocks); 591 gfs2_assert_warn(sdp, sdp->sd_log_head == sdp->sd_log_tail);
592 gfs2_assert_withdraw(sdp, sdp->sd_log_head == sdp->sd_log_tail); 592 gfs2_assert_warn(sdp, list_empty(&sdp->sd_ail2_list));
593 gfs2_assert_withdraw(sdp, list_empty(&sdp->sd_ail2_list));
594 593
595 sdp->sd_log_head = sdp->sd_log_flush_head; 594 sdp->sd_log_head = sdp->sd_log_flush_head;
596 sdp->sd_log_tail = sdp->sd_log_head; 595 sdp->sd_log_tail = sdp->sd_log_head;
diff --git a/fs/gfs2/util.h b/fs/gfs2/util.h
index 4532dbab0a2c..c9624c30cad6 100644
--- a/fs/gfs2/util.h
+++ b/fs/gfs2/util.h
@@ -30,7 +30,6 @@ void gfs2_assert_i(struct gfs2_sbd *sdp);
30do { \ 30do { \
31 if (unlikely(!(assertion))) { \ 31 if (unlikely(!(assertion))) { \
32 gfs2_assert_i(sdp); \ 32 gfs2_assert_i(sdp); \
33 BUG(); \
34 } \ 33 } \
35} while (0) 34} while (0)
36 35