Skip to content

Commit 090d2b1

Browse files
Pekka EnbergLinus Torvalds
authored andcommitted
[PATCH] read_mapping_page for address space
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>
1 parent c330dda commit 090d2b1

22 files changed

Lines changed: 38 additions & 56 deletions

File tree

‎fs/afs/dir.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,7 @@ static struct page *afs_dir_get_page(struct inode *dir, unsigned long index)
185185

186186
_enter("{%lu},%lu", dir->i_ino, index);
187187

188-
page = read_cache_page(dir->i_mapping,index,
189-
(filler_t *) dir->i_mapping->a_ops->readpage,
190-
NULL);
188+
page = read_mapping_page(dir->i_mapping, index, NULL);
191189
if (!IS_ERR(page)) {
192190
wait_on_page_locked(page);
193191
kmap(page);

‎fs/afs/mntpt.c‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,14 @@ unsigned long afs_mntpt_expiry_timeout = 20;
6363
int afs_mntpt_check_symlink(struct afs_vnode *vnode)
6464
{
6565
struct page *page;
66-
filler_t *filler;
6766
size_t size;
6867
char *buf;
6968
int ret;
7069

7170
_enter("{%u,%u}", vnode->fid.vnode, vnode->fid.unique);
7271

7372
/* read the contents of the symlink into the pagecache */
74-
filler = (filler_t *) AFS_VNODE_TO_I(vnode)->i_mapping->a_ops->readpage;
75-
76-
page = read_cache_page(AFS_VNODE_TO_I(vnode)->i_mapping, 0,
77-
filler, NULL);
73+
page = read_mapping_page(AFS_VNODE_TO_I(vnode)->i_mapping, 0, NULL);
7874
if (IS_ERR(page)) {
7975
ret = PTR_ERR(page);
8076
goto out;
@@ -160,7 +156,6 @@ static struct vfsmount *afs_mntpt_do_automount(struct dentry *mntpt)
160156
struct page *page = NULL;
161157
size_t size;
162158
char *buf, *devname = NULL, *options = NULL;
163-
filler_t *filler;
164159
int ret;
165160

166161
kenter("{%s}", mntpt->d_name.name);
@@ -182,9 +177,7 @@ static struct vfsmount *afs_mntpt_do_automount(struct dentry *mntpt)
182177
goto error;
183178

184179
/* read the contents of the AFS special symlink */
185-
filler = (filler_t *)mntpt->d_inode->i_mapping->a_ops->readpage;
186-
187-
page = read_cache_page(mntpt->d_inode->i_mapping, 0, filler, NULL);
180+
page = read_mapping_page(mntpt->d_inode->i_mapping, 0, NULL);
188181
if (IS_ERR(page)) {
189182
ret = PTR_ERR(page);
190183
goto error;

‎fs/cramfs/inode.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,7 @@ static void *cramfs_read(struct super_block *sb, unsigned int offset, unsigned i
181181
struct page *page = NULL;
182182

183183
if (blocknr + i < devsize) {
184-
page = read_cache_page(mapping, blocknr + i,
185-
(filler_t *)mapping->a_ops->readpage,
186-
NULL);
184+
page = read_mapping_page(mapping, blocknr + i, NULL);
187185
/* synchronous error? */
188186
if (IS_ERR(page))
189187
page = NULL;

‎fs/ext2/dir.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,7 @@ static void ext2_check_page(struct page *page)
159159
static struct page * ext2_get_page(struct inode *dir, unsigned long n)
160160
{
161161
struct address_space *mapping = dir->i_mapping;
162-
struct page *page = read_cache_page(mapping, n,
163-
(filler_t*)mapping->a_ops->readpage, NULL);
162+
struct page *page = read_mapping_page(mapping, n, NULL);
164163
if (!IS_ERR(page)) {
165164
wait_on_page_locked(page);
166165
kmap(page);

‎fs/freevxfs/vxfs_subr.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ vxfs_get_page(struct address_space *mapping, u_long n)
7171
{
7272
struct page * pp;
7373

74-
pp = read_cache_page(mapping, n,
75-
(filler_t*)mapping->a_ops->readpage, NULL);
74+
pp = read_mapping_page(mapping, n, NULL);
7675

7776
if (!IS_ERR(pp)) {
7877
wait_on_page_locked(pp);

‎fs/hfs/bnode.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)
280280
block = off >> PAGE_CACHE_SHIFT;
281281
node->page_offset = off & ~PAGE_CACHE_MASK;
282282
for (i = 0; i < tree->pages_per_bnode; i++) {
283-
page = read_cache_page(mapping, block++, (filler_t *)mapping->a_ops->readpage, NULL);
283+
page = read_mapping_page(mapping, block++, NULL);
284284
if (IS_ERR(page))
285285
goto fail;
286286
if (PageError(page)) {

‎fs/hfs/btree.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id, btree_keycmp ke
5959
unlock_new_inode(tree->inode);
6060

6161
mapping = tree->inode->i_mapping;
62-
page = read_cache_page(mapping, 0, (filler_t *)mapping->a_ops->readpage, NULL);
62+
page = read_mapping_page(mapping, 0, NULL);
6363
if (IS_ERR(page))
6464
goto free_tree;
6565

‎fs/hfsplus/bitmap.c‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ int hfsplus_block_allocate(struct super_block *sb, u32 size, u32 offset, u32 *ma
3131
dprint(DBG_BITMAP, "block_allocate: %u,%u,%u\n", size, offset, len);
3232
mutex_lock(&HFSPLUS_SB(sb).alloc_file->i_mutex);
3333
mapping = HFSPLUS_SB(sb).alloc_file->i_mapping;
34-
page = read_cache_page(mapping, offset / PAGE_CACHE_BITS,
35-
(filler_t *)mapping->a_ops->readpage, NULL);
34+
page = read_mapping_page(mapping, offset / PAGE_CACHE_BITS, NULL);
3635
pptr = kmap(page);
3736
curr = pptr + (offset & (PAGE_CACHE_BITS - 1)) / 32;
3837
i = offset % 32;
@@ -72,8 +71,8 @@ int hfsplus_block_allocate(struct super_block *sb, u32 size, u32 offset, u32 *ma
7271
offset += PAGE_CACHE_BITS;
7372
if (offset >= size)
7473
break;
75-
page = read_cache_page(mapping, offset / PAGE_CACHE_BITS,
76-
(filler_t *)mapping->a_ops->readpage, NULL);
74+
page = read_mapping_page(mapping, offset / PAGE_CACHE_BITS,
75+
NULL);
7776
curr = pptr = kmap(page);
7877
if ((size ^ offset) / PAGE_CACHE_BITS)
7978
end = pptr + PAGE_CACHE_BITS / 32;
@@ -119,8 +118,8 @@ int hfsplus_block_allocate(struct super_block *sb, u32 size, u32 offset, u32 *ma
119118
set_page_dirty(page);
120119
kunmap(page);
121120
offset += PAGE_CACHE_BITS;
122-
page = read_cache_page(mapping, offset / PAGE_CACHE_BITS,
123-
(filler_t *)mapping->a_ops->readpage, NULL);
121+
page = read_mapping_page(mapping, offset / PAGE_CACHE_BITS,
122+
NULL);
124123
pptr = kmap(page);
125124
curr = pptr;
126125
end = pptr + PAGE_CACHE_BITS / 32;
@@ -167,7 +166,7 @@ int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count)
167166
mutex_lock(&HFSPLUS_SB(sb).alloc_file->i_mutex);
168167
mapping = HFSPLUS_SB(sb).alloc_file->i_mapping;
169168
pnr = offset / PAGE_CACHE_BITS;
170-
page = read_cache_page(mapping, pnr, (filler_t *)mapping->a_ops->readpage, NULL);
169+
page = read_mapping_page(mapping, pnr, NULL);
171170
pptr = kmap(page);
172171
curr = pptr + (offset & (PAGE_CACHE_BITS - 1)) / 32;
173172
end = pptr + PAGE_CACHE_BITS / 32;
@@ -199,7 +198,7 @@ int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count)
199198
break;
200199
set_page_dirty(page);
201200
kunmap(page);
202-
page = read_cache_page(mapping, ++pnr, (filler_t *)mapping->a_ops->readpage, NULL);
201+
page = read_mapping_page(mapping, ++pnr, NULL);
203202
pptr = kmap(page);
204203
curr = pptr;
205204
end = pptr + PAGE_CACHE_BITS / 32;

‎fs/hfsplus/bnode.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)
440440
block = off >> PAGE_CACHE_SHIFT;
441441
node->page_offset = off & ~PAGE_CACHE_MASK;
442442
for (i = 0; i < tree->pages_per_bnode; block++, i++) {
443-
page = read_cache_page(mapping, block, (filler_t *)mapping->a_ops->readpage, NULL);
443+
page = read_mapping_page(mapping, block, NULL);
444444
if (IS_ERR(page))
445445
goto fail;
446446
if (PageError(page)) {

‎fs/hfsplus/btree.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id)
3838
goto free_tree;
3939

4040
mapping = tree->inode->i_mapping;
41-
page = read_cache_page(mapping, 0, (filler_t *)mapping->a_ops->readpage, NULL);
41+
page = read_mapping_page(mapping, 0, NULL);
4242
if (IS_ERR(page))
4343
goto free_tree;
4444

0 commit comments

Comments
 (0)