aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext2/xip.c
diff options
context:
space:
mode:
authorNick Piggin <npiggin@suse.de>2008-04-28 05:13:02 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-28 11:58:23 -0400
commit70688e4dd1647f0ceb502bbd5964fa344c5eb411 (patch)
treee0bd8c3b4b6050c067a453d800c2e87948d1abaf /fs/ext2/xip.c
parent30afcb4bd2762fa4b87b17ada9500aa46dc10b1b (diff)
xip: support non-struct page backed memory
Convert XIP to support non-struct page backed memory, using VM_MIXEDMAP for the user mappings. This requires the get_xip_page API to be changed to an address based one. Improve the API layering a little bit too, while we're here. This is required in order to support XIP filesystems on memory that isn't backed with struct page (but memory with struct page is still supported too). Signed-off-by: Nick Piggin <npiggin@suse.de> Acked-by: Carsten Otte <cotte@de.ibm.com> Cc: Jared Hulbert <jaredeh@gmail.com> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ext2/xip.c')
-rw-r--r--fs/ext2/xip.c37
1 files changed, 15 insertions, 22 deletions
diff --git a/fs/ext2/xip.c b/fs/ext2/xip.c
index 430b4c8ee971..233f7fdbe31d 100644
--- a/fs/ext2/xip.c
+++ b/fs/ext2/xip.c
@@ -15,26 +15,28 @@
15#include "xip.h" 15#include "xip.h"
16 16
17static inline int 17static inline int
18__inode_direct_access(struct inode *inode, sector_t sector, 18__inode_direct_access(struct inode *inode, sector_t block,
19 void **kaddr, unsigned long *pfn) 19 void **kaddr, unsigned long *pfn)
20{ 20{
21 struct block_device *bdev = inode->i_sb->s_bdev; 21 struct block_device *bdev = inode->i_sb->s_bdev;
22 struct block_device_operations *ops = bdev->bd_disk->fops; 22 struct block_device_operations *ops = bdev->bd_disk->fops;
23 sector_t sector;
24
25 sector = block * (PAGE_SIZE / 512); /* ext2 block to bdev sector */
23 26
24 BUG_ON(!ops->direct_access); 27 BUG_ON(!ops->direct_access);
25 return ops->direct_access(bdev, sector, kaddr, pfn); 28 return ops->direct_access(bdev, sector, kaddr, pfn);
26} 29}
27 30
28static inline int 31static inline int
29__ext2_get_sector(struct inode *inode, sector_t offset, int create, 32__ext2_get_block(struct inode *inode, pgoff_t pgoff, int create,
30 sector_t *result) 33 sector_t *result)
31{ 34{
32 struct buffer_head tmp; 35 struct buffer_head tmp;
33 int rc; 36 int rc;
34 37
35 memset(&tmp, 0, sizeof(struct buffer_head)); 38 memset(&tmp, 0, sizeof(struct buffer_head));
36 rc = ext2_get_block(inode, offset/ (PAGE_SIZE/512), &tmp, 39 rc = ext2_get_block(inode, pgoff, &tmp, create);
37 create);
38 *result = tmp.b_blocknr; 40 *result = tmp.b_blocknr;
39 41
40 /* did we get a sparse block (hole in the file)? */ 42 /* did we get a sparse block (hole in the file)? */
@@ -47,14 +49,13 @@ __ext2_get_sector(struct inode *inode, sector_t offset, int create,
47} 49}
48 50
49int 51int
50ext2_clear_xip_target(struct inode *inode, int block) 52ext2_clear_xip_target(struct inode *inode, sector_t block)
51{ 53{
52 sector_t sector = block * (PAGE_SIZE/512);
53 void *kaddr; 54 void *kaddr;
54 unsigned long pfn; 55 unsigned long pfn;
55 int rc; 56 int rc;
56 57
57 rc = __inode_direct_access(inode, sector, &kaddr, &pfn); 58 rc = __inode_direct_access(inode, block, &kaddr, &pfn);
58 if (!rc) 59 if (!rc)
59 clear_page(kaddr); 60 clear_page(kaddr);
60 return rc; 61 return rc;
@@ -72,26 +73,18 @@ void ext2_xip_verify_sb(struct super_block *sb)
72 } 73 }
73} 74}
74 75
75struct page * 76int ext2_get_xip_mem(struct address_space *mapping, pgoff_t pgoff, int create,
76ext2_get_xip_page(struct address_space *mapping, sector_t offset, 77 void **kmem, unsigned long *pfn)
77 int create)
78{ 78{
79 int rc; 79 int rc;
80 void *kaddr; 80 sector_t block;
81 unsigned long pfn;
82 sector_t sector;
83 81
84 /* first, retrieve the sector number */ 82 /* first, retrieve the sector number */
85 rc = __ext2_get_sector(mapping->host, offset, create, &sector); 83 rc = __ext2_get_block(mapping->host, pgoff, create, &block);
86 if (rc) 84 if (rc)
87 goto error; 85 return rc;
88 86
89 /* retrieve address of the target data */ 87 /* retrieve address of the target data */
90 rc = __inode_direct_access 88 rc = __inode_direct_access(mapping->host, block, kmem, pfn);
91 (mapping->host, sector * (PAGE_SIZE/512), &kaddr, &pfn); 89 return rc;
92 if (!rc)
93 return pfn_to_page(pfn);
94
95 error:
96 return ERR_PTR(rc);
97} 90}