[PATCH] read_mapping_page for address space
authorPekka Enberg <penberg@cs.helsinki.fi>
Fri, 23 Jun 2006 09:05:08 +0000 (02:05 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Fri, 23 Jun 2006 14:43:02 +0000 (07:43 -0700)
Add read_mapping_page() which is used for callers that pass
mapping->a_ops->readpage as the filler for read_cache_page.  This removes
some duplication from filesystem code.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
22 files changed:
fs/afs/dir.c
fs/afs/mntpt.c
fs/cramfs/inode.c
fs/ext2/dir.c
fs/freevxfs/vxfs_subr.c
fs/hfs/bnode.c
fs/hfs/btree.c
fs/hfsplus/bitmap.c
fs/hfsplus/bnode.c
fs/hfsplus/btree.c
fs/jfs/jfs_metapage.c
fs/minix/dir.c
fs/namei.c
fs/ntfs/aops.h
fs/ntfs/attrib.c
fs/ntfs/file.c
fs/ocfs2/symlink.c
fs/partitions/check.c
fs/reiserfs/xattr.c
fs/sysv/dir.c
include/linux/pagemap.h
mm/swapfile.c

index a6dff6a4f204c9cfa3fdcfd8b703f9cdc1d74afd..2fc99877cb0d1b55c74329a40cd23f2eaae91e13 100644 (file)
@@ -185,9 +185,7 @@ static struct page *afs_dir_get_page(struct inode *dir, unsigned long index)
 
        _enter("{%lu},%lu", dir->i_ino, index);
 
-       page = read_cache_page(dir->i_mapping,index,
-                              (filler_t *) dir->i_mapping->a_ops->readpage,
-                              NULL);
+       page = read_mapping_page(dir->i_mapping, index, NULL);
        if (!IS_ERR(page)) {
                wait_on_page_locked(page);
                kmap(page);
index 4e6eeb59b83cc02a2ccb1b24ad3ba515770f8d57..b5cf9e1205ad316c01bfdb5a34abdc81bc752dfe 100644 (file)
@@ -63,7 +63,6 @@ unsigned long afs_mntpt_expiry_timeout = 20;
 int afs_mntpt_check_symlink(struct afs_vnode *vnode)
 {
        struct page *page;
-       filler_t *filler;
        size_t size;
        char *buf;
        int ret;
@@ -71,10 +70,7 @@ int afs_mntpt_check_symlink(struct afs_vnode *vnode)
        _enter("{%u,%u}", vnode->fid.vnode, vnode->fid.unique);
 
        /* read the contents of the symlink into the pagecache */
-       filler = (filler_t *) AFS_VNODE_TO_I(vnode)->i_mapping->a_ops->readpage;
-
-       page = read_cache_page(AFS_VNODE_TO_I(vnode)->i_mapping, 0,
-                              filler, NULL);
+       page = read_mapping_page(AFS_VNODE_TO_I(vnode)->i_mapping, 0, NULL);
        if (IS_ERR(page)) {
                ret = PTR_ERR(page);
                goto out;
@@ -160,7 +156,6 @@ static struct vfsmount *afs_mntpt_do_automount(struct dentry *mntpt)
        struct page *page = NULL;
        size_t size;
        char *buf, *devname = NULL, *options = NULL;
-       filler_t *filler;
        int ret;
 
        kenter("{%s}", mntpt->d_name.name);
@@ -182,9 +177,7 @@ static struct vfsmount *afs_mntpt_do_automount(struct dentry *mntpt)
                goto error;
 
        /* read the contents of the AFS special symlink */
-       filler = (filler_t *)mntpt->d_inode->i_mapping->a_ops->readpage;
-
-       page = read_cache_page(mntpt->d_inode->i_mapping, 0, filler, NULL);
+       page = read_mapping_page(mntpt->d_inode->i_mapping, 0, NULL);
        if (IS_ERR(page)) {
                ret = PTR_ERR(page);
                goto error;
index 8a9d5d3b3262ae68a4c0a10ec2f25567e5fbe112..c45d738608039c5a20a4b2055bc3dd8e4c40cfcf 100644 (file)
@@ -181,9 +181,7 @@ static void *cramfs_read(struct super_block *sb, unsigned int offset, unsigned i
                struct page *page = NULL;
 
                if (blocknr + i < devsize) {
-                       page = read_cache_page(mapping, blocknr + i,
-                               (filler_t *)mapping->a_ops->readpage,
-                               NULL);
+                       page = read_mapping_page(mapping, blocknr + i, NULL);
                        /* synchronous error? */
                        if (IS_ERR(page))
                                page = NULL;
index d672aa9f40612b94ba9810ff5c681d7106a4c5b1..3c1c9aaaca6bef152deae5d93b03e9db7e278d67 100644 (file)
@@ -159,8 +159,7 @@ fail:
 static struct page * ext2_get_page(struct inode *dir, unsigned long n)
 {
        struct address_space *mapping = dir->i_mapping;
-       struct page *page = read_cache_page(mapping, n,
-                               (filler_t*)mapping->a_ops->readpage, NULL);
+       struct page *page = read_mapping_page(mapping, n, NULL);
        if (!IS_ERR(page)) {
                wait_on_page_locked(page);
                kmap(page);
index 50aae77651b29c9c6558ee50f77ebe7ee6e55011..c1be118fc0670a079099909c824535b599bc7423 100644 (file)
@@ -71,8 +71,7 @@ vxfs_get_page(struct address_space *mapping, u_long n)
 {
        struct page *                   pp;
 
-       pp = read_cache_page(mapping, n,
-                       (filler_t*)mapping->a_ops->readpage, NULL);
+       pp = read_mapping_page(mapping, n, NULL);
 
        if (!IS_ERR(pp)) {
                wait_on_page_locked(pp);
index 1e44dcfe49c4971315fd39d3d33772b0dfbd8a9c..13231dd5ce660c7ac5e16e476306289b12151c41 100644 (file)
@@ -280,7 +280,7 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)
        block = off >> PAGE_CACHE_SHIFT;
        node->page_offset = off & ~PAGE_CACHE_MASK;
        for (i = 0; i < tree->pages_per_bnode; i++) {
-               page = read_cache_page(mapping, block++, (filler_t *)mapping->a_ops->readpage, NULL);
+               page = read_mapping_page(mapping, block++, NULL);
                if (IS_ERR(page))
                        goto fail;
                if (PageError(page)) {
index d20131ce4b959a3260fc6cebcf29d1bd4825cb20..40035799431992573e1e97f87e25e666f1061ddf 100644 (file)
@@ -59,7 +59,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id, btree_keycmp ke
        unlock_new_inode(tree->inode);
 
        mapping = tree->inode->i_mapping;
-       page = read_cache_page(mapping, 0, (filler_t *)mapping->a_ops->readpage, NULL);
+       page = read_mapping_page(mapping, 0, NULL);
        if (IS_ERR(page))
                goto free_tree;
 
index 9fb51632303c0248b85f7ccd6c43828be3fa8dd5..d128a25b74d2e78ae14b5e06473629add09d620b 100644 (file)
@@ -31,8 +31,7 @@ int hfsplus_block_allocate(struct super_block *sb, u32 size, u32 offset, u32 *ma
        dprint(DBG_BITMAP, "block_allocate: %u,%u,%u\n", size, offset, len);
        mutex_lock(&HFSPLUS_SB(sb).alloc_file->i_mutex);
        mapping = HFSPLUS_SB(sb).alloc_file->i_mapping;
-       page = read_cache_page(mapping, offset / PAGE_CACHE_BITS,
-                              (filler_t *)mapping->a_ops->readpage, NULL);
+       page = read_mapping_page(mapping, offset / PAGE_CACHE_BITS, NULL);
        pptr = kmap(page);
        curr = pptr + (offset & (PAGE_CACHE_BITS - 1)) / 32;
        i = offset % 32;
@@ -72,8 +71,8 @@ int hfsplus_block_allocate(struct super_block *sb, u32 size, u32 offset, u32 *ma
                offset += PAGE_CACHE_BITS;
                if (offset >= size)
                        break;
-               page = read_cache_page(mapping, offset / PAGE_CACHE_BITS,
-                                      (filler_t *)mapping->a_ops->readpage, NULL);
+               page = read_mapping_page(mapping, offset / PAGE_CACHE_BITS,
+                                        NULL);
                curr = pptr = kmap(page);
                if ((size ^ offset) / PAGE_CACHE_BITS)
                        end = pptr + PAGE_CACHE_BITS / 32;
@@ -119,8 +118,8 @@ found:
                set_page_dirty(page);
                kunmap(page);
                offset += PAGE_CACHE_BITS;
-               page = read_cache_page(mapping, offset / PAGE_CACHE_BITS,
-                                      (filler_t *)mapping->a_ops->readpage, NULL);
+               page = read_mapping_page(mapping, offset / PAGE_CACHE_BITS,
+                                        NULL);
                pptr = kmap(page);
                curr = pptr;
                end = pptr + PAGE_CACHE_BITS / 32;
@@ -167,7 +166,7 @@ int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count)
        mutex_lock(&HFSPLUS_SB(sb).alloc_file->i_mutex);
        mapping = HFSPLUS_SB(sb).alloc_file->i_mapping;
        pnr = offset / PAGE_CACHE_BITS;
-       page = read_cache_page(mapping, pnr, (filler_t *)mapping->a_ops->readpage, NULL);
+       page = read_mapping_page(mapping, pnr, NULL);
        pptr = kmap(page);
        curr = pptr + (offset & (PAGE_CACHE_BITS - 1)) / 32;
        end = pptr + PAGE_CACHE_BITS / 32;
@@ -199,7 +198,7 @@ int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count)
                        break;
                set_page_dirty(page);
                kunmap(page);
-               page = read_cache_page(mapping, ++pnr, (filler_t *)mapping->a_ops->readpage, NULL);
+               page = read_mapping_page(mapping, ++pnr, NULL);
                pptr = kmap(page);
                curr = pptr;
                end = pptr + PAGE_CACHE_BITS / 32;
index 746abc9ecf70f344418c37c8f47062aeb9c5e3ef..77bf434da6796d89a9181ae50f9af0dd60a6bcf5 100644 (file)
@@ -440,7 +440,7 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)
        block = off >> PAGE_CACHE_SHIFT;
        node->page_offset = off & ~PAGE_CACHE_MASK;
        for (i = 0; i < tree->pages_per_bnode; block++, i++) {
-               page = read_cache_page(mapping, block, (filler_t *)mapping->a_ops->readpage, NULL);
+               page = read_mapping_page(mapping, block, NULL);
                if (IS_ERR(page))
                        goto fail;
                if (PageError(page)) {
index effa8991999c9d0d140939f1a81fe8ca638eb8f6..cfc852fdd1b574b0455db793706018ecdb80aef0 100644 (file)
@@ -38,7 +38,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id)
                goto free_tree;
 
        mapping = tree->inode->i_mapping;
-       page = read_cache_page(mapping, 0, (filler_t *)mapping->a_ops->readpage, NULL);
+       page = read_mapping_page(mapping, 0, NULL);
        if (IS_ERR(page))
                goto free_tree;
 
index 2b220dd6b4e7290976dc3e37765eeb6d9ec08a5e..7f6e88039700c085b09188b8ad350aaecc5b6733 100644 (file)
@@ -632,10 +632,9 @@ struct metapage *__get_metapage(struct inode *inode, unsigned long lblock,
                }
                SetPageUptodate(page);
        } else {
-               page = read_cache_page(mapping, page_index,
-                           (filler_t *)mapping->a_ops->readpage, NULL);
+               page = read_mapping_page(mapping, page_index, NULL);
                if (IS_ERR(page) || !PageUptodate(page)) {
-                       jfs_err("read_cache_page failed!");
+                       jfs_err("read_mapping_page failed!");
                        return NULL;
                }
                lock_page(page);
index 69224d1fe043d635089f60dcb0452b1366bd9839..2b0a389d19874765585f3565102005f6facdc470 100644 (file)
@@ -60,8 +60,7 @@ static int dir_commit_chunk(struct page *page, unsigned from, unsigned to)
 static struct page * dir_get_page(struct inode *dir, unsigned long n)
 {
        struct address_space *mapping = dir->i_mapping;
-       struct page *page = read_cache_page(mapping, n,
-                               (filler_t*)mapping->a_ops->readpage, NULL);
+       struct page *page = read_mapping_page(mapping, n, NULL);
        if (!IS_ERR(page)) {
                wait_on_page_locked(page);
                kmap(page);
index 184fe4acf82449dae1c62eade2d4489b078f24aa..bb4a3e40e43269944523fc4f3987d4a556ca5f84 100644 (file)
@@ -2577,8 +2577,7 @@ static char *page_getlink(struct dentry * dentry, struct page **ppage)
 {
        struct page * page;
        struct address_space *mapping = dentry->d_inode->i_mapping;
-       page = read_cache_page(mapping, 0, (filler_t *)mapping->a_ops->readpage,
-                               NULL);
+       page = read_mapping_page(mapping, 0, NULL);
        if (IS_ERR(page))
                goto sync_fail;
        wait_on_page_locked(page);
index 3b74e66ca2ff83c648ac1910de6ecbbfc6a26dbb..325ce261a107d3773040d463038ade0b34032256 100644 (file)
@@ -86,8 +86,7 @@ static inline void ntfs_unmap_page(struct page *page)
 static inline struct page *ntfs_map_page(struct address_space *mapping,
                unsigned long index)
 {
-       struct page *page = read_cache_page(mapping, index,
-                       (filler_t*)mapping->a_ops->readpage, NULL);
+       struct page *page = read_mapping_page(mapping, index, NULL);
 
        if (!IS_ERR(page)) {
                wait_on_page_locked(page);
index 1663f5c3c6aa9d097fffe9ca7fc1d7fdf5d88a0d..6708e1d68a9ed818902a40dec5a59cd002a56173 100644 (file)
@@ -2529,8 +2529,7 @@ int ntfs_attr_set(ntfs_inode *ni, const s64 ofs, const s64 cnt, const u8 val)
        end >>= PAGE_CACHE_SHIFT;
        /* If there is a first partial page, need to do it the slow way. */
        if (start_ofs) {
-               page = read_cache_page(mapping, idx,
-                               (filler_t*)mapping->a_ops->readpage, NULL);
+               page = read_mapping_page(mapping, idx, NULL);
                if (IS_ERR(page)) {
                        ntfs_error(vol->sb, "Failed to read first partial "
                                        "page (sync error, index 0x%lx).", idx);
@@ -2600,8 +2599,7 @@ int ntfs_attr_set(ntfs_inode *ni, const s64 ofs, const s64 cnt, const u8 val)
        }
        /* If there is a last partial page, need to do it the slow way. */
        if (end_ofs) {
-               page = read_cache_page(mapping, idx,
-                               (filler_t*)mapping->a_ops->readpage, NULL);
+               page = read_mapping_page(mapping, idx, NULL);
                if (IS_ERR(page)) {
                        ntfs_error(vol->sb, "Failed to read last partial page "
                                        "(sync error, index 0x%lx).", idx);
index 36e1e136bb0c65bbdf21f0b8b19602c14964dfa1..88292f9e4b9b58ebb4255b3de77c46b5d1bb8efe 100644 (file)
@@ -231,8 +231,7 @@ do_non_resident_extend:
                 * Read the page.  If the page is not present, this will zero
                 * the uninitialized regions for us.
                 */
-               page = read_cache_page(mapping, index,
-                               (filler_t*)mapping->a_ops->readpage, NULL);
+               page = read_mapping_page(mapping, index, NULL);
                if (IS_ERR(page)) {
                        err = PTR_ERR(page);
                        goto init_err_out;
index f6986bd79e75b5ae8997fc4041ac1b10a77fe8a9..0c8a1294ec967f70e0906a9dfd37a5674da11113 100644 (file)
@@ -64,8 +64,7 @@ static char *ocfs2_page_getlink(struct dentry * dentry,
 {
        struct page * page;
        struct address_space *mapping = dentry->d_inode->i_mapping;
-       page = read_cache_page(mapping, 0,
-                              (filler_t *)mapping->a_ops->readpage, NULL);
+       page = read_mapping_page(mapping, 0, NULL);
        if (IS_ERR(page))
                goto sync_fail;
        wait_on_page_locked(page);
index 8851b81e7c5afb7a7d911cb606bb0d2c98512055..cd885b23cb5ca27d393000c5e9be1edd4aa53792 100644 (file)
@@ -499,8 +499,8 @@ unsigned char *read_dev_sector(struct block_device *bdev, sector_t n, Sector *p)
        struct address_space *mapping = bdev->bd_inode->i_mapping;
        struct page *page;
 
-       page = read_cache_page(mapping, (pgoff_t)(n >> (PAGE_CACHE_SHIFT-9)),
-                       (filler_t *)mapping->a_ops->readpage, NULL);
+       page = read_mapping_page(mapping, (pgoff_t)(n >> (PAGE_CACHE_SHIFT-9)),
+                                NULL);
        if (!IS_ERR(page)) {
                wait_on_page_locked(page);
                if (!PageUptodate(page))
index ffb79c48c5bf974fb6953fe6b761e64f16bbe8fa..39fedaa88a0c13f3c081c98c7b0b37ea120504be 100644 (file)
@@ -452,8 +452,7 @@ static struct page *reiserfs_get_page(struct inode *dir, unsigned long n)
        /* 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_cache_page(mapping, n,
-                              (filler_t *) mapping->a_ops->readpage, NULL);
+       page = read_mapping_page(mapping, n, NULL);
        if (!IS_ERR(page)) {
                wait_on_page_locked(page);
                kmap(page);
index d7074341ee87e4996715bfbca1bbe2210c62d9e8..f2bef962d30983cc1f43d2d965db2faa3fd1af17 100644 (file)
@@ -53,8 +53,7 @@ static int dir_commit_chunk(struct page *page, unsigned from, unsigned to)
 static struct page * dir_get_page(struct inode *dir, unsigned long n)
 {
        struct address_space *mapping = dir->i_mapping;
-       struct page *page = read_cache_page(mapping, n,
-                               (filler_t*)mapping->a_ops->readpage, NULL);
+       struct page *page = read_mapping_page(mapping, n, NULL);
        if (!IS_ERR(page)) {
                wait_on_page_locked(page);
                kmap(page);
index 7a1af574dedfc1f09c57045e446639271891ba80..1245df7141aa6c6c1a973ac429ef417fa70488e9 100644 (file)
@@ -99,6 +99,13 @@ extern struct page * read_cache_page(struct address_space *mapping,
 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(struct address_space *mapping,
+                                            unsigned long index, void *data)
+{
+       filler_t *filler = (filler_t *)mapping->a_ops->readpage;
+       return read_cache_page(mapping, index, filler, data);
+}
+
 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,
index f2824c3c31b428053e4b77c602b357417421dd2d..cc367f7e75d87f39f27a3f4c214a9174b61e87fd 100644 (file)
@@ -1477,8 +1477,7 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
                error = -EINVAL;
                goto bad_swap;
        }
-       page = read_cache_page(mapping, 0,
-                       (filler_t *)mapping->a_ops->readpage, swap_file);
+       page = read_mapping_page(mapping, 0, swap_file);
        if (IS_ERR(page)) {
                error = PTR_ERR(page);
                goto bad_swap;