Commit 4a66af9e authored by Nick Piggin's avatar Nick Piggin Committed by Linus Torvalds

minixfs: convert to new aops

Signed-off-by: default avatarNick Piggin <npiggin@suse.de>
Cc: Andries Brouwer <Andries.Brouwer@cwi.nl>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 26a6441a
...@@ -9,8 +9,10 @@ ...@@ -9,8 +9,10 @@
*/ */
#include "minix.h" #include "minix.h"
#include <linux/buffer_head.h>
#include <linux/highmem.h> #include <linux/highmem.h>
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/swap.h>
typedef struct minix_dir_entry minix_dirent; typedef struct minix_dir_entry minix_dirent;
typedef struct minix3_dir_entry minix3_dirent; typedef struct minix3_dir_entry minix3_dirent;
...@@ -48,11 +50,17 @@ static inline unsigned long dir_pages(struct inode *inode) ...@@ -48,11 +50,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
...@@ -220,7 +228,7 @@ int minix_add_link(struct dentry *dentry, struct inode *inode) ...@@ -220,7 +228,7 @@ int minix_add_link(struct dentry *dentry, struct inode *inode)
char *kaddr, *p; char *kaddr, *p;
minix_dirent *de; minix_dirent *de;
minix3_dirent *de3; minix3_dirent *de3;
unsigned from, to; loff_t pos;
int err; int err;
char *namx = NULL; char *namx = NULL;
__u32 inumber; __u32 inumber;
...@@ -272,9 +280,9 @@ int minix_add_link(struct dentry *dentry, struct inode *inode) ...@@ -272,9 +280,9 @@ int minix_add_link(struct dentry *dentry, struct inode *inode)
return -EINVAL; return -EINVAL;
got_it: got_it:
from = p - (char*)page_address(page); pos = (page->index >> PAGE_CACHE_SHIFT) + p - (char*)page_address(page);
to = from + sbi->s_dirsize; err = __minix_write_begin(NULL, page->mapping, pos, sbi->s_dirsize,
err = page->mapping->a_ops->prepare_write(NULL, page, from, to); AOP_FLAG_UNINTERRUPTIBLE, &page, NULL);
if (err) if (err)
goto out_unlock; goto out_unlock;
memcpy (namx, name, namelen); memcpy (namx, name, namelen);
...@@ -285,7 +293,7 @@ int minix_add_link(struct dentry *dentry, struct inode *inode) ...@@ -285,7 +293,7 @@ int minix_add_link(struct dentry *dentry, struct inode *inode)
memset (namx + namelen, 0, sbi->s_dirsize - namelen - 2); memset (namx + namelen, 0, sbi->s_dirsize - namelen - 2);
de->inode = inode->i_ino; de->inode = inode->i_ino;
} }
err = dir_commit_chunk(page, from, to); err = dir_commit_chunk(page, pos, sbi->s_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_put: out_put:
...@@ -302,15 +310,16 @@ int minix_delete_entry(struct minix_dir_entry *de, struct page *page) ...@@ -302,15 +310,16 @@ int minix_delete_entry(struct minix_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 = page_address(page); char *kaddr = page_address(page);
unsigned from = (char*)de - kaddr; loff_t pos = page_offset(page) + (char*)de - kaddr;
unsigned to = from + minix_sb(inode->i_sb)->s_dirsize; unsigned len = minix_sb(inode->i_sb)->s_dirsize;
int err; int err;
lock_page(page); lock_page(page);
err = mapping->a_ops->prepare_write(NULL, page, from, to); err = __minix_write_begin(NULL, mapping, pos, len,
AOP_FLAG_UNINTERRUPTIBLE, &page, NULL);
if (err == 0) { if (err == 0) {
de->inode = 0; de->inode = 0;
err = dir_commit_chunk(page, from, to); err = dir_commit_chunk(page, pos, len);
} else { } else {
unlock_page(page); unlock_page(page);
} }
...@@ -330,7 +339,8 @@ int minix_make_empty(struct inode *inode, struct inode *dir) ...@@ -330,7 +339,8 @@ int minix_make_empty(struct inode *inode, struct inode *dir)
if (!page) if (!page)
return -ENOMEM; return -ENOMEM;
err = mapping->a_ops->prepare_write(NULL, page, 0, 2 * sbi->s_dirsize); err = __minix_write_begin(NULL, mapping, 0, 2 * sbi->s_dirsize,
AOP_FLAG_UNINTERRUPTIBLE, &page, NULL);
if (err) { if (err) {
unlock_page(page); unlock_page(page);
goto fail; goto fail;
...@@ -421,17 +431,20 @@ int minix_empty_dir(struct inode * inode) ...@@ -421,17 +431,20 @@ int minix_empty_dir(struct inode * inode)
void minix_set_link(struct minix_dir_entry *de, struct page *page, void minix_set_link(struct minix_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;
struct inode *dir = mapping->host;
struct minix_sb_info *sbi = minix_sb(dir->i_sb); struct minix_sb_info *sbi = minix_sb(dir->i_sb);
unsigned from = (char *)de-(char*)page_address(page); loff_t pos = page_offset(page) +
unsigned to = from + sbi->s_dirsize; (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 = __minix_write_begin(NULL, mapping, pos, sbi->s_dirsize,
AOP_FLAG_UNINTERRUPTIBLE, &page, NULL);
if (err == 0) { if (err == 0) {
de->inode = inode->i_ino; de->inode = inode->i_ino;
err = dir_commit_chunk(page, from, to); err = dir_commit_chunk(page, pos, sbi->s_dirsize);
} else { } else {
unlock_page(page); unlock_page(page);
} }
......
...@@ -346,24 +346,39 @@ static int minix_writepage(struct page *page, struct writeback_control *wbc) ...@@ -346,24 +346,39 @@ static int minix_writepage(struct page *page, struct writeback_control *wbc)
{ {
return block_write_full_page(page, minix_get_block, wbc); return block_write_full_page(page, minix_get_block, wbc);
} }
static int minix_readpage(struct file *file, struct page *page) static int minix_readpage(struct file *file, struct page *page)
{ {
return block_read_full_page(page,minix_get_block); return block_read_full_page(page,minix_get_block);
} }
static int minix_prepare_write(struct file *file, struct page *page, unsigned from, unsigned to)
int __minix_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,minix_get_block); return block_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
minix_get_block);
} }
static int minix_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags,
struct page **pagep, void **fsdata)
{
*pagep = NULL;
return __minix_write_begin(file, mapping, pos, len, flags, pagep, fsdata);
}
static sector_t minix_bmap(struct address_space *mapping, sector_t block) static sector_t minix_bmap(struct address_space *mapping, sector_t block)
{ {
return generic_block_bmap(mapping,block,minix_get_block); return generic_block_bmap(mapping,block,minix_get_block);
} }
static const struct address_space_operations minix_aops = { static const struct address_space_operations minix_aops = {
.readpage = minix_readpage, .readpage = minix_readpage,
.writepage = minix_writepage, .writepage = minix_writepage,
.sync_page = block_sync_page, .sync_page = block_sync_page,
.prepare_write = minix_prepare_write, .write_begin = minix_write_begin,
.commit_write = generic_commit_write, .write_end = generic_write_end,
.bmap = minix_bmap .bmap = minix_bmap
}; };
......
...@@ -54,6 +54,9 @@ extern int minix_new_block(struct inode * inode); ...@@ -54,6 +54,9 @@ extern int minix_new_block(struct inode * inode);
extern void minix_free_block(struct inode *inode, unsigned long block); extern void minix_free_block(struct inode *inode, unsigned long block);
extern unsigned long minix_count_free_blocks(struct minix_sb_info *sbi); extern unsigned long minix_count_free_blocks(struct minix_sb_info *sbi);
extern int minix_getattr(struct vfsmount *, struct dentry *, struct kstat *); extern int minix_getattr(struct vfsmount *, struct dentry *, struct kstat *);
extern int __minix_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags,
struct page **pagep, void **fsdata);
extern void V1_minix_truncate(struct inode *); extern void V1_minix_truncate(struct inode *);
extern void V2_minix_truncate(struct inode *); extern void V2_minix_truncate(struct inode *);
......
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