aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Piggin <npiggin@suse.de>2007-10-16 04:25:03 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-16 12:42:55 -0400
commit800d15a53e7d14fa26495b7b95d3bfe7877dd69d (patch)
tree09a59e32043f1b601b73ad6105e7634679337884
parent674b892ede247ef4fb8d00918f02e29c32b9bbaf (diff)
implement simple fs aops
Implement new aops for some of the simpler filesystems. Signed-off-by: Nick Piggin <npiggin@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/configfs/inode.c4
-rw-r--r--fs/hugetlbfs/inode.c16
-rw-r--r--fs/ramfs/file-mmu.c4
-rw-r--r--fs/ramfs/file-nommu.c4
-rw-r--r--fs/sysfs/inode.c4
-rw-r--r--mm/shmem.c34
6 files changed, 45 insertions, 21 deletions
diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c
index ddc003a9d214..dbd257d956c4 100644
--- a/fs/configfs/inode.c
+++ b/fs/configfs/inode.c
@@ -41,8 +41,8 @@ extern struct super_block * configfs_sb;
41 41
42static const struct address_space_operations configfs_aops = { 42static const struct address_space_operations configfs_aops = {
43 .readpage = simple_readpage, 43 .readpage = simple_readpage,
44 .prepare_write = simple_prepare_write, 44 .write_begin = simple_write_begin,
45 .commit_write = simple_commit_write 45 .write_end = simple_write_end,
46}; 46};
47 47
48static struct backing_dev_info configfs_backing_dev_info = { 48static struct backing_dev_info configfs_backing_dev_info = {
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 950c2fbb815b..70fbb29fb202 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -189,15 +189,19 @@ static int hugetlbfs_readpage(struct file *file, struct page * page)
189 return -EINVAL; 189 return -EINVAL;
190} 190}
191 191
192static int hugetlbfs_prepare_write(struct file *file, 192static int hugetlbfs_write_begin(struct file *file,
193 struct page *page, unsigned offset, unsigned to) 193 struct address_space *mapping,
194 loff_t pos, unsigned len, unsigned flags,
195 struct page **pagep, void **fsdata)
194{ 196{
195 return -EINVAL; 197 return -EINVAL;
196} 198}
197 199
198static int hugetlbfs_commit_write(struct file *file, 200static int hugetlbfs_write_end(struct file *file, struct address_space *mapping,
199 struct page *page, unsigned offset, unsigned to) 201 loff_t pos, unsigned len, unsigned copied,
202 struct page *page, void *fsdata)
200{ 203{
204 BUG();
201 return -EINVAL; 205 return -EINVAL;
202} 206}
203 207
@@ -569,8 +573,8 @@ static void hugetlbfs_destroy_inode(struct inode *inode)
569 573
570static const struct address_space_operations hugetlbfs_aops = { 574static const struct address_space_operations hugetlbfs_aops = {
571 .readpage = hugetlbfs_readpage, 575 .readpage = hugetlbfs_readpage,
572 .prepare_write = hugetlbfs_prepare_write, 576 .write_begin = hugetlbfs_write_begin,
573 .commit_write = hugetlbfs_commit_write, 577 .write_end = hugetlbfs_write_end,
574 .set_page_dirty = hugetlbfs_set_page_dirty, 578 .set_page_dirty = hugetlbfs_set_page_dirty,
575}; 579};
576 580
diff --git a/fs/ramfs/file-mmu.c b/fs/ramfs/file-mmu.c
index 97bdc0b2f9d2..b41a514b0976 100644
--- a/fs/ramfs/file-mmu.c
+++ b/fs/ramfs/file-mmu.c
@@ -29,8 +29,8 @@
29 29
30const struct address_space_operations ramfs_aops = { 30const struct address_space_operations ramfs_aops = {
31 .readpage = simple_readpage, 31 .readpage = simple_readpage,
32 .prepare_write = simple_prepare_write, 32 .write_begin = simple_write_begin,
33 .commit_write = simple_commit_write, 33 .write_end = simple_write_end,
34 .set_page_dirty = __set_page_dirty_no_writeback, 34 .set_page_dirty = __set_page_dirty_no_writeback,
35}; 35};
36 36
diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c
index 237fe8b8e819..0989bc2c2f69 100644
--- a/fs/ramfs/file-nommu.c
+++ b/fs/ramfs/file-nommu.c
@@ -29,8 +29,8 @@ static int ramfs_nommu_setattr(struct dentry *, struct iattr *);
29 29
30const struct address_space_operations ramfs_aops = { 30const struct address_space_operations ramfs_aops = {
31 .readpage = simple_readpage, 31 .readpage = simple_readpage,
32 .prepare_write = simple_prepare_write, 32 .write_begin = simple_write_begin,
33 .commit_write = simple_commit_write, 33 .write_end = simple_write_end,
34 .set_page_dirty = __set_page_dirty_no_writeback, 34 .set_page_dirty = __set_page_dirty_no_writeback,
35}; 35};
36 36
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index 9236635111f4..c4ef945d39c8 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -24,8 +24,8 @@ extern struct super_block * sysfs_sb;
24 24
25static const struct address_space_operations sysfs_aops = { 25static const struct address_space_operations sysfs_aops = {
26 .readpage = simple_readpage, 26 .readpage = simple_readpage,
27 .prepare_write = simple_prepare_write, 27 .write_begin = simple_write_begin,
28 .commit_write = simple_commit_write 28 .write_end = simple_write_end,
29}; 29};
30 30
31static struct backing_dev_info sysfs_backing_dev_info = { 31static struct backing_dev_info sysfs_backing_dev_info = {
diff --git a/mm/shmem.c b/mm/shmem.c
index 2c39925fe073..131f2938f3ad 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1108,7 +1108,7 @@ static int shmem_getpage(struct inode *inode, unsigned long idx,
1108 * Normally, filepage is NULL on entry, and either found 1108 * Normally, filepage is NULL on entry, and either found
1109 * uptodate immediately, or allocated and zeroed, or read 1109 * uptodate immediately, or allocated and zeroed, or read
1110 * in under swappage, which is then assigned to filepage. 1110 * in under swappage, which is then assigned to filepage.
1111 * But shmem_readpage and shmem_prepare_write pass in a locked 1111 * But shmem_readpage and shmem_write_begin pass in a locked
1112 * filepage, which may be found not uptodate by other callers 1112 * filepage, which may be found not uptodate by other callers
1113 * too, and may need to be copied from the swappage read in. 1113 * too, and may need to be copied from the swappage read in.
1114 */ 1114 */
@@ -1445,7 +1445,7 @@ static const struct inode_operations shmem_symlink_inode_operations;
1445static const struct inode_operations shmem_symlink_inline_operations; 1445static const struct inode_operations shmem_symlink_inline_operations;
1446 1446
1447/* 1447/*
1448 * Normally tmpfs avoids the use of shmem_readpage and shmem_prepare_write; 1448 * Normally tmpfs avoids the use of shmem_readpage and shmem_write_begin;
1449 * but providing them allows a tmpfs file to be used for splice, sendfile, and 1449 * but providing them allows a tmpfs file to be used for splice, sendfile, and
1450 * below the loop driver, in the generic fashion that many filesystems support. 1450 * below the loop driver, in the generic fashion that many filesystems support.
1451 */ 1451 */
@@ -1458,10 +1458,30 @@ static int shmem_readpage(struct file *file, struct page *page)
1458} 1458}
1459 1459
1460static int 1460static int
1461shmem_prepare_write(struct file *file, struct page *page, unsigned offset, unsigned to) 1461shmem_write_begin(struct file *file, struct address_space *mapping,
1462 loff_t pos, unsigned len, unsigned flags,
1463 struct page **pagep, void **fsdata)
1462{ 1464{
1463 struct inode *inode = page->mapping->host; 1465 struct inode *inode = mapping->host;
1464 return shmem_getpage(inode, page->index, &page, SGP_WRITE, NULL); 1466 pgoff_t index = pos >> PAGE_CACHE_SHIFT;
1467 *pagep = NULL;
1468 return shmem_getpage(inode, index, pagep, SGP_WRITE, NULL);
1469}
1470
1471static int
1472shmem_write_end(struct file *file, struct address_space *mapping,
1473 loff_t pos, unsigned len, unsigned copied,
1474 struct page *page, void *fsdata)
1475{
1476 struct inode *inode = mapping->host;
1477
1478 set_page_dirty(page);
1479 page_cache_release(page);
1480
1481 if (pos+copied > inode->i_size)
1482 i_size_write(inode, pos+copied);
1483
1484 return copied;
1465} 1485}
1466 1486
1467static ssize_t 1487static ssize_t
@@ -2337,8 +2357,8 @@ static const struct address_space_operations shmem_aops = {
2337 .set_page_dirty = __set_page_dirty_no_writeback, 2357 .set_page_dirty = __set_page_dirty_no_writeback,
2338#ifdef CONFIG_TMPFS 2358#ifdef CONFIG_TMPFS
2339 .readpage = shmem_readpage, 2359 .readpage = shmem_readpage,
2340 .prepare_write = shmem_prepare_write, 2360 .write_begin = shmem_write_begin,
2341 .commit_write = simple_commit_write, 2361 .write_end = shmem_write_end,
2342#endif 2362#endif
2343 .migratepage = migrate_page, 2363 .migratepage = migrate_page,
2344}; 2364};