diff options
author | Nick Piggin <npiggin@suse.de> | 2008-02-08 04:19:50 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-08 09:22:30 -0800 |
commit | 75acb9cd2ef0bbb463098fdd40cbcdda79d45fa3 (patch) | |
tree | acb8f0a63ac1249146041b06eaaa003ea24c8c7a /drivers/block/brd.c | |
parent | 9db5579be4bb5320c3248f6acf807aedf05ae143 (diff) |
rd: support XIP
Support direct_access XIP method with brd.
Signed-off-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/block/brd.c')
-rw-r--r-- | drivers/block/brd.c | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/drivers/block/brd.c b/drivers/block/brd.c index 50b659bedc8..85364804364 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c @@ -89,6 +89,7 @@ static struct page *brd_insert_page(struct brd_device *brd, sector_t sector) { pgoff_t idx; struct page *page; + gfp_t gfp_flags; page = brd_lookup_page(brd, sector); if (page) @@ -97,7 +98,16 @@ static struct page *brd_insert_page(struct brd_device *brd, sector_t sector) /* * Must use NOIO because we don't want to recurse back into the * block or filesystem layers from page reclaim. + * + * Cannot support XIP and highmem, because our ->direct_access + * routine for XIP must return memory that is always addressable. + * If XIP was reworked to use pfns and kmap throughout, this + * restriction might be able to be lifted. */ + gfp_flags = GFP_NOIO | __GFP_ZERO; +#ifndef CONFIG_BLK_DEV_XIP + gfp_flags |= __GFP_HIGHMEM; +#endif page = alloc_page(GFP_NOIO | __GFP_HIGHMEM | __GFP_ZERO); if (!page) return NULL; @@ -307,6 +317,28 @@ out: return 0; } +#ifdef CONFIG_BLK_DEV_XIP +static int brd_direct_access (struct block_device *bdev, sector_t sector, + unsigned long *data) +{ + struct brd_device *brd = bdev->bd_disk->private_data; + struct page *page; + + if (!brd) + return -ENODEV; + if (sector & (PAGE_SECTORS-1)) + return -EINVAL; + if (sector + PAGE_SECTORS > get_capacity(bdev->bd_disk)) + return -ERANGE; + page = brd_insert_page(brd, sector); + if (!page) + return -ENOMEM; + *data = (unsigned long)page_address(page); + + return 0; +} +#endif + static int brd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { @@ -342,8 +374,11 @@ static int brd_ioctl(struct inode *inode, struct file *file, } static struct block_device_operations brd_fops = { - .owner = THIS_MODULE, - .ioctl = brd_ioctl, + .owner = THIS_MODULE, + .ioctl = brd_ioctl, +#ifdef CONFIG_BLK_DEV_XIP + .direct_access = brd_direct_access, +#endif }; /* |