4 * Copyright (C) 2005 IBM Corporation
5 * Author: Carsten Otte (cotte@de.ibm.com)
10 #include <linux/genhd.h>
11 #include <linux/buffer_head.h>
12 #include <linux/ext2_fs_sb.h>
13 #include <linux/ext2_fs.h>
18 __inode_direct_access(struct inode
*inode
, sector_t sector
, unsigned long *data
) {
19 BUG_ON(!inode
->i_sb
->s_bdev
->bd_disk
->fops
->direct_access
);
20 return inode
->i_sb
->s_bdev
->bd_disk
->fops
21 ->direct_access(inode
->i_sb
->s_bdev
,sector
,data
);
25 ext2_clear_xip_target(struct inode
*inode
, int block
) {
26 sector_t sector
= block
*(PAGE_SIZE
/512);
30 rc
= __inode_direct_access(inode
, sector
, &data
);
33 clear_page((void*)data
);
37 void ext2_xip_verify_sb(struct super_block
*sb
)
39 struct ext2_sb_info
*sbi
= EXT2_SB(sb
);
41 if ((sbi
->s_mount_opt
& EXT2_MOUNT_XIP
)) {
42 if ((sb
->s_bdev
== NULL
) ||
43 sb
->s_bdev
->bd_disk
== NULL
||
44 sb
->s_bdev
->bd_disk
->fops
== NULL
||
45 sb
->s_bdev
->bd_disk
->fops
->direct_access
== NULL
) {
46 sbi
->s_mount_opt
&= (~EXT2_MOUNT_XIP
);
47 ext2_warning(sb
, __FUNCTION__
,
48 "ignoring xip option - not supported by bdev");
54 ext2_get_xip_page(struct address_space
*mapping
, sector_t blockno
,
59 struct buffer_head tmp
;
63 rc
= ext2_get_block(mapping
->host
, blockno
/(PAGE_SIZE
/512) , &tmp
,
67 if (tmp
.b_blocknr
== 0) {
70 return ERR_PTR(-ENODATA
);
73 rc
= __inode_direct_access
74 (mapping
->host
,tmp
.b_blocknr
*(PAGE_SIZE
/512) ,&data
);
78 SetPageUptodate(virt_to_page(data
));
79 return virt_to_page(data
);