diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2006-09-04 09:49:55 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2006-09-04 09:49:55 -0400 |
commit | 5029996547a9f3988459e11955c13259495308ef (patch) | |
tree | 4667c98c19a6f39dc820e4eb648ecfa03b29bce2 /fs/gfs2/lm.c | |
parent | e9fc2aa091ab8fa46e60d4c9d06a89305c441652 (diff) |
[GFS2] Tidy up locking code
As per Jan Engelhardt's second email, this removes some unused code,
and fixes up indenting in various places.
Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/lm.c')
-rw-r--r-- | fs/gfs2/lm.c | 62 |
1 files changed, 18 insertions, 44 deletions
diff --git a/fs/gfs2/lm.c b/fs/gfs2/lm.c index 1a9e75da19d1..fb918c7de655 100644 --- a/fs/gfs2/lm.c +++ b/fs/gfs2/lm.c | |||
@@ -124,10 +124,8 @@ int gfs2_lm_withdraw(struct gfs2_sbd *sdp, char *fmt, ...) | |||
124 | int gfs2_lm_get_lock(struct gfs2_sbd *sdp, struct lm_lockname *name, | 124 | int gfs2_lm_get_lock(struct gfs2_sbd *sdp, struct lm_lockname *name, |
125 | lm_lock_t **lockp) | 125 | lm_lock_t **lockp) |
126 | { | 126 | { |
127 | int error; | 127 | int error = -EIO; |
128 | if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | 128 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) |
129 | error = -EIO; | ||
130 | else | ||
131 | error = sdp->sd_lockstruct.ls_ops->lm_get_lock( | 129 | error = sdp->sd_lockstruct.ls_ops->lm_get_lock( |
132 | sdp->sd_lockstruct.ls_lockspace, name, lockp); | 130 | sdp->sd_lockstruct.ls_lockspace, name, lockp); |
133 | return error; | 131 | return error; |
@@ -143,12 +141,9 @@ unsigned int gfs2_lm_lock(struct gfs2_sbd *sdp, lm_lock_t *lock, | |||
143 | unsigned int cur_state, unsigned int req_state, | 141 | unsigned int cur_state, unsigned int req_state, |
144 | unsigned int flags) | 142 | unsigned int flags) |
145 | { | 143 | { |
146 | int ret; | 144 | int ret = 0; |
147 | if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | 145 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) |
148 | ret = 0; | 146 | ret = sdp->sd_lockstruct.ls_ops->lm_lock(lock, cur_state, |
149 | else | ||
150 | ret = sdp->sd_lockstruct.ls_ops->lm_lock(lock, | ||
151 | cur_state, | ||
152 | req_state, flags); | 147 | req_state, flags); |
153 | return ret; | 148 | return ret; |
154 | } | 149 | } |
@@ -156,10 +151,8 @@ unsigned int gfs2_lm_lock(struct gfs2_sbd *sdp, lm_lock_t *lock, | |||
156 | unsigned int gfs2_lm_unlock(struct gfs2_sbd *sdp, lm_lock_t *lock, | 151 | unsigned int gfs2_lm_unlock(struct gfs2_sbd *sdp, lm_lock_t *lock, |
157 | unsigned int cur_state) | 152 | unsigned int cur_state) |
158 | { | 153 | { |
159 | int ret; | 154 | int ret = 0; |
160 | if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | 155 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) |
161 | ret = 0; | ||
162 | else | ||
163 | ret = sdp->sd_lockstruct.ls_ops->lm_unlock(lock, cur_state); | 156 | ret = sdp->sd_lockstruct.ls_ops->lm_unlock(lock, cur_state); |
164 | return ret; | 157 | return ret; |
165 | } | 158 | } |
@@ -172,10 +165,8 @@ void gfs2_lm_cancel(struct gfs2_sbd *sdp, lm_lock_t *lock) | |||
172 | 165 | ||
173 | int gfs2_lm_hold_lvb(struct gfs2_sbd *sdp, lm_lock_t *lock, char **lvbp) | 166 | int gfs2_lm_hold_lvb(struct gfs2_sbd *sdp, lm_lock_t *lock, char **lvbp) |
174 | { | 167 | { |
175 | int error; | 168 | int error = -EIO; |
176 | if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | 169 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) |
177 | error = -EIO; | ||
178 | else | ||
179 | error = sdp->sd_lockstruct.ls_ops->lm_hold_lvb(lock, lvbp); | 170 | error = sdp->sd_lockstruct.ls_ops->lm_hold_lvb(lock, lvbp); |
180 | return error; | 171 | return error; |
181 | } | 172 | } |
@@ -186,50 +177,33 @@ void gfs2_lm_unhold_lvb(struct gfs2_sbd *sdp, lm_lock_t *lock, char *lvb) | |||
186 | sdp->sd_lockstruct.ls_ops->lm_unhold_lvb(lock, lvb); | 177 | sdp->sd_lockstruct.ls_ops->lm_unhold_lvb(lock, lvb); |
187 | } | 178 | } |
188 | 179 | ||
189 | #if 0 | ||
190 | void gfs2_lm_sync_lvb(struct gfs2_sbd *sdp, lm_lock_t *lock, char *lvb) | ||
191 | { | ||
192 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
193 | sdp->sd_lockstruct.ls_ops->lm_sync_lvb(lock, lvb); | ||
194 | } | ||
195 | #endif /* 0 */ | ||
196 | |||
197 | int gfs2_lm_plock_get(struct gfs2_sbd *sdp, struct lm_lockname *name, | 180 | int gfs2_lm_plock_get(struct gfs2_sbd *sdp, struct lm_lockname *name, |
198 | struct file *file, struct file_lock *fl) | 181 | struct file *file, struct file_lock *fl) |
199 | { | 182 | { |
200 | int error; | 183 | int error = -EIO; |
201 | if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | 184 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) |
202 | error = -EIO; | ||
203 | else | ||
204 | error = sdp->sd_lockstruct.ls_ops->lm_plock_get( | 185 | error = sdp->sd_lockstruct.ls_ops->lm_plock_get( |
205 | sdp->sd_lockstruct.ls_lockspace, | 186 | sdp->sd_lockstruct.ls_lockspace, name, file, fl); |
206 | name, file, fl); | ||
207 | return error; | 187 | return error; |
208 | } | 188 | } |
209 | 189 | ||
210 | int gfs2_lm_plock(struct gfs2_sbd *sdp, struct lm_lockname *name, | 190 | int gfs2_lm_plock(struct gfs2_sbd *sdp, struct lm_lockname *name, |
211 | struct file *file, int cmd, struct file_lock *fl) | 191 | struct file *file, int cmd, struct file_lock *fl) |
212 | { | 192 | { |
213 | int error; | 193 | int error = -EIO; |
214 | if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | 194 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) |
215 | error = -EIO; | ||
216 | else | ||
217 | error = sdp->sd_lockstruct.ls_ops->lm_plock( | 195 | error = sdp->sd_lockstruct.ls_ops->lm_plock( |
218 | sdp->sd_lockstruct.ls_lockspace, | 196 | sdp->sd_lockstruct.ls_lockspace, name, file, cmd, fl); |
219 | name, file, cmd, fl); | ||
220 | return error; | 197 | return error; |
221 | } | 198 | } |
222 | 199 | ||
223 | int gfs2_lm_punlock(struct gfs2_sbd *sdp, struct lm_lockname *name, | 200 | int gfs2_lm_punlock(struct gfs2_sbd *sdp, struct lm_lockname *name, |
224 | struct file *file, struct file_lock *fl) | 201 | struct file *file, struct file_lock *fl) |
225 | { | 202 | { |
226 | int error; | 203 | int error = -EIO; |
227 | if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | 204 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) |
228 | error = -EIO; | ||
229 | else | ||
230 | error = sdp->sd_lockstruct.ls_ops->lm_punlock( | 205 | error = sdp->sd_lockstruct.ls_ops->lm_punlock( |
231 | sdp->sd_lockstruct.ls_lockspace, | 206 | sdp->sd_lockstruct.ls_lockspace, name, file, fl); |
232 | name, file, fl); | ||
233 | return error; | 207 | return error; |
234 | } | 208 | } |
235 | 209 | ||