aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/glops.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/gfs2/glops.c')
-rw-r--r--fs/gfs2/glops.c110
1 files changed, 18 insertions, 92 deletions
diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
index 4670dcb2a877..c663b7a0f410 100644
--- a/fs/gfs2/glops.c
+++ b/fs/gfs2/glops.c
@@ -56,7 +56,7 @@ static void gfs2_ail_empty_gl(struct gfs2_glock *gl)
56 bd = list_entry(head->next, struct gfs2_bufdata, 56 bd = list_entry(head->next, struct gfs2_bufdata,
57 bd_ail_gl_list); 57 bd_ail_gl_list);
58 bh = bd->bd_bh; 58 bh = bd->bd_bh;
59 gfs2_remove_from_ail(NULL, bd); 59 gfs2_remove_from_ail(bd);
60 bd->bd_bh = NULL; 60 bd->bd_bh = NULL;
61 bh->b_private = NULL; 61 bh->b_private = NULL;
62 bd->bd_blkno = bh->b_blocknr; 62 bd->bd_blkno = bh->b_blocknr;
@@ -86,15 +86,10 @@ static void gfs2_pte_inval(struct gfs2_glock *gl)
86 if (!ip || !S_ISREG(inode->i_mode)) 86 if (!ip || !S_ISREG(inode->i_mode))
87 return; 87 return;
88 88
89 if (!test_bit(GIF_PAGED, &ip->i_flags))
90 return;
91
92 unmap_shared_mapping_range(inode->i_mapping, 0, 0); 89 unmap_shared_mapping_range(inode->i_mapping, 0, 0);
93
94 if (test_bit(GIF_SW_PAGED, &ip->i_flags)) 90 if (test_bit(GIF_SW_PAGED, &ip->i_flags))
95 set_bit(GLF_DIRTY, &gl->gl_flags); 91 set_bit(GLF_DIRTY, &gl->gl_flags);
96 92
97 clear_bit(GIF_SW_PAGED, &ip->i_flags);
98} 93}
99 94
100/** 95/**
@@ -143,44 +138,34 @@ static void meta_go_inval(struct gfs2_glock *gl, int flags)
143static void inode_go_sync(struct gfs2_glock *gl) 138static void inode_go_sync(struct gfs2_glock *gl)
144{ 139{
145 struct gfs2_inode *ip = gl->gl_object; 140 struct gfs2_inode *ip = gl->gl_object;
141 struct address_space *metamapping = gl->gl_aspace->i_mapping;
142 int error;
143
144 if (gl->gl_state != LM_ST_UNLOCKED)
145 gfs2_pte_inval(gl);
146 if (gl->gl_state != LM_ST_EXCLUSIVE)
147 return;
146 148
147 if (ip && !S_ISREG(ip->i_inode.i_mode)) 149 if (ip && !S_ISREG(ip->i_inode.i_mode))
148 ip = NULL; 150 ip = NULL;
149 151
150 if (test_bit(GLF_DIRTY, &gl->gl_flags)) { 152 if (test_bit(GLF_DIRTY, &gl->gl_flags)) {
151 if (ip && !gfs2_is_jdata(ip))
152 filemap_fdatawrite(ip->i_inode.i_mapping);
153 gfs2_log_flush(gl->gl_sbd, gl); 153 gfs2_log_flush(gl->gl_sbd, gl);
154 if (ip && gfs2_is_jdata(ip)) 154 filemap_fdatawrite(metamapping);
155 filemap_fdatawrite(ip->i_inode.i_mapping);
156 gfs2_meta_sync(gl);
157 if (ip) { 155 if (ip) {
158 struct address_space *mapping = ip->i_inode.i_mapping; 156 struct address_space *mapping = ip->i_inode.i_mapping;
159 int error = filemap_fdatawait(mapping); 157 filemap_fdatawrite(mapping);
158 error = filemap_fdatawait(mapping);
160 mapping_set_error(mapping, error); 159 mapping_set_error(mapping, error);
161 } 160 }
161 error = filemap_fdatawait(metamapping);
162 mapping_set_error(metamapping, error);
162 clear_bit(GLF_DIRTY, &gl->gl_flags); 163 clear_bit(GLF_DIRTY, &gl->gl_flags);
163 gfs2_ail_empty_gl(gl); 164 gfs2_ail_empty_gl(gl);
164 } 165 }
165} 166}
166 167
167/** 168/**
168 * inode_go_xmote_th - promote/demote a glock
169 * @gl: the glock
170 * @state: the requested state
171 * @flags:
172 *
173 */
174
175static void inode_go_xmote_th(struct gfs2_glock *gl)
176{
177 if (gl->gl_state != LM_ST_UNLOCKED)
178 gfs2_pte_inval(gl);
179 if (gl->gl_state == LM_ST_EXCLUSIVE)
180 inode_go_sync(gl);
181}
182
183/**
184 * inode_go_xmote_bh - After promoting/demoting a glock 169 * inode_go_xmote_bh - After promoting/demoting a glock
185 * @gl: the glock 170 * @gl: the glock
186 * 171 *
@@ -201,22 +186,6 @@ static void inode_go_xmote_bh(struct gfs2_glock *gl)
201} 186}
202 187
203/** 188/**
204 * inode_go_drop_th - unlock a glock
205 * @gl: the glock
206 *
207 * Invoked from rq_demote().
208 * Another node needs the lock in EXCLUSIVE mode, or lock (unused for too long)
209 * is being purged from our node's glock cache; we're dropping lock.
210 */
211
212static void inode_go_drop_th(struct gfs2_glock *gl)
213{
214 gfs2_pte_inval(gl);
215 if (gl->gl_state == LM_ST_EXCLUSIVE)
216 inode_go_sync(gl);
217}
218
219/**
220 * inode_go_inval - prepare a inode glock to be released 189 * inode_go_inval - prepare a inode glock to be released
221 * @gl: the glock 190 * @gl: the glock
222 * @flags: 191 * @flags:
@@ -234,10 +203,8 @@ static void inode_go_inval(struct gfs2_glock *gl, int flags)
234 set_bit(GIF_INVALID, &ip->i_flags); 203 set_bit(GIF_INVALID, &ip->i_flags);
235 } 204 }
236 205
237 if (ip && S_ISREG(ip->i_inode.i_mode)) { 206 if (ip && S_ISREG(ip->i_inode.i_mode))
238 truncate_inode_pages(ip->i_inode.i_mapping, 0); 207 truncate_inode_pages(ip->i_inode.i_mapping, 0);
239 clear_bit(GIF_PAGED, &ip->i_flags);
240 }
241} 208}
242 209
243/** 210/**
@@ -294,23 +261,6 @@ static int inode_go_lock(struct gfs2_holder *gh)
294} 261}
295 262
296/** 263/**
297 * inode_go_unlock - operation done before an inode lock is unlocked by a
298 * process
299 * @gl: the glock
300 * @flags:
301 *
302 */
303
304static void inode_go_unlock(struct gfs2_holder *gh)
305{
306 struct gfs2_glock *gl = gh->gh_gl;
307 struct gfs2_inode *ip = gl->gl_object;
308
309 if (ip)
310 gfs2_meta_cache_flush(ip);
311}
312
313/**
314 * rgrp_go_demote_ok - Check to see if it's ok to unlock a RG's glock 264 * rgrp_go_demote_ok - Check to see if it's ok to unlock a RG's glock
315 * @gl: the glock 265 * @gl: the glock
316 * 266 *
@@ -350,14 +300,14 @@ static void rgrp_go_unlock(struct gfs2_holder *gh)
350} 300}
351 301
352/** 302/**
353 * trans_go_xmote_th - promote/demote the transaction glock 303 * trans_go_sync - promote/demote the transaction glock
354 * @gl: the glock 304 * @gl: the glock
355 * @state: the requested state 305 * @state: the requested state
356 * @flags: 306 * @flags:
357 * 307 *
358 */ 308 */
359 309
360static void trans_go_xmote_th(struct gfs2_glock *gl) 310static void trans_go_sync(struct gfs2_glock *gl)
361{ 311{
362 struct gfs2_sbd *sdp = gl->gl_sbd; 312 struct gfs2_sbd *sdp = gl->gl_sbd;
363 313
@@ -384,7 +334,6 @@ static void trans_go_xmote_bh(struct gfs2_glock *gl)
384 334
385 if (gl->gl_state != LM_ST_UNLOCKED && 335 if (gl->gl_state != LM_ST_UNLOCKED &&
386 test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) { 336 test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) {
387 gfs2_meta_cache_flush(GFS2_I(sdp->sd_jdesc->jd_inode));
388 j_gl->gl_ops->go_inval(j_gl, DIO_METADATA); 337 j_gl->gl_ops->go_inval(j_gl, DIO_METADATA);
389 338
390 error = gfs2_find_jhead(sdp->sd_jdesc, &head); 339 error = gfs2_find_jhead(sdp->sd_jdesc, &head);
@@ -402,24 +351,6 @@ static void trans_go_xmote_bh(struct gfs2_glock *gl)
402} 351}
403 352
404/** 353/**
405 * trans_go_drop_th - unlock the transaction glock
406 * @gl: the glock
407 *
408 * We want to sync the device even with localcaching. Remember
409 * that localcaching journal replay only marks buffers dirty.
410 */
411
412static void trans_go_drop_th(struct gfs2_glock *gl)
413{
414 struct gfs2_sbd *sdp = gl->gl_sbd;
415
416 if (test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) {
417 gfs2_meta_syncfs(sdp);
418 gfs2_log_shutdown(sdp);
419 }
420}
421
422/**
423 * quota_go_demote_ok - Check to see if it's ok to unlock a quota glock 354 * quota_go_demote_ok - Check to see if it's ok to unlock a quota glock
424 * @gl: the glock 355 * @gl: the glock
425 * 356 *
@@ -433,25 +364,21 @@ static int quota_go_demote_ok(struct gfs2_glock *gl)
433 364
434const struct gfs2_glock_operations gfs2_meta_glops = { 365const struct gfs2_glock_operations gfs2_meta_glops = {
435 .go_xmote_th = meta_go_sync, 366 .go_xmote_th = meta_go_sync,
436 .go_drop_th = meta_go_sync,
437 .go_type = LM_TYPE_META, 367 .go_type = LM_TYPE_META,
438}; 368};
439 369
440const struct gfs2_glock_operations gfs2_inode_glops = { 370const struct gfs2_glock_operations gfs2_inode_glops = {
441 .go_xmote_th = inode_go_xmote_th, 371 .go_xmote_th = inode_go_sync,
442 .go_xmote_bh = inode_go_xmote_bh, 372 .go_xmote_bh = inode_go_xmote_bh,
443 .go_drop_th = inode_go_drop_th,
444 .go_inval = inode_go_inval, 373 .go_inval = inode_go_inval,
445 .go_demote_ok = inode_go_demote_ok, 374 .go_demote_ok = inode_go_demote_ok,
446 .go_lock = inode_go_lock, 375 .go_lock = inode_go_lock,
447 .go_unlock = inode_go_unlock,
448 .go_type = LM_TYPE_INODE, 376 .go_type = LM_TYPE_INODE,
449 .go_min_hold_time = HZ / 10, 377 .go_min_hold_time = HZ / 10,
450}; 378};
451 379
452const struct gfs2_glock_operations gfs2_rgrp_glops = { 380const struct gfs2_glock_operations gfs2_rgrp_glops = {
453 .go_xmote_th = meta_go_sync, 381 .go_xmote_th = meta_go_sync,
454 .go_drop_th = meta_go_sync,
455 .go_inval = meta_go_inval, 382 .go_inval = meta_go_inval,
456 .go_demote_ok = rgrp_go_demote_ok, 383 .go_demote_ok = rgrp_go_demote_ok,
457 .go_lock = rgrp_go_lock, 384 .go_lock = rgrp_go_lock,
@@ -461,9 +388,8 @@ const struct gfs2_glock_operations gfs2_rgrp_glops = {
461}; 388};
462 389
463const struct gfs2_glock_operations gfs2_trans_glops = { 390const struct gfs2_glock_operations gfs2_trans_glops = {
464 .go_xmote_th = trans_go_xmote_th, 391 .go_xmote_th = trans_go_sync,
465 .go_xmote_bh = trans_go_xmote_bh, 392 .go_xmote_bh = trans_go_xmote_bh,
466 .go_drop_th = trans_go_drop_th,
467 .go_type = LM_TYPE_NONDISK, 393 .go_type = LM_TYPE_NONDISK,
468}; 394};
469 395