blob: 9679f8b9870d4b662a9a49023fc8b604ade25a68 [file] [log] [blame]
David Teiglandb3b94fa2006-01-16 16:50:04 +00001/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
Robert Peterson7ae8fa82007-05-09 09:37:57 -05003 * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
David Teiglandb3b94fa2006-01-16 16:50:04 +00004 *
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
Steven Whitehousee9fc2aa2006-09-01 11:05:15 -04007 * of the GNU General Public License version 2.
David Teiglandb3b94fa2006-01-16 16:50:04 +00008 */
9
10#include <linux/sched.h>
11#include <linux/slab.h>
12#include <linux/spinlock.h>
13#include <linux/completion.h>
14#include <linux/buffer_head.h>
15#include <linux/pagemap.h>
Steven Whitehousefd88de562006-05-05 16:59:11 -040016#include <linux/pagevec.h>
Steven Whitehouse9b124fb2006-01-30 11:55:32 +000017#include <linux/mpage.h>
Steven Whitehoused1665e42006-02-14 11:54:42 +000018#include <linux/fs.h>
Steven Whitehousea8d638e2007-01-15 13:52:17 +000019#include <linux/writeback.h>
Steven Whitehouse7765ec22007-10-16 01:25:07 -070020#include <linux/swap.h>
Steven Whitehouse5c676f62006-02-27 17:23:27 -050021#include <linux/gfs2_ondisk.h>
Fabio Massimo Di Nitto7d308592006-09-19 07:56:29 +020022#include <linux/lm_interface.h>
David Teiglandb3b94fa2006-01-16 16:50:04 +000023
24#include "gfs2.h"
Steven Whitehouse5c676f62006-02-27 17:23:27 -050025#include "incore.h"
David Teiglandb3b94fa2006-01-16 16:50:04 +000026#include "bmap.h"
27#include "glock.h"
28#include "inode.h"
David Teiglandb3b94fa2006-01-16 16:50:04 +000029#include "log.h"
30#include "meta_io.h"
31#include "ops_address.h"
David Teiglandb3b94fa2006-01-16 16:50:04 +000032#include "quota.h"
33#include "trans.h"
Steven Whitehouse18ec7d52006-02-08 11:50:51 +000034#include "rgrp.h"
Steven Whitehouse61a30dc2006-02-15 10:15:18 +000035#include "ops_file.h"
Robert Petersoncd81a4b2007-05-14 12:42:18 -050036#include "super.h"
Steven Whitehouse5c676f62006-02-27 17:23:27 -050037#include "util.h"
Steven Whitehouse4340fe62006-07-11 09:46:33 -040038#include "glops.h"
David Teiglandb3b94fa2006-01-16 16:50:04 +000039
Steven Whitehouseba7f7292006-07-26 11:27:10 -040040
41static void gfs2_page_add_databufs(struct gfs2_inode *ip, struct page *page,
42 unsigned int from, unsigned int to)
43{
44 struct buffer_head *head = page_buffers(page);
45 unsigned int bsize = head->b_size;
46 struct buffer_head *bh;
47 unsigned int start, end;
48
49 for (bh = head, start = 0; bh != head || !start;
50 bh = bh->b_this_page, start = end) {
51 end = start + bsize;
52 if (end <= from || start >= to)
53 continue;
Benjamin Marzinskiddf4b422007-06-01 14:21:38 -050054 if (gfs2_is_jdata(ip))
55 set_buffer_uptodate(bh);
Steven Whitehouseba7f7292006-07-26 11:27:10 -040056 gfs2_trans_add_bh(ip->i_gl, bh, 0);
57 }
58}
59
David Teiglandb3b94fa2006-01-16 16:50:04 +000060/**
Steven Whitehouse4ff14672006-01-30 09:39:10 +000061 * gfs2_get_block - Fills in a buffer head with details about a block
David Teiglandb3b94fa2006-01-16 16:50:04 +000062 * @inode: The inode
63 * @lblock: The block number to look up
64 * @bh_result: The buffer head to return the result in
65 * @create: Non-zero if we may add block to the file
66 *
67 * Returns: errno
68 */
69
Steven Whitehouse4ff14672006-01-30 09:39:10 +000070int gfs2_get_block(struct inode *inode, sector_t lblock,
71 struct buffer_head *bh_result, int create)
David Teiglandb3b94fa2006-01-16 16:50:04 +000072{
Steven Whitehouse23591252006-10-13 17:25:45 -040073 return gfs2_block_map(inode, lblock, create, bh_result);
David Teiglandb3b94fa2006-01-16 16:50:04 +000074}
75
76/**
Steven Whitehouse7a6bbac2006-09-18 17:18:23 -040077 * gfs2_get_block_noalloc - Fills in a buffer head with details about a block
David Teiglandb3b94fa2006-01-16 16:50:04 +000078 * @inode: The inode
79 * @lblock: The block number to look up
80 * @bh_result: The buffer head to return the result in
81 * @create: Non-zero if we may add block to the file
82 *
83 * Returns: errno
84 */
85
Steven Whitehouse7a6bbac2006-09-18 17:18:23 -040086static int gfs2_get_block_noalloc(struct inode *inode, sector_t lblock,
87 struct buffer_head *bh_result, int create)
David Teiglandb3b94fa2006-01-16 16:50:04 +000088{
David Teiglandb3b94fa2006-01-16 16:50:04 +000089 int error;
90
Steven Whitehouse23591252006-10-13 17:25:45 -040091 error = gfs2_block_map(inode, lblock, 0, bh_result);
David Teiglandb3b94fa2006-01-16 16:50:04 +000092 if (error)
93 return error;
Wendy Chengde986e82007-09-18 09:19:13 -040094 if (!buffer_mapped(bh_result))
Steven Whitehouse7a6bbac2006-09-18 17:18:23 -040095 return -EIO;
Steven Whitehouse623d9352006-08-31 12:14:44 -040096 return 0;
97}
Steven Whitehouse7a6bbac2006-09-18 17:18:23 -040098
99static int gfs2_get_block_direct(struct inode *inode, sector_t lblock,
100 struct buffer_head *bh_result, int create)
101{
Steven Whitehouse23591252006-10-13 17:25:45 -0400102 return gfs2_block_map(inode, lblock, 0, bh_result);
Steven Whitehouse7a6bbac2006-09-18 17:18:23 -0400103}
104
David Teiglandb3b94fa2006-01-16 16:50:04 +0000105/**
106 * gfs2_writepage - Write complete page
107 * @page: Page to write
108 *
109 * Returns: errno
110 *
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000111 * Some of this is copied from block_write_full_page() although we still
112 * call it to do most of the work.
David Teiglandb3b94fa2006-01-16 16:50:04 +0000113 */
114
115static int gfs2_writepage(struct page *page, struct writeback_control *wbc)
116{
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000117 struct inode *inode = page->mapping->host;
Steven Whitehousef4387142006-08-08 13:23:19 -0400118 struct gfs2_inode *ip = GFS2_I(inode);
119 struct gfs2_sbd *sdp = GFS2_SB(inode);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000120 loff_t i_size = i_size_read(inode);
121 pgoff_t end_index = i_size >> PAGE_CACHE_SHIFT;
122 unsigned offset;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000123 int error;
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000124 int done_trans = 0;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000125
David Teiglandb3b94fa2006-01-16 16:50:04 +0000126 if (gfs2_assert_withdraw(sdp, gfs2_glock_is_held_excl(ip->i_gl))) {
127 unlock_page(page);
128 return -EIO;
129 }
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500130 if (current->journal_info)
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000131 goto out_ignore;
132
133 /* Is the page fully outside i_size? (truncate in progress) */
134 offset = i_size & (PAGE_CACHE_SIZE-1);
Steven Whitehoused2d7b8a2006-05-02 12:09:42 -0400135 if (page->index > end_index || (page->index == end_index && !offset)) {
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000136 page->mapping->a_ops->invalidatepage(page, 0);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000137 unlock_page(page);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000138 return 0; /* don't care */
139 }
140
Robert Peterson8fb68592007-06-12 11:24:36 -0500141 if ((sdp->sd_args.ar_data == GFS2_DATA_ORDERED || gfs2_is_jdata(ip)) &&
142 PageChecked(page)) {
143 ClearPageChecked(page);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000144 error = gfs2_trans_begin(sdp, RES_DINODE + 1, 0);
145 if (error)
146 goto out_ignore;
Steven Whitehousef4387142006-08-08 13:23:19 -0400147 if (!page_has_buffers(page)) {
148 create_empty_buffers(page, inode->i_sb->s_blocksize,
149 (1 << BH_Dirty)|(1 << BH_Uptodate));
150 }
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000151 gfs2_page_add_databufs(ip, page, 0, sdp->sd_vfs->s_blocksize-1);
152 done_trans = 1;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000153 }
Steven Whitehouse7a6bbac2006-09-18 17:18:23 -0400154 error = block_write_full_page(page, gfs2_get_block_noalloc, wbc);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000155 if (done_trans)
156 gfs2_trans_end(sdp);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000157 gfs2_meta_cache_flush(ip);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000158 return error;
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000159
160out_ignore:
161 redirty_page_for_writepage(wbc, page);
162 unlock_page(page);
163 return 0;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000164}
165
166/**
Steven Whitehousea8d638e2007-01-15 13:52:17 +0000167 * gfs2_writepages - Write a bunch of dirty pages back to disk
168 * @mapping: The mapping to write
169 * @wbc: Write-back control
170 *
171 * For journaled files and/or ordered writes this just falls back to the
172 * kernel's default writepages path for now. We will probably want to change
173 * that eventually (i.e. when we look at allocate on flush).
174 *
175 * For the data=writeback case though we can already ignore buffer heads
176 * and write whole extents at once. This is a big reduction in the
177 * number of I/O requests we send and the bmap calls we make in this case.
178 */
Adrian Bunka2cf8222007-02-06 23:12:49 +0100179static int gfs2_writepages(struct address_space *mapping,
180 struct writeback_control *wbc)
Steven Whitehousea8d638e2007-01-15 13:52:17 +0000181{
182 struct inode *inode = mapping->host;
183 struct gfs2_inode *ip = GFS2_I(inode);
184 struct gfs2_sbd *sdp = GFS2_SB(inode);
185
186 if (sdp->sd_args.ar_data == GFS2_DATA_WRITEBACK && !gfs2_is_jdata(ip))
187 return mpage_writepages(mapping, wbc, gfs2_get_block_noalloc);
188
189 return generic_writepages(mapping, wbc);
190}
191
192/**
David Teiglandb3b94fa2006-01-16 16:50:04 +0000193 * stuffed_readpage - Fill in a Linux page with stuffed file data
194 * @ip: the inode
195 * @page: the page
196 *
197 * Returns: errno
198 */
199
200static int stuffed_readpage(struct gfs2_inode *ip, struct page *page)
201{
202 struct buffer_head *dibh;
203 void *kaddr;
204 int error;
205
Steven Whitehousebf126ae2007-04-20 09:18:30 +0100206 /*
207 * Due to the order of unstuffing files and ->nopage(), we can be
208 * asked for a zero page in the case of a stuffed file being extended,
209 * so we need to supply one here. It doesn't happen often.
210 */
211 if (unlikely(page->index)) {
Steven Whitehouse28405012007-06-18 16:31:42 +0100212 zero_user_page(page, 0, PAGE_CACHE_SIZE, KM_USER0);
Steven Whitehousebf126ae2007-04-20 09:18:30 +0100213 return 0;
214 }
Steven Whitehousefd88de562006-05-05 16:59:11 -0400215
David Teiglandb3b94fa2006-01-16 16:50:04 +0000216 error = gfs2_meta_inode_buffer(ip, &dibh);
217 if (error)
218 return error;
219
Steven Whitehouse5c4e9e02006-02-15 12:26:19 +0000220 kaddr = kmap_atomic(page, KM_USER0);
Steven Whitehousefd88de562006-05-05 16:59:11 -0400221 memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode),
David Teiglandb3b94fa2006-01-16 16:50:04 +0000222 ip->i_di.di_size);
Steven Whitehousefd88de562006-05-05 16:59:11 -0400223 memset(kaddr + ip->i_di.di_size, 0, PAGE_CACHE_SIZE - ip->i_di.di_size);
Russell Cattelanc312c4f2006-10-12 09:23:41 -0400224 kunmap_atomic(kaddr, KM_USER0);
Steven Whitehousebf126ae2007-04-20 09:18:30 +0100225 flush_dcache_page(page);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000226 brelse(dibh);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000227 SetPageUptodate(page);
228
229 return 0;
230}
231
David Teiglandb3b94fa2006-01-16 16:50:04 +0000232
233/**
David Teiglandb3b94fa2006-01-16 16:50:04 +0000234 * gfs2_readpage - readpage with locking
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000235 * @file: The file to read a page for. N.B. This may be NULL if we are
236 * reading an internal file.
David Teiglandb3b94fa2006-01-16 16:50:04 +0000237 * @page: The page to read
238 *
239 * Returns: errno
240 */
241
242static int gfs2_readpage(struct file *file, struct page *page)
243{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400244 struct gfs2_inode *ip = GFS2_I(page->mapping->host);
245 struct gfs2_sbd *sdp = GFS2_SB(page->mapping->host);
Russell Cattelandc41aee2006-09-18 17:26:48 -0400246 struct gfs2_file *gf = NULL;
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000247 struct gfs2_holder gh;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000248 int error;
Steven Whitehouse59a1cc62006-08-04 15:41:22 -0400249 int do_unlock = 0;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000250
Steven Whitehousedd538c82006-09-04 14:53:30 -0400251 if (likely(file != &gfs2_internal_file_sentinel)) {
Steven Whitehouse59a1cc62006-08-04 15:41:22 -0400252 if (file) {
Russell Cattelandc41aee2006-09-18 17:26:48 -0400253 gf = file->private_data;
Steven Whitehouse59a1cc62006-08-04 15:41:22 -0400254 if (test_bit(GFF_EXLOCK, &gf->f_flags))
Nick Piggin54cb8822007-07-19 01:46:59 -0700255 /* gfs2_sharewrite_fault has grabbed the ip->i_gl already */
Steven Whitehouse59a1cc62006-08-04 15:41:22 -0400256 goto skip_lock;
257 }
Steven Whitehouse2ca99502006-11-08 10:26:54 -0500258 gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME|LM_FLAG_TRY_1CB, &gh);
Steven Whitehouse59a1cc62006-08-04 15:41:22 -0400259 do_unlock = 1;
Steven Whitehousedcd24792006-11-16 11:08:16 -0500260 error = gfs2_glock_nq_atime(&gh);
Steven Whitehousefd88de562006-05-05 16:59:11 -0400261 if (unlikely(error))
Steven Whitehouse61a30dc2006-02-15 10:15:18 +0000262 goto out_unlock;
263 }
David Teiglandb3b94fa2006-01-16 16:50:04 +0000264
Steven Whitehouse59a1cc62006-08-04 15:41:22 -0400265skip_lock:
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000266 if (gfs2_is_stuffed(ip)) {
Steven Whitehousefd88de562006-05-05 16:59:11 -0400267 error = stuffed_readpage(ip, page);
268 unlock_page(page);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000269 } else
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000270 error = mpage_readpage(page, gfs2_get_block);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000271
272 if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
273 error = -EIO;
274
Steven Whitehouse07903c02006-09-18 17:30:05 -0400275 if (do_unlock) {
Steven Whitehouse61a30dc2006-02-15 10:15:18 +0000276 gfs2_glock_dq_m(1, &gh);
277 gfs2_holder_uninit(&gh);
278 }
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000279out:
David Teiglandb3b94fa2006-01-16 16:50:04 +0000280 return error;
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000281out_unlock:
282 unlock_page(page);
Josef Whitera13cbe32007-02-23 12:49:51 -0500283 if (error == GLR_TRYFAILED) {
284 error = AOP_TRUNCATED_PAGE;
285 yield();
286 }
Steven Whitehouse59a1cc62006-08-04 15:41:22 -0400287 if (do_unlock)
Steven Whitehousefd88de562006-05-05 16:59:11 -0400288 gfs2_holder_uninit(&gh);
289 goto out;
290}
291
Steven Whitehousefd88de562006-05-05 16:59:11 -0400292/**
293 * gfs2_readpages - Read a bunch of pages at once
294 *
295 * Some notes:
296 * 1. This is only for readahead, so we can simply ignore any things
297 * which are slightly inconvenient (such as locking conflicts between
298 * the page lock and the glock) and return having done no I/O. Its
299 * obviously not something we'd want to do on too regular a basis.
300 * Any I/O we ignore at this time will be done via readpage later.
Steven Whitehousee1d5b182006-12-15 16:49:51 -0500301 * 2. We don't handle stuffed files here we let readpage do the honours.
Steven Whitehousefd88de562006-05-05 16:59:11 -0400302 * 3. mpage_readpages() does most of the heavy lifting in the common case.
303 * 4. gfs2_get_block() is relied upon to set BH_Boundary in the right places.
304 * 5. We use LM_FLAG_TRY_1CB here, effectively we then have lock-ahead as
305 * well as read-ahead.
306 */
307static int gfs2_readpages(struct file *file, struct address_space *mapping,
308 struct list_head *pages, unsigned nr_pages)
309{
310 struct inode *inode = mapping->host;
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400311 struct gfs2_inode *ip = GFS2_I(inode);
312 struct gfs2_sbd *sdp = GFS2_SB(inode);
Steven Whitehousefd88de562006-05-05 16:59:11 -0400313 struct gfs2_holder gh;
Steven Whitehousee1d5b182006-12-15 16:49:51 -0500314 int ret = 0;
Steven Whitehouse59a1cc62006-08-04 15:41:22 -0400315 int do_unlock = 0;
Steven Whitehousefd88de562006-05-05 16:59:11 -0400316
Steven Whitehousedd538c82006-09-04 14:53:30 -0400317 if (likely(file != &gfs2_internal_file_sentinel)) {
Steven Whitehouse59a1cc62006-08-04 15:41:22 -0400318 if (file) {
319 struct gfs2_file *gf = file->private_data;
320 if (test_bit(GFF_EXLOCK, &gf->f_flags))
321 goto skip_lock;
322 }
Steven Whitehousefd88de562006-05-05 16:59:11 -0400323 gfs2_holder_init(ip->i_gl, LM_ST_SHARED,
Steven Whitehouse2ca99502006-11-08 10:26:54 -0500324 LM_FLAG_TRY_1CB|GL_ATIME, &gh);
Steven Whitehouse59a1cc62006-08-04 15:41:22 -0400325 do_unlock = 1;
Steven Whitehousedcd24792006-11-16 11:08:16 -0500326 ret = gfs2_glock_nq_atime(&gh);
Steven Whitehouse907b9bc2006-09-25 09:26:04 -0400327 if (ret == GLR_TRYFAILED)
Steven Whitehousefd88de562006-05-05 16:59:11 -0400328 goto out_noerror;
329 if (unlikely(ret))
330 goto out_unlock;
331 }
Steven Whitehouse59a1cc62006-08-04 15:41:22 -0400332skip_lock:
Steven Whitehousee1d5b182006-12-15 16:49:51 -0500333 if (!gfs2_is_stuffed(ip))
Steven Whitehousefd88de562006-05-05 16:59:11 -0400334 ret = mpage_readpages(mapping, pages, nr_pages, gfs2_get_block);
Steven Whitehousefd88de562006-05-05 16:59:11 -0400335
Steven Whitehouse59a1cc62006-08-04 15:41:22 -0400336 if (do_unlock) {
Steven Whitehousefd88de562006-05-05 16:59:11 -0400337 gfs2_glock_dq_m(1, &gh);
338 gfs2_holder_uninit(&gh);
339 }
340out:
341 if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
342 ret = -EIO;
343 return ret;
344out_noerror:
345 ret = 0;
346out_unlock:
Steven Whitehouse59a1cc62006-08-04 15:41:22 -0400347 if (do_unlock)
Steven Whitehousefd88de562006-05-05 16:59:11 -0400348 gfs2_holder_uninit(&gh);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000349 goto out;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000350}
351
352/**
Steven Whitehouse7765ec22007-10-16 01:25:07 -0700353 * gfs2_write_begin - Begin to write to a file
David Teiglandb3b94fa2006-01-16 16:50:04 +0000354 * @file: The file to write to
Steven Whitehouse7765ec22007-10-16 01:25:07 -0700355 * @mapping: The mapping in which to write
356 * @pos: The file offset at which to start writing
357 * @len: Length of the write
358 * @flags: Various flags
359 * @pagep: Pointer to return the page
360 * @fsdata: Pointer to return fs data (unused by GFS2)
David Teiglandb3b94fa2006-01-16 16:50:04 +0000361 *
362 * Returns: errno
363 */
364
Steven Whitehouse7765ec22007-10-16 01:25:07 -0700365static int gfs2_write_begin(struct file *file, struct address_space *mapping,
366 loff_t pos, unsigned len, unsigned flags,
367 struct page **pagep, void **fsdata)
David Teiglandb3b94fa2006-01-16 16:50:04 +0000368{
Steven Whitehouse7765ec22007-10-16 01:25:07 -0700369 struct gfs2_inode *ip = GFS2_I(mapping->host);
370 struct gfs2_sbd *sdp = GFS2_SB(mapping->host);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000371 unsigned int data_blocks, ind_blocks, rblocks;
372 int alloc_required;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000373 int error = 0;
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000374 struct gfs2_alloc *al;
Steven Whitehouse7765ec22007-10-16 01:25:07 -0700375 pgoff_t index = pos >> PAGE_CACHE_SHIFT;
376 unsigned from = pos & (PAGE_CACHE_SIZE - 1);
377 unsigned to = from + len;
378 struct page *page;
Russell Cattelan52ae7b72006-10-09 12:11:54 -0500379
Steven Whitehouse7765ec22007-10-16 01:25:07 -0700380 gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_ATIME, &ip->i_gh);
Steven Whitehousedcd24792006-11-16 11:08:16 -0500381 error = gfs2_glock_nq_atime(&ip->i_gh);
Steven Whitehouse7765ec22007-10-16 01:25:07 -0700382 if (unlikely(error))
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000383 goto out_uninit;
384
Steven Whitehouse7765ec22007-10-16 01:25:07 -0700385 error = -ENOMEM;
386 page = __grab_cache_page(mapping, index);
387 *pagep = page;
388 if (!page)
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000389 goto out_unlock;
390
Steven Whitehouse7765ec22007-10-16 01:25:07 -0700391 gfs2_write_calc_reserv(ip, len, &data_blocks, &ind_blocks);
392
393 error = gfs2_write_alloc_required(ip, pos, len, &alloc_required);
394 if (error)
395 goto out_putpage;
396
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000397
Steven Whitehousef5c54802006-10-10 13:45:15 -0400398 ip->i_alloc.al_requested = 0;
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000399 if (alloc_required) {
400 al = gfs2_alloc_get(ip);
401
402 error = gfs2_quota_lock(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
403 if (error)
404 goto out_alloc_put;
405
Steven Whitehouse2933f922006-11-01 13:23:29 -0500406 error = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000407 if (error)
408 goto out_qunlock;
409
410 al->al_requested = data_blocks + ind_blocks;
411 error = gfs2_inplace_reserve(ip);
412 if (error)
413 goto out_qunlock;
414 }
415
416 rblocks = RES_DINODE + ind_blocks;
417 if (gfs2_is_jdata(ip))
418 rblocks += data_blocks ? data_blocks : 1;
419 if (ind_blocks || data_blocks)
420 rblocks += RES_STATFS + RES_QUOTA;
421
Steven Whitehouse16615be2007-09-17 10:59:52 +0100422 error = gfs2_trans_begin(sdp, rblocks,
423 PAGE_CACHE_SIZE/sdp->sd_sb.sb_bsize);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000424 if (error)
Steven Whitehousea867bb22007-07-17 10:29:02 +0100425 goto out_trans_fail;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000426
427 if (gfs2_is_stuffed(ip)) {
Steven Whitehouse7765ec22007-10-16 01:25:07 -0700428 if (pos + len > sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode)) {
Steven Whitehousef25ef0c2006-07-26 10:51:20 -0400429 error = gfs2_unstuff_dinode(ip, page);
Steven Whitehouse5c4e9e02006-02-15 12:26:19 +0000430 if (error == 0)
431 goto prepare_write;
432 } else if (!PageUptodate(page))
David Teiglandb3b94fa2006-01-16 16:50:04 +0000433 error = stuffed_readpage(ip, page);
Steven Whitehouse5c4e9e02006-02-15 12:26:19 +0000434 goto out;
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000435 }
436
Steven Whitehouse5c4e9e02006-02-15 12:26:19 +0000437prepare_write:
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000438 error = block_prepare_write(page, from, to, gfs2_get_block);
439
440out:
441 if (error) {
442 gfs2_trans_end(sdp);
Steven Whitehousea867bb22007-07-17 10:29:02 +0100443out_trans_fail:
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000444 if (alloc_required) {
445 gfs2_inplace_release(ip);
446out_qunlock:
447 gfs2_quota_unlock(ip);
448out_alloc_put:
449 gfs2_alloc_put(ip);
450 }
Steven Whitehouse7765ec22007-10-16 01:25:07 -0700451out_putpage:
452 page_cache_release(page);
453 if (pos + len > ip->i_inode.i_size)
454 vmtruncate(&ip->i_inode, ip->i_inode.i_size);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000455out_unlock:
456 gfs2_glock_dq_m(1, &ip->i_gh);
457out_uninit:
458 gfs2_holder_uninit(&ip->i_gh);
459 }
David Teiglandb3b94fa2006-01-16 16:50:04 +0000460
461 return error;
462}
463
464/**
Robert Peterson7ae8fa82007-05-09 09:37:57 -0500465 * adjust_fs_space - Adjusts the free space available due to gfs2_grow
466 * @inode: the rindex inode
467 */
468static void adjust_fs_space(struct inode *inode)
469{
470 struct gfs2_sbd *sdp = inode->i_sb->s_fs_info;
471 struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master;
472 struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local;
473 u64 fs_total, new_free;
474
475 /* Total up the file system space, according to the latest rindex. */
476 fs_total = gfs2_ri_total(sdp);
477
478 spin_lock(&sdp->sd_statfs_spin);
479 if (fs_total > (m_sc->sc_total + l_sc->sc_total))
480 new_free = fs_total - (m_sc->sc_total + l_sc->sc_total);
481 else
482 new_free = 0;
483 spin_unlock(&sdp->sd_statfs_spin);
Robert Peterson6c532672007-05-10 16:54:38 -0500484 fs_warn(sdp, "File system extended by %llu blocks.\n",
485 (unsigned long long)new_free);
Robert Peterson7ae8fa82007-05-09 09:37:57 -0500486 gfs2_statfs_change(sdp, new_free, new_free, 0);
487}
488
489/**
Steven Whitehouse7765ec22007-10-16 01:25:07 -0700490 * gfs2_stuffed_write_end - Write end for stuffed files
491 * @inode: The inode
492 * @dibh: The buffer_head containing the on-disk inode
493 * @pos: The file position
494 * @len: The length of the write
495 * @copied: How much was actually copied by the VFS
496 * @page: The page
497 *
498 * This copies the data from the page into the inode block after
499 * the inode data structure itself.
David Teiglandb3b94fa2006-01-16 16:50:04 +0000500 *
501 * Returns: errno
502 */
Steven Whitehouse7765ec22007-10-16 01:25:07 -0700503static int gfs2_stuffed_write_end(struct inode *inode, struct buffer_head *dibh,
504 loff_t pos, unsigned len, unsigned copied,
505 struct page *page)
David Teiglandb3b94fa2006-01-16 16:50:04 +0000506{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400507 struct gfs2_inode *ip = GFS2_I(inode);
508 struct gfs2_sbd *sdp = GFS2_SB(inode);
Steven Whitehouse7765ec22007-10-16 01:25:07 -0700509 u64 to = pos + copied;
510 void *kaddr;
511 unsigned char *buf = dibh->b_data + sizeof(struct gfs2_dinode);
512 struct gfs2_dinode *di = (struct gfs2_dinode *)dibh->b_data;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000513
Steven Whitehouse7765ec22007-10-16 01:25:07 -0700514 BUG_ON((pos + len) > (dibh->b_size - sizeof(struct gfs2_dinode)));
515 kaddr = kmap_atomic(page, KM_USER0);
516 memcpy(buf + pos, kaddr + pos, copied);
517 memset(kaddr + pos + copied, 0, len - copied);
518 flush_dcache_page(page);
519 kunmap_atomic(kaddr, KM_USER0);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000520
Steven Whitehouse7765ec22007-10-16 01:25:07 -0700521 if (!PageUptodate(page))
David Teiglandb3b94fa2006-01-16 16:50:04 +0000522 SetPageUptodate(page);
Steven Whitehouse7765ec22007-10-16 01:25:07 -0700523 unlock_page(page);
524 page_cache_release(page);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000525
Steven Whitehouse7765ec22007-10-16 01:25:07 -0700526 if (inode->i_size < to) {
527 i_size_write(inode, to);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000528 ip->i_di.di_size = inode->i_size;
Steven Whitehouse48516ce2006-10-02 12:39:19 -0400529 di->di_size = cpu_to_be64(inode->i_size);
Steven Whitehouse7765ec22007-10-16 01:25:07 -0700530 mark_inode_dirty(inode);
Steven Whitehouse48516ce2006-10-02 12:39:19 -0400531 }
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000532
Robert Peterson7ae8fa82007-05-09 09:37:57 -0500533 if (inode == sdp->sd_rindex)
534 adjust_fs_space(inode);
535
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000536 brelse(dibh);
537 gfs2_trans_end(sdp);
Steven Whitehouse7765ec22007-10-16 01:25:07 -0700538 gfs2_glock_dq(&ip->i_gh);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000539 gfs2_holder_uninit(&ip->i_gh);
Steven Whitehouse7765ec22007-10-16 01:25:07 -0700540 return copied;
541}
David Teiglandb3b94fa2006-01-16 16:50:04 +0000542
Steven Whitehouse7765ec22007-10-16 01:25:07 -0700543/**
544 * gfs2_write_end
545 * @file: The file to write to
546 * @mapping: The address space to write to
547 * @pos: The file position
548 * @len: The length of the data
549 * @copied:
550 * @page: The page that has been written
551 * @fsdata: The fsdata (unused in GFS2)
552 *
553 * The main write_end function for GFS2. We have a separate one for
554 * stuffed files as they are slightly different, otherwise we just
555 * put our locking around the VFS provided functions.
556 *
557 * Returns: errno
558 */
559
560static int gfs2_write_end(struct file *file, struct address_space *mapping,
561 loff_t pos, unsigned len, unsigned copied,
562 struct page *page, void *fsdata)
563{
564 struct inode *inode = page->mapping->host;
565 struct gfs2_inode *ip = GFS2_I(inode);
566 struct gfs2_sbd *sdp = GFS2_SB(inode);
567 struct buffer_head *dibh;
568 struct gfs2_alloc *al = &ip->i_alloc;
569 struct gfs2_dinode *di;
570 unsigned int from = pos & (PAGE_CACHE_SIZE - 1);
571 unsigned int to = from + len;
572 int ret;
573
574 BUG_ON(gfs2_glock_is_locked_by_me(ip->i_gl) == 0);
575
576 ret = gfs2_meta_inode_buffer(ip, &dibh);
577 if (unlikely(ret)) {
578 unlock_page(page);
579 page_cache_release(page);
580 goto failed;
581 }
582
583 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
584
585 if (gfs2_is_stuffed(ip))
586 return gfs2_stuffed_write_end(inode, dibh, pos, len, copied, page);
587
588 if (sdp->sd_args.ar_data == GFS2_DATA_ORDERED || gfs2_is_jdata(ip))
589 gfs2_page_add_databufs(ip, page, from, to);
590
591 ret = generic_write_end(file, mapping, pos, len, copied, page, fsdata);
592
593 if (likely(ret >= 0)) {
594 copied = ret;
595 if ((pos + copied) > inode->i_size) {
596 di = (struct gfs2_dinode *)dibh->b_data;
597 ip->i_di.di_size = inode->i_size;
598 di->di_size = cpu_to_be64(inode->i_size);
599 mark_inode_dirty(inode);
600 }
601 }
602
603 if (inode == sdp->sd_rindex)
604 adjust_fs_space(inode);
605
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000606 brelse(dibh);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000607 gfs2_trans_end(sdp);
Steven Whitehouse7765ec22007-10-16 01:25:07 -0700608failed:
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000609 if (al->al_requested) {
610 gfs2_inplace_release(ip);
611 gfs2_quota_unlock(ip);
612 gfs2_alloc_put(ip);
613 }
Steven Whitehouse7765ec22007-10-16 01:25:07 -0700614 gfs2_glock_dq(&ip->i_gh);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +0000615 gfs2_holder_uninit(&ip->i_gh);
Steven Whitehouse7765ec22007-10-16 01:25:07 -0700616 return ret;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000617}
618
619/**
Robert Peterson8fb68592007-06-12 11:24:36 -0500620 * gfs2_set_page_dirty - Page dirtying function
621 * @page: The page to dirty
622 *
623 * Returns: 1 if it dirtyed the page, or 0 otherwise
624 */
625
626static int gfs2_set_page_dirty(struct page *page)
627{
628 struct gfs2_inode *ip = GFS2_I(page->mapping->host);
629 struct gfs2_sbd *sdp = GFS2_SB(page->mapping->host);
630
631 if (sdp->sd_args.ar_data == GFS2_DATA_ORDERED || gfs2_is_jdata(ip))
632 SetPageChecked(page);
633 return __set_page_dirty_buffers(page);
634}
635
636/**
David Teiglandb3b94fa2006-01-16 16:50:04 +0000637 * gfs2_bmap - Block map function
638 * @mapping: Address space info
639 * @lblock: The block to map
640 *
641 * Returns: The disk address for the block or 0 on hole or error
642 */
643
644static sector_t gfs2_bmap(struct address_space *mapping, sector_t lblock)
645{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400646 struct gfs2_inode *ip = GFS2_I(mapping->host);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000647 struct gfs2_holder i_gh;
648 sector_t dblock = 0;
649 int error;
650
David Teiglandb3b94fa2006-01-16 16:50:04 +0000651 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh);
652 if (error)
653 return 0;
654
655 if (!gfs2_is_stuffed(ip))
Steven Whitehouse4ff14672006-01-30 09:39:10 +0000656 dblock = generic_block_bmap(mapping, lblock, gfs2_get_block);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000657
658 gfs2_glock_dq_uninit(&i_gh);
659
660 return dblock;
661}
662
Steven Whitehoused7b616e2007-09-02 10:48:13 +0100663static void gfs2_discard(struct gfs2_sbd *sdp, struct buffer_head *bh)
664{
665 struct gfs2_bufdata *bd;
666
667 lock_buffer(bh);
668 gfs2_log_lock(sdp);
669 clear_buffer_dirty(bh);
670 bd = bh->b_private;
671 if (bd) {
Steven Whitehouse16615be2007-09-17 10:59:52 +0100672 if (!list_empty(&bd->bd_le.le_list) && !buffer_pinned(bh))
673 list_del_init(&bd->bd_le.le_list);
674 else
675 gfs2_remove_from_journal(bh, current->journal_info, 0);
Steven Whitehoused7b616e2007-09-02 10:48:13 +0100676 }
677 bh->b_bdev = NULL;
678 clear_buffer_mapped(bh);
679 clear_buffer_req(bh);
680 clear_buffer_new(bh);
681 gfs2_log_unlock(sdp);
682 unlock_buffer(bh);
683}
684
Steven Whitehouse8628de02006-03-31 16:48:41 -0500685static void gfs2_invalidatepage(struct page *page, unsigned long offset)
David Teiglandb3b94fa2006-01-16 16:50:04 +0000686{
Steven Whitehoused7b616e2007-09-02 10:48:13 +0100687 struct gfs2_sbd *sdp = GFS2_SB(page->mapping->host);
688 struct buffer_head *bh, *head;
689 unsigned long pos = 0;
690
David Teiglandb3b94fa2006-01-16 16:50:04 +0000691 BUG_ON(!PageLocked(page));
Robert Peterson8fb68592007-06-12 11:24:36 -0500692 if (offset == 0)
693 ClearPageChecked(page);
Steven Whitehoused7b616e2007-09-02 10:48:13 +0100694 if (!page_has_buffers(page))
695 goto out;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000696
Steven Whitehoused7b616e2007-09-02 10:48:13 +0100697 bh = head = page_buffers(page);
698 do {
699 if (offset <= pos)
700 gfs2_discard(sdp, bh);
701 pos += bh->b_size;
702 bh = bh->b_this_page;
703 } while (bh != head);
704out:
705 if (offset == 0)
706 try_to_release_page(page, 0);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000707}
708
Steven Whitehousec7b33832006-12-14 18:24:26 +0000709/**
710 * gfs2_ok_for_dio - check that dio is valid on this file
711 * @ip: The inode
712 * @rw: READ or WRITE
713 * @offset: The offset at which we are reading or writing
714 *
715 * Returns: 0 (to ignore the i/o request and thus fall back to buffered i/o)
716 * 1 (to accept the i/o request)
717 */
718static int gfs2_ok_for_dio(struct gfs2_inode *ip, int rw, loff_t offset)
719{
720 /*
721 * Should we return an error here? I can't see that O_DIRECT for
722 * a journaled file makes any sense. For now we'll silently fall
723 * back to buffered I/O, likewise we do the same for stuffed
724 * files since they are (a) small and (b) unaligned.
725 */
726 if (gfs2_is_jdata(ip))
727 return 0;
728
729 if (gfs2_is_stuffed(ip))
730 return 0;
731
732 if (offset > i_size_read(&ip->i_inode))
733 return 0;
734 return 1;
735}
736
737
738
Steven Whitehousea9e5f4d2006-07-25 17:24:12 -0400739static ssize_t gfs2_direct_IO(int rw, struct kiocb *iocb,
740 const struct iovec *iov, loff_t offset,
741 unsigned long nr_segs)
Steven Whitehoused1665e42006-02-14 11:54:42 +0000742{
743 struct file *file = iocb->ki_filp;
744 struct inode *inode = file->f_mapping->host;
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400745 struct gfs2_inode *ip = GFS2_I(inode);
Steven Whitehoused1665e42006-02-14 11:54:42 +0000746 struct gfs2_holder gh;
747 int rv;
748
749 /*
Steven Whitehousec7b33832006-12-14 18:24:26 +0000750 * Deferred lock, even if its a write, since we do no allocation
751 * on this path. All we need change is atime, and this lock mode
752 * ensures that other nodes have flushed their buffered read caches
753 * (i.e. their page cache entries for this inode). We do not,
754 * unfortunately have the option of only flushing a range like
755 * the VFS does.
Steven Whitehoused1665e42006-02-14 11:54:42 +0000756 */
Steven Whitehousec7b33832006-12-14 18:24:26 +0000757 gfs2_holder_init(ip->i_gl, LM_ST_DEFERRED, GL_ATIME, &gh);
Steven Whitehousedcd24792006-11-16 11:08:16 -0500758 rv = gfs2_glock_nq_atime(&gh);
Steven Whitehoused1665e42006-02-14 11:54:42 +0000759 if (rv)
Steven Whitehousec7b33832006-12-14 18:24:26 +0000760 return rv;
761 rv = gfs2_ok_for_dio(ip, rw, offset);
762 if (rv != 1)
763 goto out; /* dio not valid, fall back to buffered i/o */
Steven Whitehoused1665e42006-02-14 11:54:42 +0000764
Steven Whitehousec7b33832006-12-14 18:24:26 +0000765 rv = blockdev_direct_IO_no_locking(rw, iocb, inode, inode->i_sb->s_bdev,
766 iov, offset, nr_segs,
767 gfs2_get_block_direct, NULL);
Steven Whitehoused1665e42006-02-14 11:54:42 +0000768out:
769 gfs2_glock_dq_m(1, &gh);
770 gfs2_holder_uninit(&gh);
Steven Whitehoused1665e42006-02-14 11:54:42 +0000771 return rv;
772}
773
774/**
Steven Whitehouse623d9352006-08-31 12:14:44 -0400775 * gfs2_releasepage - free the metadata associated with a page
Steven Whitehouse4340fe62006-07-11 09:46:33 -0400776 * @page: the page that's being released
777 * @gfp_mask: passed from Linux VFS, ignored by us
778 *
779 * Call try_to_free_buffers() if the buffers in this page can be
780 * released.
781 *
782 * Returns: 0
783 */
784
785int gfs2_releasepage(struct page *page, gfp_t gfp_mask)
786{
787 struct inode *aspace = page->mapping->host;
788 struct gfs2_sbd *sdp = aspace->i_sb->s_fs_info;
789 struct buffer_head *bh, *head;
790 struct gfs2_bufdata *bd;
Steven Whitehouse4340fe62006-07-11 09:46:33 -0400791
792 if (!page_has_buffers(page))
Steven Whitehouse891ba6d2007-09-20 15:26:33 +0100793 return 0;
Steven Whitehouse4340fe62006-07-11 09:46:33 -0400794
Steven Whitehousebb3b0e32007-08-16 16:03:57 +0100795 gfs2_log_lock(sdp);
Steven Whitehouse4340fe62006-07-11 09:46:33 -0400796 head = bh = page_buffers(page);
797 do {
Steven Whitehousebb3b0e32007-08-16 16:03:57 +0100798 if (atomic_read(&bh->b_count))
799 goto cannot_release;
800 bd = bh->b_private;
801 if (bd && bd->bd_ail)
802 goto cannot_release;
Steven Whitehouse4340fe62006-07-11 09:46:33 -0400803 gfs2_assert_warn(sdp, !buffer_pinned(bh));
Steven Whitehouse623d9352006-08-31 12:14:44 -0400804 gfs2_assert_warn(sdp, !buffer_dirty(bh));
Steven Whitehousebb3b0e32007-08-16 16:03:57 +0100805 bh = bh->b_this_page;
806 } while(bh != head);
807 gfs2_log_unlock(sdp);
Steven Whitehouse4340fe62006-07-11 09:46:33 -0400808
Steven Whitehousebb3b0e32007-08-16 16:03:57 +0100809 head = bh = page_buffers(page);
810 do {
Steven Whitehouse623d9352006-08-31 12:14:44 -0400811 gfs2_log_lock(sdp);
Steven Whitehouse4340fe62006-07-11 09:46:33 -0400812 bd = bh->b_private;
813 if (bd) {
814 gfs2_assert_warn(sdp, bd->bd_bh == bh);
815 gfs2_assert_warn(sdp, list_empty(&bd->bd_list_tr));
Steven Whitehoused7b616e2007-09-02 10:48:13 +0100816 if (!list_empty(&bd->bd_le.le_list)) {
817 if (!buffer_pinned(bh))
818 list_del_init(&bd->bd_le.le_list);
819 else
820 bd = NULL;
821 }
822 if (bd)
823 bd->bd_bh = NULL;
Steven Whitehouse4340fe62006-07-11 09:46:33 -0400824 bh->b_private = NULL;
825 }
Steven Whitehouse623d9352006-08-31 12:14:44 -0400826 gfs2_log_unlock(sdp);
827 if (bd)
828 kmem_cache_free(gfs2_bufdata_cachep, bd);
Steven Whitehouse4340fe62006-07-11 09:46:33 -0400829
830 bh = bh->b_this_page;
Steven Whitehouse166afcc2006-08-24 15:59:40 -0400831 } while (bh != head);
Steven Whitehouse4340fe62006-07-11 09:46:33 -0400832
Steven Whitehouse4340fe62006-07-11 09:46:33 -0400833 return try_to_free_buffers(page);
Steven Whitehousebb3b0e32007-08-16 16:03:57 +0100834cannot_release:
835 gfs2_log_unlock(sdp);
836 return 0;
Steven Whitehouse4340fe62006-07-11 09:46:33 -0400837}
838
Steven Whitehouse66de0452006-07-03 13:37:30 -0400839const struct address_space_operations gfs2_file_aops = {
David Teiglandb3b94fa2006-01-16 16:50:04 +0000840 .writepage = gfs2_writepage,
Steven Whitehousea8d638e2007-01-15 13:52:17 +0000841 .writepages = gfs2_writepages,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000842 .readpage = gfs2_readpage,
Steven Whitehousefd88de562006-05-05 16:59:11 -0400843 .readpages = gfs2_readpages,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000844 .sync_page = block_sync_page,
Steven Whitehouse7765ec22007-10-16 01:25:07 -0700845 .write_begin = gfs2_write_begin,
846 .write_end = gfs2_write_end,
Robert Peterson8fb68592007-06-12 11:24:36 -0500847 .set_page_dirty = gfs2_set_page_dirty,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000848 .bmap = gfs2_bmap,
849 .invalidatepage = gfs2_invalidatepage,
Steven Whitehouse4340fe62006-07-11 09:46:33 -0400850 .releasepage = gfs2_releasepage,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000851 .direct_IO = gfs2_direct_IO,
852};
853