-/**
+/*
* fs/f2fs/data.c
*
* Copyright (c) 2012 Samsung Electronics Co., Ltd.
#include <linux/backing-dev.h>
#include <linux/blkdev.h>
#include <linux/bio.h>
+#include <linux/prefetch.h>
#include "f2fs.h"
#include "node.h"
#include "segment.h"
-/**
+/*
* Lock ordering for the change of data block address:
* ->data_page
* ->node_page
return page;
}
-/**
+/*
* If it tries to access a hole, return an error.
* Because, the callers, functions in dir.c and GC, should be able to know
* whether this page exists or not.
return page;
}
-/**
+/*
* Caller ensures that this data page is never allocated.
* A new zero-filled data page is allocated in the page cache.
*/
bio_put(bio);
}
-/**
+/*
* Fill the locked page with data located in the block address.
* Read operation is synchronous, and caller must unlock the page.
*/
down_read(&sbi->bio_sem);
/* Allocate a new bio */
- bio = f2fs_bio_alloc(bdev, blk_addr << (sbi->log_blocksize - 9),
- 1, GFP_NOFS | __GFP_HIGH);
+ bio = f2fs_bio_alloc(bdev, 1);
/* Initialize the bio */
+ bio->bi_sector = SECTOR_FROM_BLOCK(sbi, blk_addr);
bio->bi_end_io = read_end_io;
+
if (bio_add_page(bio, page, PAGE_CACHE_SIZE, 0) < PAGE_CACHE_SIZE) {
kfree(bio->bi_private);
bio_put(bio);
return 0;
}
-/**
+/*
* This function should be used by the data read flow only where it
* does not check the "create" flag that indicates block allocation.
* The reason for this special functionality is to exploit VFS readahead
#define MAX_DESIRED_PAGES_WP 4096
-int f2fs_write_data_pages(struct address_space *mapping,
+static int __f2fs_writepage(struct page *page, struct writeback_control *wbc,
+ void *data)
+{
+ struct address_space *mapping = data;
+ int ret = mapping->a_ops->writepage(page, wbc);
+ mapping_set_error(mapping, ret);
+ return ret;
+}
+
+static int f2fs_write_data_pages(struct address_space *mapping,
struct writeback_control *wbc)
{
struct inode *inode = mapping->host;
if (!S_ISDIR(inode->i_mode))
mutex_lock(&sbi->writepages);
- ret = generic_writepages(mapping, wbc);
+ ret = write_cache_pages(mapping, wbc, __f2fs_writepage, mapping);
if (!S_ISDIR(inode->i_mode))
mutex_unlock(&sbi->writepages);
f2fs_submit_bio(sbi, DATA, (wbc->sync_mode == WB_SYNC_ALL));