Commit 800d15a5 authored by Nick Piggin's avatar Nick Piggin Committed by Linus Torvalds

implement simple fs aops

Implement new aops for some of the simpler filesystems.
Signed-off-by: default avatarNick Piggin <npiggin@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 674b892e
...@@ -41,8 +41,8 @@ extern struct super_block * configfs_sb; ...@@ -41,8 +41,8 @@ extern struct super_block * configfs_sb;
static const struct address_space_operations configfs_aops = { static const struct address_space_operations configfs_aops = {
.readpage = simple_readpage, .readpage = simple_readpage,
.prepare_write = simple_prepare_write, .write_begin = simple_write_begin,
.commit_write = simple_commit_write .write_end = simple_write_end,
}; };
static struct backing_dev_info configfs_backing_dev_info = { static struct backing_dev_info configfs_backing_dev_info = {
......
...@@ -189,15 +189,19 @@ static int hugetlbfs_readpage(struct file *file, struct page * page) ...@@ -189,15 +189,19 @@ static int hugetlbfs_readpage(struct file *file, struct page * page)
return -EINVAL; return -EINVAL;
} }
static int hugetlbfs_prepare_write(struct file *file, static int hugetlbfs_write_begin(struct file *file,
struct page *page, unsigned offset, unsigned to) struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags,
struct page **pagep, void **fsdata)
{ {
return -EINVAL; return -EINVAL;
} }
static int hugetlbfs_commit_write(struct file *file, static int hugetlbfs_write_end(struct file *file, struct address_space *mapping,
struct page *page, unsigned offset, unsigned to) loff_t pos, unsigned len, unsigned copied,
struct page *page, void *fsdata)
{ {
BUG();
return -EINVAL; return -EINVAL;
} }
...@@ -569,8 +573,8 @@ static void hugetlbfs_destroy_inode(struct inode *inode) ...@@ -569,8 +573,8 @@ static void hugetlbfs_destroy_inode(struct inode *inode)
static const struct address_space_operations hugetlbfs_aops = { static const struct address_space_operations hugetlbfs_aops = {
.readpage = hugetlbfs_readpage, .readpage = hugetlbfs_readpage,
.prepare_write = hugetlbfs_prepare_write, .write_begin = hugetlbfs_write_begin,
.commit_write = hugetlbfs_commit_write, .write_end = hugetlbfs_write_end,
.set_page_dirty = hugetlbfs_set_page_dirty, .set_page_dirty = hugetlbfs_set_page_dirty,
}; };
......
...@@ -29,8 +29,8 @@ ...@@ -29,8 +29,8 @@
const struct address_space_operations ramfs_aops = { const struct address_space_operations ramfs_aops = {
.readpage = simple_readpage, .readpage = simple_readpage,
.prepare_write = simple_prepare_write, .write_begin = simple_write_begin,
.commit_write = simple_commit_write, .write_end = simple_write_end,
.set_page_dirty = __set_page_dirty_no_writeback, .set_page_dirty = __set_page_dirty_no_writeback,
}; };
......
...@@ -29,8 +29,8 @@ static int ramfs_nommu_setattr(struct dentry *, struct iattr *); ...@@ -29,8 +29,8 @@ static int ramfs_nommu_setattr(struct dentry *, struct iattr *);
const struct address_space_operations ramfs_aops = { const struct address_space_operations ramfs_aops = {
.readpage = simple_readpage, .readpage = simple_readpage,
.prepare_write = simple_prepare_write, .write_begin = simple_write_begin,
.commit_write = simple_commit_write, .write_end = simple_write_end,
.set_page_dirty = __set_page_dirty_no_writeback, .set_page_dirty = __set_page_dirty_no_writeback,
}; };
......
...@@ -24,8 +24,8 @@ extern struct super_block * sysfs_sb; ...@@ -24,8 +24,8 @@ extern struct super_block * sysfs_sb;
static const struct address_space_operations sysfs_aops = { static const struct address_space_operations sysfs_aops = {
.readpage = simple_readpage, .readpage = simple_readpage,
.prepare_write = simple_prepare_write, .write_begin = simple_write_begin,
.commit_write = simple_commit_write .write_end = simple_write_end,
}; };
static struct backing_dev_info sysfs_backing_dev_info = { static struct backing_dev_info sysfs_backing_dev_info = {
......
...@@ -1108,7 +1108,7 @@ static int shmem_getpage(struct inode *inode, unsigned long idx, ...@@ -1108,7 +1108,7 @@ static int shmem_getpage(struct inode *inode, unsigned long idx,
* Normally, filepage is NULL on entry, and either found * Normally, filepage is NULL on entry, and either found
* uptodate immediately, or allocated and zeroed, or read * uptodate immediately, or allocated and zeroed, or read
* in under swappage, which is then assigned to filepage. * in under swappage, which is then assigned to filepage.
* But shmem_readpage and shmem_prepare_write pass in a locked * But shmem_readpage and shmem_write_begin pass in a locked
* filepage, which may be found not uptodate by other callers * filepage, which may be found not uptodate by other callers
* too, and may need to be copied from the swappage read in. * too, and may need to be copied from the swappage read in.
*/ */
...@@ -1445,7 +1445,7 @@ static const struct inode_operations shmem_symlink_inode_operations; ...@@ -1445,7 +1445,7 @@ static const struct inode_operations shmem_symlink_inode_operations;
static const struct inode_operations shmem_symlink_inline_operations; static const struct inode_operations shmem_symlink_inline_operations;
/* /*
* Normally tmpfs avoids the use of shmem_readpage and shmem_prepare_write; * Normally tmpfs avoids the use of shmem_readpage and shmem_write_begin;
* but providing them allows a tmpfs file to be used for splice, sendfile, and * but providing them allows a tmpfs file to be used for splice, sendfile, and
* below the loop driver, in the generic fashion that many filesystems support. * below the loop driver, in the generic fashion that many filesystems support.
*/ */
...@@ -1458,10 +1458,30 @@ static int shmem_readpage(struct file *file, struct page *page) ...@@ -1458,10 +1458,30 @@ static int shmem_readpage(struct file *file, struct page *page)
} }
static int static int
shmem_prepare_write(struct file *file, struct page *page, unsigned offset, unsigned to) shmem_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags,
struct page **pagep, void **fsdata)
{ {
struct inode *inode = page->mapping->host; struct inode *inode = mapping->host;
return shmem_getpage(inode, page->index, &page, SGP_WRITE, NULL); pgoff_t index = pos >> PAGE_CACHE_SHIFT;
*pagep = NULL;
return shmem_getpage(inode, index, pagep, SGP_WRITE, NULL);
}
static int
shmem_write_end(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned copied,
struct page *page, void *fsdata)
{
struct inode *inode = mapping->host;
set_page_dirty(page);
page_cache_release(page);
if (pos+copied > inode->i_size)
i_size_write(inode, pos+copied);
return copied;
} }
static ssize_t static ssize_t
...@@ -2337,8 +2357,8 @@ static const struct address_space_operations shmem_aops = { ...@@ -2337,8 +2357,8 @@ static const struct address_space_operations shmem_aops = {
.set_page_dirty = __set_page_dirty_no_writeback, .set_page_dirty = __set_page_dirty_no_writeback,
#ifdef CONFIG_TMPFS #ifdef CONFIG_TMPFS
.readpage = shmem_readpage, .readpage = shmem_readpage,
.prepare_write = shmem_prepare_write, .write_begin = shmem_write_begin,
.commit_write = simple_commit_write, .write_end = shmem_write_end,
#endif #endif
.migratepage = migrate_page, .migratepage = migrate_page,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment