Commit 26a6441a authored by Nick Piggin's avatar Nick Piggin Committed by Linus Torvalds

sysv: convert to new aops

Signed-off-by: default avatarNick Piggin <npiggin@suse.de>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent be021ee4
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <linux/pagemap.h> #include <linux/pagemap.h>
#include <linux/highmem.h> #include <linux/highmem.h>
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/swap.h>
#include "sysv.h" #include "sysv.h"
static int sysv_readdir(struct file *, void *, filldir_t); static int sysv_readdir(struct file *, void *, filldir_t);
...@@ -37,12 +38,17 @@ static inline unsigned long dir_pages(struct inode *inode) ...@@ -37,12 +38,17 @@ static inline unsigned long dir_pages(struct inode *inode)
return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT; return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT;
} }
static int dir_commit_chunk(struct page *page, unsigned from, unsigned to) static int dir_commit_chunk(struct page *page, loff_t pos, unsigned len)
{ {
struct inode *dir = (struct inode *)page->mapping->host; struct address_space *mapping = page->mapping;
struct inode *dir = mapping->host;
int err = 0; int err = 0;
page->mapping->a_ops->commit_write(NULL, page, from, to); block_write_end(NULL, mapping, pos, len, len, page, NULL);
if (pos+len > dir->i_size) {
i_size_write(dir, pos+len);
mark_inode_dirty(dir);
}
if (IS_DIRSYNC(dir)) if (IS_DIRSYNC(dir))
err = write_one_page(page, 1); err = write_one_page(page, 1);
else else
...@@ -186,7 +192,7 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode) ...@@ -186,7 +192,7 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode)
unsigned long npages = dir_pages(dir); unsigned long npages = dir_pages(dir);
unsigned long n; unsigned long n;
char *kaddr; char *kaddr;
unsigned from, to; loff_t pos;
int err; int err;
/* We take care of directory expansion in the same loop */ /* We take care of directory expansion in the same loop */
...@@ -212,16 +218,17 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode) ...@@ -212,16 +218,17 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode)
return -EINVAL; return -EINVAL;
got_it: got_it:
from = (char*)de - (char*)page_address(page); pos = page_offset(page) +
to = from + SYSV_DIRSIZE; (char*)de - (char*)page_address(page);
lock_page(page); lock_page(page);
err = page->mapping->a_ops->prepare_write(NULL, page, from, to); err = __sysv_write_begin(NULL, page->mapping, pos, SYSV_DIRSIZE,
AOP_FLAG_UNINTERRUPTIBLE, &page, NULL);
if (err) if (err)
goto out_unlock; goto out_unlock;
memcpy (de->name, name, namelen); memcpy (de->name, name, namelen);
memset (de->name + namelen, 0, SYSV_DIRSIZE - namelen - 2); memset (de->name + namelen, 0, SYSV_DIRSIZE - namelen - 2);
de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), inode->i_ino); de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), inode->i_ino);
err = dir_commit_chunk(page, from, to); err = dir_commit_chunk(page, pos, SYSV_DIRSIZE);
dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC; dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
mark_inode_dirty(dir); mark_inode_dirty(dir);
out_page: out_page:
...@@ -238,15 +245,15 @@ int sysv_delete_entry(struct sysv_dir_entry *de, struct page *page) ...@@ -238,15 +245,15 @@ int sysv_delete_entry(struct sysv_dir_entry *de, struct page *page)
struct address_space *mapping = page->mapping; struct address_space *mapping = page->mapping;
struct inode *inode = (struct inode*)mapping->host; struct inode *inode = (struct inode*)mapping->host;
char *kaddr = (char*)page_address(page); char *kaddr = (char*)page_address(page);
unsigned from = (char*)de - kaddr; loff_t pos = page_offset(page) + (char *)de - kaddr;
unsigned to = from + SYSV_DIRSIZE;
int err; int err;
lock_page(page); lock_page(page);
err = mapping->a_ops->prepare_write(NULL, page, from, to); err = __sysv_write_begin(NULL, mapping, pos, SYSV_DIRSIZE,
AOP_FLAG_UNINTERRUPTIBLE, &page, NULL);
BUG_ON(err); BUG_ON(err);
de->inode = 0; de->inode = 0;
err = dir_commit_chunk(page, from, to); err = dir_commit_chunk(page, pos, SYSV_DIRSIZE);
dir_put_page(page); dir_put_page(page);
inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC; inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC;
mark_inode_dirty(inode); mark_inode_dirty(inode);
...@@ -263,12 +270,13 @@ int sysv_make_empty(struct inode *inode, struct inode *dir) ...@@ -263,12 +270,13 @@ int sysv_make_empty(struct inode *inode, struct inode *dir)
if (!page) if (!page)
return -ENOMEM; return -ENOMEM;
kmap(page); err = __sysv_write_begin(NULL, mapping, 0, 2 * SYSV_DIRSIZE,
err = mapping->a_ops->prepare_write(NULL, page, 0, 2 * SYSV_DIRSIZE); AOP_FLAG_UNINTERRUPTIBLE, &page, NULL);
if (err) { if (err) {
unlock_page(page); unlock_page(page);
goto fail; goto fail;
} }
kmap(page);
base = (char*)page_address(page); base = (char*)page_address(page);
memset(base, 0, PAGE_CACHE_SIZE); memset(base, 0, PAGE_CACHE_SIZE);
...@@ -280,9 +288,9 @@ int sysv_make_empty(struct inode *inode, struct inode *dir) ...@@ -280,9 +288,9 @@ int sysv_make_empty(struct inode *inode, struct inode *dir)
de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), dir->i_ino); de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), dir->i_ino);
strcpy(de->name,".."); strcpy(de->name,"..");
kunmap(page);
err = dir_commit_chunk(page, 0, 2 * SYSV_DIRSIZE); err = dir_commit_chunk(page, 0, 2 * SYSV_DIRSIZE);
fail: fail:
kunmap(page);
page_cache_release(page); page_cache_release(page);
return err; return err;
} }
...@@ -336,16 +344,18 @@ not_empty: ...@@ -336,16 +344,18 @@ not_empty:
void sysv_set_link(struct sysv_dir_entry *de, struct page *page, void sysv_set_link(struct sysv_dir_entry *de, struct page *page,
struct inode *inode) struct inode *inode)
{ {
struct inode *dir = (struct inode*)page->mapping->host; struct address_space *mapping = page->mapping;
unsigned from = (char *)de-(char*)page_address(page); struct inode *dir = mapping->host;
unsigned to = from + SYSV_DIRSIZE; loff_t pos = page_offset(page) +
(char *)de-(char*)page_address(page);
int err; int err;
lock_page(page); lock_page(page);
err = page->mapping->a_ops->prepare_write(NULL, page, from, to); err = __sysv_write_begin(NULL, mapping, pos, SYSV_DIRSIZE,
AOP_FLAG_UNINTERRUPTIBLE, &page, NULL);
BUG_ON(err); BUG_ON(err);
de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), inode->i_ino); de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), inode->i_ino);
err = dir_commit_chunk(page, from, to); err = dir_commit_chunk(page, pos, SYSV_DIRSIZE);
dir_put_page(page); dir_put_page(page);
dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC; dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
mark_inode_dirty(dir); mark_inode_dirty(dir);
......
...@@ -453,23 +453,38 @@ static int sysv_writepage(struct page *page, struct writeback_control *wbc) ...@@ -453,23 +453,38 @@ static int sysv_writepage(struct page *page, struct writeback_control *wbc)
{ {
return block_write_full_page(page,get_block,wbc); return block_write_full_page(page,get_block,wbc);
} }
static int sysv_readpage(struct file *file, struct page *page) static int sysv_readpage(struct file *file, struct page *page)
{ {
return block_read_full_page(page,get_block); return block_read_full_page(page,get_block);
} }
static int sysv_prepare_write(struct file *file, struct page *page, unsigned from, unsigned to)
int __sysv_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags,
struct page **pagep, void **fsdata)
{ {
return block_prepare_write(page,from,to,get_block); return block_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
get_block);
} }
static int sysv_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags,
struct page **pagep, void **fsdata)
{
*pagep = NULL;
return __sysv_write_begin(file, mapping, pos, len, flags, pagep, fsdata);
}
static sector_t sysv_bmap(struct address_space *mapping, sector_t block) static sector_t sysv_bmap(struct address_space *mapping, sector_t block)
{ {
return generic_block_bmap(mapping,block,get_block); return generic_block_bmap(mapping,block,get_block);
} }
const struct address_space_operations sysv_aops = { const struct address_space_operations sysv_aops = {
.readpage = sysv_readpage, .readpage = sysv_readpage,
.writepage = sysv_writepage, .writepage = sysv_writepage,
.sync_page = block_sync_page, .sync_page = block_sync_page,
.prepare_write = sysv_prepare_write, .write_begin = sysv_write_begin,
.commit_write = generic_commit_write, .write_end = generic_write_end,
.bmap = sysv_bmap .bmap = sysv_bmap
}; };
...@@ -136,6 +136,9 @@ extern unsigned long sysv_count_free_blocks(struct super_block *); ...@@ -136,6 +136,9 @@ extern unsigned long sysv_count_free_blocks(struct super_block *);
/* itree.c */ /* itree.c */
extern void sysv_truncate(struct inode *); extern void sysv_truncate(struct inode *);
extern int __sysv_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags,
struct page **pagep, void **fsdata);
/* inode.c */ /* inode.c */
extern int sysv_write_inode(struct inode *, int); extern int sysv_write_inode(struct inode *, int);
......
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