glops.c (1a14d3a68f04527546121eb7b45187ff6af63151) glops.c (b004157ab5b374a498a5874cda68c389219d23e7)
1/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2006 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 */

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

102
103 if (test_bit(GIF_SW_PAGED, &ip->i_flags))
104 set_bit(GLF_DIRTY, &gl->gl_flags);
105
106 clear_bit(GIF_SW_PAGED, &ip->i_flags);
107}
108
109/**
1/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2006 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 */

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

102
103 if (test_bit(GIF_SW_PAGED, &ip->i_flags))
104 set_bit(GLF_DIRTY, &gl->gl_flags);
105
106 clear_bit(GIF_SW_PAGED, &ip->i_flags);
107}
108
109/**
110 * gfs2_page_inval - Invalidate all pages associated with a glock
111 * @gl: the glock
112 *
113 */
114
115static void gfs2_page_inval(struct gfs2_glock *gl)
116{
117 struct gfs2_inode *ip;
118 struct inode *inode;
119
120 ip = gl->gl_object;
121 inode = &ip->i_inode;
122 if (!ip || !S_ISREG(inode->i_mode))
123 return;
124
125 truncate_inode_pages(inode->i_mapping, 0);
126 gfs2_assert_withdraw(GFS2_SB(&ip->i_inode), !inode->i_mapping->nrpages);
127 clear_bit(GIF_PAGED, &ip->i_flags);
128}
129
130/**
131 * gfs2_page_wait - Wait for writeback of data
132 * @gl: the glock
133 *
134 * Syncs data (not metadata) for a regular file.
135 * No-op for all other types.
136 */
137
138static void gfs2_page_wait(struct gfs2_glock *gl)
139{
140 struct gfs2_inode *ip = gl->gl_object;
141 struct inode *inode = &ip->i_inode;
142 struct address_space *mapping = inode->i_mapping;
143 int error;
144
145 if (!S_ISREG(inode->i_mode))
146 return;
147
148 error = filemap_fdatawait(mapping);
149
150 /* Put back any errors cleared by filemap_fdatawait()
151 so they can be caught by someone who can pass them
152 up to user space. */
153
154 if (error == -ENOSPC)
155 set_bit(AS_ENOSPC, &mapping->flags);
156 else if (error)
157 set_bit(AS_EIO, &mapping->flags);
158
159}
160
161static void gfs2_page_writeback(struct gfs2_glock *gl)
162{
163 struct gfs2_inode *ip = gl->gl_object;
164 struct inode *inode = &ip->i_inode;
165 struct address_space *mapping = inode->i_mapping;
166
167 if (!S_ISREG(inode->i_mode))
168 return;
169
170 filemap_fdatawrite(mapping);
171}
172
173/**
174 * meta_go_sync - sync out the metadata for this glock
175 * @gl: the glock
176 *
177 * Called when demoting or unlocking an EX glock. We must flush
178 * to disk all dirty buffers/pages relating to this glock, and must not
179 * not return to caller to demote/unlock the glock until I/O is complete.
180 */
181

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

259/**
260 * inode_go_sync - Sync the dirty data and/or metadata for an inode glock
261 * @gl: the glock protecting the inode
262 *
263 */
264
265static void inode_go_sync(struct gfs2_glock *gl)
266{
110 * meta_go_sync - sync out the metadata for this glock
111 * @gl: the glock
112 *
113 * Called when demoting or unlocking an EX glock. We must flush
114 * to disk all dirty buffers/pages relating to this glock, and must not
115 * not return to caller to demote/unlock the glock until I/O is complete.
116 */
117

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

195/**
196 * inode_go_sync - Sync the dirty data and/or metadata for an inode glock
197 * @gl: the glock protecting the inode
198 *
199 */
200
201static void inode_go_sync(struct gfs2_glock *gl)
202{
203 struct gfs2_inode *ip = gl->gl_object;
204
205 if (ip && !S_ISREG(ip->i_inode.i_mode))
206 ip = NULL;
207
267 if (test_bit(GLF_DIRTY, &gl->gl_flags)) {
208 if (test_bit(GLF_DIRTY, &gl->gl_flags)) {
268 gfs2_page_writeback(gl);
269 gfs2_log_flush(gl->gl_sbd, gl);
209 gfs2_log_flush(gl->gl_sbd, gl);
210 if (ip)
211 filemap_fdatawrite(ip->i_inode.i_mapping);
270 gfs2_meta_sync(gl);
212 gfs2_meta_sync(gl);
271 gfs2_page_wait(gl);
213 if (ip) {
214 struct address_space *mapping = ip->i_inode.i_mapping;
215 int error = filemap_fdatawait(mapping);
216 if (error == -ENOSPC)
217 set_bit(AS_ENOSPC, &mapping->flags);
218 else if (error)
219 set_bit(AS_EIO, &mapping->flags);
220 }
272 clear_bit(GLF_DIRTY, &gl->gl_flags);
273 gfs2_ail_empty_gl(gl);
274 }
275}
276
277/**
278 * inode_go_inval - prepare a inode glock to be released
279 * @gl: the glock
280 * @flags:
281 *
282 */
283
284static void inode_go_inval(struct gfs2_glock *gl, int flags)
285{
221 clear_bit(GLF_DIRTY, &gl->gl_flags);
222 gfs2_ail_empty_gl(gl);
223 }
224}
225
226/**
227 * inode_go_inval - prepare a inode glock to be released
228 * @gl: the glock
229 * @flags:
230 *
231 */
232
233static void inode_go_inval(struct gfs2_glock *gl, int flags)
234{
235 struct gfs2_inode *ip = gl->gl_object;
286 int meta = (flags & DIO_METADATA);
287
288 if (meta) {
236 int meta = (flags & DIO_METADATA);
237
238 if (meta) {
289 struct gfs2_inode *ip = gl->gl_object;
290 gfs2_meta_inval(gl);
239 gfs2_meta_inval(gl);
291 set_bit(GIF_INVALID, &ip->i_flags);
240 if (ip)
241 set_bit(GIF_INVALID, &ip->i_flags);
292 }
242 }
293 gfs2_page_inval(gl);
243
244 if (ip && S_ISREG(ip->i_inode.i_mode)) {
245 truncate_inode_pages(ip->i_inode.i_mapping, 0);
246 gfs2_assert_withdraw(GFS2_SB(&ip->i_inode), !ip->i_inode.i_mapping->nrpages);
247 clear_bit(GIF_PAGED, &ip->i_flags);
248 }
294}
295
296/**
297 * inode_go_demote_ok - Check to see if it's ok to unlock an inode glock
298 * @gl: the glock
299 *
300 * Returns: 1 if it's ok
301 */

--- 291 unchanged lines hidden ---
249}
250
251/**
252 * inode_go_demote_ok - Check to see if it's ok to unlock an inode glock
253 * @gl: the glock
254 *
255 * Returns: 1 if it's ok
256 */

--- 291 unchanged lines hidden ---