Commit 2f444347 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'pull-minix' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull minixfs updates from Al Viro:
 "minixfs kmap_local_page() switchover and related fixes - very similar
  to sysv series"

* tag 'pull-minix' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  minixfs: switch to kmap_local_page()
  minixfs: Use dir_put_page() in minix_unlink() and minix_rename()
  minixfs: change the signature of dir_get_page()
  minixfs: use offset_in_page()
parents 5b9b4161 41e9a7fa
...@@ -26,12 +26,6 @@ const struct file_operations minix_dir_operations = { ...@@ -26,12 +26,6 @@ const struct file_operations minix_dir_operations = {
.fsync = generic_file_fsync, .fsync = generic_file_fsync,
}; };
static inline void dir_put_page(struct page *page)
{
kunmap(page);
put_page(page);
}
/* /*
* Return the offset into page `page_nr' of the last valid * Return the offset into page `page_nr' of the last valid
* byte in that page, plus one. * byte in that page, plus one.
...@@ -70,13 +64,14 @@ static int minix_handle_dirsync(struct inode *dir) ...@@ -70,13 +64,14 @@ static int minix_handle_dirsync(struct inode *dir)
return err; return err;
} }
static struct page * dir_get_page(struct inode *dir, unsigned long n) static void *dir_get_page(struct inode *dir, unsigned long n, struct page **p)
{ {
struct address_space *mapping = dir->i_mapping; struct address_space *mapping = dir->i_mapping;
struct page *page = read_mapping_page(mapping, n, NULL); struct page *page = read_mapping_page(mapping, n, NULL);
if (!IS_ERR(page)) if (IS_ERR(page))
kmap(page); return ERR_CAST(page);
return page; *p = page;
return kmap_local_page(page);
} }
static inline void *minix_next_entry(void *de, struct minix_sb_info *sbi) static inline void *minix_next_entry(void *de, struct minix_sb_info *sbi)
...@@ -104,11 +99,11 @@ static int minix_readdir(struct file *file, struct dir_context *ctx) ...@@ -104,11 +99,11 @@ static int minix_readdir(struct file *file, struct dir_context *ctx)
for ( ; n < npages; n++, offset = 0) { for ( ; n < npages; n++, offset = 0) {
char *p, *kaddr, *limit; char *p, *kaddr, *limit;
struct page *page = dir_get_page(inode, n); struct page *page;
if (IS_ERR(page)) kaddr = dir_get_page(inode, n, &page);
if (IS_ERR(kaddr))
continue; continue;
kaddr = (char *)page_address(page);
p = kaddr+offset; p = kaddr+offset;
limit = kaddr + minix_last_byte(inode, n) - chunk_size; limit = kaddr + minix_last_byte(inode, n) - chunk_size;
for ( ; p <= limit; p = minix_next_entry(p, sbi)) { for ( ; p <= limit; p = minix_next_entry(p, sbi)) {
...@@ -127,13 +122,13 @@ static int minix_readdir(struct file *file, struct dir_context *ctx) ...@@ -127,13 +122,13 @@ static int minix_readdir(struct file *file, struct dir_context *ctx)
unsigned l = strnlen(name, sbi->s_namelen); unsigned l = strnlen(name, sbi->s_namelen);
if (!dir_emit(ctx, name, l, if (!dir_emit(ctx, name, l,
inumber, DT_UNKNOWN)) { inumber, DT_UNKNOWN)) {
dir_put_page(page); unmap_and_put_page(page, p);
return 0; return 0;
} }
} }
ctx->pos += chunk_size; ctx->pos += chunk_size;
} }
dir_put_page(page); unmap_and_put_page(page, kaddr);
} }
return 0; return 0;
} }
...@@ -173,11 +168,10 @@ minix_dirent *minix_find_entry(struct dentry *dentry, struct page **res_page) ...@@ -173,11 +168,10 @@ minix_dirent *minix_find_entry(struct dentry *dentry, struct page **res_page)
for (n = 0; n < npages; n++) { for (n = 0; n < npages; n++) {
char *kaddr, *limit; char *kaddr, *limit;
page = dir_get_page(dir, n); kaddr = dir_get_page(dir, n, &page);
if (IS_ERR(page)) if (IS_ERR(kaddr))
continue; continue;
kaddr = (char*)page_address(page);
limit = kaddr + minix_last_byte(dir, n) - sbi->s_dirsize; limit = kaddr + minix_last_byte(dir, n) - sbi->s_dirsize;
for (p = kaddr; p <= limit; p = minix_next_entry(p, sbi)) { for (p = kaddr; p <= limit; p = minix_next_entry(p, sbi)) {
if (sbi->s_version == MINIX_V3) { if (sbi->s_version == MINIX_V3) {
...@@ -194,7 +188,7 @@ minix_dirent *minix_find_entry(struct dentry *dentry, struct page **res_page) ...@@ -194,7 +188,7 @@ minix_dirent *minix_find_entry(struct dentry *dentry, struct page **res_page)
if (namecompare(namelen, sbi->s_namelen, name, namx)) if (namecompare(namelen, sbi->s_namelen, name, namx))
goto found; goto found;
} }
dir_put_page(page); unmap_and_put_page(page, kaddr);
} }
return NULL; return NULL;
...@@ -229,12 +223,10 @@ int minix_add_link(struct dentry *dentry, struct inode *inode) ...@@ -229,12 +223,10 @@ int minix_add_link(struct dentry *dentry, struct inode *inode)
for (n = 0; n <= npages; n++) { for (n = 0; n <= npages; n++) {
char *limit, *dir_end; char *limit, *dir_end;
page = dir_get_page(dir, n); kaddr = dir_get_page(dir, n, &page);
err = PTR_ERR(page); if (IS_ERR(kaddr))
if (IS_ERR(page)) return PTR_ERR(kaddr);
goto out;
lock_page(page); lock_page(page);
kaddr = (char*)page_address(page);
dir_end = kaddr + minix_last_byte(dir, n); dir_end = kaddr + minix_last_byte(dir, n);
limit = kaddr + PAGE_SIZE - sbi->s_dirsize; limit = kaddr + PAGE_SIZE - sbi->s_dirsize;
for (p = kaddr; p <= limit; p = minix_next_entry(p, sbi)) { for (p = kaddr; p <= limit; p = minix_next_entry(p, sbi)) {
...@@ -262,13 +254,13 @@ int minix_add_link(struct dentry *dentry, struct inode *inode) ...@@ -262,13 +254,13 @@ int minix_add_link(struct dentry *dentry, struct inode *inode)
goto out_unlock; goto out_unlock;
} }
unlock_page(page); unlock_page(page);
dir_put_page(page); unmap_and_put_page(page, kaddr);
} }
BUG(); BUG();
return -EINVAL; return -EINVAL;
got_it: got_it:
pos = page_offset(page) + p - (char *)page_address(page); pos = page_offset(page) + offset_in_page(p);
err = minix_prepare_chunk(page, pos, sbi->s_dirsize); err = minix_prepare_chunk(page, pos, sbi->s_dirsize);
if (err) if (err)
goto out_unlock; goto out_unlock;
...@@ -285,8 +277,7 @@ int minix_add_link(struct dentry *dentry, struct inode *inode) ...@@ -285,8 +277,7 @@ int minix_add_link(struct dentry *dentry, struct inode *inode)
mark_inode_dirty(dir); mark_inode_dirty(dir);
err = minix_handle_dirsync(dir); err = minix_handle_dirsync(dir);
out_put: out_put:
dir_put_page(page); unmap_and_put_page(page, kaddr);
out:
return err; return err;
out_unlock: out_unlock:
unlock_page(page); unlock_page(page);
...@@ -296,8 +287,7 @@ int minix_add_link(struct dentry *dentry, struct inode *inode) ...@@ -296,8 +287,7 @@ int minix_add_link(struct dentry *dentry, struct inode *inode)
int minix_delete_entry(struct minix_dir_entry *de, struct page *page) int minix_delete_entry(struct minix_dir_entry *de, struct page *page)
{ {
struct inode *inode = page->mapping->host; struct inode *inode = page->mapping->host;
char *kaddr = page_address(page); loff_t pos = page_offset(page) + offset_in_page(de);
loff_t pos = page_offset(page) + (char*)de - kaddr;
struct minix_sb_info *sbi = minix_sb(inode->i_sb); struct minix_sb_info *sbi = minix_sb(inode->i_sb);
unsigned len = sbi->s_dirsize; unsigned len = sbi->s_dirsize;
int err; int err;
...@@ -333,7 +323,7 @@ int minix_make_empty(struct inode *inode, struct inode *dir) ...@@ -333,7 +323,7 @@ int minix_make_empty(struct inode *inode, struct inode *dir)
goto fail; goto fail;
} }
kaddr = kmap_atomic(page); kaddr = kmap_local_page(page);
memset(kaddr, 0, PAGE_SIZE); memset(kaddr, 0, PAGE_SIZE);
if (sbi->s_version == MINIX_V3) { if (sbi->s_version == MINIX_V3) {
...@@ -353,7 +343,7 @@ int minix_make_empty(struct inode *inode, struct inode *dir) ...@@ -353,7 +343,7 @@ int minix_make_empty(struct inode *inode, struct inode *dir)
de->inode = dir->i_ino; de->inode = dir->i_ino;
strcpy(de->name, ".."); strcpy(de->name, "..");
} }
kunmap_atomic(kaddr); kunmap_local(kaddr);
dir_commit_chunk(page, 0, 2 * sbi->s_dirsize); dir_commit_chunk(page, 0, 2 * sbi->s_dirsize);
err = minix_handle_dirsync(inode); err = minix_handle_dirsync(inode);
...@@ -370,17 +360,16 @@ int minix_empty_dir(struct inode * inode) ...@@ -370,17 +360,16 @@ int minix_empty_dir(struct inode * inode)
struct page *page = NULL; struct page *page = NULL;
unsigned long i, npages = dir_pages(inode); unsigned long i, npages = dir_pages(inode);
struct minix_sb_info *sbi = minix_sb(inode->i_sb); struct minix_sb_info *sbi = minix_sb(inode->i_sb);
char *name; char *name, *kaddr;
__u32 inumber; __u32 inumber;
for (i = 0; i < npages; i++) { for (i = 0; i < npages; i++) {
char *p, *kaddr, *limit; char *p, *limit;
page = dir_get_page(inode, i); kaddr = dir_get_page(inode, i, &page);
if (IS_ERR(page)) if (IS_ERR(kaddr))
continue; continue;
kaddr = (char *)page_address(page);
limit = kaddr + minix_last_byte(inode, i) - sbi->s_dirsize; limit = kaddr + minix_last_byte(inode, i) - sbi->s_dirsize;
for (p = kaddr; p <= limit; p = minix_next_entry(p, sbi)) { for (p = kaddr; p <= limit; p = minix_next_entry(p, sbi)) {
if (sbi->s_version == MINIX_V3) { if (sbi->s_version == MINIX_V3) {
...@@ -406,12 +395,12 @@ int minix_empty_dir(struct inode * inode) ...@@ -406,12 +395,12 @@ int minix_empty_dir(struct inode * inode)
goto not_empty; goto not_empty;
} }
} }
dir_put_page(page); unmap_and_put_page(page, kaddr);
} }
return 1; return 1;
not_empty: not_empty:
dir_put_page(page); unmap_and_put_page(page, kaddr);
return 0; return 0;
} }
...@@ -421,8 +410,7 @@ int minix_set_link(struct minix_dir_entry *de, struct page *page, ...@@ -421,8 +410,7 @@ int minix_set_link(struct minix_dir_entry *de, struct page *page,
{ {
struct inode *dir = page->mapping->host; struct inode *dir = page->mapping->host;
struct minix_sb_info *sbi = minix_sb(dir->i_sb); struct minix_sb_info *sbi = minix_sb(dir->i_sb);
loff_t pos = page_offset(page) + loff_t pos = page_offset(page) + offset_in_page(de);
(char *)de-(char*)page_address(page);
int err; int err;
lock_page(page); lock_page(page);
...@@ -443,15 +431,12 @@ int minix_set_link(struct minix_dir_entry *de, struct page *page, ...@@ -443,15 +431,12 @@ int minix_set_link(struct minix_dir_entry *de, struct page *page,
struct minix_dir_entry * minix_dotdot (struct inode *dir, struct page **p) struct minix_dir_entry * minix_dotdot (struct inode *dir, struct page **p)
{ {
struct page *page = dir_get_page(dir, 0);
struct minix_sb_info *sbi = minix_sb(dir->i_sb); struct minix_sb_info *sbi = minix_sb(dir->i_sb);
struct minix_dir_entry *de = NULL; struct minix_dir_entry *de = dir_get_page(dir, 0, p);
if (!IS_ERR(page)) { if (!IS_ERR(de))
de = minix_next_entry(page_address(page), sbi); return minix_next_entry(de, sbi);
*p = page; return NULL;
}
return de;
} }
ino_t minix_inode_by_name(struct dentry *dentry) ino_t minix_inode_by_name(struct dentry *dentry)
...@@ -469,7 +454,7 @@ ino_t minix_inode_by_name(struct dentry *dentry) ...@@ -469,7 +454,7 @@ ino_t minix_inode_by_name(struct dentry *dentry)
res = ((minix3_dirent *) de)->inode; res = ((minix3_dirent *) de)->inode;
else else
res = de->inode; res = de->inode;
dir_put_page(page); unmap_and_put_page(page, de);
} }
return res; return res;
} }
...@@ -149,8 +149,7 @@ static int minix_unlink(struct inode * dir, struct dentry *dentry) ...@@ -149,8 +149,7 @@ static int minix_unlink(struct inode * dir, struct dentry *dentry)
if (!de) if (!de)
return -ENOENT; return -ENOENT;
err = minix_delete_entry(de, page); err = minix_delete_entry(de, page);
kunmap(page); unmap_and_put_page(page, de);
put_page(page);
if (err) if (err)
return err; return err;
...@@ -242,13 +241,10 @@ static int minix_rename(struct mnt_idmap *idmap, ...@@ -242,13 +241,10 @@ static int minix_rename(struct mnt_idmap *idmap,
inode_dec_link_count(old_dir); inode_dec_link_count(old_dir);
} }
out_dir: out_dir:
if (dir_de) { if (dir_de)
kunmap(dir_page); unmap_and_put_page(dir_page, dir_de);
put_page(dir_page);
}
out_old: out_old:
kunmap(old_page); unmap_and_put_page(old_page, old_de);
put_page(old_page);
out: out:
return err; return err;
} }
......
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