Commit 82b9d1d0 authored by Nick Piggin's avatar Nick Piggin Committed by Linus Torvalds

ufs: convert to new aops

Signed-off-by: default avatarNick Piggin <npiggin@suse.de>
Cc: Evgeniy Dushistov <dushistov@mail.ru>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 205c109a
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/time.h> #include <linux/time.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/ufs_fs.h> #include <linux/ufs_fs.h>
#include <linux/swap.h>
#include "swab.h" #include "swab.h"
#include "util.h" #include "util.h"
...@@ -38,12 +39,18 @@ static inline int ufs_match(struct super_block *sb, int len, ...@@ -38,12 +39,18 @@ static inline int ufs_match(struct super_block *sb, int len,
return !memcmp(name, de->d_name, len); return !memcmp(name, de->d_name, len);
} }
static int ufs_commit_chunk(struct page *page, unsigned from, unsigned to) static int ufs_commit_chunk(struct page *page, loff_t pos, unsigned len)
{ {
struct inode *dir = page->mapping->host; struct address_space *mapping = page->mapping;
struct inode *dir = mapping->host;
int err = 0; int err = 0;
dir->i_version++; dir->i_version++;
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
...@@ -81,16 +88,20 @@ ino_t ufs_inode_by_name(struct inode *dir, struct dentry *dentry) ...@@ -81,16 +88,20 @@ ino_t ufs_inode_by_name(struct inode *dir, struct dentry *dentry)
void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de, void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de,
struct page *page, struct inode *inode) struct page *page, struct inode *inode)
{ {
unsigned from = (char *) de - (char *) page_address(page); loff_t pos = page_offset(page) +
unsigned to = from + fs16_to_cpu(dir->i_sb, de->d_reclen); (char *) de - (char *) page_address(page);
unsigned len = fs16_to_cpu(dir->i_sb, de->d_reclen);
int err; int err;
lock_page(page); lock_page(page);
err = page->mapping->a_ops->prepare_write(NULL, page, from, to); err = __ufs_write_begin(NULL, page->mapping, pos, len,
AOP_FLAG_UNINTERRUPTIBLE, &page, NULL);
BUG_ON(err); BUG_ON(err);
de->d_ino = cpu_to_fs32(dir->i_sb, inode->i_ino); de->d_ino = cpu_to_fs32(dir->i_sb, inode->i_ino);
ufs_set_de_type(dir->i_sb, de, inode->i_mode); ufs_set_de_type(dir->i_sb, de, inode->i_mode);
err = ufs_commit_chunk(page, from, to);
err = ufs_commit_chunk(page, pos, len);
ufs_put_page(page); ufs_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);
...@@ -312,7 +323,7 @@ int ufs_add_link(struct dentry *dentry, struct inode *inode) ...@@ -312,7 +323,7 @@ int ufs_add_link(struct dentry *dentry, struct inode *inode)
unsigned long npages = ufs_dir_pages(dir); unsigned long npages = ufs_dir_pages(dir);
unsigned long n; unsigned long n;
char *kaddr; char *kaddr;
unsigned from, to; loff_t pos;
int err; int err;
UFSD("ENTER, name %s, namelen %u\n", name, namelen); UFSD("ENTER, name %s, namelen %u\n", name, namelen);
...@@ -367,9 +378,10 @@ int ufs_add_link(struct dentry *dentry, struct inode *inode) ...@@ -367,9 +378,10 @@ int ufs_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 + rec_len; (char*)de - (char*)page_address(page);
err = page->mapping->a_ops->prepare_write(NULL, page, from, to); err = __ufs_write_begin(NULL, page->mapping, pos, rec_len,
AOP_FLAG_UNINTERRUPTIBLE, &page, NULL);
if (err) if (err)
goto out_unlock; goto out_unlock;
if (de->d_ino) { if (de->d_ino) {
...@@ -386,7 +398,7 @@ int ufs_add_link(struct dentry *dentry, struct inode *inode) ...@@ -386,7 +398,7 @@ int ufs_add_link(struct dentry *dentry, struct inode *inode)
de->d_ino = cpu_to_fs32(sb, inode->i_ino); de->d_ino = cpu_to_fs32(sb, inode->i_ino);
ufs_set_de_type(sb, de, inode->i_mode); ufs_set_de_type(sb, de, inode->i_mode);
err = ufs_commit_chunk(page, from, to); err = ufs_commit_chunk(page, pos, rec_len);
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);
...@@ -509,6 +521,7 @@ int ufs_delete_entry(struct inode *inode, struct ufs_dir_entry *dir, ...@@ -509,6 +521,7 @@ int ufs_delete_entry(struct inode *inode, struct ufs_dir_entry *dir,
char *kaddr = page_address(page); char *kaddr = page_address(page);
unsigned from = ((char*)dir - kaddr) & ~(UFS_SB(sb)->s_uspi->s_dirblksize - 1); unsigned from = ((char*)dir - kaddr) & ~(UFS_SB(sb)->s_uspi->s_dirblksize - 1);
unsigned to = ((char*)dir - kaddr) + fs16_to_cpu(sb, dir->d_reclen); unsigned to = ((char*)dir - kaddr) + fs16_to_cpu(sb, dir->d_reclen);
loff_t pos;
struct ufs_dir_entry *pde = NULL; struct ufs_dir_entry *pde = NULL;
struct ufs_dir_entry *de = (struct ufs_dir_entry *) (kaddr + from); struct ufs_dir_entry *de = (struct ufs_dir_entry *) (kaddr + from);
int err; int err;
...@@ -532,13 +545,16 @@ int ufs_delete_entry(struct inode *inode, struct ufs_dir_entry *dir, ...@@ -532,13 +545,16 @@ int ufs_delete_entry(struct inode *inode, struct ufs_dir_entry *dir,
} }
if (pde) if (pde)
from = (char*)pde - (char*)page_address(page); from = (char*)pde - (char*)page_address(page);
pos = page_offset(page) + from;
lock_page(page); lock_page(page);
err = mapping->a_ops->prepare_write(NULL, page, from, to); err = __ufs_write_begin(NULL, mapping, pos, to - from,
AOP_FLAG_UNINTERRUPTIBLE, &page, NULL);
BUG_ON(err); BUG_ON(err);
if (pde) if (pde)
pde->d_reclen = cpu_to_fs16(sb, to-from); pde->d_reclen = cpu_to_fs16(sb, to - from);
dir->d_ino = 0; dir->d_ino = 0;
err = ufs_commit_chunk(page, from, to); err = ufs_commit_chunk(page, pos, to - from);
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);
out: out:
...@@ -559,14 +575,15 @@ int ufs_make_empty(struct inode * inode, struct inode *dir) ...@@ -559,14 +575,15 @@ int ufs_make_empty(struct inode * inode, struct inode *dir)
if (!page) if (!page)
return -ENOMEM; return -ENOMEM;
kmap(page);
err = mapping->a_ops->prepare_write(NULL, page, 0, chunk_size); err = __ufs_write_begin(NULL, mapping, 0, chunk_size,
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);
...@@ -584,10 +601,10 @@ int ufs_make_empty(struct inode * inode, struct inode *dir) ...@@ -584,10 +601,10 @@ int ufs_make_empty(struct inode * inode, struct inode *dir)
de->d_reclen = cpu_to_fs16(sb, chunk_size - UFS_DIR_REC_LEN(1)); de->d_reclen = cpu_to_fs16(sb, chunk_size - UFS_DIR_REC_LEN(1));
ufs_set_de_namlen(sb, de, 2); ufs_set_de_namlen(sb, de, 2);
strcpy (de->d_name, ".."); strcpy (de->d_name, "..");
kunmap(page);
err = ufs_commit_chunk(page, 0, chunk_size); err = ufs_commit_chunk(page, 0, chunk_size);
fail: fail:
kunmap(page);
page_cache_release(page); page_cache_release(page);
return err; return err;
} }
......
...@@ -558,24 +558,39 @@ static int ufs_writepage(struct page *page, struct writeback_control *wbc) ...@@ -558,24 +558,39 @@ static int ufs_writepage(struct page *page, struct writeback_control *wbc)
{ {
return block_write_full_page(page,ufs_getfrag_block,wbc); return block_write_full_page(page,ufs_getfrag_block,wbc);
} }
static int ufs_readpage(struct file *file, struct page *page) static int ufs_readpage(struct file *file, struct page *page)
{ {
return block_read_full_page(page,ufs_getfrag_block); return block_read_full_page(page,ufs_getfrag_block);
} }
static int ufs_prepare_write(struct file *file, struct page *page, unsigned from, unsigned to)
int __ufs_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,ufs_getfrag_block); return block_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
ufs_getfrag_block);
} }
static int ufs_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags,
struct page **pagep, void **fsdata)
{
*pagep = NULL;
return __ufs_write_begin(file, mapping, pos, len, flags, pagep, fsdata);
}
static sector_t ufs_bmap(struct address_space *mapping, sector_t block) static sector_t ufs_bmap(struct address_space *mapping, sector_t block)
{ {
return generic_block_bmap(mapping,block,ufs_getfrag_block); return generic_block_bmap(mapping,block,ufs_getfrag_block);
} }
const struct address_space_operations ufs_aops = { const struct address_space_operations ufs_aops = {
.readpage = ufs_readpage, .readpage = ufs_readpage,
.writepage = ufs_writepage, .writepage = ufs_writepage,
.sync_page = block_sync_page, .sync_page = block_sync_page,
.prepare_write = ufs_prepare_write, .write_begin = ufs_write_begin,
.commit_write = generic_commit_write, .write_end = generic_write_end,
.bmap = ufs_bmap .bmap = ufs_bmap
}; };
......
...@@ -231,6 +231,9 @@ ufs_set_inode_gid(struct super_block *sb, struct ufs_inode *inode, u32 value) ...@@ -231,6 +231,9 @@ ufs_set_inode_gid(struct super_block *sb, struct ufs_inode *inode, u32 value)
extern dev_t ufs_get_inode_dev(struct super_block *, struct ufs_inode_info *); extern dev_t ufs_get_inode_dev(struct super_block *, struct ufs_inode_info *);
extern void ufs_set_inode_dev(struct super_block *, struct ufs_inode_info *, dev_t); extern void ufs_set_inode_dev(struct super_block *, struct ufs_inode_info *, dev_t);
extern int __ufs_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags,
struct page **pagep, void **fsdata);
/* /*
* These functions manipulate ufs buffers * These functions manipulate ufs buffers
......
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