Blame view
fs/ext2/xip.c
2.04 KB
6d79125bb [PATCH] xip: ext2... |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
/* * linux/fs/ext2/xip.c * * Copyright (C) 2005 IBM Corporation * Author: Carsten Otte (cotte@de.ibm.com) */ #include <linux/mm.h> #include <linux/fs.h> #include <linux/genhd.h> #include <linux/buffer_head.h> #include <linux/ext2_fs_sb.h> #include <linux/ext2_fs.h> |
08f858512 [PATCH] move bloc... |
14 |
#include <linux/blkdev.h> |
6d79125bb [PATCH] xip: ext2... |
15 16 17 18 |
#include "ext2.h" #include "xip.h" static inline int |
70688e4dd xip: support non-... |
19 |
__inode_direct_access(struct inode *inode, sector_t block, |
30afcb4bd return pfn from d... |
20 |
void **kaddr, unsigned long *pfn) |
afa597ba2 [PATCH] execute-i... |
21 |
{ |
30afcb4bd return pfn from d... |
22 |
struct block_device *bdev = inode->i_sb->s_bdev; |
83d5cde47 const: make block... |
23 |
const struct block_device_operations *ops = bdev->bd_disk->fops; |
70688e4dd xip: support non-... |
24 25 26 |
sector_t sector; sector = block * (PAGE_SIZE / 512); /* ext2 block to bdev sector */ |
30afcb4bd return pfn from d... |
27 28 29 |
BUG_ON(!ops->direct_access); return ops->direct_access(bdev, sector, kaddr, pfn); |
6d79125bb [PATCH] xip: ext2... |
30 |
} |
afa597ba2 [PATCH] execute-i... |
31 |
static inline int |
70688e4dd xip: support non-... |
32 |
__ext2_get_block(struct inode *inode, pgoff_t pgoff, int create, |
afa597ba2 [PATCH] execute-i... |
33 34 35 36 37 38 |
sector_t *result) { struct buffer_head tmp; int rc; memset(&tmp, 0, sizeof(struct buffer_head)); |
70688e4dd xip: support non-... |
39 |
rc = ext2_get_block(inode, pgoff, &tmp, create); |
afa597ba2 [PATCH] execute-i... |
40 41 42 |
*result = tmp.b_blocknr; /* did we get a sparse block (hole in the file)? */ |
0cfc11ed4 [PATCH] fix xip s... |
43 |
if (!tmp.b_blocknr && !rc) { |
afa597ba2 [PATCH] execute-i... |
44 45 46 47 48 49 |
BUG_ON(create); rc = -ENODATA; } return rc; } |
6d79125bb [PATCH] xip: ext2... |
50 |
int |
70688e4dd xip: support non-... |
51 |
ext2_clear_xip_target(struct inode *inode, sector_t block) |
afa597ba2 [PATCH] execute-i... |
52 |
{ |
30afcb4bd return pfn from d... |
53 54 |
void *kaddr; unsigned long pfn; |
6d79125bb [PATCH] xip: ext2... |
55 |
int rc; |
70688e4dd xip: support non-... |
56 |
rc = __inode_direct_access(inode, block, &kaddr, &pfn); |
afa597ba2 [PATCH] execute-i... |
57 |
if (!rc) |
30afcb4bd return pfn from d... |
58 |
clear_page(kaddr); |
afa597ba2 [PATCH] execute-i... |
59 |
return rc; |
6d79125bb [PATCH] xip: ext2... |
60 61 62 63 64 |
} void ext2_xip_verify_sb(struct super_block *sb) { struct ext2_sb_info *sbi = EXT2_SB(sb); |
afa597ba2 [PATCH] execute-i... |
65 66 67 |
if ((sbi->s_mount_opt & EXT2_MOUNT_XIP) && !sb->s_bdev->bd_disk->fops->direct_access) { sbi->s_mount_opt &= (~EXT2_MOUNT_XIP); |
2314b07cb ext2: Unify log m... |
68 69 70 |
ext2_msg(sb, KERN_WARNING, "warning: ignoring xip option - " "not supported by bdev"); |
6d79125bb [PATCH] xip: ext2... |
71 72 |
} } |
70688e4dd xip: support non-... |
73 74 |
int ext2_get_xip_mem(struct address_space *mapping, pgoff_t pgoff, int create, void **kmem, unsigned long *pfn) |
6d79125bb [PATCH] xip: ext2... |
75 76 |
{ int rc; |
70688e4dd xip: support non-... |
77 |
sector_t block; |
6d79125bb [PATCH] xip: ext2... |
78 |
|
afa597ba2 [PATCH] execute-i... |
79 |
/* first, retrieve the sector number */ |
70688e4dd xip: support non-... |
80 |
rc = __ext2_get_block(mapping->host, pgoff, create, &block); |
6d79125bb [PATCH] xip: ext2... |
81 |
if (rc) |
70688e4dd xip: support non-... |
82 |
return rc; |
6d79125bb [PATCH] xip: ext2... |
83 |
|
afa597ba2 [PATCH] execute-i... |
84 |
/* retrieve address of the target data */ |
70688e4dd xip: support non-... |
85 86 |
rc = __inode_direct_access(mapping->host, block, kmem, pfn); return rc; |
6d79125bb [PATCH] xip: ext2... |
87 |
} |