diff options
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 50b659bedc8f..85364804364f 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) | |||
89 | { | 89 | { |
90 | pgoff_t idx; | 90 | pgoff_t idx; |
91 | struct page *page; | 91 | struct page *page; |
92 | gfp_t gfp_flags; | ||
92 | 93 | ||
93 | page = brd_lookup_page(brd, sector); | 94 | page = brd_lookup_page(brd, sector); |
94 | if (page) | 95 | if (page) |
@@ -97,7 +98,16 @@ static struct page *brd_insert_page(struct brd_device *brd, sector_t sector) | |||
97 | /* | 98 | /* |
98 | * Must use NOIO because we don't want to recurse back into the | 99 | * Must use NOIO because we don't want to recurse back into the |
99 | * block or filesystem layers from page reclaim. | 100 | * block or filesystem layers from page reclaim. |
101 | * | ||
102 | * Cannot support XIP and highmem, because our ->direct_access | ||
103 | * routine for XIP must return memory that is always addressable. | ||
104 | * If XIP was reworked to use pfns and kmap throughout, this | ||
105 | * restriction might be able to be lifted. | ||
100 | */ | 106 | */ |
107 | gfp_flags = GFP_NOIO | __GFP_ZERO; | ||
108 | #ifndef CONFIG_BLK_DEV_XIP | ||
109 | gfp_flags |= __GFP_HIGHMEM; | ||
110 | #endif | ||
101 | page = alloc_page(GFP_NOIO | __GFP_HIGHMEM | __GFP_ZERO); | 111 | page = alloc_page(GFP_NOIO | __GFP_HIGHMEM | __GFP_ZERO); |
102 | if (!page) | 112 | if (!page) |
103 | return NULL; | 113 | return NULL; |
@@ -307,6 +317,28 @@ out: | |||
307 | return 0; | 317 | return 0; |
308 | } | 318 | } |
309 | 319 | ||
320 | #ifdef CONFIG_BLK_DEV_XIP | ||
321 | static int brd_direct_access (struct block_device *bdev, sector_t sector, | ||
322 | unsigned long *data) | ||
323 | { | ||
324 | struct brd_device *brd = bdev->bd_disk->private_data; | ||
325 | struct page *page; | ||
326 | |||
327 | if (!brd) | ||
328 | return -ENODEV; | ||
329 | if (sector & (PAGE_SECTORS-1)) | ||
330 | return -EINVAL; | ||
331 | if (sector + PAGE_SECTORS > get_capacity(bdev->bd_disk)) | ||
332 | return -ERANGE; | ||
333 | page = brd_insert_page(brd, sector); | ||
334 | if (!page) | ||
335 | return -ENOMEM; | ||
336 | *data = (unsigned long)page_address(page); | ||
337 | |||
338 | return 0; | ||
339 | } | ||
340 | #endif | ||
341 | |||
310 | static int brd_ioctl(struct inode *inode, struct file *file, | 342 | static int brd_ioctl(struct inode *inode, struct file *file, |
311 | unsigned int cmd, unsigned long arg) | 343 | unsigned int cmd, unsigned long arg) |
312 | { | 344 | { |
@@ -342,8 +374,11 @@ static int brd_ioctl(struct inode *inode, struct file *file, | |||
342 | } | 374 | } |
343 | 375 | ||
344 | static struct block_device_operations brd_fops = { | 376 | static struct block_device_operations brd_fops = { |
345 | .owner = THIS_MODULE, | 377 | .owner = THIS_MODULE, |
346 | .ioctl = brd_ioctl, | 378 | .ioctl = brd_ioctl, |
379 | #ifdef CONFIG_BLK_DEV_XIP | ||
380 | .direct_access = brd_direct_access, | ||
381 | #endif | ||
347 | }; | 382 | }; |
348 | 383 | ||
349 | /* | 384 | /* |