glops.c (b7e56edba4b02f2079042c326a8cd72a44635817) glops.c (009d851837ab26cab18adda6169a813f70b0b21b)
1/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
4 *
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
7 * of the GNU General Public License version 2.
8 */

--- 73 unchanged lines hidden (view full) ---

82 *
83 * Called when demoting or unlocking an EX glock. We must flush
84 * to disk all dirty buffers/pages relating to this glock, and must not
85 * not return to caller to demote/unlock the glock until I/O is complete.
86 */
87
88static void rgrp_go_sync(struct gfs2_glock *gl)
89{
1/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
4 *
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
7 * of the GNU General Public License version 2.
8 */

--- 73 unchanged lines hidden (view full) ---

82 *
83 * Called when demoting or unlocking an EX glock. We must flush
84 * to disk all dirty buffers/pages relating to this glock, and must not
85 * not return to caller to demote/unlock the glock until I/O is complete.
86 */
87
88static void rgrp_go_sync(struct gfs2_glock *gl)
89{
90 struct address_space *metamapping = gl->gl_aspace->i_mapping;
90 struct address_space *metamapping = gfs2_glock2aspace(gl);
91 int error;
92
93 if (!test_and_clear_bit(GLF_DIRTY, &gl->gl_flags))
94 return;
95 BUG_ON(gl->gl_state != LM_ST_EXCLUSIVE);
96
97 gfs2_log_flush(gl->gl_sbd, gl);
98 filemap_fdatawrite(metamapping);

--- 9 unchanged lines hidden (view full) ---

108 *
109 * We never used LM_ST_DEFERRED with resource groups, so that we
110 * should always see the metadata flag set here.
111 *
112 */
113
114static void rgrp_go_inval(struct gfs2_glock *gl, int flags)
115{
91 int error;
92
93 if (!test_and_clear_bit(GLF_DIRTY, &gl->gl_flags))
94 return;
95 BUG_ON(gl->gl_state != LM_ST_EXCLUSIVE);
96
97 gfs2_log_flush(gl->gl_sbd, gl);
98 filemap_fdatawrite(metamapping);

--- 9 unchanged lines hidden (view full) ---

108 *
109 * We never used LM_ST_DEFERRED with resource groups, so that we
110 * should always see the metadata flag set here.
111 *
112 */
113
114static void rgrp_go_inval(struct gfs2_glock *gl, int flags)
115{
116 struct address_space *mapping = gl->gl_aspace->i_mapping;
116 struct address_space *mapping = gfs2_glock2aspace(gl);
117
118 BUG_ON(!(flags & DIO_METADATA));
119 gfs2_assert_withdraw(gl->gl_sbd, !atomic_read(&gl->gl_ail_count));
120 truncate_inode_pages(mapping, 0);
121
122 if (gl->gl_object) {
123 struct gfs2_rgrpd *rgd = (struct gfs2_rgrpd *)gl->gl_object;
124 rgd->rd_flags &= ~GFS2_RDF_UPTODATE;

--- 4 unchanged lines hidden (view full) ---

129 * inode_go_sync - Sync the dirty data and/or metadata for an inode glock
130 * @gl: the glock protecting the inode
131 *
132 */
133
134static void inode_go_sync(struct gfs2_glock *gl)
135{
136 struct gfs2_inode *ip = gl->gl_object;
117
118 BUG_ON(!(flags & DIO_METADATA));
119 gfs2_assert_withdraw(gl->gl_sbd, !atomic_read(&gl->gl_ail_count));
120 truncate_inode_pages(mapping, 0);
121
122 if (gl->gl_object) {
123 struct gfs2_rgrpd *rgd = (struct gfs2_rgrpd *)gl->gl_object;
124 rgd->rd_flags &= ~GFS2_RDF_UPTODATE;

--- 4 unchanged lines hidden (view full) ---

129 * inode_go_sync - Sync the dirty data and/or metadata for an inode glock
130 * @gl: the glock protecting the inode
131 *
132 */
133
134static void inode_go_sync(struct gfs2_glock *gl)
135{
136 struct gfs2_inode *ip = gl->gl_object;
137 struct address_space *metamapping = gl->gl_aspace->i_mapping;
137 struct address_space *metamapping = gfs2_glock2aspace(gl);
138 int error;
139
140 if (ip && !S_ISREG(ip->i_inode.i_mode))
141 ip = NULL;
142 if (ip && test_and_clear_bit(GIF_SW_PAGED, &ip->i_flags))
143 unmap_shared_mapping_range(ip->i_inode.i_mapping, 0, 0);
144 if (!test_and_clear_bit(GLF_DIRTY, &gl->gl_flags))
145 return;

--- 32 unchanged lines hidden (view full) ---

178
179static void inode_go_inval(struct gfs2_glock *gl, int flags)
180{
181 struct gfs2_inode *ip = gl->gl_object;
182
183 gfs2_assert_withdraw(gl->gl_sbd, !atomic_read(&gl->gl_ail_count));
184
185 if (flags & DIO_METADATA) {
138 int error;
139
140 if (ip && !S_ISREG(ip->i_inode.i_mode))
141 ip = NULL;
142 if (ip && test_and_clear_bit(GIF_SW_PAGED, &ip->i_flags))
143 unmap_shared_mapping_range(ip->i_inode.i_mapping, 0, 0);
144 if (!test_and_clear_bit(GLF_DIRTY, &gl->gl_flags))
145 return;

--- 32 unchanged lines hidden (view full) ---

178
179static void inode_go_inval(struct gfs2_glock *gl, int flags)
180{
181 struct gfs2_inode *ip = gl->gl_object;
182
183 gfs2_assert_withdraw(gl->gl_sbd, !atomic_read(&gl->gl_ail_count));
184
185 if (flags & DIO_METADATA) {
186 struct address_space *mapping = gl->gl_aspace->i_mapping;
186 struct address_space *mapping = gfs2_glock2aspace(gl);
187 truncate_inode_pages(mapping, 0);
188 if (ip) {
189 set_bit(GIF_INVALID, &ip->i_flags);
190 forget_all_cached_acls(&ip->i_inode);
191 }
192 }
193
194 if (ip == GFS2_I(gl->gl_sbd->sd_rindex))

--- 82 unchanged lines hidden (view full) ---

277 * rgrp_go_demote_ok - Check to see if it's ok to unlock a RG's glock
278 * @gl: the glock
279 *
280 * Returns: 1 if it's ok
281 */
282
283static int rgrp_go_demote_ok(const struct gfs2_glock *gl)
284{
187 truncate_inode_pages(mapping, 0);
188 if (ip) {
189 set_bit(GIF_INVALID, &ip->i_flags);
190 forget_all_cached_acls(&ip->i_inode);
191 }
192 }
193
194 if (ip == GFS2_I(gl->gl_sbd->sd_rindex))

--- 82 unchanged lines hidden (view full) ---

277 * rgrp_go_demote_ok - Check to see if it's ok to unlock a RG's glock
278 * @gl: the glock
279 *
280 * Returns: 1 if it's ok
281 */
282
283static int rgrp_go_demote_ok(const struct gfs2_glock *gl)
284{
285 return !gl->gl_aspace->i_mapping->nrpages;
285 const struct address_space *mapping = (const struct address_space *)(gl + 1);
286 return !mapping->nrpages;
286}
287
288/**
289 * rgrp_go_lock - operation done after an rgrp lock is locked by
290 * a first holder on this node.
291 * @gl: the glock
292 * @flags:
293 *

--- 88 unchanged lines hidden (view full) ---

382 *
383 * gl_spin lock is held while calling this
384 */
385static void iopen_go_callback(struct gfs2_glock *gl)
386{
387 struct gfs2_inode *ip = (struct gfs2_inode *)gl->gl_object;
388
389 if (gl->gl_demote_state == LM_ST_UNLOCKED &&
287}
288
289/**
290 * rgrp_go_lock - operation done after an rgrp lock is locked by
291 * a first holder on this node.
292 * @gl: the glock
293 * @flags:
294 *

--- 88 unchanged lines hidden (view full) ---

383 *
384 * gl_spin lock is held while calling this
385 */
386static void iopen_go_callback(struct gfs2_glock *gl)
387{
388 struct gfs2_inode *ip = (struct gfs2_inode *)gl->gl_object;
389
390 if (gl->gl_demote_state == LM_ST_UNLOCKED &&
390 gl->gl_state == LM_ST_SHARED &&
391 ip && test_bit(GIF_USER, &ip->i_flags)) {
391 gl->gl_state == LM_ST_SHARED && ip) {
392 gfs2_glock_hold(gl);
393 if (queue_work(gfs2_delete_workqueue, &gl->gl_delete) == 0)
394 gfs2_glock_put_nolock(gl);
395 }
396}
397
398const struct gfs2_glock_operations gfs2_meta_glops = {
399 .go_type = LM_TYPE_META,
400};
401
402const struct gfs2_glock_operations gfs2_inode_glops = {
403 .go_xmote_th = inode_go_sync,
404 .go_inval = inode_go_inval,
405 .go_demote_ok = inode_go_demote_ok,
406 .go_lock = inode_go_lock,
407 .go_dump = inode_go_dump,
408 .go_type = LM_TYPE_INODE,
409 .go_min_hold_time = HZ / 5,
392 gfs2_glock_hold(gl);
393 if (queue_work(gfs2_delete_workqueue, &gl->gl_delete) == 0)
394 gfs2_glock_put_nolock(gl);
395 }
396}
397
398const struct gfs2_glock_operations gfs2_meta_glops = {
399 .go_type = LM_TYPE_META,
400};
401
402const struct gfs2_glock_operations gfs2_inode_glops = {
403 .go_xmote_th = inode_go_sync,
404 .go_inval = inode_go_inval,
405 .go_demote_ok = inode_go_demote_ok,
406 .go_lock = inode_go_lock,
407 .go_dump = inode_go_dump,
408 .go_type = LM_TYPE_INODE,
409 .go_min_hold_time = HZ / 5,
410 .go_flags = GLOF_ASPACE,
410};
411
412const struct gfs2_glock_operations gfs2_rgrp_glops = {
413 .go_xmote_th = rgrp_go_sync,
414 .go_inval = rgrp_go_inval,
415 .go_demote_ok = rgrp_go_demote_ok,
416 .go_lock = rgrp_go_lock,
417 .go_unlock = rgrp_go_unlock,
418 .go_dump = gfs2_rgrp_dump,
419 .go_type = LM_TYPE_RGRP,
420 .go_min_hold_time = HZ / 5,
411};
412
413const struct gfs2_glock_operations gfs2_rgrp_glops = {
414 .go_xmote_th = rgrp_go_sync,
415 .go_inval = rgrp_go_inval,
416 .go_demote_ok = rgrp_go_demote_ok,
417 .go_lock = rgrp_go_lock,
418 .go_unlock = rgrp_go_unlock,
419 .go_dump = gfs2_rgrp_dump,
420 .go_type = LM_TYPE_RGRP,
421 .go_min_hold_time = HZ / 5,
422 .go_flags = GLOF_ASPACE,
421};
422
423const struct gfs2_glock_operations gfs2_trans_glops = {
424 .go_xmote_th = trans_go_sync,
425 .go_xmote_bh = trans_go_xmote_bh,
426 .go_demote_ok = trans_go_demote_ok,
427 .go_type = LM_TYPE_NONDISK,
428};

--- 34 unchanged lines hidden ---
423};
424
425const struct gfs2_glock_operations gfs2_trans_glops = {
426 .go_xmote_th = trans_go_sync,
427 .go_xmote_bh = trans_go_xmote_bh,
428 .go_demote_ok = trans_go_demote_ok,
429 .go_type = LM_TYPE_NONDISK,
430};

--- 34 unchanged lines hidden ---