blob: fb5e5c2627e56d329b1157fcb996178855af7e48 [file] [log] [blame]
Jaegeuk Kim0a8165d2012-11-29 13:28:09 +09001/*
Jaegeuk Kimeb47b802012-11-02 17:10:12 +09002 * fs/f2fs/data.c
3 *
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com/
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#include <linux/fs.h>
12#include <linux/f2fs_fs.h>
13#include <linux/buffer_head.h>
14#include <linux/mpage.h>
Kent Overstreeta27bb332013-05-07 16:19:08 -070015#include <linux/aio.h>
Jaegeuk Kimeb47b802012-11-02 17:10:12 +090016#include <linux/writeback.h>
17#include <linux/backing-dev.h>
18#include <linux/blkdev.h>
19#include <linux/bio.h>
Geert Uytterhoeven690e4a32012-12-19 22:19:30 +010020#include <linux/prefetch.h>
Jaegeuk Kimeb47b802012-11-02 17:10:12 +090021
22#include "f2fs.h"
23#include "node.h"
24#include "segment.h"
Namjae Jeon848753a2013-04-23 16:38:02 +090025#include <trace/events/f2fs.h>
Jaegeuk Kimeb47b802012-11-02 17:10:12 +090026
Jaegeuk Kim0a8165d2012-11-29 13:28:09 +090027/*
Jaegeuk Kim93dfe2a2013-11-30 12:51:14 +090028 * Low-level block read/write IO operations.
29 */
30static struct bio *__bio_alloc(struct block_device *bdev, int npages)
31{
32 struct bio *bio;
33
34 /* No failure on bio allocation */
35 bio = bio_alloc(GFP_NOIO, npages);
36 bio->bi_bdev = bdev;
37 bio->bi_private = NULL;
38 return bio;
39}
40
41static void f2fs_read_end_io(struct bio *bio, int err)
42{
43 const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
44 struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1;
45
46 do {
47 struct page *page = bvec->bv_page;
48
49 if (--bvec >= bio->bi_io_vec)
50 prefetchw(&bvec->bv_page->flags);
51
Jaegeuk Kim6bacf522013-12-06 15:00:58 +090052 if (unlikely(!uptodate)) {
Jaegeuk Kim93dfe2a2013-11-30 12:51:14 +090053 ClearPageUptodate(page);
54 SetPageError(page);
Jaegeuk Kim6bacf522013-12-06 15:00:58 +090055 } else {
56 SetPageUptodate(page);
Jaegeuk Kim93dfe2a2013-11-30 12:51:14 +090057 }
58 unlock_page(page);
59 } while (bvec >= bio->bi_io_vec);
60
61 bio_put(bio);
62}
63
64static void f2fs_write_end_io(struct bio *bio, int err)
65{
66 const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
67 struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1;
68 struct f2fs_sb_info *sbi = F2FS_SB(bvec->bv_page->mapping->host->i_sb);
69
70 do {
71 struct page *page = bvec->bv_page;
72
73 if (--bvec >= bio->bi_io_vec)
74 prefetchw(&bvec->bv_page->flags);
75
Jaegeuk Kim6bacf522013-12-06 15:00:58 +090076 if (unlikely(!uptodate)) {
Jaegeuk Kim93dfe2a2013-11-30 12:51:14 +090077 SetPageError(page);
78 set_bit(AS_EIO, &page->mapping->flags);
79 set_ckpt_flags(sbi->ckpt, CP_ERROR_FLAG);
80 sbi->sb->s_flags |= MS_RDONLY;
81 }
82 end_page_writeback(page);
83 dec_page_count(sbi, F2FS_WRITEBACK);
84 } while (bvec >= bio->bi_io_vec);
85
86 if (bio->bi_private)
87 complete(bio->bi_private);
88
89 if (!get_pages(sbi, F2FS_WRITEBACK) &&
90 !list_empty(&sbi->cp_wait.task_list))
91 wake_up(&sbi->cp_wait);
92
93 bio_put(bio);
94}
95
96static void __submit_merged_bio(struct f2fs_sb_info *sbi,
97 struct f2fs_bio_info *io,
98 enum page_type type, bool sync, int rw)
99{
100 enum page_type btype = PAGE_TYPE_OF_BIO(type);
101
102 if (!io->bio)
103 return;
104
105 if (btype == META)
106 rw |= REQ_META;
107
108 if (is_read_io(rw)) {
109 if (sync)
110 rw |= READ_SYNC;
111 submit_bio(rw, io->bio);
112 trace_f2fs_submit_read_bio(sbi->sb, rw, type, io->bio);
113 io->bio = NULL;
114 return;
115 }
116
117 if (sync)
118 rw |= WRITE_SYNC;
119 if (type >= META_FLUSH)
120 rw |= WRITE_FLUSH_FUA;
121
122 /*
123 * META_FLUSH is only from the checkpoint procedure, and we should wait
124 * this metadata bio for FS consistency.
125 */
126 if (type == META_FLUSH) {
127 DECLARE_COMPLETION_ONSTACK(wait);
128 io->bio->bi_private = &wait;
129 submit_bio(rw, io->bio);
130 wait_for_completion(&wait);
131 } else {
132 submit_bio(rw, io->bio);
133 }
134 trace_f2fs_submit_write_bio(sbi->sb, rw, btype, io->bio);
135 io->bio = NULL;
136}
137
138void f2fs_submit_merged_bio(struct f2fs_sb_info *sbi,
139 enum page_type type, bool sync, int rw)
140{
141 enum page_type btype = PAGE_TYPE_OF_BIO(type);
142 struct f2fs_bio_info *io;
143
144 io = is_read_io(rw) ? &sbi->read_io : &sbi->write_io[btype];
145
146 mutex_lock(&io->io_mutex);
147 __submit_merged_bio(sbi, io, type, sync, rw);
148 mutex_unlock(&io->io_mutex);
149}
150
151/*
152 * Fill the locked page with data located in the block address.
153 * Return unlocked page.
154 */
155int f2fs_submit_page_bio(struct f2fs_sb_info *sbi, struct page *page,
156 block_t blk_addr, int rw)
157{
158 struct block_device *bdev = sbi->sb->s_bdev;
159 struct bio *bio;
160
161 trace_f2fs_submit_page_bio(page, blk_addr, rw);
162
163 /* Allocate a new bio */
164 bio = __bio_alloc(bdev, 1);
165
166 /* Initialize the bio */
167 bio->bi_sector = SECTOR_FROM_BLOCK(sbi, blk_addr);
168 bio->bi_end_io = is_read_io(rw) ? f2fs_read_end_io : f2fs_write_end_io;
169
170 if (bio_add_page(bio, page, PAGE_CACHE_SIZE, 0) < PAGE_CACHE_SIZE) {
171 bio_put(bio);
172 f2fs_put_page(page, 1);
173 return -EFAULT;
174 }
175
176 submit_bio(rw, bio);
177 return 0;
178}
179
180void f2fs_submit_page_mbio(struct f2fs_sb_info *sbi, struct page *page,
181 block_t blk_addr, enum page_type type, int rw)
182{
183 enum page_type btype = PAGE_TYPE_OF_BIO(type);
184 struct block_device *bdev = sbi->sb->s_bdev;
185 struct f2fs_bio_info *io;
186 int bio_blocks;
187
188 io = is_read_io(rw) ? &sbi->read_io : &sbi->write_io[btype];
189
190 verify_block_addr(sbi, blk_addr);
191
192 mutex_lock(&io->io_mutex);
193
194 if (!is_read_io(rw))
195 inc_page_count(sbi, F2FS_WRITEBACK);
196
Fan Li63a0b7cb2013-12-09 16:09:00 +0800197 if (io->bio && (io->last_block_in_bio != blk_addr - 1 ||
198 io->rw_flag != rw))
199 __submit_merged_bio(sbi, io, type, false, io->rw_flag);
Jaegeuk Kim93dfe2a2013-11-30 12:51:14 +0900200alloc_new:
201 if (io->bio == NULL) {
202 bio_blocks = MAX_BIO_BLOCKS(max_hw_blocks(sbi));
203 io->bio = __bio_alloc(bdev, bio_blocks);
204 io->bio->bi_sector = SECTOR_FROM_BLOCK(sbi, blk_addr);
205 io->bio->bi_end_io = is_read_io(rw) ? f2fs_read_end_io :
206 f2fs_write_end_io;
Fan Li63a0b7cb2013-12-09 16:09:00 +0800207 io->rw_flag = rw;
Jaegeuk Kim93dfe2a2013-11-30 12:51:14 +0900208 /*
209 * The end_io will be assigned at the sumbission phase.
210 * Until then, let bio_add_page() merge consecutive IOs as much
211 * as possible.
212 */
213 }
214
215 if (bio_add_page(io->bio, page, PAGE_CACHE_SIZE, 0) <
216 PAGE_CACHE_SIZE) {
Fan Li63a0b7cb2013-12-09 16:09:00 +0800217 __submit_merged_bio(sbi, io, type, false, rw);
Jaegeuk Kim93dfe2a2013-11-30 12:51:14 +0900218 goto alloc_new;
219 }
220
221 io->last_block_in_bio = blk_addr;
222
223 mutex_unlock(&io->io_mutex);
224 trace_f2fs_submit_page_mbio(page, rw, type, blk_addr);
225}
226
227/*
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900228 * Lock ordering for the change of data block address:
229 * ->data_page
230 * ->node_page
231 * update block addresses in the node page
232 */
233static void __set_data_blkaddr(struct dnode_of_data *dn, block_t new_addr)
234{
235 struct f2fs_node *rn;
236 __le32 *addr_array;
237 struct page *node_page = dn->node_page;
238 unsigned int ofs_in_node = dn->ofs_in_node;
239
Jin Xua5694692013-08-05 20:02:04 +0800240 f2fs_wait_on_page_writeback(node_page, NODE, false);
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900241
Gu Zheng45590712013-07-15 17:57:38 +0800242 rn = F2FS_NODE(node_page);
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900243
244 /* Get physical address of data block */
245 addr_array = blkaddr_in_node(rn);
246 addr_array[ofs_in_node] = cpu_to_le32(new_addr);
247 set_page_dirty(node_page);
248}
249
250int reserve_new_block(struct dnode_of_data *dn)
251{
252 struct f2fs_sb_info *sbi = F2FS_SB(dn->inode->i_sb);
253
Jaegeuk Kim6bacf522013-12-06 15:00:58 +0900254 if (unlikely(is_inode_flag_set(F2FS_I(dn->inode), FI_NO_ALLOC)))
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900255 return -EPERM;
Chao Yucfb271d2013-12-05 17:15:22 +0800256 if (unlikely(!inc_valid_block_count(sbi, dn->inode, 1)))
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900257 return -ENOSPC;
258
Namjae Jeonc01e2852013-04-23 17:00:52 +0900259 trace_f2fs_reserve_new_block(dn->inode, dn->nid, dn->ofs_in_node);
260
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900261 __set_data_blkaddr(dn, NEW_ADDR);
262 dn->data_blkaddr = NEW_ADDR;
263 sync_inode_page(dn);
264 return 0;
265}
266
Huajun Lib6009652013-11-10 23:13:18 +0800267int f2fs_reserve_block(struct dnode_of_data *dn, pgoff_t index)
268{
269 bool need_put = dn->inode_page ? false : true;
270 int err;
271
272 err = get_dnode_of_data(dn, index, ALLOC_NODE);
273 if (err)
274 return err;
275 if (dn->data_blkaddr == NULL_ADDR)
276 err = reserve_new_block(dn);
277
278 if (need_put)
279 f2fs_put_dnode(dn);
280 return err;
281}
282
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900283static int check_extent_cache(struct inode *inode, pgoff_t pgofs,
284 struct buffer_head *bh_result)
285{
286 struct f2fs_inode_info *fi = F2FS_I(inode);
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900287 pgoff_t start_fofs, end_fofs;
288 block_t start_blkaddr;
289
Jaegeuk Kimc11abd12013-11-19 10:41:54 +0900290 if (is_inode_flag_set(fi, FI_NO_EXTENT))
291 return 0;
292
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900293 read_lock(&fi->ext.ext_lock);
294 if (fi->ext.len == 0) {
295 read_unlock(&fi->ext.ext_lock);
296 return 0;
297 }
298
Jaegeuk Kimdcdfff62013-10-22 20:56:10 +0900299 stat_inc_total_hit(inode->i_sb);
300
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900301 start_fofs = fi->ext.fofs;
302 end_fofs = fi->ext.fofs + fi->ext.len - 1;
303 start_blkaddr = fi->ext.blk_addr;
304
305 if (pgofs >= start_fofs && pgofs <= end_fofs) {
306 unsigned int blkbits = inode->i_sb->s_blocksize_bits;
307 size_t count;
308
309 clear_buffer_new(bh_result);
310 map_bh(bh_result, inode->i_sb,
311 start_blkaddr + pgofs - start_fofs);
312 count = end_fofs - pgofs + 1;
313 if (count < (UINT_MAX >> blkbits))
314 bh_result->b_size = (count << blkbits);
315 else
316 bh_result->b_size = UINT_MAX;
317
Jaegeuk Kimdcdfff62013-10-22 20:56:10 +0900318 stat_inc_read_hit(inode->i_sb);
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900319 read_unlock(&fi->ext.ext_lock);
320 return 1;
321 }
322 read_unlock(&fi->ext.ext_lock);
323 return 0;
324}
325
326void update_extent_cache(block_t blk_addr, struct dnode_of_data *dn)
327{
328 struct f2fs_inode_info *fi = F2FS_I(dn->inode);
329 pgoff_t fofs, start_fofs, end_fofs;
330 block_t start_blkaddr, end_blkaddr;
Jaegeuk Kimc11abd12013-11-19 10:41:54 +0900331 int need_update = true;
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900332
Jaegeuk Kim5d56b672013-10-29 15:14:54 +0900333 f2fs_bug_on(blk_addr == NEW_ADDR);
Jaegeuk Kimde936532013-08-12 21:08:03 +0900334 fofs = start_bidx_of_node(ofs_of_node(dn->node_page), fi) +
335 dn->ofs_in_node;
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900336
337 /* Update the page address in the parent node */
338 __set_data_blkaddr(dn, blk_addr);
339
Jaegeuk Kimc11abd12013-11-19 10:41:54 +0900340 if (is_inode_flag_set(fi, FI_NO_EXTENT))
341 return;
342
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900343 write_lock(&fi->ext.ext_lock);
344
345 start_fofs = fi->ext.fofs;
346 end_fofs = fi->ext.fofs + fi->ext.len - 1;
347 start_blkaddr = fi->ext.blk_addr;
348 end_blkaddr = fi->ext.blk_addr + fi->ext.len - 1;
349
350 /* Drop and initialize the matched extent */
351 if (fi->ext.len == 1 && fofs == start_fofs)
352 fi->ext.len = 0;
353
354 /* Initial extent */
355 if (fi->ext.len == 0) {
356 if (blk_addr != NULL_ADDR) {
357 fi->ext.fofs = fofs;
358 fi->ext.blk_addr = blk_addr;
359 fi->ext.len = 1;
360 }
361 goto end_update;
362 }
363
Namjae Jeon6224da82013-04-06 14:44:32 +0900364 /* Front merge */
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900365 if (fofs == start_fofs - 1 && blk_addr == start_blkaddr - 1) {
366 fi->ext.fofs--;
367 fi->ext.blk_addr--;
368 fi->ext.len++;
369 goto end_update;
370 }
371
372 /* Back merge */
373 if (fofs == end_fofs + 1 && blk_addr == end_blkaddr + 1) {
374 fi->ext.len++;
375 goto end_update;
376 }
377
378 /* Split the existing extent */
379 if (fi->ext.len > 1 &&
380 fofs >= start_fofs && fofs <= end_fofs) {
381 if ((end_fofs - fofs) < (fi->ext.len >> 1)) {
382 fi->ext.len = fofs - start_fofs;
383 } else {
384 fi->ext.fofs = fofs + 1;
385 fi->ext.blk_addr = start_blkaddr +
386 fofs - start_fofs + 1;
387 fi->ext.len -= fofs - start_fofs + 1;
388 }
Jaegeuk Kimc11abd12013-11-19 10:41:54 +0900389 } else {
390 need_update = false;
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900391 }
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900392
Jaegeuk Kimc11abd12013-11-19 10:41:54 +0900393 /* Finally, if the extent is very fragmented, let's drop the cache. */
394 if (fi->ext.len < F2FS_MIN_EXTENT_LEN) {
395 fi->ext.len = 0;
396 set_inode_flag(fi, FI_NO_EXTENT);
397 need_update = true;
398 }
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900399end_update:
400 write_unlock(&fi->ext.ext_lock);
Jaegeuk Kimc11abd12013-11-19 10:41:54 +0900401 if (need_update)
402 sync_inode_page(dn);
403 return;
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900404}
405
Jaegeuk Kimc718379b2013-04-24 13:19:56 +0900406struct page *find_data_page(struct inode *inode, pgoff_t index, bool sync)
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900407{
408 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
409 struct address_space *mapping = inode->i_mapping;
410 struct dnode_of_data dn;
411 struct page *page;
412 int err;
413
414 page = find_get_page(mapping, index);
415 if (page && PageUptodate(page))
416 return page;
417 f2fs_put_page(page, 0);
418
419 set_new_dnode(&dn, inode, NULL, NULL, 0);
Jaegeuk Kim266e97a2013-02-26 13:10:46 +0900420 err = get_dnode_of_data(&dn, index, LOOKUP_NODE);
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900421 if (err)
422 return ERR_PTR(err);
423 f2fs_put_dnode(&dn);
424
425 if (dn.data_blkaddr == NULL_ADDR)
426 return ERR_PTR(-ENOENT);
427
428 /* By fallocate(), there is no cached page, but with NEW_ADDR */
Jaegeuk Kim6bacf522013-12-06 15:00:58 +0900429 if (unlikely(dn.data_blkaddr == NEW_ADDR))
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900430 return ERR_PTR(-EINVAL);
431
Jaegeuk Kim6f85b352013-05-20 16:15:22 +0900432 page = grab_cache_page_write_begin(mapping, index, AOP_FLAG_NOFS);
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900433 if (!page)
434 return ERR_PTR(-ENOMEM);
435
Jaegeuk Kim393ff912013-03-08 21:29:23 +0900436 if (PageUptodate(page)) {
437 unlock_page(page);
438 return page;
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900439 }
Jaegeuk Kim393ff912013-03-08 21:29:23 +0900440
Jaegeuk Kim93dfe2a2013-11-30 12:51:14 +0900441 err = f2fs_submit_page_bio(sbi, page, dn.data_blkaddr,
Jaegeuk Kimc718379b2013-04-24 13:19:56 +0900442 sync ? READ_SYNC : READA);
Chao Yu1069bbf2013-11-28 15:43:43 +0800443 if (err)
444 return ERR_PTR(err);
445
Jaegeuk Kimc718379b2013-04-24 13:19:56 +0900446 if (sync) {
447 wait_on_page_locked(page);
Jaegeuk Kim6bacf522013-12-06 15:00:58 +0900448 if (unlikely(!PageUptodate(page))) {
Jaegeuk Kimc718379b2013-04-24 13:19:56 +0900449 f2fs_put_page(page, 0);
450 return ERR_PTR(-EIO);
451 }
Jaegeuk Kim393ff912013-03-08 21:29:23 +0900452 }
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900453 return page;
454}
455
Jaegeuk Kim0a8165d2012-11-29 13:28:09 +0900456/*
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900457 * If it tries to access a hole, return an error.
458 * Because, the callers, functions in dir.c and GC, should be able to know
459 * whether this page exists or not.
460 */
461struct page *get_lock_data_page(struct inode *inode, pgoff_t index)
462{
463 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
464 struct address_space *mapping = inode->i_mapping;
465 struct dnode_of_data dn;
466 struct page *page;
467 int err;
468
Jaegeuk Kimafcb7ca02013-04-26 11:55:17 +0900469repeat:
Jaegeuk Kim6f85b352013-05-20 16:15:22 +0900470 page = grab_cache_page_write_begin(mapping, index, AOP_FLAG_NOFS);
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900471 if (!page)
472 return ERR_PTR(-ENOMEM);
473
Jaegeuk Kim650495d2013-05-13 08:38:35 +0900474 set_new_dnode(&dn, inode, NULL, NULL, 0);
475 err = get_dnode_of_data(&dn, index, LOOKUP_NODE);
476 if (err) {
477 f2fs_put_page(page, 1);
478 return ERR_PTR(err);
479 }
480 f2fs_put_dnode(&dn);
481
Jaegeuk Kim6bacf522013-12-06 15:00:58 +0900482 if (unlikely(dn.data_blkaddr == NULL_ADDR)) {
Jaegeuk Kim650495d2013-05-13 08:38:35 +0900483 f2fs_put_page(page, 1);
484 return ERR_PTR(-ENOENT);
485 }
486
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900487 if (PageUptodate(page))
488 return page;
489
Jaegeuk Kimd59ff4d2013-08-20 19:13:07 +0900490 /*
491 * A new dentry page is allocated but not able to be written, since its
492 * new inode page couldn't be allocated due to -ENOSPC.
493 * In such the case, its blkaddr can be remained as NEW_ADDR.
494 * see, f2fs_add_link -> get_new_data_page -> init_inode_metadata.
495 */
496 if (dn.data_blkaddr == NEW_ADDR) {
497 zero_user_segment(page, 0, PAGE_CACHE_SIZE);
498 SetPageUptodate(page);
499 return page;
500 }
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900501
Jaegeuk Kim93dfe2a2013-11-30 12:51:14 +0900502 err = f2fs_submit_page_bio(sbi, page, dn.data_blkaddr, READ_SYNC);
Jaegeuk Kim393ff912013-03-08 21:29:23 +0900503 if (err)
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900504 return ERR_PTR(err);
Jaegeuk Kim393ff912013-03-08 21:29:23 +0900505
506 lock_page(page);
Jaegeuk Kim6bacf522013-12-06 15:00:58 +0900507 if (unlikely(!PageUptodate(page))) {
Jaegeuk Kim393ff912013-03-08 21:29:23 +0900508 f2fs_put_page(page, 1);
509 return ERR_PTR(-EIO);
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900510 }
Jaegeuk Kim6bacf522013-12-06 15:00:58 +0900511 if (unlikely(page->mapping != mapping)) {
Jaegeuk Kimafcb7ca02013-04-26 11:55:17 +0900512 f2fs_put_page(page, 1);
513 goto repeat;
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900514 }
515 return page;
516}
517
Jaegeuk Kim0a8165d2012-11-29 13:28:09 +0900518/*
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900519 * Caller ensures that this data page is never allocated.
520 * A new zero-filled data page is allocated in the page cache.
Jaegeuk Kim39936832012-11-22 16:21:29 +0900521 *
522 * Also, caller should grab and release a mutex by calling mutex_lock_op() and
523 * mutex_unlock_op().
Jaegeuk Kim44a83ff2013-05-20 10:10:29 +0900524 * Note that, npage is set only by make_empty_dir.
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900525 */
Jaegeuk Kim64aa7ed2013-05-20 09:55:50 +0900526struct page *get_new_data_page(struct inode *inode,
527 struct page *npage, pgoff_t index, bool new_i_size)
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900528{
529 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
530 struct address_space *mapping = inode->i_mapping;
531 struct page *page;
532 struct dnode_of_data dn;
533 int err;
534
Jaegeuk Kim64aa7ed2013-05-20 09:55:50 +0900535 set_new_dnode(&dn, inode, npage, npage, 0);
Huajun Lib6009652013-11-10 23:13:18 +0800536 err = f2fs_reserve_block(&dn, index);
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900537 if (err)
538 return ERR_PTR(err);
Jaegeuk Kimafcb7ca02013-04-26 11:55:17 +0900539repeat:
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900540 page = grab_cache_page(mapping, index);
541 if (!page)
542 return ERR_PTR(-ENOMEM);
543
544 if (PageUptodate(page))
545 return page;
546
547 if (dn.data_blkaddr == NEW_ADDR) {
548 zero_user_segment(page, 0, PAGE_CACHE_SIZE);
Jaegeuk Kim393ff912013-03-08 21:29:23 +0900549 SetPageUptodate(page);
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900550 } else {
Jaegeuk Kim93dfe2a2013-11-30 12:51:14 +0900551 err = f2fs_submit_page_bio(sbi, page, dn.data_blkaddr,
552 READ_SYNC);
Jaegeuk Kim393ff912013-03-08 21:29:23 +0900553 if (err)
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900554 return ERR_PTR(err);
Jaegeuk Kim393ff912013-03-08 21:29:23 +0900555 lock_page(page);
Jaegeuk Kim6bacf522013-12-06 15:00:58 +0900556 if (unlikely(!PageUptodate(page))) {
Jaegeuk Kim393ff912013-03-08 21:29:23 +0900557 f2fs_put_page(page, 1);
558 return ERR_PTR(-EIO);
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900559 }
Jaegeuk Kim6bacf522013-12-06 15:00:58 +0900560 if (unlikely(page->mapping != mapping)) {
Jaegeuk Kimafcb7ca02013-04-26 11:55:17 +0900561 f2fs_put_page(page, 1);
562 goto repeat;
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900563 }
564 }
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900565
566 if (new_i_size &&
567 i_size_read(inode) < ((index + 1) << PAGE_CACHE_SHIFT)) {
568 i_size_write(inode, ((index + 1) << PAGE_CACHE_SHIFT));
Jaegeuk Kim699489b2013-06-07 22:08:23 +0900569 /* Only the directory inode sets new_i_size */
570 set_inode_flag(F2FS_I(inode), FI_UPDATE_DIR);
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900571 mark_inode_dirty_sync(inode);
572 }
573 return page;
574}
575
Jaegeuk Kim0a8165d2012-11-29 13:28:09 +0900576/*
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900577 * This function should be used by the data read flow only where it
578 * does not check the "create" flag that indicates block allocation.
579 * The reason for this special functionality is to exploit VFS readahead
580 * mechanism.
581 */
582static int get_data_block_ro(struct inode *inode, sector_t iblock,
583 struct buffer_head *bh_result, int create)
584{
585 unsigned int blkbits = inode->i_sb->s_blocksize_bits;
586 unsigned maxblocks = bh_result->b_size >> blkbits;
587 struct dnode_of_data dn;
588 pgoff_t pgofs;
589 int err;
590
591 /* Get the page offset from the block offset(iblock) */
592 pgofs = (pgoff_t)(iblock >> (PAGE_CACHE_SHIFT - blkbits));
593
Namjae Jeon848753a2013-04-23 16:38:02 +0900594 if (check_extent_cache(inode, pgofs, bh_result)) {
595 trace_f2fs_get_data_block(inode, iblock, bh_result, 0);
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900596 return 0;
Namjae Jeon848753a2013-04-23 16:38:02 +0900597 }
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900598
599 /* When reading holes, we need its node page */
600 set_new_dnode(&dn, inode, NULL, NULL, 0);
Jaegeuk Kim266e97a2013-02-26 13:10:46 +0900601 err = get_dnode_of_data(&dn, pgofs, LOOKUP_NODE_RA);
Namjae Jeon848753a2013-04-23 16:38:02 +0900602 if (err) {
603 trace_f2fs_get_data_block(inode, iblock, bh_result, err);
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900604 return (err == -ENOENT) ? 0 : err;
Namjae Jeon848753a2013-04-23 16:38:02 +0900605 }
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900606
607 /* It does not support data allocation */
Jaegeuk Kim5d56b672013-10-29 15:14:54 +0900608 f2fs_bug_on(create);
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900609
610 if (dn.data_blkaddr != NEW_ADDR && dn.data_blkaddr != NULL_ADDR) {
611 int i;
612 unsigned int end_offset;
613
614 end_offset = IS_INODE(dn.node_page) ?
Jaegeuk Kimde936532013-08-12 21:08:03 +0900615 ADDRS_PER_INODE(F2FS_I(inode)) :
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900616 ADDRS_PER_BLOCK;
617
618 clear_buffer_new(bh_result);
619
620 /* Give more consecutive addresses for the read ahead */
621 for (i = 0; i < end_offset - dn.ofs_in_node; i++)
622 if (((datablock_addr(dn.node_page,
623 dn.ofs_in_node + i))
624 != (dn.data_blkaddr + i)) || maxblocks == i)
625 break;
626 map_bh(bh_result, inode->i_sb, dn.data_blkaddr);
Jaegeuk Kimf9a4e6d2013-11-28 12:44:05 +0900627 bh_result->b_size = (((size_t)i) << blkbits);
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900628 }
629 f2fs_put_dnode(&dn);
Namjae Jeon848753a2013-04-23 16:38:02 +0900630 trace_f2fs_get_data_block(inode, iblock, bh_result, 0);
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900631 return 0;
632}
633
634static int f2fs_read_data_page(struct file *file, struct page *page)
635{
636 return mpage_readpage(page, get_data_block_ro);
637}
638
639static int f2fs_read_data_pages(struct file *file,
640 struct address_space *mapping,
641 struct list_head *pages, unsigned nr_pages)
642{
643 return mpage_readpages(mapping, pages, nr_pages, get_data_block_ro);
644}
645
Fan Li63a0b7cb2013-12-09 16:09:00 +0800646int do_write_data_page(struct page *page, struct writeback_control *wbc)
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900647{
648 struct inode *inode = page->mapping->host;
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900649 block_t old_blk_addr, new_blk_addr;
650 struct dnode_of_data dn;
651 int err = 0;
652
653 set_new_dnode(&dn, inode, NULL, NULL, 0);
Jaegeuk Kim266e97a2013-02-26 13:10:46 +0900654 err = get_dnode_of_data(&dn, page->index, LOOKUP_NODE);
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900655 if (err)
656 return err;
657
658 old_blk_addr = dn.data_blkaddr;
659
660 /* This page is already truncated */
661 if (old_blk_addr == NULL_ADDR)
662 goto out_writepage;
663
664 set_page_writeback(page);
665
666 /*
667 * If current allocation needs SSR,
668 * it had better in-place writes for updated data.
669 */
Haicheng Lib25958b2013-06-13 16:59:29 +0800670 if (unlikely(old_blk_addr != NEW_ADDR &&
671 !is_cold_data(page) &&
672 need_inplace_update(inode))) {
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900673 rewrite_data_page(F2FS_SB(inode->i_sb), page,
Fan Li63a0b7cb2013-12-09 16:09:00 +0800674 old_blk_addr, wbc);
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900675 } else {
676 write_data_page(inode, page, &dn,
Fan Li63a0b7cb2013-12-09 16:09:00 +0800677 old_blk_addr, &new_blk_addr, wbc);
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900678 update_extent_cache(new_blk_addr, &dn);
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900679 }
680out_writepage:
681 f2fs_put_dnode(&dn);
682 return err;
683}
684
685static int f2fs_write_data_page(struct page *page,
686 struct writeback_control *wbc)
687{
688 struct inode *inode = page->mapping->host;
689 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
690 loff_t i_size = i_size_read(inode);
691 const pgoff_t end_index = ((unsigned long long) i_size)
692 >> PAGE_CACHE_SHIFT;
693 unsigned offset;
Jaegeuk Kim39936832012-11-22 16:21:29 +0900694 bool need_balance_fs = false;
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900695 int err = 0;
696
697 if (page->index < end_index)
Jaegeuk Kim39936832012-11-22 16:21:29 +0900698 goto write;
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900699
700 /*
701 * If the offset is out-of-range of file size,
702 * this page does not have to be written to disk.
703 */
704 offset = i_size & (PAGE_CACHE_SIZE - 1);
705 if ((page->index >= end_index + 1) || !offset) {
706 if (S_ISDIR(inode->i_mode)) {
707 dec_page_count(sbi, F2FS_DIRTY_DENTS);
708 inode_dec_dirty_dents(inode);
709 }
Jaegeuk Kim39936832012-11-22 16:21:29 +0900710 goto out;
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900711 }
712
713 zero_user_segment(page, offset, PAGE_CACHE_SIZE);
Jaegeuk Kim39936832012-11-22 16:21:29 +0900714write:
Chao Yucfb271d2013-12-05 17:15:22 +0800715 if (unlikely(sbi->por_doing)) {
Jaegeuk Kim39936832012-11-22 16:21:29 +0900716 err = AOP_WRITEPAGE_ACTIVATE;
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900717 goto redirty_out;
Jaegeuk Kim39936832012-11-22 16:21:29 +0900718 }
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900719
Jaegeuk Kim39936832012-11-22 16:21:29 +0900720 /* Dentry blocks are controlled by checkpoint */
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900721 if (S_ISDIR(inode->i_mode)) {
722 dec_page_count(sbi, F2FS_DIRTY_DENTS);
723 inode_dec_dirty_dents(inode);
Fan Li63a0b7cb2013-12-09 16:09:00 +0800724 err = do_write_data_page(page, wbc);
Jaegeuk Kim39936832012-11-22 16:21:29 +0900725 } else {
Gu Zhenge4795562013-09-27 18:08:30 +0800726 f2fs_lock_op(sbi);
Fan Li63a0b7cb2013-12-09 16:09:00 +0800727 err = do_write_data_page(page, wbc);
Gu Zhenge4795562013-09-27 18:08:30 +0800728 f2fs_unlock_op(sbi);
Jaegeuk Kim39936832012-11-22 16:21:29 +0900729 need_balance_fs = true;
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900730 }
Jaegeuk Kim39936832012-11-22 16:21:29 +0900731 if (err == -ENOENT)
732 goto out;
733 else if (err)
734 goto redirty_out;
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900735
736 if (wbc->for_reclaim)
Jaegeuk Kim93dfe2a2013-11-30 12:51:14 +0900737 f2fs_submit_merged_bio(sbi, DATA, true, WRITE);
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900738
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900739 clear_cold_data(page);
Jaegeuk Kim39936832012-11-22 16:21:29 +0900740out:
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900741 unlock_page(page);
Jaegeuk Kim39936832012-11-22 16:21:29 +0900742 if (need_balance_fs)
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900743 f2fs_balance_fs(sbi);
744 return 0;
745
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900746redirty_out:
747 wbc->pages_skipped++;
748 set_page_dirty(page);
Jaegeuk Kim39936832012-11-22 16:21:29 +0900749 return err;
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900750}
751
752#define MAX_DESIRED_PAGES_WP 4096
753
Namjae Jeonfa9150a2013-01-15 16:45:24 +0900754static int __f2fs_writepage(struct page *page, struct writeback_control *wbc,
755 void *data)
756{
757 struct address_space *mapping = data;
758 int ret = mapping->a_ops->writepage(page, wbc);
759 mapping_set_error(mapping, ret);
760 return ret;
761}
762
Jaegeuk Kim25ca9232012-11-28 16:12:41 +0900763static int f2fs_write_data_pages(struct address_space *mapping,
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900764 struct writeback_control *wbc)
765{
766 struct inode *inode = mapping->host;
767 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
Jaegeuk Kim531ad7d2013-04-30 11:33:27 +0900768 bool locked = false;
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900769 int ret;
770 long excess_nrtw = 0, desired_nrtw;
771
P J Pcfb185a2013-04-03 11:38:00 +0900772 /* deal with chardevs and other special file */
773 if (!mapping->a_ops->writepage)
774 return 0;
775
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900776 if (wbc->nr_to_write < MAX_DESIRED_PAGES_WP) {
777 desired_nrtw = MAX_DESIRED_PAGES_WP;
778 excess_nrtw = desired_nrtw - wbc->nr_to_write;
779 wbc->nr_to_write = desired_nrtw;
780 }
781
Jaegeuk Kim531ad7d2013-04-30 11:33:27 +0900782 if (!S_ISDIR(inode->i_mode)) {
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900783 mutex_lock(&sbi->writepages);
Jaegeuk Kim531ad7d2013-04-30 11:33:27 +0900784 locked = true;
785 }
Namjae Jeonfa9150a2013-01-15 16:45:24 +0900786 ret = write_cache_pages(mapping, wbc, __f2fs_writepage, mapping);
Jaegeuk Kim531ad7d2013-04-30 11:33:27 +0900787 if (locked)
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900788 mutex_unlock(&sbi->writepages);
Jaegeuk Kim93dfe2a2013-11-30 12:51:14 +0900789 f2fs_submit_merged_bio(sbi, DATA, wbc->sync_mode == WB_SYNC_ALL, WRITE);
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900790
791 remove_dirty_dir_inode(inode);
792
793 wbc->nr_to_write -= excess_nrtw;
794 return ret;
795}
796
797static int f2fs_write_begin(struct file *file, struct address_space *mapping,
798 loff_t pos, unsigned len, unsigned flags,
799 struct page **pagep, void **fsdata)
800{
801 struct inode *inode = mapping->host;
802 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
803 struct page *page;
804 pgoff_t index = ((unsigned long long) pos) >> PAGE_CACHE_SHIFT;
805 struct dnode_of_data dn;
806 int err = 0;
807
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900808 f2fs_balance_fs(sbi);
Jaegeuk Kimafcb7ca02013-04-26 11:55:17 +0900809repeat:
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900810 page = grab_cache_page_write_begin(mapping, index, flags);
811 if (!page)
812 return -ENOMEM;
813 *pagep = page;
814
Gu Zhenge4795562013-09-27 18:08:30 +0800815 f2fs_lock_op(sbi);
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900816 set_new_dnode(&dn, inode, NULL, NULL, 0);
Huajun Lib6009652013-11-10 23:13:18 +0800817 err = f2fs_reserve_block(&dn, index);
Gu Zhenge4795562013-09-27 18:08:30 +0800818 f2fs_unlock_op(sbi);
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900819
Huajun Lib6009652013-11-10 23:13:18 +0800820 if (err) {
821 f2fs_put_page(page, 1);
822 return err;
823 }
824
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900825 if ((len == PAGE_CACHE_SIZE) || PageUptodate(page))
826 return 0;
827
828 if ((pos & PAGE_CACHE_MASK) >= i_size_read(inode)) {
829 unsigned start = pos & (PAGE_CACHE_SIZE - 1);
830 unsigned end = start + len;
831
832 /* Reading beyond i_size is simple: memset to zero */
833 zero_user_segments(page, 0, start, end, PAGE_CACHE_SIZE);
Jaegeuk Kim393ff912013-03-08 21:29:23 +0900834 goto out;
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900835 }
836
837 if (dn.data_blkaddr == NEW_ADDR) {
838 zero_user_segment(page, 0, PAGE_CACHE_SIZE);
839 } else {
Jaegeuk Kim93dfe2a2013-11-30 12:51:14 +0900840 err = f2fs_submit_page_bio(sbi, page, dn.data_blkaddr,
841 READ_SYNC);
Jaegeuk Kim393ff912013-03-08 21:29:23 +0900842 if (err)
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900843 return err;
Jaegeuk Kim393ff912013-03-08 21:29:23 +0900844 lock_page(page);
Jaegeuk Kim6bacf522013-12-06 15:00:58 +0900845 if (unlikely(!PageUptodate(page))) {
Jaegeuk Kim393ff912013-03-08 21:29:23 +0900846 f2fs_put_page(page, 1);
847 return -EIO;
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900848 }
Jaegeuk Kim6bacf522013-12-06 15:00:58 +0900849 if (unlikely(page->mapping != mapping)) {
Jaegeuk Kimafcb7ca02013-04-26 11:55:17 +0900850 f2fs_put_page(page, 1);
851 goto repeat;
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900852 }
853 }
Jaegeuk Kim393ff912013-03-08 21:29:23 +0900854out:
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900855 SetPageUptodate(page);
856 clear_cold_data(page);
857 return 0;
858}
859
Jaegeuk Kima1dd3c12013-06-27 13:04:08 +0900860static int f2fs_write_end(struct file *file,
861 struct address_space *mapping,
862 loff_t pos, unsigned len, unsigned copied,
863 struct page *page, void *fsdata)
864{
865 struct inode *inode = page->mapping->host;
866
867 SetPageUptodate(page);
868 set_page_dirty(page);
869
870 if (pos + copied > i_size_read(inode)) {
871 i_size_write(inode, pos + copied);
872 mark_inode_dirty(inode);
873 update_inode_page(inode);
874 }
875
Chao Yu75c3c8b2013-11-16 14:15:59 +0800876 f2fs_put_page(page, 1);
Jaegeuk Kima1dd3c12013-06-27 13:04:08 +0900877 return copied;
878}
879
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900880static ssize_t f2fs_direct_IO(int rw, struct kiocb *iocb,
881 const struct iovec *iov, loff_t offset, unsigned long nr_segs)
882{
883 struct file *file = iocb->ki_filp;
884 struct inode *inode = file->f_mapping->host;
885
886 if (rw == WRITE)
887 return 0;
888
889 /* Needs synchronization with the cleaner */
890 return blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs,
891 get_data_block_ro);
892}
893
Lukas Czernerd47992f2013-05-21 23:17:23 -0400894static void f2fs_invalidate_data_page(struct page *page, unsigned int offset,
895 unsigned int length)
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900896{
897 struct inode *inode = page->mapping->host;
898 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
899 if (S_ISDIR(inode->i_mode) && PageDirty(page)) {
900 dec_page_count(sbi, F2FS_DIRTY_DENTS);
901 inode_dec_dirty_dents(inode);
902 }
903 ClearPagePrivate(page);
904}
905
906static int f2fs_release_data_page(struct page *page, gfp_t wait)
907{
908 ClearPagePrivate(page);
Jaegeuk Kimc3850aa2013-03-14 09:24:32 +0900909 return 1;
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900910}
911
912static int f2fs_set_data_page_dirty(struct page *page)
913{
914 struct address_space *mapping = page->mapping;
915 struct inode *inode = mapping->host;
916
Jaegeuk Kim26c6b882013-10-24 17:53:29 +0900917 trace_f2fs_set_page_dirty(page, DATA);
918
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900919 SetPageUptodate(page);
920 if (!PageDirty(page)) {
921 __set_page_dirty_nobuffers(page);
922 set_dirty_dir_page(inode, page);
923 return 1;
924 }
925 return 0;
926}
927
Jaegeuk Kimc01e54b2013-01-17 20:30:23 +0900928static sector_t f2fs_bmap(struct address_space *mapping, sector_t block)
929{
930 return generic_block_bmap(mapping, block, get_data_block_ro);
931}
932
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900933const struct address_space_operations f2fs_dblock_aops = {
934 .readpage = f2fs_read_data_page,
935 .readpages = f2fs_read_data_pages,
936 .writepage = f2fs_write_data_page,
937 .writepages = f2fs_write_data_pages,
938 .write_begin = f2fs_write_begin,
Jaegeuk Kima1dd3c12013-06-27 13:04:08 +0900939 .write_end = f2fs_write_end,
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900940 .set_page_dirty = f2fs_set_data_page_dirty,
941 .invalidatepage = f2fs_invalidate_data_page,
942 .releasepage = f2fs_release_data_page,
943 .direct_IO = f2fs_direct_IO,
Jaegeuk Kimc01e54b2013-01-17 20:30:23 +0900944 .bmap = f2fs_bmap,
Jaegeuk Kimeb47b802012-11-02 17:10:12 +0900945};