* [PATCH 0/17] fs: cleanup single page synchronous read interface
@ 2007-04-12 2:49 Nate Diller
2007-04-12 2:49 ` [PATCH 7/17] jffs2: convert jffs2_gc_fetch_page to read_cache_page Nate Diller
` (16 more replies)
0 siblings, 17 replies; 33+ messages in thread
From: Nate Diller @ 2007-04-12 2:49 UTC (permalink / raw)
To: Andrew Morton, Alexander Viro, Christoph Hellwig, Roman Zippel,
Mikulas Patocka, David Woodhouse, Dave Kleikamp,
Anton Altaparmakov, Evgeniy Dushistov
Cc: linux-kernel, linux-fsdevel, reiserfs-dev
Nick Piggin recently changed the read_cache_page interface to be
synchronous, which is pretty much what the file systems want anyway. Turns
out that they have more in common than that, though, and some of them want
to be able to get an uptodate *locked* page. Many of them want a kmapped
page, which is uptodate and unlocked, and they all have their own individual
helper functions to achieve this.
Since the helper functions are so similar, this patch just combines them
into a small number of simple library functions, which call read_cache_page
(renamed to __read_cache_page because it now returns a locked page). The
immediate result is a vast reduction in the number of fs-specific helper
functions. The secondary goal is to reduce the number of places the page
lock is taken, and eliminate a lot of PageUptodate and PageError checks.
The file systems that still use PageChecked now have checker functions that
return an error if the page is corrupted or has some other error. This
simplifies the logic since the checker function is not part of any helper
function anymore.
Compile tested on x86_64.
Signed-off-by: Nate Diller <nate.diller@gmail.com>
---
drivers/mtd/devices/block2mtd.c | 28 +------
fs/afs/dir.c | 56 +++-----------
fs/afs/mntpt.c | 10 --
fs/cramfs/inode.c | 3
fs/ext2/dir.c | 82 ++++++++-------------
fs/freevxfs/vxfs_extern.h | 1
fs/freevxfs/vxfs_inode.c | 2
fs/freevxfs/vxfs_lookup.c | 4 -
fs/freevxfs/vxfs_subr.c | 33 --------
fs/hfs/bnode.c | 4 -
fs/hfsplus/bnode.c | 4 -
fs/jffs2/fs.c | 27 -------
fs/jffs2/gc.c | 15 ++-
fs/jfs/jfs_metapage.c | 5 -
fs/minix/dir.c | 59 ++++-----------
fs/ntfs/aops.h | 67 -----------------
fs/ntfs/bitmap.c | 8 +-
fs/ntfs/dir.c | 65 ++++++-----------
fs/ntfs/index.c | 12 +--
fs/ntfs/lcnalloc.c | 6 -
fs/ntfs/logfile.c | 12 +--
fs/ntfs/mft.c | 53 +++++--------
fs/ntfs/super.c | 38 ++++-----
fs/ntfs/usnjrnl.c | 4 -
fs/partitions/check.c | 14 +--
fs/reiser4/plugin/file/tail_conversion.c | 8 --
fs/reiser4/plugin/item/extent_file_ops.c | 9 --
fs/reiserfs/xattr.c | 48 ++----------
fs/sysv/dir.c | 19 +---
fs/ufs/balloc.c | 8 +-
fs/ufs/dir.c | 90 +++++++++--------------
fs/ufs/truncate.c | 8 +-
fs/ufs/util.c | 52 -------------
fs/ufs/util.h | 10 --
include/linux/pagemap.h | 53 ++++++++++++-
mm/filemap.c | 118 +++++++------------------------
36 files changed, 315 insertions(+), 720 deletions(-)
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH 2/17] fs: introduce new read_cache_page interface
2007-04-12 2:49 [PATCH 0/17] fs: cleanup single page synchronous read interface Nate Diller
` (9 preceding siblings ...)
2007-04-12 2:49 ` [PATCH 15/17] sysv: convert dir_get_page " Nate Diller
@ 2007-04-12 2:49 ` Nate Diller
2007-04-12 2:49 ` [PATCH 8/17] jfs: use locking read_mapping_page Nate Diller
` (5 subsequent siblings)
16 siblings, 0 replies; 33+ messages in thread
From: Nate Diller @ 2007-04-12 2:49 UTC (permalink / raw)
To: Andrew Morton, Alexander Viro, Christoph Hellwig, Roman Zippel,
Mikulas Patocka, David Woodhouse, Dave Kleikamp,
Anton Altaparmakov, Evgeniy Dushistov
Cc: linux-kernel, linux-fsdevel, reiserfs-dev
Export a single version of read_cache_page, which returns with a locked,
Uptodate page or a synchronous error, and use inline helper functions to
replicate the old behavior. Also, introduce new helper functions for the
most common file system uses, which include kmapping the page, as well as
needing to keep the page locked. These changes collectively eliminate a
substantial amount of private fs logic in favor of generic code.
It also simplifies filemap.c significantly, by assuming that callers want
synchronous behavior, which is true for all callers anyway except one.
Signed-off-by: Nate Diller <nate.diller@gmail.com>
---
diff -urpN -X dontdiff linux-2.6.21-rc6-mm1/include/linux/pagemap.h linux-2.6.21-rc6-mm1-test/include/linux/pagemap.h
--- linux-2.6.21-rc6-mm1/include/linux/pagemap.h 2007-04-11 14:22:19.000000000 -0700
+++ linux-2.6.21-rc6-mm1-test/include/linux/pagemap.h 2007-04-11 14:29:31.000000000 -0700
@@ -108,21 +108,30 @@ static inline struct page *grab_cache_pa
extern struct page * grab_cache_page_nowait(struct address_space *mapping,
unsigned long index);
-extern struct page * read_cache_page_async(struct address_space *mapping,
- unsigned long index, filler_t *filler,
- void *data);
-extern struct page * read_cache_page(struct address_space *mapping,
+extern struct page *__read_cache_page(struct address_space *mapping,
unsigned long index, filler_t *filler,
void *data);
extern int read_cache_pages(struct address_space *mapping,
struct list_head *pages, filler_t *filler, void *data);
-static inline struct page *read_mapping_page_async(
- struct address_space *mapping,
+void fastcall unlock_page(struct page *page);
+static inline struct page *read_cache_page(struct address_space *mapping,
+ unsigned long index, filler_t *filler,
+ void *data)
+{
+ struct page *page;
+
+ page = __read_cache_page(mapping, index, filler, data);
+ if (!IS_ERR(page))
+ unlock_page(page);
+ return page;
+}
+
+static inline struct page *__read_mapping_page(struct address_space *mapping,
unsigned long index, void *data)
{
filler_t *filler = (filler_t *)mapping->a_ops->readpage;
- return read_cache_page_async(mapping, index, filler, data);
+ return __read_cache_page(mapping, index, filler, data);
}
static inline struct page *read_mapping_page(struct address_space *mapping,
@@ -132,6 +141,36 @@ static inline struct page *read_mapping_
return read_cache_page(mapping, index, filler, data);
}
+static inline struct page *__read_kmap_page(struct address_space *mapping,
+ unsigned long index)
+{
+ struct page *page = __read_mapping_page(mapping, index, NULL);
+ if (!IS_ERR(page))
+ kmap(page);
+ return page;
+}
+
+static inline struct page *read_kmap_page(struct address_space *mapping,
+ unsigned long index)
+{
+ struct page *page = read_mapping_page(mapping, index, NULL);
+ if (!IS_ERR(page))
+ kmap(page);
+ return page;
+}
+
+static inline void put_kmapped_page(struct page *page)
+{
+ kunmap(page);
+ page_cache_release(page);
+}
+
+static inline void put_locked_page(struct page *page)
+{
+ unlock_page(page);
+ put_kmapped_page(page);
+}
+
int add_to_page_cache(struct page *page, struct address_space *mapping,
unsigned long index, gfp_t gfp_mask);
int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
diff -urpN -X dontdiff linux-2.6.21-rc6-mm1/mm/filemap.c linux-2.6.21-rc6-mm1-test/mm/filemap.c
--- linux-2.6.21-rc6-mm1/mm/filemap.c 2007-04-11 14:26:42.000000000 -0700
+++ linux-2.6.21-rc6-mm1-test/mm/filemap.c 2007-04-10 21:46:03.000000000 -0700
@@ -1600,115 +1600,53 @@ int generic_file_readonly_mmap(struct fi
EXPORT_SYMBOL(generic_file_mmap);
EXPORT_SYMBOL(generic_file_readonly_mmap);
-static struct page *__read_cache_page(struct address_space *mapping,
- unsigned long index,
- int (*filler)(void *,struct page*),
- void *data)
-{
- struct page *page, *cached_page = NULL;
- int err;
-repeat:
- page = find_get_page(mapping, index);
- if (!page) {
- if (!cached_page) {
- cached_page = page_cache_alloc_cold(mapping);
- if (!cached_page)
- return ERR_PTR(-ENOMEM);
- }
- err = add_to_page_cache_lru(cached_page, mapping,
- index, GFP_KERNEL);
- if (err == -EEXIST)
- goto repeat;
- if (err < 0) {
- /* Presumably ENOMEM for radix tree node */
- page_cache_release(cached_page);
- return ERR_PTR(err);
- }
- page = cached_page;
- cached_page = NULL;
- err = filler(data, page);
- if (err < 0) {
- page_cache_release(page);
- page = ERR_PTR(err);
- }
- }
- if (cached_page)
- page_cache_release(cached_page);
- return page;
-}
-
-/*
- * Same as read_cache_page, but don't wait for page to become unlocked
- * after submitting it to the filler.
+/**
+ * __read_cache_page - read into page cache, fill it if needed
+ * @mapping: the page's address_space
+ * @index: the page index
+ * @filler: function to perform the read
+ * @data: destination for read data
+ *
+ * Read into the page cache. If a page already exists, and PageUptodate() is
+ * not set, try to fill the page then wait for I/O.
+ *
+ * Returns a locked, uptodate page, or an error.
*/
-struct page *read_cache_page_async(struct address_space *mapping,
+struct page *__read_cache_page(struct address_space *mapping,
unsigned long index,
int (*filler)(void *,struct page*),
void *data)
{
struct page *page;
+ int gfp_mask = mapping_gfp_mask(mapping)|__GFP_COLD;
int err;
-
-retry:
- page = __read_cache_page(mapping, index, filler, data);
- if (IS_ERR(page))
- goto out;
+repeat:
+ page = find_or_create_page(mapping, index, gfp_mask);
mark_page_accessed(page);
if (PageUptodate(page))
- goto out;
+ return page;
- lock_page(page);
- if (!page->mapping) {
- unlock_page(page);
- page_cache_release(page);
- goto retry;
- }
- if (PageUptodate(page)) {
- unlock_page(page);
- goto out;
- }
err = filler(data, page);
if (err < 0) {
page_cache_release(page);
- page = ERR_PTR(err);
+ return ERR_PTR(err);
}
- out:
- mark_page_accessed(page);
- return page;
-}
-EXPORT_SYMBOL(read_cache_page_async);
-/**
- * read_cache_page - read into page cache, fill it if needed
- * @mapping: the page's address_space
- * @index: the page index
- * @filler: function to perform the read
- * @data: destination for read data
- *
- * Read into the page cache. If a page already exists, and PageUptodate() is
- * not set, try to fill the page then wait for it to become unlocked.
- *
- * If the page does not get brought uptodate, return -EIO.
- */
-struct page *read_cache_page(struct address_space *mapping,
- unsigned long index,
- int (*filler)(void *,struct page*),
- void *data)
-{
- struct page *page;
+ lock_page(page);
+ if (PageUptodate(page))
+ return page;
- page = read_cache_page_async(mapping, index, filler, data);
- if (IS_ERR(page))
- goto out;
- wait_on_page_locked(page);
- if (!PageUptodate(page)) {
+ if (!page->mapping) {
+ unlock_page(page);
page_cache_release(page);
- page = ERR_PTR(-EIO);
+ goto repeat;
}
- out:
- return page;
+
+ unlock_page(page);
+ page_cache_release(page);
+ return ERR_PTR(-EIO);
}
-EXPORT_SYMBOL(read_cache_page);
+EXPORT_SYMBOL(__read_cache_page);
/*
* If the page was newly created, increment its refcount and add it to the
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH 4/17] ext2: convert ext2_get_page to read_kmap_page
2007-04-12 2:49 [PATCH 0/17] fs: cleanup single page synchronous read interface Nate Diller
2007-04-12 2:49 ` [PATCH 7/17] jffs2: convert jffs2_gc_fetch_page to read_cache_page Nate Diller
@ 2007-04-12 2:49 ` Nate Diller
2007-04-12 2:49 ` [PATCH 17/17] vxfs: convert vxfs_get_page " Nate Diller
` (14 subsequent siblings)
16 siblings, 0 replies; 33+ messages in thread
From: Nate Diller @ 2007-04-12 2:49 UTC (permalink / raw)
To: Andrew Morton, Alexander Viro, Christoph Hellwig, Roman Zippel,
Mikulas Patocka, David Woodhouse, Dave Kleikamp,
Anton Altaparmakov, Evgeniy Dushistov
Cc: linux-kernel, linux-fsdevel, reiserfs-dev
Replace ext2_get_page() and ext2_put_page() using the new read_kmap_page()
and put_kmapped_page() calls. Also, change the ext2_check_page() call to
return the page's error status, and update the call sites accordingly.
Signed-off-by: Nate Diller <nate.diller@gmail.com>
---
diff -urpN -X dontdiff linux-2.6.21-rc5-mm4/fs/ext2/dir.c linux-2.6.21-rc5-mm4-test/fs/ext2/dir.c
--- linux-2.6.21-rc5-mm4/fs/ext2/dir.c 2007-04-06 12:27:03.000000000 -0700
+++ linux-2.6.21-rc5-mm4-test/fs/ext2/dir.c 2007-04-06 14:34:23.000000000 -0700
@@ -35,12 +35,6 @@ static inline unsigned ext2_chunk_size(s
return inode->i_sb->s_blocksize;
}
-static inline void ext2_put_page(struct page *page)
-{
- kunmap(page);
- page_cache_release(page);
-}
-
static inline unsigned long dir_pages(struct inode *inode)
{
return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT;
@@ -74,7 +68,7 @@ static int ext2_commit_chunk(struct page
return err;
}
-static void ext2_check_page(struct page *page)
+static int ext2_check_page(struct page *page)
{
struct inode *dir = page->mapping->host;
struct super_block *sb = dir->i_sb;
@@ -86,6 +80,14 @@ static void ext2_check_page(struct page
ext2_dirent *p;
char *error;
+ if (likely(PageChecked(page))) {
+ if (likely(!PageError(page)))
+ return 0;
+
+ put_kmapped_page(page);
+ return -EIO;
+ }
+
if ((dir->i_size >> PAGE_CACHE_SHIFT) == page->index) {
limit = dir->i_size & ~PAGE_CACHE_MASK;
if (limit & (chunk_size - 1))
@@ -112,7 +114,7 @@ static void ext2_check_page(struct page
goto Eend;
out:
SetPageChecked(page);
- return;
+ return 0;
/* Too bad, we had an error */
@@ -153,24 +155,8 @@ Eend:
fail:
SetPageChecked(page);
SetPageError(page);
-}
-
-static struct page * ext2_get_page(struct inode *dir, unsigned long n)
-{
- struct address_space *mapping = dir->i_mapping;
- struct page *page = read_mapping_page(mapping, n, NULL);
- if (!IS_ERR(page)) {
- kmap(page);
- if (!PageChecked(page))
- ext2_check_page(page);
- if (PageError(page))
- goto fail;
- }
- return page;
-
-fail:
- ext2_put_page(page);
- return ERR_PTR(-EIO);
+ put_kmapped_page(page);
+ return -EIO;
}
/*
@@ -262,9 +248,9 @@ ext2_readdir (struct file * filp, void *
for ( ; n < npages; n++, offset = 0) {
char *kaddr, *limit;
ext2_dirent *de;
- struct page *page = ext2_get_page(inode, n);
+ struct page *page = read_kmap_page(inode->i_mapping, n);
- if (IS_ERR(page)) {
+ if (IS_ERR(page) || ext2_check_page(page)) {
ext2_error(sb, __FUNCTION__,
"bad page in #%lu",
inode->i_ino);
@@ -286,7 +272,7 @@ ext2_readdir (struct file * filp, void *
if (de->rec_len == 0) {
ext2_error(sb, __FUNCTION__,
"zero-length directory entry");
- ext2_put_page(page);
+ put_kmapped_page(page);
return -EIO;
}
if (de->inode) {
@@ -301,13 +287,13 @@ ext2_readdir (struct file * filp, void *
(n<<PAGE_CACHE_SHIFT) | offset,
le32_to_cpu(de->inode), d_type);
if (over) {
- ext2_put_page(page);
+ put_kmapped_page(page);
return 0;
}
}
filp->f_pos += le16_to_cpu(de->rec_len);
}
- ext2_put_page(page);
+ put_kmapped_page(page);
}
return 0;
}
@@ -344,8 +330,8 @@ struct ext2_dir_entry_2 * ext2_find_entr
n = start;
do {
char *kaddr;
- page = ext2_get_page(dir, n);
- if (!IS_ERR(page)) {
+ page = read_kmap_page(dir->i_mapping, n);
+ if (!IS_ERR(page) && !ext2_check_page(page)) {
kaddr = page_address(page);
de = (ext2_dirent *) kaddr;
kaddr += ext2_last_byte(dir, n) - reclen;
@@ -353,14 +339,14 @@ struct ext2_dir_entry_2 * ext2_find_entr
if (de->rec_len == 0) {
ext2_error(dir->i_sb, __FUNCTION__,
"zero-length directory entry");
- ext2_put_page(page);
+ put_kmapped_page(page);
goto out;
}
if (ext2_match (namelen, name, de))
goto found;
de = ext2_next_entry(de);
}
- ext2_put_page(page);
+ put_kmapped_page(page);
}
if (++n >= npages)
n = 0;
@@ -384,10 +370,10 @@ found:
struct ext2_dir_entry_2 * ext2_dotdot (struct inode *dir, struct page **p)
{
- struct page *page = ext2_get_page(dir, 0);
+ struct page *page = read_kmap_page(dir->i_mapping, 0);
ext2_dirent *de = NULL;
- if (!IS_ERR(page)) {
+ if (!IS_ERR(page) && !ext2_check_page(page)) {
de = ext2_next_entry((ext2_dirent *) page_address(page));
*p = page;
}
@@ -403,7 +389,7 @@ ino_t ext2_inode_by_name(struct inode *
de = ext2_find_entry (dir, dentry, &page);
if (de) {
res = le32_to_cpu(de->inode);
- ext2_put_page(page);
+ put_kmapped_page(page);
}
return res;
}
@@ -422,7 +408,7 @@ void ext2_set_link(struct inode *dir, st
de->inode = cpu_to_le32(inode->i_ino);
ext2_set_de_type (de, inode);
err = ext2_commit_chunk(page, from, to);
- ext2_put_page(page);
+ put_kmapped_page(page);
dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
EXT2_I(dir)->i_flags &= ~EXT2_BTREE_FL;
mark_inode_dirty(dir);
@@ -455,9 +441,9 @@ int ext2_add_link (struct dentry *dentry
for (n = 0; n <= npages; n++) {
char *dir_end;
- page = ext2_get_page(dir, n);
+ page = read_kmap_page(dir->i_mapping, n);
err = PTR_ERR(page);
- if (IS_ERR(page))
+ if (IS_ERR(page) || (err = ext2_check_page(page)))
goto out;
lock_page(page);
kaddr = page_address(page);
@@ -491,7 +477,7 @@ int ext2_add_link (struct dentry *dentry
de = (ext2_dirent *) ((char *) de + rec_len);
}
unlock_page(page);
- ext2_put_page(page);
+ put_kmapped_page(page);
}
BUG();
return -EINVAL;
@@ -518,7 +504,7 @@ got_it:
mark_inode_dirty(dir);
/* OFFSET_CACHE */
out_put:
- ext2_put_page(page);
+ put_kmapped_page(page);
out:
return err;
out_unlock:
@@ -564,7 +550,7 @@ int ext2_delete_entry (struct ext2_dir_e
EXT2_I(inode)->i_flags &= ~EXT2_BTREE_FL;
mark_inode_dirty(inode);
out:
- ext2_put_page(page);
+ put_kmapped_page(page);
return err;
}
@@ -620,9 +606,9 @@ int ext2_empty_dir (struct inode * inode
for (i = 0; i < npages; i++) {
char *kaddr;
ext2_dirent * de;
- page = ext2_get_page(inode, i);
+ page = read_kmap_page(inode->i_mapping, i);
- if (IS_ERR(page))
+ if (IS_ERR(page) || ext2_check_page(page))
continue;
kaddr = page_address(page);
@@ -651,12 +637,12 @@ int ext2_empty_dir (struct inode * inode
}
de = ext2_next_entry(de);
}
- ext2_put_page(page);
+ put_kmapped_page(page);
}
return 1;
not_empty:
- ext2_put_page(page);
+ put_kmapped_page(page);
return 0;
}
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH 3/17] afs: convert afs_dir_get_page to read_kmap_page
2007-04-12 2:49 [PATCH 0/17] fs: cleanup single page synchronous read interface Nate Diller
` (2 preceding siblings ...)
2007-04-12 2:49 ` [PATCH 17/17] vxfs: convert vxfs_get_page " Nate Diller
@ 2007-04-12 2:49 ` Nate Diller
2007-04-12 10:58 ` David Howells
2007-04-12 2:49 ` [PATCH 6/17] hfs: remove redundant read_mapping_page error check Nate Diller
` (12 subsequent siblings)
16 siblings, 1 reply; 33+ messages in thread
From: Nate Diller @ 2007-04-12 2:49 UTC (permalink / raw)
To: Andrew Morton, Alexander Viro, Christoph Hellwig, Roman Zippel,
Mikulas Patocka, David Woodhouse, Dave Kleikamp,
Anton Altaparmakov, Evgeniy Dushistov
Cc: linux-kernel, linux-fsdevel, reiserfs-dev
Replace afs_dir_get_page() and afs_dir_put_page() using the new
read_kmap_page() and put_kmapped_page() calls, and eliminate unnecessary
PageError checks. Also, change the afs_dir_check_page() call to return
the page's error status, and update the call site accordingly.
Signed-off-by: Nate Diller <nate.diller@gmail.com>
---
diff -urpN -X dontdiff linux-2.6.21-rc5-mm4/fs/afs/dir.c linux-2.6.21-rc5-mm4-test/fs/afs/dir.c
--- linux-2.6.21-rc5-mm4/fs/afs/dir.c 2007-04-06 12:27:03.000000000 -0700
+++ linux-2.6.21-rc5-mm4-test/fs/afs/dir.c 2007-04-06 14:30:22.000000000 -0700
@@ -115,12 +115,15 @@ struct afs_dir_lookup_cookie {
/*
* check that a directory page is valid
*/
-static inline void afs_dir_check_page(struct inode *dir, struct page *page)
+static inline int afs_dir_check_page(struct inode *dir, struct page *page)
{
struct afs_dir_page *dbuf;
loff_t latter;
int tmp, qty;
+ if (likely(PageChecked(page)))
+ return PageError(page);
+
#if 0
/* check the page count */
qty = desc.size / sizeof(dbuf->blocks[0]);
@@ -154,52 +157,16 @@ static inline void afs_dir_check_page(st
}
SetPageChecked(page);
- return;
+ return 0;
error:
SetPageChecked(page);
SetPageError(page);
-
+ return 1;
} /* end afs_dir_check_page() */
/*****************************************************************************/
/*
- * discard a page cached in the pagecache
- */
-static inline void afs_dir_put_page(struct page *page)
-{
- kunmap(page);
- page_cache_release(page);
-
-} /* end afs_dir_put_page() */
-
-/*****************************************************************************/
-/*
- * get a page into the pagecache
- */
-static struct page *afs_dir_get_page(struct inode *dir, unsigned long index)
-{
- struct page *page;
-
- _enter("{%lu},%lu", dir->i_ino, index);
-
- page = read_mapping_page(dir->i_mapping, index, NULL);
- if (!IS_ERR(page)) {
- kmap(page);
- if (!PageChecked(page))
- afs_dir_check_page(dir, page);
- if (PageError(page))
- goto fail;
- }
- return page;
-
- fail:
- afs_dir_put_page(page);
- return ERR_PTR(-EIO);
-} /* end afs_dir_get_page() */
-
-/*****************************************************************************/
-/*
* open an AFS directory file
*/
static int afs_dir_open(struct inode *inode, struct file *file)
@@ -344,11 +311,16 @@ static int afs_dir_iterate(struct inode
blkoff = *fpos & ~(sizeof(union afs_dir_block) - 1);
/* fetch the appropriate page from the directory */
- page = afs_dir_get_page(dir, blkoff / PAGE_SIZE);
+ page = read_kmap_page(dir->i_mapping, blkoff / PAGE_SIZE);
if (IS_ERR(page)) {
ret = PTR_ERR(page);
break;
}
+ if (afs_check_page(dir, page)) {
+ err = -EIO;
+ put_kmapped_page(page);
+ break;
+ }
limit = blkoff & ~(PAGE_SIZE - 1);
@@ -361,7 +333,7 @@ static int afs_dir_iterate(struct inode
ret = afs_dir_iterate_block(fpos, dblock, blkoff,
cookie, filldir);
if (ret != 1) {
- afs_dir_put_page(page);
+ put_kmapped_page(page);
goto out;
}
@@ -369,7 +341,7 @@ static int afs_dir_iterate(struct inode
} while (*fpos < dir->i_size && blkoff < limit);
- afs_dir_put_page(page);
+ put_kmapped_page(page);
ret = 0;
}
diff -urpN -X dontdiff linux-2.6.21-rc6-mm1/fs/afs/mntpt.c linux-2.6.21-rc6-mm1-test/fs/afs/mntpt.c
--- linux-2.6.21-rc6-mm1/fs/afs/mntpt.c 2007-04-09 17:24:03.000000000 -0700
+++ linux-2.6.21-rc6-mm1-test/fs/afs/mntpt.c 2007-04-10 21:22:07.000000000 -0700
@@ -74,11 +74,6 @@ int afs_mntpt_check_symlink(struct afs_v
ret = PTR_ERR(page);
goto out;
}
-
- ret = -EIO;
- if (PageError(page))
- goto out_free;
-
buf = kmap(page);
/* examine the symlink's contents */
@@ -98,7 +93,6 @@ int afs_mntpt_check_symlink(struct afs_v
ret = 0;
kunmap(page);
- out_free:
page_cache_release(page);
out:
_leave(" = %d", ret);
@@ -180,10 +174,6 @@ static struct vfsmount *afs_mntpt_do_aut
goto error;
}
- ret = -EIO;
- if (PageError(page))
- goto error;
-
buf = kmap(page);
memcpy(devname, buf, size);
kunmap(page);
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH 8/17] jfs: use locking read_mapping_page
2007-04-12 2:49 [PATCH 0/17] fs: cleanup single page synchronous read interface Nate Diller
` (10 preceding siblings ...)
2007-04-12 2:49 ` [PATCH 2/17] fs: introduce new read_cache_page interface Nate Diller
@ 2007-04-12 2:49 ` Nate Diller
2007-04-12 2:49 ` [PATCH 1/17] cramfs: use read_mapping_page Nate Diller
` (4 subsequent siblings)
16 siblings, 0 replies; 33+ messages in thread
From: Nate Diller @ 2007-04-12 2:49 UTC (permalink / raw)
To: Andrew Morton, Alexander Viro, Christoph Hellwig, Roman Zippel,
Mikulas Patocka, David Woodhouse, Dave Kleikamp,
Anton Altaparmakov, Evgeniy Dushistov
Cc: linux-kernel, linux-fsdevel, reiserfs-dev
Use the new locking variant of read_mapping_page to avoid doing extra work.
Signed-off-by: Nate Diller <nate.diller@gmail.com>
---
diff -urpN -X dontdiff linux-2.6.21-rc6-mm1/fs/jfs/jfs_metapage.c linux-2.6.21-rc6-mm1-test/fs/jfs/jfs_metapage.c
--- linux-2.6.21-rc6-mm1/fs/jfs/jfs_metapage.c 2007-04-09 17:23:48.000000000 -0700
+++ linux-2.6.21-rc6-mm1-test/fs/jfs/jfs_metapage.c 2007-04-09 21:37:09.000000000 -0700
@@ -632,12 +632,11 @@ struct metapage *__get_metapage(struct i
}
SetPageUptodate(page);
} else {
- page = read_mapping_page(mapping, page_index, NULL);
- if (IS_ERR(page) || !PageUptodate(page)) {
+ page = __read_mapping_page(mapping, page_index, NULL);
+ if (IS_ERR(page)) {
jfs_err("read_mapping_page failed!");
return NULL;
}
- lock_page(page);
}
mp = page_to_mp(page, page_offset);
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH 9/17] minix: convert dir_get_page to read_kmap_page
2007-04-12 2:49 [PATCH 0/17] fs: cleanup single page synchronous read interface Nate Diller
` (15 preceding siblings ...)
2007-04-12 2:49 ` [PATCH 5/17] hfsplus: remove redundant read_mapping_page error check Nate Diller
@ 2007-04-12 2:49 ` Nate Diller
16 siblings, 0 replies; 33+ messages in thread
From: Nate Diller @ 2007-04-12 2:49 UTC (permalink / raw)
To: Andrew Morton, Alexander Viro, Christoph Hellwig, Roman Zippel,
Mikulas Patocka, David Woodhouse, Dave Kleikamp,
Anton Altaparmakov, Evgeniy Dushistov
Cc: linux-kernel, linux-fsdevel, reiserfs-dev
Replace minix dir_get_page() and dir_put_page() using the new
read_kmap_page() and put_kmapped_page()/put_locked_page() calls. Also, use
__read_kmap_page() instead of re-taking the page_lock.
Signed-off-by: Nate Diller <nate.diller@gmail.com>
---
diff -urpN -X dontdiff linux-2.6.21-rc5-mm4/fs/minix/dir.c linux-2.6.21-rc5-mm4-test/fs/minix/dir.c
--- linux-2.6.21-rc5-mm4/fs/minix/dir.c 2007-04-05 17:14:25.000000000 -0700
+++ linux-2.6.21-rc5-mm4-test/fs/minix/dir.c 2007-04-06 02:31:55.000000000 -0700
@@ -23,12 +23,6 @@ const struct file_operations minix_dir_o
.fsync = minix_sync_file,
};
-static inline void dir_put_page(struct page *page)
-{
- kunmap(page);
- page_cache_release(page);
-}
-
/*
* Return the offset into page `page_nr' of the last valid
* byte in that page, plus one.
@@ -60,22 +54,6 @@ static int dir_commit_chunk(struct page
return err;
}
-static struct page * dir_get_page(struct inode *dir, unsigned long n)
-{
- struct address_space *mapping = dir->i_mapping;
- struct page *page = read_mapping_page(mapping, n, NULL);
- if (!IS_ERR(page)) {
- kmap(page);
- if (!PageUptodate(page))
- goto fail;
- }
- return page;
-
-fail:
- dir_put_page(page);
- return ERR_PTR(-EIO);
-}
-
static inline void *minix_next_entry(void *de, struct minix_sb_info *sbi)
{
return (void*)((char*)de + sbi->s_dirsize);
@@ -102,7 +80,7 @@ static int minix_readdir(struct file * f
for ( ; n < npages; n++, offset = 0) {
char *p, *kaddr, *limit;
- struct page *page = dir_get_page(inode, n);
+ struct page *page = read_kmap_page(inode->i_mapping, n);
if (IS_ERR(page))
continue;
@@ -128,12 +106,12 @@ static int minix_readdir(struct file * f
(n << PAGE_CACHE_SHIFT) | offset,
inumber, DT_UNKNOWN);
if (over) {
- dir_put_page(page);
+ put_kmapped_page(page);
goto done;
}
}
}
- dir_put_page(page);
+ put_kmapped_page(page);
}
done:
@@ -177,7 +155,7 @@ minix_dirent *minix_find_entry(struct de
for (n = 0; n < npages; n++) {
char *kaddr, *limit;
- page = dir_get_page(dir, n);
+ page = read_kmap_page(dir->i_mapping, n);
if (IS_ERR(page))
continue;
@@ -198,7 +176,7 @@ minix_dirent *minix_find_entry(struct de
if (namecompare(namelen, sbi->s_namelen, name, namx))
goto found;
}
- dir_put_page(page);
+ put_kmapped_page(page);
}
return NULL;
@@ -233,11 +211,10 @@ int minix_add_link(struct dentry *dentry
for (n = 0; n <= npages; n++) {
char *limit, *dir_end;
- page = dir_get_page(dir, n);
+ page = __read_kmap_page(dir->i_mapping, n);
err = PTR_ERR(page);
if (IS_ERR(page))
goto out;
- lock_page(page);
kaddr = (char*)page_address(page);
dir_end = kaddr + minix_last_byte(dir, n);
limit = kaddr + PAGE_CACHE_SIZE - sbi->s_dirsize;
@@ -265,8 +242,7 @@ int minix_add_link(struct dentry *dentry
if (namecompare(namelen, sbi->s_namelen, name, namx))
goto out_unlock;
}
- unlock_page(page);
- dir_put_page(page);
+ put_locked_page(page);
}
BUG();
return -EINVAL;
@@ -288,13 +264,12 @@ got_it:
err = dir_commit_chunk(page, from, to);
dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
mark_inode_dirty(dir);
-out_put:
- dir_put_page(page);
+ put_kmapped_page(page);
out:
return err;
out_unlock:
- unlock_page(page);
- goto out_put;
+ put_locked_page(page);
+ return err;
}
int minix_delete_entry(struct minix_dir_entry *de, struct page *page)
@@ -314,7 +289,7 @@ int minix_delete_entry(struct minix_dir_
} else {
unlock_page(page);
}
- dir_put_page(page);
+ put_kmapped_page(page);
inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC;
mark_inode_dirty(inode);
return err;
@@ -378,7 +353,7 @@ int minix_empty_dir(struct inode * inode
for (i = 0; i < npages; i++) {
char *p, *kaddr, *limit;
- page = dir_get_page(inode, i);
+ page = read_kmap_page(inode->i_mapping, i);
if (IS_ERR(page))
continue;
@@ -408,12 +383,12 @@ int minix_empty_dir(struct inode * inode
goto not_empty;
}
}
- dir_put_page(page);
+ put_kmapped_page(page);
}
return 1;
not_empty:
- dir_put_page(page);
+ put_kmapped_page(page);
return 0;
}
@@ -435,14 +410,14 @@ void minix_set_link(struct minix_dir_ent
} else {
unlock_page(page);
}
- dir_put_page(page);
+ put_kmapped_page(page);
dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
mark_inode_dirty(dir);
}
struct minix_dir_entry * minix_dotdot (struct inode *dir, struct page **p)
{
- struct page *page = dir_get_page(dir, 0);
+ struct page *page = read_kmap_page(dir->i_mapping, 0);
struct minix_sb_info *sbi = minix_sb(dir->i_sb);
struct minix_dir_entry *de = NULL;
@@ -461,7 +436,7 @@ ino_t minix_inode_by_name(struct dentry
if (de) {
res = de->inode;
- dir_put_page(page);
+ put_kmapped_page(page);
}
return res;
}
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH 10/17] mtd: convert page_read to read_kmap_page
2007-04-12 2:49 [PATCH 0/17] fs: cleanup single page synchronous read interface Nate Diller
` (13 preceding siblings ...)
2007-04-12 2:49 ` [PATCH 13/17] reiser4: remove redundant read_mapping_page error checks Nate Diller
@ 2007-04-12 2:49 ` Nate Diller
2007-04-12 2:49 ` [PATCH 5/17] hfsplus: remove redundant read_mapping_page error check Nate Diller
2007-04-12 2:49 ` [PATCH 9/17] minix: convert dir_get_page to read_kmap_page Nate Diller
16 siblings, 0 replies; 33+ messages in thread
From: Nate Diller @ 2007-04-12 2:49 UTC (permalink / raw)
To: Andrew Morton, Alexander Viro, Christoph Hellwig, Roman Zippel,
Mikulas Patocka, David Woodhouse, Dave Kleikamp,
Anton Altaparmakov, Evgeniy Dushistov
Cc: linux-kernel, linux-fsdevel, reiserfs-dev
Replace page_read() with read_kmap_page()/__read_kmap_page(). This probably
fixes behaviour on highmem systems, since page_address() was being used
without kmap(). Also eliminate the need to re-take the page lock during
writes to the page.
Signed-off-by: Nate Diller <nate.diller@gmail.com>
---
diff -urpN -X dontdiff linux-2.6.21-rc5-mm4/drivers/mtd/devices/block2mtd.c linux-2.6.21-rc5-mm4-test/drivers/mtd/devices/block2mtd.c
--- linux-2.6.21-rc5-mm4/drivers/mtd/devices/block2mtd.c 2007-04-05 17:14:24.000000000 -0700
+++ linux-2.6.21-rc5-mm4-test/drivers/mtd/devices/block2mtd.c 2007-04-06 01:59:19.000000000 -0700
@@ -39,12 +39,6 @@ struct block2mtd_dev {
/* Static info about the MTD, used in cleanup_module */
static LIST_HEAD(blkmtd_device_list);
-
-static struct page *page_read(struct address_space *mapping, int index)
-{
- return read_mapping_page(mapping, index, NULL);
-}
-
/* erase a specified part of the device */
static int _block2mtd_erase(struct block2mtd_dev *dev, loff_t to, size_t len)
{
@@ -56,23 +50,19 @@ static int _block2mtd_erase(struct block
u_long *max;
while (pages) {
- page = page_read(mapping, index);
- if (!page)
- return -ENOMEM;
+ page = __read_kmap_page(mapping, index);
if (IS_ERR(page))
return PTR_ERR(page);
max = page_address(page) + PAGE_SIZE;
for (p=page_address(page); p<max; p++)
if (*p != -1UL) {
- lock_page(page);
memset(page_address(page), 0xff, PAGE_SIZE);
set_page_dirty(page);
- unlock_page(page);
break;
}
- page_cache_release(page);
+ put_locked_page(page);
pages--;
index++;
}
@@ -125,14 +115,12 @@ static int block2mtd_read(struct mtd_inf
cpylen = len; // this page
len = len - cpylen;
- page = page_read(dev->blkdev->bd_inode->i_mapping, index);
- if (!page)
- return -ENOMEM;
+ page = read_kmap_page(dev->blkdev->bd_inode->i_mapping, index);
if (IS_ERR(page))
return PTR_ERR(page);
memcpy(buf, page_address(page) + offset, cpylen);
- page_cache_release(page);
+ put_kmapped_page(page);
if (retlen)
*retlen += cpylen;
@@ -163,19 +151,15 @@ static int _block2mtd_write(struct block
cpylen = len; // this page
len = len - cpylen;
- page = page_read(mapping, index);
- if (!page)
- return -ENOMEM;
+ page = __read_kmap_page(mapping, index);
if (IS_ERR(page))
return PTR_ERR(page);
if (memcmp(page_address(page)+offset, buf, cpylen)) {
- lock_page(page);
memcpy(page_address(page) + offset, buf, cpylen);
set_page_dirty(page);
- unlock_page(page);
}
- page_cache_release(page);
+ put_locked_page(page);
if (retlen)
*retlen += cpylen;
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH 13/17] reiser4: remove redundant read_mapping_page error checks
2007-04-12 2:49 [PATCH 0/17] fs: cleanup single page synchronous read interface Nate Diller
` (12 preceding siblings ...)
2007-04-12 2:49 ` [PATCH 1/17] cramfs: use read_mapping_page Nate Diller
@ 2007-04-12 2:49 ` Nate Diller
2007-04-12 2:49 ` [PATCH 10/17] mtd: convert page_read to read_kmap_page Nate Diller
` (2 subsequent siblings)
16 siblings, 0 replies; 33+ messages in thread
From: Nate Diller @ 2007-04-12 2:49 UTC (permalink / raw)
To: Andrew Morton, Alexander Viro, Christoph Hellwig, Roman Zippel,
Mikulas Patocka, David Woodhouse, Dave Kleikamp,
Anton Altaparmakov, Evgeniy Dushistov
Cc: linux-kernel, linux-fsdevel, reiserfs-dev
read_mapping_page() is now fully synchronous, so there's no need wait for
the page lock or check for I/O errors.
Signed-off-by: Nate Diller <nate.diller@gmail.com>
---
diff -urpN -X dontdiff linux-2.6.21-rc6-mm1/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.21-rc6-mm1-test/fs/reiser4/plugin/file/tail_conversion.c
--- linux-2.6.21-rc6-mm1/fs/reiser4/plugin/file/tail_conversion.c 2007-04-09 17:24:03.000000000 -0700
+++ linux-2.6.21-rc6-mm1-test/fs/reiser4/plugin/file/tail_conversion.c 2007-04-10 21:33:47.000000000 -0700
@@ -608,14 +608,6 @@ int extent2tail(unix_file_info_t *uf_inf
break;
}
- wait_on_page_locked(page);
-
- if (!PageUptodate(page)) {
- page_cache_release(page);
- result = RETERR(-EIO);
- break;
- }
-
/* cut part of file we have read */
start_byte = (__u64) (i << PAGE_CACHE_SHIFT);
set_key_offset(&from, start_byte);
diff -urpN -X dontdiff linux-2.6.21-rc6-mm1/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.21-rc6-mm1-test/fs/reiser4/plugin/item/extent_file_ops.c
--- linux-2.6.21-rc6-mm1/fs/reiser4/plugin/item/extent_file_ops.c 2007-04-10 19:41:14.000000000 -0700
+++ linux-2.6.21-rc6-mm1-test/fs/reiser4/plugin/item/extent_file_ops.c 2007-04-10 21:38:41.000000000 -0700
@@ -1220,15 +1220,8 @@ int reiser4_read_extent(struct file *fil
page = read_mapping_page(mapping, cur_page, file);
if (IS_ERR(page))
return PTR_ERR(page);
- lock_page(page);
- if (!PageUptodate(page)) {
- unlock_page(page);
- page_cache_release(page);
- warning("jmacd-97178", "extent_read: page is not up to date");
- return RETERR(-EIO);
- }
+
mark_page_accessed(page);
- unlock_page(page);
/* If users can be writing to this page using arbitrary virtual
addresses, take care about potential aliasing before reading
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH 12/17] partition: remove redundant read_mapping_page error checks
2007-04-12 2:49 [PATCH 0/17] fs: cleanup single page synchronous read interface Nate Diller
` (5 preceding siblings ...)
2007-04-12 2:49 ` [PATCH 14/17] reiserfs: convert reiserfs_get_page to read_kmap_page Nate Diller
@ 2007-04-12 2:49 ` Nate Diller
2007-04-12 2:49 ` [PATCH 11/17] ntfs: convert ntfs_map_page to read_kmap_page Nate Diller
` (9 subsequent siblings)
16 siblings, 0 replies; 33+ messages in thread
From: Nate Diller @ 2007-04-12 2:49 UTC (permalink / raw)
To: Andrew Morton, Alexander Viro, Christoph Hellwig, Roman Zippel,
Mikulas Patocka, David Woodhouse, Dave Kleikamp,
Anton Altaparmakov, Evgeniy Dushistov
Cc: linux-kernel, linux-fsdevel, reiserfs-dev
Remove unneeded PageError checking in read_dev_sector(), and clean up the
code a bit.
Can anyone point out why it's OK to use page_address() here on a page which
has not been kmapped? If it's not OK, then a good number of callers need to
be fixed.
Signed-off-by: Nate Diller <nate.diller@gmail.com>
---
diff -urpN -X dontdiff linux-2.6.21-rc6-mm1/fs/partitions/check.c linux-2.6.21-rc6-mm1-test/fs/partitions/check.c
--- linux-2.6.21-rc6-mm1/fs/partitions/check.c 2007-04-09 17:24:03.000000000 -0700
+++ linux-2.6.21-rc6-mm1-test/fs/partitions/check.c 2007-04-10 21:59:01.000000000 -0700
@@ -568,16 +568,12 @@ unsigned char *read_dev_sector(struct bl
page = read_mapping_page(mapping, (pgoff_t)(n >> (PAGE_CACHE_SHIFT-9)),
NULL);
- if (!IS_ERR(page)) {
- if (PageError(page))
- goto fail;
- p->v = page;
- return (unsigned char *)page_address(page) + ((n & ((1 << (PAGE_CACHE_SHIFT - 9)) - 1)) << 9);
-fail:
- page_cache_release(page);
+ if (IS_ERR(page)) {
+ p->v = NULL;
+ return NULL;
}
- p->v = NULL;
- return NULL;
+ p->v = page;
+ return (unsigned char *)page_address(page) + ((n & ((1 << (PAGE_CACHE_SHIFT - 9)) - 1)) << 9);
}
EXPORT_SYMBOL(read_dev_sector);
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH 15/17] sysv: convert dir_get_page to read_kmap_page
2007-04-12 2:49 [PATCH 0/17] fs: cleanup single page synchronous read interface Nate Diller
` (8 preceding siblings ...)
2007-04-12 2:49 ` [PATCH 16/17] ufs: convert ufs_get_page " Nate Diller
@ 2007-04-12 2:49 ` Nate Diller
2007-04-12 2:49 ` [PATCH 2/17] fs: introduce new read_cache_page interface Nate Diller
` (6 subsequent siblings)
16 siblings, 0 replies; 33+ messages in thread
From: Nate Diller @ 2007-04-12 2:49 UTC (permalink / raw)
To: Andrew Morton, Alexander Viro, Christoph Hellwig, Roman Zippel,
Mikulas Patocka, David Woodhouse, Dave Kleikamp,
Anton Altaparmakov, Evgeniy Dushistov
Cc: linux-kernel, linux-fsdevel, reiserfs-dev
Replace sysv dir_get_page() with the new read_kmap_page().
Signed-off-by: Nate Diller <nate.diller@gmail.com>
---
diff -urpN -X dontdiff linux-2.6.21-rc5-mm4/fs/sysv/dir.c linux-2.6.21-rc5-mm4-test/fs/sysv/dir.c
--- linux-2.6.21-rc5-mm4/fs/sysv/dir.c 2007-04-05 17:14:25.000000000 -0700
+++ linux-2.6.21-rc5-mm4-test/fs/sysv/dir.c 2007-04-06 01:59:19.000000000 -0700
@@ -50,15 +50,6 @@ static int dir_commit_chunk(struct page
return err;
}
-static struct page * dir_get_page(struct inode *dir, unsigned long n)
-{
- struct address_space *mapping = dir->i_mapping;
- struct page *page = read_mapping_page(mapping, n, NULL);
- if (!IS_ERR(page))
- kmap(page);
- return page;
-}
-
static int sysv_readdir(struct file * filp, void * dirent, filldir_t filldir)
{
unsigned long pos = filp->f_pos;
@@ -77,7 +68,7 @@ static int sysv_readdir(struct file * fi
for ( ; n < npages; n++, offset = 0) {
char *kaddr, *limit;
struct sysv_dir_entry *de;
- struct page *page = dir_get_page(inode, n);
+ struct page *page = read_kmap_page(inode->i_mapping, n);
if (IS_ERR(page))
continue;
@@ -149,7 +140,7 @@ struct sysv_dir_entry *sysv_find_entry(s
do {
char *kaddr;
- page = dir_get_page(dir, n);
+ page = read_kmap_page(dir->i_mapping, n);
if (!IS_ERR(page)) {
kaddr = (char*)page_address(page);
de = (struct sysv_dir_entry *) kaddr;
@@ -191,7 +182,7 @@ int sysv_add_link(struct dentry *dentry,
/* We take care of directory expansion in the same loop */
for (n = 0; n <= npages; n++) {
- page = dir_get_page(dir, n);
+ page = read_kmap_page(dir->i_mapping, n);
err = PTR_ERR(page);
if (IS_ERR(page))
goto out;
@@ -299,7 +290,7 @@ int sysv_empty_dir(struct inode * inode)
for (i = 0; i < npages; i++) {
char *kaddr;
struct sysv_dir_entry * de;
- page = dir_get_page(inode, i);
+ page = read_kmap_page(inode->i_mapping, i);
if (IS_ERR(page))
continue;
@@ -353,7 +344,7 @@ void sysv_set_link(struct sysv_dir_entry
struct sysv_dir_entry * sysv_dotdot (struct inode *dir, struct page **p)
{
- struct page *page = dir_get_page(dir, 0);
+ struct page *page = read_kmap_page(dir->i_mapping, 0);
struct sysv_dir_entry *de = NULL;
if (!IS_ERR(page)) {
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH 16/17] ufs: convert ufs_get_page to read_kmap_page
2007-04-12 2:49 [PATCH 0/17] fs: cleanup single page synchronous read interface Nate Diller
` (7 preceding siblings ...)
2007-04-12 2:49 ` [PATCH 11/17] ntfs: convert ntfs_map_page to read_kmap_page Nate Diller
@ 2007-04-12 2:49 ` Nate Diller
2007-04-12 2:49 ` [PATCH 15/17] sysv: convert dir_get_page " Nate Diller
` (7 subsequent siblings)
16 siblings, 0 replies; 33+ messages in thread
From: Nate Diller @ 2007-04-12 2:49 UTC (permalink / raw)
To: Andrew Morton, Alexander Viro, Christoph Hellwig, Roman Zippel,
Mikulas Patocka, David Woodhouse, Dave Kleikamp,
Anton Altaparmakov, Evgeniy Dushistov
Cc: linux-kernel, linux-fsdevel, reiserfs-dev
Replace ufs_get_page()/ufs_get_locked_page() and
ufs_put_page()/ufs_put_locked_page() using the new read_kmap_page() and
put_kmapped_page() calls and their locking variants. Also, change the
ufs_check_page() call to return the page's error status, and update the
call sites accordingly.
Signed-off-by: Nate Diller <nate.diller@gmail.com>
---
diff -urpN -X dontdiff linux-2.6.21-rc5-mm4/fs/ufs/balloc.c linux-2.6.21-rc5-mm4-test/fs/ufs/balloc.c
--- linux-2.6.21-rc5-mm4/fs/ufs/balloc.c 2007-04-05 17:13:29.000000000 -0700
+++ linux-2.6.21-rc5-mm4-test/fs/ufs/balloc.c 2007-04-06 12:46:02.000000000 -0700
@@ -272,7 +272,7 @@ static void ufs_change_blocknr(struct in
index = i >> (PAGE_CACHE_SHIFT - inode->i_blkbits);
if (likely(cur_index != index)) {
- page = ufs_get_locked_page(mapping, index);
+ page = __read_mapping_page(mapping, index, NULL);
if (!page)/* it was truncated */
continue;
if (IS_ERR(page)) {/* or EIO */
@@ -325,8 +325,10 @@ static void ufs_change_blocknr(struct in
bh = bh->b_this_page;
} while (bh != head);
- if (likely(cur_index != index))
- ufs_put_locked_page(page);
+ if (likely(cur_index != index)) {
+ unlock_page(page);
+ page_cache_release(page);
+ }
}
UFSD("EXIT\n");
}
diff -urpN -X dontdiff linux-2.6.21-rc5-mm4/fs/ufs/truncate.c linux-2.6.21-rc5-mm4-test/fs/ufs/truncate.c
--- linux-2.6.21-rc5-mm4/fs/ufs/truncate.c 2007-04-05 17:13:29.000000000 -0700
+++ linux-2.6.21-rc5-mm4-test/fs/ufs/truncate.c 2007-04-06 12:46:14.000000000 -0700
@@ -395,8 +395,9 @@ static int ufs_alloc_lastblock(struct in
lastfrag--;
- lastpage = ufs_get_locked_page(mapping, lastfrag >>
- (PAGE_CACHE_SHIFT - inode->i_blkbits));
+ lastpage = __read_mapping_page(mapping, lastfrag >>
+ (PAGE_CACHE_SHIFT - inode->i_blkbits),
+ NULL);
if (IS_ERR(lastpage)) {
err = -EIO;
goto out;
@@ -441,7 +442,8 @@ static int ufs_alloc_lastblock(struct in
}
}
out_unlock:
- ufs_put_locked_page(lastpage);
+ unlock_page(lastpage);
+ page_cache_release(lastpage);
out:
return err;
}
diff -urpN -X dontdiff linux-2.6.21-rc5-mm4/fs/ufs/util.c linux-2.6.21-rc5-mm4-test/fs/ufs/util.c
--- linux-2.6.21-rc5-mm4/fs/ufs/util.c 2007-04-05 17:14:25.000000000 -0700
+++ linux-2.6.21-rc5-mm4-test/fs/ufs/util.c 2007-04-06 12:40:53.000000000 -0700
@@ -232,55 +232,3 @@ ufs_set_inode_dev(struct super_block *sb
ufsi->i_u1.i_data[0] = cpu_to_fs32(sb, fs32);
}
-/**
- * ufs_get_locked_page() - locate, pin and lock a pagecache page, if not exist
- * read it from disk.
- * @mapping: the address_space to search
- * @index: the page index
- *
- * Locates the desired pagecache page, if not exist we'll read it,
- * locks it, increments its reference
- * count and returns its address.
- *
- */
-
-struct page *ufs_get_locked_page(struct address_space *mapping,
- pgoff_t index)
-{
- struct page *page;
-
- page = find_lock_page(mapping, index);
- if (!page) {
- page = read_mapping_page(mapping, index, NULL);
-
- if (IS_ERR(page)) {
- printk(KERN_ERR "ufs_change_blocknr: "
- "read_mapping_page error: ino %lu, index: %lu\n",
- mapping->host->i_ino, index);
- goto out;
- }
-
- lock_page(page);
-
- if (unlikely(page->mapping == NULL)) {
- /* Truncate got there first */
- unlock_page(page);
- page_cache_release(page);
- page = NULL;
- goto out;
- }
-
- if (!PageUptodate(page) || PageError(page)) {
- unlock_page(page);
- page_cache_release(page);
-
- printk(KERN_ERR "ufs_change_blocknr: "
- "can not read page: ino %lu, index: %lu\n",
- mapping->host->i_ino, index);
-
- page = ERR_PTR(-EIO);
- }
- }
-out:
- return page;
-}
diff -urpN -X dontdiff linux-2.6.21-rc5-mm4/fs/ufs/util.h linux-2.6.21-rc5-mm4-test/fs/ufs/util.h
--- linux-2.6.21-rc5-mm4/fs/ufs/util.h 2007-04-05 17:13:29.000000000 -0700
+++ linux-2.6.21-rc5-mm4-test/fs/ufs/util.h 2007-04-06 12:46:36.000000000 -0700
@@ -251,16 +251,6 @@ extern void _ubh_ubhcpymem_(struct ufs_s
#define ubh_memcpyubh(ubh,mem,size) _ubh_memcpyubh_(uspi,ubh,mem,size)
extern void _ubh_memcpyubh_(struct ufs_sb_private_info *, struct ufs_buffer_head *, unsigned char *, unsigned);
-/* This functions works with cache pages*/
-extern struct page *ufs_get_locked_page(struct address_space *mapping,
- pgoff_t index);
-static inline void ufs_put_locked_page(struct page *page)
-{
- unlock_page(page);
- page_cache_release(page);
-}
-
-
/*
* macros and inline function to get important structures from ufs_sb_private_info
*/
diff -urpN -X dontdiff linux-2.6.21-rc5-mm4/fs/ufs/dir.c linux-2.6.21-rc5-mm4-test/fs/ufs/dir.c
--- linux-2.6.21-rc5-mm4/fs/ufs/dir.c 2007-04-06 12:27:03.000000000 -0700
+++ linux-2.6.21-rc5-mm4-test/fs/ufs/dir.c 2007-04-06 14:43:23.000000000 -0700
@@ -51,12 +51,6 @@ static int ufs_commit_chunk(struct page
return err;
}
-static inline void ufs_put_page(struct page *page)
-{
- kunmap(page);
- page_cache_release(page);
-}
-
static inline unsigned long ufs_dir_pages(struct inode *inode)
{
return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT;
@@ -71,7 +65,7 @@ ino_t ufs_inode_by_name(struct inode *di
de = ufs_find_entry(dir, dentry, &page);
if (de) {
res = fs32_to_cpu(dir->i_sb, de->d_ino);
- ufs_put_page(page);
+ put_kmapped_page(page);
}
return res;
}
@@ -91,13 +85,13 @@ void ufs_set_link(struct inode *dir, str
de->d_ino = cpu_to_fs32(dir->i_sb, inode->i_ino);
ufs_set_de_type(dir->i_sb, de, inode->i_mode);
err = ufs_commit_chunk(page, from, to);
- ufs_put_page(page);
+ put_kmapped_page(page);
dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
mark_inode_dirty(dir);
}
-static void ufs_check_page(struct page *page)
+static int ufs_check_page(struct page *page)
{
struct inode *dir = page->mapping->host;
struct super_block *sb = dir->i_sb;
@@ -108,6 +102,14 @@ static void ufs_check_page(struct page *
struct ufs_dir_entry *p;
char *error;
+ if (likely(PageChecked(page))) {
+ if (likely(!PageError(page)))
+ return 0;
+
+ put_kmapped_page(page);
+ return -EIO;
+ }
+
if ((dir->i_size >> PAGE_CACHE_SHIFT) == page->index) {
limit = dir->i_size & ~PAGE_CACHE_MASK;
if (limit & chunk_mask)
@@ -135,7 +137,7 @@ static void ufs_check_page(struct page *
goto Eend;
out:
SetPageChecked(page);
- return;
+ return 0;
/* Too bad, we had an error */
@@ -174,24 +176,8 @@ Eend:
fail:
SetPageChecked(page);
SetPageError(page);
-}
-
-static struct page *ufs_get_page(struct inode *dir, unsigned long n)
-{
- struct address_space *mapping = dir->i_mapping;
- struct page *page = read_mapping_page(mapping, n, NULL);
- if (!IS_ERR(page)) {
- kmap(page);
- if (!PageChecked(page))
- ufs_check_page(page);
- if (PageError(page))
- goto fail;
- }
- return page;
-
-fail:
- ufs_put_page(page);
- return ERR_PTR(-EIO);
+ put_kmapped_page(page);
+ return -EIO;
}
/*
@@ -218,10 +204,10 @@ ufs_next_entry(struct super_block *sb, s
struct ufs_dir_entry *ufs_dotdot(struct inode *dir, struct page **p)
{
- struct page *page = ufs_get_page(dir, 0);
+ struct page *page = read_kmap_page(dir->i_mapping, 0);
struct ufs_dir_entry *de = NULL;
- if (!IS_ERR(page)) {
+ if (!IS_ERR(page) && !ufs_check_page(page)) {
de = ufs_next_entry(dir->i_sb,
(struct ufs_dir_entry *)page_address(page));
*p = page;
@@ -265,8 +251,8 @@ struct ufs_dir_entry *ufs_find_entry(str
n = start;
do {
char *kaddr;
- page = ufs_get_page(dir, n);
- if (!IS_ERR(page)) {
+ page = read_kmap_page(dir->i_mapping, n);
+ if (!IS_ERR(page) && !ufs_check_page(page)) {
kaddr = page_address(page);
de = (struct ufs_dir_entry *) kaddr;
kaddr += ufs_last_byte(dir, n) - reclen;
@@ -274,14 +260,14 @@ struct ufs_dir_entry *ufs_find_entry(str
if (de->d_reclen == 0) {
ufs_error(dir->i_sb, __FUNCTION__,
"zero-length directory entry");
- ufs_put_page(page);
+ put_kmapped_page(page);
goto out;
}
if (ufs_match(sb, namelen, name, de))
goto found;
de = ufs_next_entry(sb, de);
}
- ufs_put_page(page);
+ put_kmapped_page(page);
}
if (++n >= npages)
n = 0;
@@ -325,11 +311,13 @@ int ufs_add_link(struct dentry *dentry,
for (n = 0; n <= npages; n++) {
char *dir_end;
- page = ufs_get_page(dir, n);
+ page = __read_kmap_page(dir->i_mapping, n);
err = PTR_ERR(page);
if (IS_ERR(page))
goto out;
- lock_page(page);
+ err = ufs_check_page(page);
+ if (err)
+ goto out_unlock;
kaddr = page_address(page);
dir_end = kaddr + ufs_last_byte(dir, n);
de = (struct ufs_dir_entry *)kaddr;
@@ -360,8 +348,7 @@ int ufs_add_link(struct dentry *dentry,
goto got_it;
de = (struct ufs_dir_entry *) ((char *) de + rec_len);
}
- unlock_page(page);
- ufs_put_page(page);
+ put_locked_page(page);
}
BUG();
return -EINVAL;
@@ -391,13 +378,12 @@ got_it:
mark_inode_dirty(dir);
/* OFFSET_CACHE */
-out_put:
- ufs_put_page(page);
+ put_kmapped_page(page);
out:
return err;
out_unlock:
- unlock_page(page);
- goto out_put;
+ put_locked_page(page);
+ return err;
}
static inline unsigned
@@ -440,9 +426,9 @@ ufs_readdir(struct file *filp, void *dir
char *kaddr, *limit;
struct ufs_dir_entry *de;
- struct page *page = ufs_get_page(inode, n);
+ struct page *page = read_kmap_page(inode->i_mapping, n);
- if (IS_ERR(page)) {
+ if (IS_ERR(page) || ufs_check_page(page)) {
ufs_error(sb, __FUNCTION__,
"bad page in #%lu",
inode->i_ino);
@@ -464,7 +450,7 @@ ufs_readdir(struct file *filp, void *dir
if (de->d_reclen == 0) {
ufs_error(sb, __FUNCTION__,
"zero-length directory entry");
- ufs_put_page(page);
+ put_kmapped_page(page);
return -EIO;
}
if (de->d_ino) {
@@ -485,13 +471,13 @@ ufs_readdir(struct file *filp, void *dir
(n<<PAGE_CACHE_SHIFT) | offset,
fs32_to_cpu(sb, de->d_ino), d_type);
if (over) {
- ufs_put_page(page);
+ put_kmapped_page(page);
return 0;
}
}
filp->f_pos += fs16_to_cpu(sb, de->d_reclen);
}
- ufs_put_page(page);
+ put_kmapped_page(page);
}
return 0;
}
@@ -542,7 +528,7 @@ int ufs_delete_entry(struct inode *inode
inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC;
mark_inode_dirty(inode);
out:
- ufs_put_page(page);
+ put_kmapped_page(page);
UFSD("EXIT\n");
return err;
}
@@ -604,9 +590,9 @@ int ufs_empty_dir(struct inode * inode)
for (i = 0; i < npages; i++) {
char *kaddr;
struct ufs_dir_entry *de;
- page = ufs_get_page(inode, i);
+ page = read_kmap_page(inode->i_mapping, i);
- if (IS_ERR(page))
+ if (IS_ERR(page) || ufs_check_page(page))
continue;
kaddr = page_address(page);
@@ -636,12 +622,12 @@ int ufs_empty_dir(struct inode * inode)
}
de = ufs_next_entry(sb, de);
}
- ufs_put_page(page);
+ put_kmapped_page(page);
}
return 1;
not_empty:
- ufs_put_page(page);
+ put_kmapped_page(page);
return 0;
}
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH 14/17] reiserfs: convert reiserfs_get_page to read_kmap_page
2007-04-12 2:49 [PATCH 0/17] fs: cleanup single page synchronous read interface Nate Diller
` (4 preceding siblings ...)
2007-04-12 2:49 ` [PATCH 6/17] hfs: remove redundant read_mapping_page error check Nate Diller
@ 2007-04-12 2:49 ` Nate Diller
2007-04-12 2:49 ` [PATCH 12/17] partition: remove redundant read_mapping_page error checks Nate Diller
` (10 subsequent siblings)
16 siblings, 0 replies; 33+ messages in thread
From: Nate Diller @ 2007-04-12 2:49 UTC (permalink / raw)
To: Andrew Morton, Alexander Viro, Christoph Hellwig, Roman Zippel,
Mikulas Patocka, David Woodhouse, Dave Kleikamp,
Anton Altaparmakov, Evgeniy Dushistov
Cc: linux-kernel, linux-fsdevel, reiserfs-dev
Replace reiserfs_get_page() and reiserfs_put_page() using the new
read_kmap_page() and put_kmapped_page() calls and their locking variants.
Also, propagate the gfp_mask() deadlock comment to callsites.
Signed-off-by: Nate Diller <nate.diller@gmail.com>
---
diff -urpN -X dontdiff linux-2.6.21-rc5-mm4/fs/reiserfs/xattr.c linux-2.6.21-rc5-mm4-test/fs/reiserfs/xattr.c
--- linux-2.6.21-rc5-mm4/fs/reiserfs/xattr.c 2007-04-05 17:14:25.000000000 -0700
+++ linux-2.6.21-rc5-mm4-test/fs/reiserfs/xattr.c 2007-04-06 14:41:34.000000000 -0700
@@ -438,33 +438,6 @@ int xattr_readdir(struct file *file, fil
return res;
}
-/* Internal operations on file data */
-static inline void reiserfs_put_page(struct page *page)
-{
- kunmap(page);
- page_cache_release(page);
-}
-
-static struct page *reiserfs_get_page(struct inode *dir, unsigned long n)
-{
- struct address_space *mapping = dir->i_mapping;
- struct page *page;
- /* We can deadlock if we try to free dentries,
- and an unlink/rmdir has just occured - GFP_NOFS avoids this */
- mapping_set_gfp_mask(mapping, GFP_NOFS);
- page = read_mapping_page(mapping, n, NULL);
- if (!IS_ERR(page)) {
- kmap(page);
- if (PageError(page))
- goto fail;
- }
- return page;
-
- fail:
- reiserfs_put_page(page);
- return ERR_PTR(-EIO);
-}
-
static inline __u32 xattr_hash(const char *msg, int len)
{
return csum_partial(msg, len, 0);
@@ -537,13 +510,15 @@ reiserfs_xattr_set(struct inode *inode,
else
chunk = buffer_size - buffer_pos;
- page = reiserfs_get_page(xinode, file_pos >> PAGE_CACHE_SHIFT);
+ /* We can deadlock if we try to free dentries,
+ and an unlink/rmdir has just occured - GFP_NOFS avoids this */
+ mapping_set_gfp_mask(mapping, GFP_NOFS);
+ page = __read_kmap_page(mapping, file_pos >> PAGE_CACHE_SHIFT);
if (IS_ERR(page)) {
err = PTR_ERR(page);
goto out_filp;
}
- lock_page(page);
data = page_address(page);
if (file_pos == 0) {
@@ -566,8 +541,7 @@ reiserfs_xattr_set(struct inode *inode,
page_offset + chunk +
skip);
}
- unlock_page(page);
- reiserfs_put_page(page);
+ put_locked_page(page);
buffer_pos += chunk;
file_pos += chunk;
skip = 0;
@@ -646,13 +620,15 @@ reiserfs_xattr_get(const struct inode *i
else
chunk = isize - file_pos;
- page = reiserfs_get_page(xinode, file_pos >> PAGE_CACHE_SHIFT);
+ /* We can deadlock if we try to free dentries,
+ and an unlink/rmdir has just occured - GFP_NOFS avoids this */
+ mapping_set_gfp_mask(xinode->i_mapping, GFP_NOFS);
+ page = __read_kmap_page(xinode->i_mapping, file_pos >> PAGE_CACHE_SHIFT);
if (IS_ERR(page)) {
err = PTR_ERR(page);
goto out_dput;
}
- lock_page(page);
data = page_address(page);
if (file_pos == 0) {
struct reiserfs_xattr_header *rxh =
@@ -661,8 +637,7 @@ reiserfs_xattr_get(const struct inode *i
chunk -= skip;
/* Magic doesn't match up.. */
if (rxh->h_magic != cpu_to_le32(REISERFS_XATTR_MAGIC)) {
- unlock_page(page);
- reiserfs_put_page(page);
+ put_locked_page(page);
reiserfs_warning(inode->i_sb,
"Invalid magic for xattr (%s) "
"associated with %k", name,
@@ -673,8 +648,7 @@ reiserfs_xattr_get(const struct inode *i
hash = le32_to_cpu(rxh->h_hash);
}
memcpy(buffer + buffer_pos, data + skip, chunk);
- unlock_page(page);
- reiserfs_put_page(page);
+ put_locked_page(page);
file_pos += chunk;
buffer_pos += chunk;
skip = 0;
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH 17/17] vxfs: convert vxfs_get_page to read_kmap_page
2007-04-12 2:49 [PATCH 0/17] fs: cleanup single page synchronous read interface Nate Diller
2007-04-12 2:49 ` [PATCH 7/17] jffs2: convert jffs2_gc_fetch_page to read_cache_page Nate Diller
2007-04-12 2:49 ` [PATCH 4/17] ext2: convert ext2_get_page to read_kmap_page Nate Diller
@ 2007-04-12 2:49 ` Nate Diller
2007-04-12 2:49 ` [PATCH 3/17] afs: convert afs_dir_get_page " Nate Diller
` (13 subsequent siblings)
16 siblings, 0 replies; 33+ messages in thread
From: Nate Diller @ 2007-04-12 2:49 UTC (permalink / raw)
To: Andrew Morton, Alexander Viro, Christoph Hellwig, Roman Zippel,
Mikulas Patocka, David Woodhouse, Dave Kleikamp,
Anton Altaparmakov, Evgeniy Dushistov
Cc: linux-kernel, linux-fsdevel, reiserfs-dev
Replace vxfs_get_page() with the new read_kmap_page().
Signed-off-by: Nate Diller <nate.diller@gmail.com>
---
diff -urpN -X dontdiff linux-2.6.21-rc5-mm4/fs/freevxfs/vxfs_extern.h linux-2.6.21-rc5-mm4-test/fs/freevxfs/vxfs_extern.h
--- linux-2.6.21-rc5-mm4/fs/freevxfs/vxfs_extern.h 2007-04-05 17:13:29.000000000 -0700
+++ linux-2.6.21-rc5-mm4-test/fs/freevxfs/vxfs_extern.h 2007-04-06 01:59:19.000000000 -0700
@@ -69,7 +69,6 @@ extern const struct file_operations vxfs
extern int vxfs_read_olt(struct super_block *, u_long);
/* vxfs_subr.c */
-extern struct page * vxfs_get_page(struct address_space *, u_long);
extern void vxfs_put_page(struct page *);
extern struct buffer_head * vxfs_bread(struct inode *, int);
diff -urpN -X dontdiff linux-2.6.21-rc5-mm4/fs/freevxfs/vxfs_inode.c linux-2.6.21-rc5-mm4-test/fs/freevxfs/vxfs_inode.c
--- linux-2.6.21-rc5-mm4/fs/freevxfs/vxfs_inode.c 2007-04-05 17:14:25.000000000 -0700
+++ linux-2.6.21-rc5-mm4-test/fs/freevxfs/vxfs_inode.c 2007-04-06 01:59:19.000000000 -0700
@@ -138,7 +138,7 @@ __vxfs_iget(ino_t ino, struct inode *ili
u_long offset;
offset = (ino % (PAGE_SIZE / VXFS_ISIZE)) * VXFS_ISIZE;
- pp = vxfs_get_page(ilistp->i_mapping, ino * VXFS_ISIZE / PAGE_SIZE);
+ pp = read_kmap_page(ilistp->i_mapping, ino * VXFS_ISIZE / PAGE_SIZE);
if (!IS_ERR(pp)) {
struct vxfs_inode_info *vip;
diff -urpN -X dontdiff linux-2.6.21-rc5-mm4/fs/freevxfs/vxfs_lookup.c linux-2.6.21-rc5-mm4-test/fs/freevxfs/vxfs_lookup.c
--- linux-2.6.21-rc5-mm4/fs/freevxfs/vxfs_lookup.c 2007-04-05 17:13:29.000000000 -0700
+++ linux-2.6.21-rc5-mm4-test/fs/freevxfs/vxfs_lookup.c 2007-04-06 01:59:19.000000000 -0700
@@ -125,7 +125,7 @@ vxfs_find_entry(struct inode *ip, struct
caddr_t kaddr;
struct page *pp;
- pp = vxfs_get_page(ip->i_mapping, page);
+ pp = read_kmap_page(ip->i_mapping, page);
if (IS_ERR(pp))
continue;
kaddr = (caddr_t)page_address(pp);
@@ -280,7 +280,7 @@ vxfs_readdir(struct file *fp, void *retp
caddr_t kaddr;
struct page *pp;
- pp = vxfs_get_page(ip->i_mapping, page);
+ pp = read_kmap_page(ip->i_mapping, page);
if (IS_ERR(pp))
continue;
kaddr = (caddr_t)page_address(pp);
diff -urpN -X dontdiff linux-2.6.21-rc5-mm4/fs/freevxfs/vxfs_subr.c linux-2.6.21-rc5-mm4-test/fs/freevxfs/vxfs_subr.c
--- linux-2.6.21-rc5-mm4/fs/freevxfs/vxfs_subr.c 2007-04-05 17:14:25.000000000 -0700
+++ linux-2.6.21-rc5-mm4-test/fs/freevxfs/vxfs_subr.c 2007-04-06 01:59:19.000000000 -0700
@@ -56,39 +56,6 @@ vxfs_put_page(struct page *pp)
}
/**
- * vxfs_get_page - read a page into memory.
- * @ip: inode to read from
- * @n: page number
- *
- * Description:
- * vxfs_get_page reads the @n th page of @ip into the pagecache.
- *
- * Returns:
- * The wanted page on success, else a NULL pointer.
- */
-struct page *
-vxfs_get_page(struct address_space *mapping, u_long n)
-{
- struct page * pp;
-
- pp = read_mapping_page(mapping, n, NULL);
-
- if (!IS_ERR(pp)) {
- kmap(pp);
- /** if (!PageChecked(pp)) **/
- /** vxfs_check_page(pp); **/
- if (PageError(pp))
- goto fail;
- }
-
- return (pp);
-
-fail:
- vxfs_put_page(pp);
- return ERR_PTR(-EIO);
-}
-
-/**
* vxfs_bread - read buffer for a give inode,block tuple
* @ip: inode
* @block: logical block
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH 11/17] ntfs: convert ntfs_map_page to read_kmap_page
2007-04-12 2:49 [PATCH 0/17] fs: cleanup single page synchronous read interface Nate Diller
` (6 preceding siblings ...)
2007-04-12 2:49 ` [PATCH 12/17] partition: remove redundant read_mapping_page error checks Nate Diller
@ 2007-04-12 2:49 ` Nate Diller
2007-04-12 2:49 ` [PATCH 16/17] ufs: convert ufs_get_page " Nate Diller
` (8 subsequent siblings)
16 siblings, 0 replies; 33+ messages in thread
From: Nate Diller @ 2007-04-12 2:49 UTC (permalink / raw)
To: Andrew Morton, Alexander Viro, Christoph Hellwig, Roman Zippel,
Mikulas Patocka, David Woodhouse, Dave Kleikamp,
Anton Altaparmakov, Evgeniy Dushistov
Cc: linux-kernel, linux-fsdevel, reiserfs-dev
Replace ntfs_map_page() and ntfs_unmap_page() using the new read_kmap_page()
and put_kmapped_page() calls, and their locking variants, and remove
unneeded PageError checking.
Signed-off-by: Nate Diller <nate.diller@gmail.com>
---
diff -urpN -X dontdiff linux-2.6.21-rc5-mm4/fs/ntfs/aops.h linux-2.6.21-rc5-mm4-test/fs/ntfs/aops.h
--- linux-2.6.21-rc5-mm4/fs/ntfs/aops.h 2007-04-05 17:14:25.000000000 -0700
+++ linux-2.6.21-rc5-mm4-test/fs/ntfs/aops.h 2007-04-06 01:59:19.000000000 -0700
@@ -31,73 +31,6 @@
#include "inode.h"
-/**
- * ntfs_unmap_page - release a page that was mapped using ntfs_map_page()
- * @page: the page to release
- *
- * Unpin, unmap and release a page that was obtained from ntfs_map_page().
- */
-static inline void ntfs_unmap_page(struct page *page)
-{
- kunmap(page);
- page_cache_release(page);
-}
-
-/**
- * ntfs_map_page - map a page into accessible memory, reading it if necessary
- * @mapping: address space for which to obtain the page
- * @index: index into the page cache for @mapping of the page to map
- *
- * Read a page from the page cache of the address space @mapping at position
- * @index, where @index is in units of PAGE_CACHE_SIZE, and not in bytes.
- *
- * If the page is not in memory it is loaded from disk first using the readpage
- * method defined in the address space operations of @mapping and the page is
- * added to the page cache of @mapping in the process.
- *
- * If the page belongs to an mst protected attribute and it is marked as such
- * in its ntfs inode (NInoMstProtected()) the mst fixups are applied but no
- * error checking is performed. This means the caller has to verify whether
- * the ntfs record(s) contained in the page are valid or not using one of the
- * ntfs_is_XXXX_record{,p}() macros, where XXXX is the record type you are
- * expecting to see. (For details of the macros, see fs/ntfs/layout.h.)
- *
- * If the page is in high memory it is mapped into memory directly addressible
- * by the kernel.
- *
- * Finally the page count is incremented, thus pinning the page into place.
- *
- * The above means that page_address(page) can be used on all pages obtained
- * with ntfs_map_page() to get the kernel virtual address of the page.
- *
- * When finished with the page, the caller has to call ntfs_unmap_page() to
- * unpin, unmap and release the page.
- *
- * Note this does not grant exclusive access. If such is desired, the caller
- * must provide it independently of the ntfs_{un}map_page() calls by using
- * a {rw_}semaphore or other means of serialization. A spin lock cannot be
- * used as ntfs_map_page() can block.
- *
- * The unlocked and uptodate page is returned on success or an encoded error
- * on failure. Caller has to test for error using the IS_ERR() macro on the
- * return value. If that evaluates to 'true', the negative error code can be
- * obtained using PTR_ERR() on the return value of ntfs_map_page().
- */
-static inline struct page *ntfs_map_page(struct address_space *mapping,
- unsigned long index)
-{
- struct page *page = read_mapping_page(mapping, index, NULL);
-
- if (!IS_ERR(page)) {
- kmap(page);
- if (!PageError(page))
- return page;
- ntfs_unmap_page(page);
- return ERR_PTR(-EIO);
- }
- return page;
-}
-
#ifdef NTFS_RW
extern void mark_ntfs_record_dirty(struct page *page, const unsigned int ofs);
diff -urpN -X dontdiff linux-2.6.21-rc5-mm4/fs/ntfs/bitmap.c linux-2.6.21-rc5-mm4-test/fs/ntfs/bitmap.c
--- linux-2.6.21-rc5-mm4/fs/ntfs/bitmap.c 2006-11-29 13:57:37.000000000 -0800
+++ linux-2.6.21-rc5-mm4-test/fs/ntfs/bitmap.c 2007-04-06 12:40:53.000000000 -0700
@@ -72,7 +72,7 @@ int __ntfs_bitmap_set_bits_in_run(struct
/* Get the page containing the first bit (@start_bit). */
mapping = vi->i_mapping;
- page = ntfs_map_page(mapping, index);
+ page = read_kmap_page(mapping, index);
if (IS_ERR(page)) {
if (!is_rollback)
ntfs_error(vi->i_sb, "Failed to map first page (error "
@@ -123,8 +123,8 @@ int __ntfs_bitmap_set_bits_in_run(struct
/* Update @index and get the next page. */
flush_dcache_page(page);
set_page_dirty(page);
- ntfs_unmap_page(page);
- page = ntfs_map_page(mapping, ++index);
+ put_kmapped_page(page);
+ page = read_kmap_page(mapping, ++index);
if (IS_ERR(page))
goto rollback;
kaddr = page_address(page);
@@ -159,7 +159,7 @@ done:
/* We are done. Unmap the page and return success. */
flush_dcache_page(page);
set_page_dirty(page);
- ntfs_unmap_page(page);
+ put_kmapped_page(page);
ntfs_debug("Done.");
return 0;
rollback:
diff -urpN -X dontdiff linux-2.6.21-rc5-mm4/fs/ntfs/dir.c linux-2.6.21-rc5-mm4-test/fs/ntfs/dir.c
--- linux-2.6.21-rc5-mm4/fs/ntfs/dir.c 2007-04-05 17:14:25.000000000 -0700
+++ linux-2.6.21-rc5-mm4-test/fs/ntfs/dir.c 2007-04-06 12:40:53.000000000 -0700
@@ -317,7 +317,7 @@ descend_into_child_node:
* of PAGE_CACHE_SIZE and map the page cache page, reading it from
* disk if necessary.
*/
- page = ntfs_map_page(ia_mapping, vcn <<
+ page = __read_kmap_page(ia_mapping, vcn <<
dir_ni->itype.index.vcn_size_bits >> PAGE_CACHE_SHIFT);
if (IS_ERR(page)) {
ntfs_error(sb, "Failed to map directory index page, error %ld.",
@@ -325,7 +325,6 @@ descend_into_child_node:
err = PTR_ERR(page);
goto err_out;
}
- lock_page(page);
kaddr = (u8*)page_address(page);
fast_descend_into_child_node:
/* Get to the index allocation block. */
@@ -446,8 +445,7 @@ found_it2:
*res = NULL;
}
mref = le64_to_cpu(ie->data.dir.indexed_file);
- unlock_page(page);
- ntfs_unmap_page(page);
+ put_locked_page(page);
return mref;
}
/*
@@ -479,8 +477,7 @@ found_it2:
"this message to "
"linux-ntfs-dev@lists."
"sourceforge.net.");
- unlock_page(page);
- ntfs_unmap_page(page);
+ put_locked_page(page);
goto dir_err_out;
}
@@ -562,8 +559,7 @@ found_it2:
vol->cluster_size_bits >>
PAGE_CACHE_SHIFT)
goto fast_descend_into_child_node;
- unlock_page(page);
- ntfs_unmap_page(page);
+ put_locked_page(page);
goto descend_into_child_node;
}
ntfs_error(sb, "Negative child node vcn in directory inode "
@@ -576,15 +572,13 @@ found_it2:
* associated with it.
*/
if (name) {
- unlock_page(page);
- ntfs_unmap_page(page);
+ put_locked_page(page);
return name->mref;
}
ntfs_debug("Entry not found.");
err = -ENOENT;
unm_err_out:
- unlock_page(page);
- ntfs_unmap_page(page);
+ put_locked_page(page);
err_out:
if (!err)
err = -EIO;
@@ -795,7 +789,7 @@ descend_into_child_node:
* of PAGE_CACHE_SIZE and map the page cache page, reading it from
* disk if necessary.
*/
- page = ntfs_map_page(ia_mapping, vcn <<
+ page = __read_kmap_page(ia_mapping, vcn <<
dir_ni->itype.index.vcn_size_bits >> PAGE_CACHE_SHIFT);
if (IS_ERR(page)) {
ntfs_error(sb, "Failed to map directory index page, error %ld.",
@@ -803,7 +797,6 @@ descend_into_child_node:
err = PTR_ERR(page);
goto err_out;
}
- lock_page(page);
kaddr = (u8*)page_address(page);
fast_descend_into_child_node:
/* Get to the index allocation block. */
@@ -907,8 +900,7 @@ fast_descend_into_child_node:
vol->upcase, vol->upcase_len)) {
found_it2:
mref = le64_to_cpu(ie->data.dir.indexed_file);
- unlock_page(page);
- ntfs_unmap_page(page);
+ put_locked_page(page);
return mref;
}
/*
@@ -971,8 +963,7 @@ found_it2:
vol->cluster_size_bits >>
PAGE_CACHE_SHIFT)
goto fast_descend_into_child_node;
- unlock_page(page);
- ntfs_unmap_page(page);
+ put_locked_page(page);
goto descend_into_child_node;
}
ntfs_error(sb, "Negative child node vcn in directory inode "
@@ -983,8 +974,7 @@ found_it2:
ntfs_debug("Entry not found.");
err = -ENOENT;
unm_err_out:
- unlock_page(page);
- ntfs_unmap_page(page);
+ put_locked_page(page);
err_out:
if (!err)
err = -EIO;
@@ -1271,7 +1261,7 @@ get_next_bmp_page:
(unsigned long long)bmp_pos >> (3 + PAGE_CACHE_SHIFT),
(unsigned long long)bmp_pos &
(unsigned long long)((PAGE_CACHE_SIZE * 8) - 1));
- bmp_page = ntfs_map_page(bmp_mapping,
+ bmp_page = read_kmap_page(bmp_mapping,
bmp_pos >> (3 + PAGE_CACHE_SHIFT));
if (IS_ERR(bmp_page)) {
ntfs_error(sb, "Reading index bitmap failed.");
@@ -1289,7 +1279,7 @@ find_next_index_buffer:
* page, and put away the old one.
*/
if (unlikely((cur_bmp_pos >> 3) >= PAGE_CACHE_SIZE)) {
- ntfs_unmap_page(bmp_page);
+ put_kmapped_page(bmp_page);
bmp_pos += PAGE_CACHE_SIZE * 8;
cur_bmp_pos = 0;
goto get_next_bmp_page;
@@ -1306,22 +1296,20 @@ find_next_index_buffer:
if ((prev_ia_pos & (s64)PAGE_CACHE_MASK) !=
(ia_pos & (s64)PAGE_CACHE_MASK)) {
prev_ia_pos = ia_pos;
- if (likely(ia_page != NULL)) {
- unlock_page(ia_page);
- ntfs_unmap_page(ia_page);
- }
+ if (likely(ia_page != NULL))
+ put_locked_page(ia_page);
+
/*
* Map the page cache page containing the current ia_pos,
* reading it from disk if necessary.
*/
- ia_page = ntfs_map_page(ia_mapping, ia_pos >> PAGE_CACHE_SHIFT);
+ ia_page = __read_kmap_page(ia_mapping, ia_pos >> PAGE_CACHE_SHIFT);
if (IS_ERR(ia_page)) {
ntfs_error(sb, "Reading index allocation data failed.");
err = PTR_ERR(ia_page);
ia_page = NULL;
goto err_out;
}
- lock_page(ia_page);
kaddr = (u8*)page_address(ia_page);
}
/* Get the current index buffer. */
@@ -1422,19 +1410,18 @@ find_next_index_buffer:
filldir);
if (rc) {
/* @ia_page is already unlocked in this case. */
- ntfs_unmap_page(ia_page);
- ntfs_unmap_page(bmp_page);
+ put_kmapped_page(ia_page);
+ put_kmapped_page(bmp_page);
iput(bmp_vi);
goto abort;
}
}
goto find_next_index_buffer;
unm_EOD:
- if (ia_page) {
- unlock_page(ia_page);
- ntfs_unmap_page(ia_page);
- }
- ntfs_unmap_page(bmp_page);
+ if (ia_page)
+ put_locked_page(ia_page);
+
+ put_kmapped_page(bmp_page);
iput(bmp_vi);
EOD:
/* We are finished, set fpos to EOD. */
@@ -1453,14 +1440,12 @@ done:
return 0;
err_out:
if (bmp_page) {
- ntfs_unmap_page(bmp_page);
+ put_kmapped_page(bmp_page);
iput_err_out:
iput(bmp_vi);
}
- if (ia_page) {
- unlock_page(ia_page);
- ntfs_unmap_page(ia_page);
- }
+ if (ia_page)
+ put_locked_page(ia_page);
kfree(ir);
kfree(name);
if (ctx)
diff -urpN -X dontdiff linux-2.6.21-rc5-mm4/fs/ntfs/index.c linux-2.6.21-rc5-mm4-test/fs/ntfs/index.c
--- linux-2.6.21-rc5-mm4/fs/ntfs/index.c 2007-04-05 17:13:11.000000000 -0700
+++ linux-2.6.21-rc5-mm4-test/fs/ntfs/index.c 2007-04-06 01:59:19.000000000 -0700
@@ -64,8 +64,7 @@ void ntfs_index_ctx_put(ntfs_index_conte
struct page *page = ictx->page;
if (page) {
BUG_ON(!PageLocked(page));
- unlock_page(page);
- ntfs_unmap_page(page);
+ put_locked_page(page);
}
}
}
@@ -273,7 +272,7 @@ descend_into_child_node:
* of PAGE_CACHE_SIZE and map the page cache page, reading it from
* disk if necessary.
*/
- page = ntfs_map_page(ia_mapping, vcn <<
+ page = __read_kmap_page(ia_mapping, vcn <<
idx_ni->itype.index.vcn_size_bits >> PAGE_CACHE_SHIFT);
if (IS_ERR(page)) {
ntfs_error(sb, "Failed to map index page, error %ld.",
@@ -281,7 +280,6 @@ descend_into_child_node:
err = PTR_ERR(page);
goto err_out;
}
- lock_page(page);
kaddr = (u8*)page_address(page);
fast_descend_into_child_node:
/* Get to the index allocation block. */
@@ -429,15 +427,13 @@ ia_done:
vol->cluster_size_bits >>
PAGE_CACHE_SHIFT)
goto fast_descend_into_child_node;
- unlock_page(page);
- ntfs_unmap_page(page);
+ put_locked_page(page);
goto descend_into_child_node;
}
ntfs_error(sb, "Negative child node vcn in inode 0x%lx.",
idx_ni->mft_no);
unm_err_out:
- unlock_page(page);
- ntfs_unmap_page(page);
+ put_locked_page(page);
err_out:
if (!err)
err = -EIO;
diff -urpN -X dontdiff linux-2.6.21-rc5-mm4/fs/ntfs/lcnalloc.c linux-2.6.21-rc5-mm4-test/fs/ntfs/lcnalloc.c
--- linux-2.6.21-rc5-mm4/fs/ntfs/lcnalloc.c 2006-11-29 13:57:37.000000000 -0800
+++ linux-2.6.21-rc5-mm4-test/fs/ntfs/lcnalloc.c 2007-04-06 01:59:19.000000000 -0700
@@ -280,9 +280,9 @@ runlist_element *ntfs_cluster_alloc(ntfs
set_page_dirty(page);
need_writeback = 0;
}
- ntfs_unmap_page(page);
+ put_kmapped_page(page);
}
- page = ntfs_map_page(mapping, last_read_pos >>
+ page = read_kmap_page(mapping, last_read_pos >>
PAGE_CACHE_SHIFT);
if (IS_ERR(page)) {
err = PTR_ERR(page);
@@ -748,7 +748,7 @@ out:
set_page_dirty(page);
need_writeback = 0;
}
- ntfs_unmap_page(page);
+ put_kmapped_page(page);
}
if (likely(!err)) {
up_write(&vol->lcnbmp_lock);
diff -urpN -X dontdiff linux-2.6.21-rc5-mm4/fs/ntfs/logfile.c linux-2.6.21-rc5-mm4-test/fs/ntfs/logfile.c
--- linux-2.6.21-rc5-mm4/fs/ntfs/logfile.c 2006-11-29 13:57:37.000000000 -0800
+++ linux-2.6.21-rc5-mm4-test/fs/ntfs/logfile.c 2007-04-06 01:59:19.000000000 -0700
@@ -396,7 +396,7 @@ static int ntfs_check_and_load_restart_p
idx = (pos + size) >> PAGE_CACHE_SHIFT;
BUG_ON((pos + size) & ~PAGE_CACHE_MASK);
do {
- page = ntfs_map_page(vi->i_mapping, idx);
+ page = read_kmap_page(vi->i_mapping, idx);
if (IS_ERR(page)) {
ntfs_error(vi->i_sb, "Error mapping $LogFile "
"page (index %lu).", idx);
@@ -407,7 +407,7 @@ static int ntfs_check_and_load_restart_p
}
size = min_t(int, to_read, PAGE_CACHE_SIZE);
memcpy((u8*)trp + have_read, page_address(page), size);
- ntfs_unmap_page(page);
+ put_kmapped_page(page);
have_read += size;
to_read -= size;
idx++;
@@ -541,8 +541,8 @@ bool ntfs_check_logfile(struct inode *lo
pgoff_t idx = pos >> PAGE_CACHE_SHIFT;
if (!page || page->index != idx) {
if (page)
- ntfs_unmap_page(page);
- page = ntfs_map_page(mapping, idx);
+ put_kmapped_page(page);
+ page = read_kmap_page(mapping, idx);
if (IS_ERR(page)) {
ntfs_error(vol->sb, "Error mapping $LogFile "
"page (index %lu).", idx);
@@ -602,7 +602,7 @@ bool ntfs_check_logfile(struct inode *lo
* find a valid one further in the file.
*/
if (err != -EINVAL) {
- ntfs_unmap_page(page);
+ put_kmapped_page(page);
goto err_out;
}
/* Continue looking. */
@@ -610,7 +610,7 @@ bool ntfs_check_logfile(struct inode *lo
pos = NTFS_BLOCK_SIZE >> 1;
}
if (page)
- ntfs_unmap_page(page);
+ put_kmapped_page(page);
if (logfile_is_empty) {
NVolSetLogFileEmpty(vol);
is_empty:
diff -urpN -X dontdiff linux-2.6.21-rc5-mm4/fs/ntfs/mft.c linux-2.6.21-rc5-mm4-test/fs/ntfs/mft.c
--- linux-2.6.21-rc5-mm4/fs/ntfs/mft.c 2006-11-29 13:57:37.000000000 -0800
+++ linux-2.6.21-rc5-mm4-test/fs/ntfs/mft.c 2007-04-06 01:59:19.000000000 -0700
@@ -80,7 +80,7 @@ static inline MFT_RECORD *map_mft_record
}
}
/* Read, map, and pin the page. */
- page = ntfs_map_page(mft_vi->i_mapping, index);
+ page = read_kmap_page(mft_vi->i_mapping, index);
if (likely(!IS_ERR(page))) {
/* Catch multi sector transfer fixup errors. */
if (likely(ntfs_is_mft_recordp((le32*)(page_address(page) +
@@ -91,7 +91,7 @@ static inline MFT_RECORD *map_mft_record
}
ntfs_error(vol->sb, "Mft record 0x%lx is corrupt. "
"Run chkdsk.", ni->mft_no);
- ntfs_unmap_page(page);
+ put_kmapped_page(page);
page = ERR_PTR(-EIO);
NVolSetErrors(vol);
}
@@ -192,7 +192,7 @@ static inline void unmap_mft_record_page
BUG_ON(!ni->page);
// TODO: If dirty, blah...
- ntfs_unmap_page(ni->page);
+ put_kmapped_page(ni->page);
ni->page = NULL;
ni->page_ofs = 0;
return;
@@ -486,14 +486,13 @@ int ntfs_sync_mft_mirror(ntfs_volume *vo
goto err_out;
}
/* Get the page containing the mirror copy of the mft record @m. */
- page = ntfs_map_page(vol->mftmirr_ino->i_mapping, mft_no >>
+ page = __read_kmap_page(vol->mftmirr_ino->i_mapping, mft_no >>
(PAGE_CACHE_SHIFT - vol->mft_record_size_bits));
if (IS_ERR(page)) {
ntfs_error(vol->sb, "Failed to map mft mirror page.");
err = PTR_ERR(page);
goto err_out;
}
- lock_page(page);
BUG_ON(!PageUptodate(page));
ClearPageUptodate(page);
/* Offset of the mft mirror record inside the page. */
@@ -618,8 +617,7 @@ int ntfs_sync_mft_mirror(ntfs_volume *vo
post_write_mst_fixup((NTFS_RECORD*)kmirr);
flush_dcache_page(page);
SetPageUptodate(page);
- unlock_page(page);
- ntfs_unmap_page(page);
+ put_locked_page(page);
if (likely(!err)) {
ntfs_debug("Done.");
} else {
@@ -1189,7 +1187,7 @@ static int ntfs_mft_bitmap_find_and_allo
* for a zero bit.
*/
if (size) {
- page = ntfs_map_page(mftbmp_mapping,
+ page = read_kmap_page(mftbmp_mapping,
ofs >> PAGE_CACHE_SHIFT);
if (unlikely(IS_ERR(page))) {
ntfs_error(vol->sb, "Failed to read mft "
@@ -1211,13 +1209,13 @@ static int ntfs_mft_bitmap_find_and_allo
if (b < 8 && b >= (bit & 7)) {
ll = data_pos + (bit & ~7ull) + b;
if (unlikely(ll > (1ll << 32))) {
- ntfs_unmap_page(page);
+ put_kmapped_page(page);
return -ENOSPC;
}
*byte |= 1 << b;
flush_dcache_page(page);
set_page_dirty(page);
- ntfs_unmap_page(page);
+ put_kmapped_page(page);
ntfs_debug("Done. (Found and "
"allocated mft record "
"0x%llx.)",
@@ -1229,7 +1227,7 @@ static int ntfs_mft_bitmap_find_and_allo
"data_pos 0x%llx, bit 0x%llx", size,
(long long)data_pos, (long long)bit);
data_pos += size;
- ntfs_unmap_page(page);
+ put_kmapped_page(page);
/*
* If the end of the pass has not been reached yet,
* continue searching the mft bitmap for a zero bit.
@@ -1327,7 +1325,7 @@ static int ntfs_mft_bitmap_extend_alloca
* to us.
*/
ll = lcn >> 3;
- page = ntfs_map_page(vol->lcnbmp_ino->i_mapping,
+ page = read_kmap_page(vol->lcnbmp_ino->i_mapping,
ll >> PAGE_CACHE_SHIFT);
if (IS_ERR(page)) {
up_write(&mftbmp_ni->runlist.lock);
@@ -1343,7 +1341,7 @@ static int ntfs_mft_bitmap_extend_alloca
flush_dcache_page(page);
set_page_dirty(page);
up_write(&vol->lcnbmp_lock);
- ntfs_unmap_page(page);
+ put_kmapped_page(page);
/* Update the mft bitmap runlist. */
rl->length++;
rl[1].vcn++;
@@ -1351,7 +1349,7 @@ static int ntfs_mft_bitmap_extend_alloca
ntfs_debug("Appending one cluster to mft bitmap.");
} else {
up_write(&vol->lcnbmp_lock);
- ntfs_unmap_page(page);
+ put_kmapped_page(page);
/* Allocate a cluster from the DATA_ZONE. */
rl2 = ntfs_cluster_alloc(vol, rl[1].vcn, 1, lcn, DATA_ZONE,
true);
@@ -2117,13 +2115,12 @@ static int ntfs_mft_record_format(const
}
}
/* Read, map, and pin the page containing the mft record. */
- page = ntfs_map_page(mft_vi->i_mapping, index);
+ page = __read_kmap_page(mft_vi->i_mapping, index);
if (unlikely(IS_ERR(page))) {
ntfs_error(vol->sb, "Failed to map page containing mft record "
"to format 0x%llx.", (long long)mft_no);
return PTR_ERR(page);
}
- lock_page(page);
BUG_ON(!PageUptodate(page));
ClearPageUptodate(page);
m = (MFT_RECORD*)((u8*)page_address(page) + ofs);
@@ -2132,20 +2129,18 @@ static int ntfs_mft_record_format(const
ntfs_error(vol->sb, "Failed to layout mft record 0x%llx.",
(long long)mft_no);
SetPageUptodate(page);
- unlock_page(page);
- ntfs_unmap_page(page);
+ put_locked_page(page);
return err;
}
flush_dcache_page(page);
SetPageUptodate(page);
- unlock_page(page);
/*
* Make sure the mft record is written out to disk. We could use
* ilookup5() to check if an inode is in icache and so on but this is
* unnecessary as ntfs_writepage() will write the dirty record anyway.
*/
mark_ntfs_record_dirty(page, ofs);
- ntfs_unmap_page(page);
+ put_locked_page(page);
ntfs_debug("Done.");
return 0;
}
@@ -2518,14 +2513,13 @@ mft_rec_already_initialized:
index = bit << vol->mft_record_size_bits >> PAGE_CACHE_SHIFT;
ofs = (bit << vol->mft_record_size_bits) & ~PAGE_CACHE_MASK;
/* Read, map, and pin the page containing the mft record. */
- page = ntfs_map_page(vol->mft_ino->i_mapping, index);
+ page = __read_kmap_page(vol->mft_ino->i_mapping, index);
if (unlikely(IS_ERR(page))) {
ntfs_error(vol->sb, "Failed to map page containing allocated "
"mft record 0x%llx.", (long long)bit);
err = PTR_ERR(page);
goto undo_mftbmp_alloc;
}
- lock_page(page);
BUG_ON(!PageUptodate(page));
ClearPageUptodate(page);
m = (MFT_RECORD*)((u8*)page_address(page) + ofs);
@@ -2541,8 +2535,7 @@ mft_rec_already_initialized:
(long long)bit);
err = -EIO;
SetPageUptodate(page);
- unlock_page(page);
- ntfs_unmap_page(page);
+ put_locked_page(page);
NVolSetErrors(vol);
goto undo_mftbmp_alloc;
}
@@ -2560,8 +2553,7 @@ mft_rec_already_initialized:
ntfs_error(vol->sb, "Failed to layout allocated mft "
"record 0x%llx.", (long long)bit);
SetPageUptodate(page);
- unlock_page(page);
- ntfs_unmap_page(page);
+ put_locked_page(page);
goto undo_mftbmp_alloc;
}
if (seq_no)
@@ -2599,8 +2591,7 @@ mft_rec_already_initialized:
flush_dcache_page(page);
/* Make sure the mft record is written out to disk. */
mark_ntfs_record_dirty(page, ofs);
- unlock_page(page);
- ntfs_unmap_page(page);
+ put_locked_page(page);
goto undo_mftbmp_alloc;
}
/*
@@ -2611,12 +2602,11 @@ mft_rec_already_initialized:
* the mft record.
*/
mark_ntfs_record_dirty(page, ofs);
- unlock_page(page);
/*
* Need to unmap the page since map_extent_mft_record() mapped
* it as well so we have it mapped twice at the moment.
*/
- ntfs_unmap_page(page);
+ put_locked_page(page);
} else {
/*
* Allocate a new VFS inode and set it up. NOTE: @vi->i_nlink
@@ -2632,8 +2622,7 @@ mft_rec_already_initialized:
flush_dcache_page(page);
/* Make sure the mft record is written out to disk. */
mark_ntfs_record_dirty(page, ofs);
- unlock_page(page);
- ntfs_unmap_page(page);
+ put_locked_page(page);
goto undo_mftbmp_alloc;
}
vi->i_ino = bit;
diff -urpN -X dontdiff linux-2.6.21-rc5-mm4/fs/ntfs/super.c linux-2.6.21-rc5-mm4-test/fs/ntfs/super.c
--- linux-2.6.21-rc5-mm4/fs/ntfs/super.c 2007-04-05 17:14:25.000000000 -0700
+++ linux-2.6.21-rc5-mm4-test/fs/ntfs/super.c 2007-04-06 12:40:53.000000000 -0700
@@ -1078,11 +1078,11 @@ static bool check_mft_mirror(ntfs_volume
/* Switch pages if necessary. */
if (!(i % mrecs_per_page)) {
if (index) {
- ntfs_unmap_page(mft_page);
- ntfs_unmap_page(mirr_page);
+ put_kmapped_page(mft_page);
+ put_kmapped_page(mirr_page);
}
/* Get the $MFT page. */
- mft_page = ntfs_map_page(vol->mft_ino->i_mapping,
+ mft_page = read_kmap_page(vol->mft_ino->i_mapping,
index);
if (IS_ERR(mft_page)) {
ntfs_error(sb, "Failed to read $MFT.");
@@ -1090,7 +1090,7 @@ static bool check_mft_mirror(ntfs_volume
}
kmft = page_address(mft_page);
/* Get the $MFTMirr page. */
- mirr_page = ntfs_map_page(vol->mftmirr_ino->i_mapping,
+ mirr_page = read_kmap_page(vol->mftmirr_ino->i_mapping,
index);
if (IS_ERR(mirr_page)) {
ntfs_error(sb, "Failed to read $MFTMirr.");
@@ -1107,9 +1107,9 @@ static bool check_mft_mirror(ntfs_volume
"transfer detected in mft "
"record %i.", i);
mm_unmap_out:
- ntfs_unmap_page(mirr_page);
+ put_kmapped_page(mirr_page);
mft_unmap_out:
- ntfs_unmap_page(mft_page);
+ put_kmapped_page(mft_page);
return false;
}
}
@@ -1143,8 +1143,8 @@ mft_unmap_out:
kmirr += vol->mft_record_size;
} while (++i < vol->mftmirr_size);
/* Release the last pages. */
- ntfs_unmap_page(mft_page);
- ntfs_unmap_page(mirr_page);
+ put_kmapped_page(mft_page);
+ put_kmapped_page(mirr_page);
/* Construct the mft mirror runlist by hand. */
rl2[0].vcn = 0;
@@ -1289,7 +1289,7 @@ static int check_windows_hibernation_sta
goto iput_out;
}
ni = NTFS_I(vi);
- page = ntfs_map_page(vi->i_mapping, 0);
+ page = read_kmap_page(vi->i_mapping, 0);
if (IS_ERR(page)) {
ntfs_error(vol->sb, "Failed to read from hiberfil.sys.");
ret = PTR_ERR(page);
@@ -1319,7 +1319,7 @@ static int check_windows_hibernation_sta
"volume.");
ret = 0;
unm_iput_out:
- ntfs_unmap_page(page);
+ put_kmapped_page(page);
iput_out:
iput(vi);
return ret;
@@ -1509,7 +1509,7 @@ not_enabled:
return false;
}
/* Read the USN_HEADER from $DATA/$Max. */
- page = ntfs_map_page(vol->usnjrnl_max_ino->i_mapping, 0);
+ page = read_kmap_page(vol->usnjrnl_max_ino->i_mapping, 0);
if (IS_ERR(page)) {
ntfs_error(vol->sb, "Failed to read from $UsnJrnl/$DATA/$Max "
"attribute.");
@@ -1523,7 +1523,7 @@ not_enabled:
"maximum size (0x%llx). $UsnJrnl is corrupt.",
(long long)sle64_to_cpu(uh->allocation_delta),
(long long)sle64_to_cpu(uh->maximum_size));
- ntfs_unmap_page(page);
+ put_kmapped_page(page);
return false;
}
/*
@@ -1534,7 +1534,7 @@ not_enabled:
i_size_read(vol->usnjrnl_j_ino))) {
if (likely(sle64_to_cpu(uh->lowest_valid_usn) ==
i_size_read(vol->usnjrnl_j_ino))) {
- ntfs_unmap_page(page);
+ put_kmapped_page(page);
ntfs_debug("$UsnJrnl is enabled but nothing has been "
"logged since it was last stamped. "
"Treating this as if the volume does "
@@ -1547,10 +1547,10 @@ not_enabled:
"is corrupt.",
(long long)sle64_to_cpu(uh->lowest_valid_usn),
i_size_read(vol->usnjrnl_j_ino));
- ntfs_unmap_page(page);
+ put_kmapped_page(page);
return false;
}
- ntfs_unmap_page(page);
+ put_kmapped_page(page);
ntfs_debug("Done.");
return true;
}
@@ -1592,12 +1592,12 @@ static bool load_and_init_attrdef(ntfs_v
while (index < max_index) {
/* Read the attrdef table and copy it into the linear buffer. */
read_partial_attrdef_page:
- page = ntfs_map_page(ino->i_mapping, index);
+ page = read_kmap_page(ino->i_mapping, index);
if (IS_ERR(page))
goto free_iput_failed;
memcpy((u8*)vol->attrdef + (index++ << PAGE_CACHE_SHIFT),
page_address(page), size);
- ntfs_unmap_page(page);
+ put_kmapped_page(page);
};
if (size == PAGE_CACHE_SIZE) {
size = i_size & ~PAGE_CACHE_MASK;
@@ -1661,12 +1661,12 @@ static bool load_and_init_upcase(ntfs_vo
while (index < max_index) {
/* Read the upcase table and copy it into the linear buffer. */
read_partial_upcase_page:
- page = ntfs_map_page(ino->i_mapping, index);
+ page = read_kmap_page(ino->i_mapping, index);
if (IS_ERR(page))
goto iput_upcase_failed;
memcpy((char*)vol->upcase + (index++ << PAGE_CACHE_SHIFT),
page_address(page), size);
- ntfs_unmap_page(page);
+ put_kmapped_page(page);
};
if (size == PAGE_CACHE_SIZE) {
size = i_size & ~PAGE_CACHE_MASK;
diff -urpN -X dontdiff linux-2.6.21-rc5-mm4/fs/ntfs/usnjrnl.c linux-2.6.21-rc5-mm4-test/fs/ntfs/usnjrnl.c
--- linux-2.6.21-rc5-mm4/fs/ntfs/usnjrnl.c 2006-11-29 13:57:37.000000000 -0800
+++ linux-2.6.21-rc5-mm4-test/fs/ntfs/usnjrnl.c 2007-04-06 01:59:19.000000000 -0700
@@ -52,7 +52,7 @@ bool ntfs_stamp_usnjrnl(ntfs_volume *vol
struct page *page;
USN_HEADER *uh;
- page = ntfs_map_page(vol->usnjrnl_max_ino->i_mapping, 0);
+ page = read_kmap_page(vol->usnjrnl_max_ino->i_mapping, 0);
if (IS_ERR(page)) {
ntfs_error(vol->sb, "Failed to read from "
"$UsnJrnl/$DATA/$Max attribute.");
@@ -73,7 +73,7 @@ bool ntfs_stamp_usnjrnl(ntfs_volume *vol
uh->journal_id = stamp;
flush_dcache_page(page);
set_page_dirty(page);
- ntfs_unmap_page(page);
+ put_kmapped_page(page);
/* Set the flag so we do not have to do it again on remount. */
NVolSetUsnJrnlStamped(vol);
}
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH 5/17] hfsplus: remove redundant read_mapping_page error check
2007-04-12 2:49 [PATCH 0/17] fs: cleanup single page synchronous read interface Nate Diller
` (14 preceding siblings ...)
2007-04-12 2:49 ` [PATCH 10/17] mtd: convert page_read to read_kmap_page Nate Diller
@ 2007-04-12 2:49 ` Nate Diller
2007-04-12 2:49 ` [PATCH 9/17] minix: convert dir_get_page to read_kmap_page Nate Diller
16 siblings, 0 replies; 33+ messages in thread
From: Nate Diller @ 2007-04-12 2:49 UTC (permalink / raw)
To: Andrew Morton, Alexander Viro, Christoph Hellwig, Roman Zippel,
Mikulas Patocka, David Woodhouse, Dave Kleikamp,
Anton Altaparmakov, Evgeniy Dushistov
Cc: linux-kernel, linux-fsdevel, reiserfs-dev
Now that read_mapping_page() does error checking internally, there is no
need to check PageError here.
Signed-off-by: Nate Diller <nate.diller@gmail.com>
---
diff -urpN -X dontdiff linux-2.6.21-rc6-mm1/fs/hfsplus/bnode.c linux-2.6.21-rc6-mm1-test/fs/hfsplus/bnode.c
--- linux-2.6.21-rc6-mm1/fs/hfsplus/bnode.c 2007-04-09 17:20:13.000000000 -0700
+++ linux-2.6.21-rc6-mm1-test/fs/hfsplus/bnode.c 2007-04-10 21:28:45.000000000 -0700
@@ -442,10 +442,6 @@ static struct hfs_bnode *__hfs_bnode_cre
page = read_mapping_page(mapping, block, NULL);
if (IS_ERR(page))
goto fail;
- if (PageError(page)) {
- page_cache_release(page);
- goto fail;
- }
page_cache_release(page);
node->page[i] = page;
}
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH 6/17] hfs: remove redundant read_mapping_page error check
2007-04-12 2:49 [PATCH 0/17] fs: cleanup single page synchronous read interface Nate Diller
` (3 preceding siblings ...)
2007-04-12 2:49 ` [PATCH 3/17] afs: convert afs_dir_get_page " Nate Diller
@ 2007-04-12 2:49 ` Nate Diller
2007-04-12 2:49 ` [PATCH 14/17] reiserfs: convert reiserfs_get_page to read_kmap_page Nate Diller
` (11 subsequent siblings)
16 siblings, 0 replies; 33+ messages in thread
From: Nate Diller @ 2007-04-12 2:49 UTC (permalink / raw)
To: Andrew Morton, Alexander Viro, Christoph Hellwig, Roman Zippel,
Mikulas Patocka, David Woodhouse, Dave Kleikamp,
Anton Altaparmakov, Evgeniy Dushistov
Cc: linux-kernel, linux-fsdevel, reiserfs-dev
Now that read_mapping_page() does error checking internally, there is no
need to check PageError here.
Signed-off-by: Nate Diller <nate.diller@gmail.com>
---
diff -urpN -X dontdiff linux-2.6.21-rc6-mm1/fs/hfs/bnode.c linux-2.6.21-rc6-mm1-test/fs/hfs/bnode.c
--- linux-2.6.21-rc6-mm1/fs/hfs/bnode.c 2007-04-09 17:20:13.000000000 -0700
+++ linux-2.6.21-rc6-mm1-test/fs/hfs/bnode.c 2007-04-10 21:28:03.000000000 -0700
@@ -282,10 +282,6 @@ static struct hfs_bnode *__hfs_bnode_cre
page = read_mapping_page(mapping, block++, NULL);
if (IS_ERR(page))
goto fail;
- if (PageError(page)) {
- page_cache_release(page);
- goto fail;
- }
page_cache_release(page);
node->page[i] = page;
}
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH 7/17] jffs2: convert jffs2_gc_fetch_page to read_cache_page
2007-04-12 2:49 [PATCH 0/17] fs: cleanup single page synchronous read interface Nate Diller
@ 2007-04-12 2:49 ` Nate Diller
2007-04-12 11:40 ` Phillip Lougher
2007-04-15 10:52 ` David Woodhouse
2007-04-12 2:49 ` [PATCH 4/17] ext2: convert ext2_get_page to read_kmap_page Nate Diller
` (15 subsequent siblings)
16 siblings, 2 replies; 33+ messages in thread
From: Nate Diller @ 2007-04-12 2:49 UTC (permalink / raw)
To: Andrew Morton, Alexander Viro, Christoph Hellwig, Roman Zippel,
Mikulas Patocka, David Woodhouse, Dave Kleikamp,
Anton Altaparmakov, Evgeniy Dushistov
Cc: linux-kernel, linux-fsdevel, reiserfs-dev
Replace jffs2_gc_fetch_page() and jffs2_gc_release_page() using the
read_cache_page() and put_kmapped_page() calls, and update the call site
accordingly. Explicit calls to kmap()/kunmap() make the code more clear.
Signed-off-by: Nate Diller <nate.diller@gmail.com>
---
diff -urpN -X dontdiff linux-2.6.21-rc5-mm4/fs/jffs2/fs.c linux-2.6.21-rc5-mm4-test/fs/jffs2/fs.c
--- linux-2.6.21-rc5-mm4/fs/jffs2/fs.c 2007-04-05 17:14:25.000000000 -0700
+++ linux-2.6.21-rc5-mm4-test/fs/jffs2/fs.c 2007-04-06 01:59:19.000000000 -0700
@@ -621,33 +621,6 @@ struct jffs2_inode_info *jffs2_gc_fetch_
return JFFS2_INODE_INFO(inode);
}
-unsigned char *jffs2_gc_fetch_page(struct jffs2_sb_info *c,
- struct jffs2_inode_info *f,
- unsigned long offset,
- unsigned long *priv)
-{
- struct inode *inode = OFNI_EDONI_2SFFJ(f);
- struct page *pg;
-
- pg = read_cache_page(inode->i_mapping, offset >> PAGE_CACHE_SHIFT,
- (void *)jffs2_do_readpage_unlock, inode);
- if (IS_ERR(pg))
- return (void *)pg;
-
- *priv = (unsigned long)pg;
- return kmap(pg);
-}
-
-void jffs2_gc_release_page(struct jffs2_sb_info *c,
- unsigned char *ptr,
- unsigned long *priv)
-{
- struct page *pg = (void *)*priv;
-
- kunmap(pg);
- page_cache_release(pg);
-}
-
static int jffs2_flash_setup(struct jffs2_sb_info *c) {
int ret = 0;
diff -urpN -X dontdiff linux-2.6.21-rc5-mm4/fs/jffs2/gc.c linux-2.6.21-rc5-mm4-test/fs/jffs2/gc.c
--- linux-2.6.21-rc5-mm4/fs/jffs2/gc.c 2007-04-05 17:13:10.000000000 -0700
+++ linux-2.6.21-rc5-mm4-test/fs/jffs2/gc.c 2007-04-06 01:59:19.000000000 -0700
@@ -1078,7 +1078,7 @@ static int jffs2_garbage_collect_dnode(s
uint32_t alloclen, offset, orig_end, orig_start;
int ret = 0;
unsigned char *comprbuf = NULL, *writebuf;
- unsigned long pg;
+ struct page *page;
unsigned char *pg_ptr;
memset(&ri, 0, sizeof(ri));
@@ -1219,12 +1219,16 @@ static int jffs2_garbage_collect_dnode(s
* page OK. We'll actually write it out again in commit_write, which is a little
* suboptimal, but at least we're correct.
*/
- pg_ptr = jffs2_gc_fetch_page(c, f, start, &pg);
+ page = read_cache_page(OFNI_EDONI_2SFFJ(f)->i_mapping,
+ start >> PAGE_CACHE_SHIFT,
+ (void *)jffs2_do_readpage_unlock,
+ OFNI_EDONI_2SFFJ(f));
- if (IS_ERR(pg_ptr)) {
+ if (IS_ERR(page)) {
printk(KERN_WARNING "read_cache_page() returned error: %ld\n", PTR_ERR(pg_ptr));
- return PTR_ERR(pg_ptr);
+ return PTR_ERR(page);
}
+ pg_ptr = kmap(page);
offset = start;
while(offset < orig_end) {
@@ -1287,6 +1291,7 @@ static int jffs2_garbage_collect_dnode(s
}
}
- jffs2_gc_release_page(c, pg_ptr, &pg);
+ kunmap(page);
+ page_cache_release(page);
return ret;
}
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH 1/17] cramfs: use read_mapping_page
2007-04-12 2:49 [PATCH 0/17] fs: cleanup single page synchronous read interface Nate Diller
` (11 preceding siblings ...)
2007-04-12 2:49 ` [PATCH 8/17] jfs: use locking read_mapping_page Nate Diller
@ 2007-04-12 2:49 ` Nate Diller
2007-04-12 9:54 ` Christoph Hellwig
2007-04-12 2:49 ` [PATCH 13/17] reiser4: remove redundant read_mapping_page error checks Nate Diller
` (3 subsequent siblings)
16 siblings, 1 reply; 33+ messages in thread
From: Nate Diller @ 2007-04-12 2:49 UTC (permalink / raw)
To: Andrew Morton, Alexander Viro, Christoph Hellwig, Roman Zippel,
Mikulas Patocka, David Woodhouse, Dave Kleikamp,
Anton Altaparmakov, Evgeniy Dushistov
Cc: linux-kernel, linux-fsdevel, reiserfs-dev
read_mapping_page_async() is going away, so convert its only user to
read_mapping_page(). This change has not been benchmarked, however, in
order to get real parallelism this wants something completely different,
like __do_page_cache_readahead(), which is not currently exported.
Signed-off-by: Nate Diller <nate.diller@gmail.com>
---
diff -urpN -X dontdiff linux-2.6.21-rc6-mm1/fs/cramfs/inode.c linux-2.6.21-rc6-mm1-test/fs/cramfs/inode.c
--- linux-2.6.21-rc6-mm1/fs/cramfs/inode.c 2007-04-09 17:24:03.000000000 -0700
+++ linux-2.6.21-rc6-mm1-test/fs/cramfs/inode.c 2007-04-09 21:37:09.000000000 -0700
@@ -180,8 +180,7 @@ static void *cramfs_read(struct super_bl
struct page *page = NULL;
if (blocknr + i < devsize) {
- page = read_mapping_page_async(mapping, blocknr + i,
- NULL);
+ page = read_mapping_page(mapping, blocknr + i, NULL);
/* synchronous error? */
if (IS_ERR(page))
page = NULL;
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 1/17] cramfs: use read_mapping_page
2007-04-12 2:49 ` [PATCH 1/17] cramfs: use read_mapping_page Nate Diller
@ 2007-04-12 9:54 ` Christoph Hellwig
2007-04-12 11:26 ` Roman Zippel
0 siblings, 1 reply; 33+ messages in thread
From: Christoph Hellwig @ 2007-04-12 9:54 UTC (permalink / raw)
To: Nate Diller
Cc: Andrew Morton, Alexander Viro, Christoph Hellwig, Roman Zippel,
Mikulas Patocka, David Woodhouse, Dave Kleikamp,
Anton Altaparmakov, Evgeniy Dushistov, linux-kernel,
linux-fsdevel, reiserfs-dev
On Wed, Apr 11, 2007 at 07:49:38PM -0700, Nate Diller wrote:
> read_mapping_page_async() is going away, so convert its only user to
> read_mapping_page(). This change has not been benchmarked, however, in
> order to get real parallelism this wants something completely different,
> like __do_page_cache_readahead(), which is not currently exported.
Why is read_mapping_page_async going away? This probably needs a lot more
testing, and I'd be much happier if you split it out of the series and
sent it separately at the end.
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 3/17] afs: convert afs_dir_get_page to read_kmap_page
2007-04-12 2:49 ` [PATCH 3/17] afs: convert afs_dir_get_page " Nate Diller
@ 2007-04-12 10:58 ` David Howells
2007-04-12 18:23 ` Nate Diller
0 siblings, 1 reply; 33+ messages in thread
From: David Howells @ 2007-04-12 10:58 UTC (permalink / raw)
To: Nate Diller
Cc: Andrew Morton, Alexander Viro, Christoph Hellwig, Roman Zippel,
Mikulas Patocka, David Woodhouse, Dave Kleikamp,
Anton Altaparmakov, Evgeniy Dushistov, linux-kernel,
linux-fsdevel, reiserfs-dev
Nate Diller <nate.diller@gmail.com> wrote:
> -static struct page *afs_dir_get_page(struct inode *dir, unsigned long index)
NAK. This conflicts with my AFS security patches, and eliminates any way of
passing the key through to readpage().
David
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 1/17] cramfs: use read_mapping_page
2007-04-12 9:54 ` Christoph Hellwig
@ 2007-04-12 11:26 ` Roman Zippel
2007-04-12 18:36 ` Nate Diller
0 siblings, 1 reply; 33+ messages in thread
From: Roman Zippel @ 2007-04-12 11:26 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Nate Diller, Andrew Morton, Alexander Viro, Mikulas Patocka,
David Woodhouse, Dave Kleikamp, Anton Altaparmakov,
Evgeniy Dushistov, linux-kernel, linux-fsdevel, reiserfs-dev
Hi,
On Thu, 12 Apr 2007, Christoph Hellwig wrote:
> On Wed, Apr 11, 2007 at 07:49:38PM -0700, Nate Diller wrote:
> > read_mapping_page_async() is going away, so convert its only user to
> > read_mapping_page(). This change has not been benchmarked, however, in
> > order to get real parallelism this wants something completely different,
> > like __do_page_cache_readahead(), which is not currently exported.
>
> Why is read_mapping_page_async going away? This probably needs a lot more
> testing, and I'd be much happier if you split it out of the series and
> sent it separately at the end.
That function wasn't fully async anyway, as it would often sleep in
lock_page(). AFAICT only in the special case of a partial written page
would this function return a not yet uptodate page.
bye, Roman
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 7/17] jffs2: convert jffs2_gc_fetch_page to read_cache_page
2007-04-12 2:49 ` [PATCH 7/17] jffs2: convert jffs2_gc_fetch_page to read_cache_page Nate Diller
@ 2007-04-12 11:40 ` Phillip Lougher
2007-04-12 18:29 ` Nate Diller
2007-04-15 10:52 ` David Woodhouse
1 sibling, 1 reply; 33+ messages in thread
From: Phillip Lougher @ 2007-04-12 11:40 UTC (permalink / raw)
To: Nate Diller; +Cc: Andrew Morton, David Woodhouse, linux-kernel, linux-fsdevel
Nate Diller wrote:
> + page = read_cache_page(OFNI_EDONI_2SFFJ(f)->i_mapping,
> + start >> PAGE_CACHE_SHIFT,
> + (void *)jffs2_do_readpage_unlock,
> + OFNI_EDONI_2SFFJ(f));
>
> - if (IS_ERR(pg_ptr)) {
> + if (IS_ERR(page)) {
> printk(KERN_WARNING "read_cache_page() returned error: %ld\n", PTR_ERR(pg_ptr));
should be
printk(KERN_WARNING "read_cache_page() returned error: %ld\n", PTR_ERR(page));
> - return PTR_ERR(pg_ptr);
> + return PTR_ERR(page);
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 3/17] afs: convert afs_dir_get_page to read_kmap_page
2007-04-12 10:58 ` David Howells
@ 2007-04-12 18:23 ` Nate Diller
2007-04-12 18:57 ` David Howells
0 siblings, 1 reply; 33+ messages in thread
From: Nate Diller @ 2007-04-12 18:23 UTC (permalink / raw)
To: David Howells
Cc: Andrew Morton, Alexander Viro, Christoph Hellwig, Roman Zippel,
Mikulas Patocka, David Woodhouse, Dave Kleikamp,
Anton Altaparmakov, Evgeniy Dushistov, linux-kernel,
linux-fsdevel, reiserfs-dev
On 4/12/07, David Howells <dhowells@redhat.com> wrote:
> Nate Diller <nate.diller@gmail.com> wrote:
>
> > -static struct page *afs_dir_get_page(struct inode *dir, unsigned long index)
>
> NAK. This conflicts with my AFS security patches, and eliminates any way of
> passing the key through to readpage().
Hmmm you're right. Is your security work going into the next -mm? If
so, I'll just re-base this cleanup patch on that ... at the very least
I want to get rid of afs_dir_put_page(). Also, did you consider
passing the key pointer directly and modifying the readpage actor to
simply cast the pointer back, like read_mapping_page(mapping, page,
(struct file *)key)? It seems like a waste to allocate a whole file
struct on the stack just for the ->private field.
Andrew in the mean time just disregard this patch.
NATE
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 7/17] jffs2: convert jffs2_gc_fetch_page to read_cache_page
2007-04-12 11:40 ` Phillip Lougher
@ 2007-04-12 18:29 ` Nate Diller
2007-04-12 18:53 ` Phillip Lougher
0 siblings, 1 reply; 33+ messages in thread
From: Nate Diller @ 2007-04-12 18:29 UTC (permalink / raw)
To: Phillip Lougher
Cc: Andrew Morton, David Woodhouse, linux-kernel, linux-fsdevel
On 4/12/07, Phillip Lougher <phillip@lougher.demon.co.uk> wrote:
> Nate Diller wrote:
>
> > + page = read_cache_page(OFNI_EDONI_2SFFJ(f)->i_mapping,
> > + start >> PAGE_CACHE_SHIFT,
> > + (void *)jffs2_do_readpage_unlock,
> > + OFNI_EDONI_2SFFJ(f));
> >
> > - if (IS_ERR(pg_ptr)) {
> > + if (IS_ERR(page)) {
> > printk(KERN_WARNING "read_cache_page() returned error: %ld\n", PTR_ERR(pg_ptr));
>
> should be
>
> printk(KERN_WARNING "read_cache_page() returned error: %ld\n", PTR_ERR(page));
>
> > - return PTR_ERR(pg_ptr);
> > + return PTR_ERR(page);
>
wow, you're right. I was sure I compile-tested this ... oh, "depends
on MTD". oops.
thanks for reviewing. does it look OK to you otherwise?
NATE
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 1/17] cramfs: use read_mapping_page
2007-04-12 11:26 ` Roman Zippel
@ 2007-04-12 18:36 ` Nate Diller
0 siblings, 0 replies; 33+ messages in thread
From: Nate Diller @ 2007-04-12 18:36 UTC (permalink / raw)
To: Roman Zippel
Cc: Christoph Hellwig, Andrew Morton, Alexander Viro, Mikulas Patocka,
David Woodhouse, Dave Kleikamp, Anton Altaparmakov,
Evgeniy Dushistov, linux-kernel, linux-fsdevel, reiserfs-dev
On 4/12/07, Roman Zippel <zippel@linux-m68k.org> wrote:
> Hi,
>
> On Thu, 12 Apr 2007, Christoph Hellwig wrote:
>
> > On Wed, Apr 11, 2007 at 07:49:38PM -0700, Nate Diller wrote:
> > > read_mapping_page_async() is going away, so convert its only user to
> > > read_mapping_page(). This change has not been benchmarked, however, in
> > > order to get real parallelism this wants something completely different,
> > > like __do_page_cache_readahead(), which is not currently exported.
> >
> > Why is read_mapping_page_async going away? This probably needs a lot more
> > testing, and I'd be much happier if you split it out of the series and
> > sent it separately at the end.
>
> That function wasn't fully async anyway, as it would often sleep in
> lock_page(). AFAICT only in the special case of a partial written page
> would this function return a not yet uptodate page.
yes, exactly, the structure of read_cache_page() and friends is
totally not appropriate for doing async I/O to more than one page at a
time, and the whole point of the special treatment in cramfs was to
read 4 pages at once rather than synchronously reading each of the 4
seperately. read_cache_page_async() is totally wrong for that use,
its purpose would be to get a reference to a single page that is
likely to be in cache already without having to take the page_lock.
Turns out nobody needs to do that, so there's no point in keeping it
around.
If the performance gain of reading all 4 pages at once would be worth
the effort, this code should be using __do_page_cache_readahead().
That function allocates all the pages first, then reads them in
asynchronously as a group. It is currently not exported.
NATE
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 7/17] jffs2: convert jffs2_gc_fetch_page to read_cache_page
2007-04-12 18:29 ` Nate Diller
@ 2007-04-12 18:53 ` Phillip Lougher
0 siblings, 0 replies; 33+ messages in thread
From: Phillip Lougher @ 2007-04-12 18:53 UTC (permalink / raw)
To: Nate Diller; +Cc: Andrew Morton, David Woodhouse, linux-kernel, linux-fsdevel
Nate Diller wrote:
>
> wow, you're right. I was sure I compile-tested this ... oh, "depends
> on MTD". oops.
>
> thanks for reviewing. does it look OK to you otherwise?
>
Yes..
> NATE
>
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 3/17] afs: convert afs_dir_get_page to read_kmap_page
2007-04-12 18:23 ` Nate Diller
@ 2007-04-12 18:57 ` David Howells
2007-04-12 19:21 ` Andrew Morton
2007-04-12 19:27 ` [PATCH 3/17] afs: convert afs_dir_get_page to read_kmap_page Nate Diller
0 siblings, 2 replies; 33+ messages in thread
From: David Howells @ 2007-04-12 18:57 UTC (permalink / raw)
To: Nate Diller
Cc: Andrew Morton, Alexander Viro, Christoph Hellwig, Roman Zippel,
Mikulas Patocka, David Woodhouse, Dave Kleikamp,
Anton Altaparmakov, Evgeniy Dushistov, linux-kernel,
linux-fsdevel, reiserfs-dev
Nate Diller <nate.diller@gmail.com> wrote:
> Hmmm you're right. Is your security work going into the next -mm?
I don't know. Andrew hasn't said anything. Andrew? Are you waiting for it
to go through DaveM's networking tree?
> If so, I'll just re-base this cleanup patch on that ... at the very least I
> want to get rid of afs_dir_put_page().
That's reasonable.
> Also, did you consider passing the key pointer directly and modifying the
> readpage actor to simply cast the pointer back, like
> read_mapping_page(mapping, page, (struct file *)key)? It seems like a waste
> to allocate a whole file struct on the stack just for the ->private field.
There's one small problem with that... And that's filemap_nopage() (it passes
vma->vm_file to readpage() unconditionally). Unless, of course, your patches
fix that too...
David
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 3/17] afs: convert afs_dir_get_page to read_kmap_page
2007-04-12 18:57 ` David Howells
@ 2007-04-12 19:21 ` Andrew Morton
2007-04-12 19:29 ` David Howells
2007-07-16 6:05 ` Drop patch update-isdn-tree-to-use-pci_get_device.patch from -mm tree Surya Prabhakar N
2007-04-12 19:27 ` [PATCH 3/17] afs: convert afs_dir_get_page to read_kmap_page Nate Diller
1 sibling, 2 replies; 33+ messages in thread
From: Andrew Morton @ 2007-04-12 19:21 UTC (permalink / raw)
To: David Howells
Cc: Nate Diller, Alexander Viro, Christoph Hellwig, Roman Zippel,
Mikulas Patocka, David Woodhouse, Dave Kleikamp,
Anton Altaparmakov, Evgeniy Dushistov, linux-kernel,
linux-fsdevel, reiserfs-dev
On Thu, 12 Apr 2007 19:57:23 +0100
David Howells <dhowells@redhat.com> wrote:
> > Hmmm you're right. Is your security work going into the next -mm?
>
> I don't know. Andrew hasn't said anything. Andrew? Are you waiting for it
> to go through DaveM's networking tree?
AF_RXRPC is a davem thing and "AFS: Add security support and fix bugs"
has dependencise upon it. So we're waiting for you and the networking
guys to sort all that out.
Or am I wrong??
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 3/17] afs: convert afs_dir_get_page to read_kmap_page
2007-04-12 18:57 ` David Howells
2007-04-12 19:21 ` Andrew Morton
@ 2007-04-12 19:27 ` Nate Diller
2007-04-12 19:43 ` David Howells
1 sibling, 1 reply; 33+ messages in thread
From: Nate Diller @ 2007-04-12 19:27 UTC (permalink / raw)
To: David Howells
Cc: Andrew Morton, Alexander Viro, Christoph Hellwig, Roman Zippel,
Mikulas Patocka, David Woodhouse, Dave Kleikamp,
Anton Altaparmakov, Evgeniy Dushistov, linux-kernel,
linux-fsdevel, reiserfs-dev
On 4/12/07, David Howells <dhowells@redhat.com> wrote:
> Nate Diller <nate.diller@gmail.com> wrote:
>
> > Hmmm you're right. Is your security work going into the next -mm?
>
> I don't know. Andrew hasn't said anything. Andrew? Are you waiting for it
> to go through DaveM's networking tree?
>
> > If so, I'll just re-base this cleanup patch on that ... at the very least I
> > want to get rid of afs_dir_put_page().
>
> That's reasonable.
>
> > Also, did you consider passing the key pointer directly and modifying the
> > readpage actor to simply cast the pointer back, like
> > read_mapping_page(mapping, page, (struct file *)key)? It seems like a waste
> > to allocate a whole file struct on the stack just for the ->private field.
>
> There's one small problem with that... And that's filemap_nopage() (it passes
> vma->vm_file to readpage() unconditionally). Unless, of course, your patches
> fix that too...
But you can't mmap() a directory anyway so ... oh. Interesting.
afs_file_readpage() does directories too. The only thing I can think
of then is
struct address_space_operations afs_file_aops = {
.readpage = afs_file_readpage,
}
struct address_space_operations afs_dir_aops = {
.readpage = afs_key_readpage,
}
int afs_file_readpage(file, page){
return afs_key_readpage(file->private, page)
}
but that's a lot of code to avoid a single stack allocation. The
whole fake file pointer thing still strikes me as a little ugly, and
you're definitely not the first one who needed this sort of hackery.
ugh
NATE
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 3/17] afs: convert afs_dir_get_page to read_kmap_page
2007-04-12 19:21 ` Andrew Morton
@ 2007-04-12 19:29 ` David Howells
2007-07-16 6:05 ` Drop patch update-isdn-tree-to-use-pci_get_device.patch from -mm tree Surya Prabhakar N
1 sibling, 0 replies; 33+ messages in thread
From: David Howells @ 2007-04-12 19:29 UTC (permalink / raw)
To: Andrew Morton
Cc: Nate Diller, Alexander Viro, Christoph Hellwig, Roman Zippel,
Mikulas Patocka, David Woodhouse, Dave Kleikamp,
Anton Altaparmakov, Evgeniy Dushistov, linux-kernel,
linux-fsdevel, reiserfs-dev
Andrew Morton <akpm@linux-foundation.org> wrote:
> > > Hmmm you're right. Is your security work going into the next -mm?
> >
> > I don't know. Andrew hasn't said anything. Andrew? Are you waiting for it
> > to go through DaveM's networking tree?
>
> AF_RXRPC is a davem thing and "AFS: Add security support and fix bugs"
> has dependencise upon it. So we're waiting for you and the networking
> guys to sort all that out.
I thought this was probably the case, but no-one's actually said what the
assimilation procedure is.
> Or am I wrong??
Doubtful.
David
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 3/17] afs: convert afs_dir_get_page to read_kmap_page
2007-04-12 19:27 ` [PATCH 3/17] afs: convert afs_dir_get_page to read_kmap_page Nate Diller
@ 2007-04-12 19:43 ` David Howells
0 siblings, 0 replies; 33+ messages in thread
From: David Howells @ 2007-04-12 19:43 UTC (permalink / raw)
To: Nate Diller
Cc: Andrew Morton, Alexander Viro, Christoph Hellwig, Roman Zippel,
Mikulas Patocka, David Woodhouse, Dave Kleikamp,
Anton Altaparmakov, Evgeniy Dushistov, linux-kernel,
linux-fsdevel, reiserfs-dev
Nate Diller <nate.diller@gmail.com> wrote:
> but that's a lot of code to avoid a single stack allocation. The
> whole fake file pointer thing still strikes me as a little ugly, and
> you're definitely not the first one who needed this sort of hackery.
> ugh
A better way might be to stick a void * in struct file and pass that through
to readpage() and readpages() instead of the struct file *. That way, anyone
who wants the traditional arrangement can just point that extra void * at the
struct file.
Of course, I'm in favour of making it a struct key * like this:
struct address_space_operations {
...
int (*readpage)(struct key *, struct page *);
...
int (*readpages)(struct key *, struct address_space *,
struct list_head *, unsigned);
...
};
struct file {
...
struct key *f_key;
};
struct page *filemap_nopage(struct vm_area_struct *area, ...)
{
...
struct file *file = area->vm_file;
...
error = mapping->a_ops->readpage(file->f_key, page);
...
}
But I'm not sure the NFS crew, for instance, would be happy with that. Maybe
passing file->private_data through would do. That's basically what NFS and
FUSE, for instance, want, and it would also do for AFS.
David
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 7/17] jffs2: convert jffs2_gc_fetch_page to read_cache_page
2007-04-12 2:49 ` [PATCH 7/17] jffs2: convert jffs2_gc_fetch_page to read_cache_page Nate Diller
2007-04-12 11:40 ` Phillip Lougher
@ 2007-04-15 10:52 ` David Woodhouse
1 sibling, 0 replies; 33+ messages in thread
From: David Woodhouse @ 2007-04-15 10:52 UTC (permalink / raw)
To: Nate Diller
Cc: Andrew Morton, Alexander Viro, Christoph Hellwig, Roman Zippel,
Mikulas Patocka, Dave Kleikamp, Anton Altaparmakov,
Evgeniy Dushistov, linux-kernel, linux-fsdevel, reiserfs-dev
On Wed, 2007-04-11 at 19:49 -0700, Nate Diller wrote:
> Replace jffs2_gc_fetch_page() and jffs2_gc_release_page() using the
> read_cache_page() and put_kmapped_page() calls, and update the call site
> accordingly. Explicit calls to kmap()/kunmap() make the code more clear.
>
> Signed-off-by: Nate Diller <nate.diller@gmail.com>
Please don't remove the jffs2_gc_{fetch,release}_page functions. The
reason they're in a separate file is because that file (fs.c) is built
on Linux only, while the file you're moving the code into (gc.c) is
OS-agnostic; it's used on other sytems (eCos) too.
Rather than forcing eCos and any other systems which have a JFFS2 port
to implement a crappy Linux 'emulation' layer, I try to keep the
Linuxisms localised to certain files which can be completely
reimplemented for a non-Linux port.
--
dwmw2
^ permalink raw reply [flat|nested] 33+ messages in thread
* Drop patch update-isdn-tree-to-use-pci_get_device.patch from -mm tree
2007-04-12 19:21 ` Andrew Morton
2007-04-12 19:29 ` David Howells
@ 2007-07-16 6:05 ` Surya Prabhakar N
1 sibling, 0 replies; 33+ messages in thread
From: Surya Prabhakar N @ 2007-07-16 6:05 UTC (permalink / raw)
To: Andrew Morton; +Cc: kkeil, Linux Kernel, isdn4linux, Jeff Garzik
Hi Andrew,
I would request you to drop the patch
update-isdn-tree-to-use-pci_get_device.patch
from the -mm tree since a new bug is been identified in that by jeff.
thanks.
surya.
^ permalink raw reply [flat|nested] 33+ messages in thread
end of thread, other threads:[~2007-07-16 6:02 UTC | newest]
Thread overview: 33+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-12 2:49 [PATCH 0/17] fs: cleanup single page synchronous read interface Nate Diller
2007-04-12 2:49 ` [PATCH 7/17] jffs2: convert jffs2_gc_fetch_page to read_cache_page Nate Diller
2007-04-12 11:40 ` Phillip Lougher
2007-04-12 18:29 ` Nate Diller
2007-04-12 18:53 ` Phillip Lougher
2007-04-15 10:52 ` David Woodhouse
2007-04-12 2:49 ` [PATCH 4/17] ext2: convert ext2_get_page to read_kmap_page Nate Diller
2007-04-12 2:49 ` [PATCH 17/17] vxfs: convert vxfs_get_page " Nate Diller
2007-04-12 2:49 ` [PATCH 3/17] afs: convert afs_dir_get_page " Nate Diller
2007-04-12 10:58 ` David Howells
2007-04-12 18:23 ` Nate Diller
2007-04-12 18:57 ` David Howells
2007-04-12 19:21 ` Andrew Morton
2007-04-12 19:29 ` David Howells
2007-07-16 6:05 ` Drop patch update-isdn-tree-to-use-pci_get_device.patch from -mm tree Surya Prabhakar N
2007-04-12 19:27 ` [PATCH 3/17] afs: convert afs_dir_get_page to read_kmap_page Nate Diller
2007-04-12 19:43 ` David Howells
2007-04-12 2:49 ` [PATCH 6/17] hfs: remove redundant read_mapping_page error check Nate Diller
2007-04-12 2:49 ` [PATCH 14/17] reiserfs: convert reiserfs_get_page to read_kmap_page Nate Diller
2007-04-12 2:49 ` [PATCH 12/17] partition: remove redundant read_mapping_page error checks Nate Diller
2007-04-12 2:49 ` [PATCH 11/17] ntfs: convert ntfs_map_page to read_kmap_page Nate Diller
2007-04-12 2:49 ` [PATCH 16/17] ufs: convert ufs_get_page " Nate Diller
2007-04-12 2:49 ` [PATCH 15/17] sysv: convert dir_get_page " Nate Diller
2007-04-12 2:49 ` [PATCH 2/17] fs: introduce new read_cache_page interface Nate Diller
2007-04-12 2:49 ` [PATCH 8/17] jfs: use locking read_mapping_page Nate Diller
2007-04-12 2:49 ` [PATCH 1/17] cramfs: use read_mapping_page Nate Diller
2007-04-12 9:54 ` Christoph Hellwig
2007-04-12 11:26 ` Roman Zippel
2007-04-12 18:36 ` Nate Diller
2007-04-12 2:49 ` [PATCH 13/17] reiser4: remove redundant read_mapping_page error checks Nate Diller
2007-04-12 2:49 ` [PATCH 10/17] mtd: convert page_read to read_kmap_page Nate Diller
2007-04-12 2:49 ` [PATCH 5/17] hfsplus: remove redundant read_mapping_page error check Nate Diller
2007-04-12 2:49 ` [PATCH 9/17] minix: convert dir_get_page to read_kmap_page Nate Diller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox