aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext2
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext2')
-rw-r--r--fs/ext2/Makefile1
-rw-r--r--fs/ext2/acl.c12
-rw-r--r--fs/ext2/acl.h2
-rw-r--r--fs/ext2/ext2.h11
-rw-r--r--fs/ext2/file.c14
-rw-r--r--fs/ext2/ialloc.c1
-rw-r--r--fs/ext2/inode.c31
-rw-r--r--fs/ext2/namei.c12
-rw-r--r--fs/ext2/super.c51
-rw-r--r--fs/ext2/symlink.c4
-rw-r--r--fs/ext2/xattr.c2
-rw-r--r--fs/ext2/xip.c93
-rw-r--r--fs/ext2/xip.h25
13 files changed, 238 insertions, 21 deletions
diff --git a/fs/ext2/Makefile b/fs/ext2/Makefile
index ee240a14e7..c5d02da73b 100644
--- a/fs/ext2/Makefile
+++ b/fs/ext2/Makefile
@@ -10,3 +10,4 @@ ext2-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
10ext2-$(CONFIG_EXT2_FS_XATTR) += xattr.o xattr_user.o xattr_trusted.o 10ext2-$(CONFIG_EXT2_FS_XATTR) += xattr.o xattr_user.o xattr_trusted.o
11ext2-$(CONFIG_EXT2_FS_POSIX_ACL) += acl.o 11ext2-$(CONFIG_EXT2_FS_POSIX_ACL) += acl.o
12ext2-$(CONFIG_EXT2_FS_SECURITY) += xattr_security.o 12ext2-$(CONFIG_EXT2_FS_SECURITY) += xattr_security.o
13ext2-$(CONFIG_EXT2_FS_XIP) += xip.o
diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c
index 25f4a64fd6..213148c36e 100644
--- a/fs/ext2/acl.c
+++ b/fs/ext2/acl.c
@@ -396,12 +396,12 @@ static size_t
396ext2_xattr_list_acl_access(struct inode *inode, char *list, size_t list_size, 396ext2_xattr_list_acl_access(struct inode *inode, char *list, size_t list_size,
397 const char *name, size_t name_len) 397 const char *name, size_t name_len)
398{ 398{
399 const size_t size = sizeof(XATTR_NAME_ACL_ACCESS); 399 const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS);
400 400
401 if (!test_opt(inode->i_sb, POSIX_ACL)) 401 if (!test_opt(inode->i_sb, POSIX_ACL))
402 return 0; 402 return 0;
403 if (list && size <= list_size) 403 if (list && size <= list_size)
404 memcpy(list, XATTR_NAME_ACL_ACCESS, size); 404 memcpy(list, POSIX_ACL_XATTR_ACCESS, size);
405 return size; 405 return size;
406} 406}
407 407
@@ -409,12 +409,12 @@ static size_t
409ext2_xattr_list_acl_default(struct inode *inode, char *list, size_t list_size, 409ext2_xattr_list_acl_default(struct inode *inode, char *list, size_t list_size,
410 const char *name, size_t name_len) 410 const char *name, size_t name_len)
411{ 411{
412 const size_t size = sizeof(XATTR_NAME_ACL_DEFAULT); 412 const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT);
413 413
414 if (!test_opt(inode->i_sb, POSIX_ACL)) 414 if (!test_opt(inode->i_sb, POSIX_ACL))
415 return 0; 415 return 0;
416 if (list && size <= list_size) 416 if (list && size <= list_size)
417 memcpy(list, XATTR_NAME_ACL_DEFAULT, size); 417 memcpy(list, POSIX_ACL_XATTR_DEFAULT, size);
418 return size; 418 return size;
419} 419}
420 420
@@ -506,14 +506,14 @@ ext2_xattr_set_acl_default(struct inode *inode, const char *name,
506} 506}
507 507
508struct xattr_handler ext2_xattr_acl_access_handler = { 508struct xattr_handler ext2_xattr_acl_access_handler = {
509 .prefix = XATTR_NAME_ACL_ACCESS, 509 .prefix = POSIX_ACL_XATTR_ACCESS,
510 .list = ext2_xattr_list_acl_access, 510 .list = ext2_xattr_list_acl_access,
511 .get = ext2_xattr_get_acl_access, 511 .get = ext2_xattr_get_acl_access,
512 .set = ext2_xattr_set_acl_access, 512 .set = ext2_xattr_set_acl_access,
513}; 513};
514 514
515struct xattr_handler ext2_xattr_acl_default_handler = { 515struct xattr_handler ext2_xattr_acl_default_handler = {
516 .prefix = XATTR_NAME_ACL_DEFAULT, 516 .prefix = POSIX_ACL_XATTR_DEFAULT,
517 .list = ext2_xattr_list_acl_default, 517 .list = ext2_xattr_list_acl_default,
518 .get = ext2_xattr_get_acl_default, 518 .get = ext2_xattr_get_acl_default,
519 .set = ext2_xattr_set_acl_default, 519 .set = ext2_xattr_set_acl_default,
diff --git a/fs/ext2/acl.h b/fs/ext2/acl.h
index fed96ae81a..0bde85bafe 100644
--- a/fs/ext2/acl.h
+++ b/fs/ext2/acl.h
@@ -4,7 +4,7 @@
4 (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org> 4 (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
5*/ 5*/
6 6
7#include <linux/xattr_acl.h> 7#include <linux/posix_acl_xattr.h>
8 8
9#define EXT2_ACL_VERSION 0x0001 9#define EXT2_ACL_VERSION 0x0001
10 10
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
index 8f0fd726c3..e977f8566d 100644
--- a/fs/ext2/ext2.h
+++ b/fs/ext2/ext2.h
@@ -2,6 +2,15 @@
2#include <linux/ext2_fs.h> 2#include <linux/ext2_fs.h>
3 3
4/* 4/*
5 * ext2 mount options
6 */
7struct ext2_mount_options {
8 unsigned long s_mount_opt;
9 uid_t s_resuid;
10 gid_t s_resgid;
11};
12
13/*
5 * second extended file system inode data in memory 14 * second extended file system inode data in memory
6 */ 15 */
7struct ext2_inode_info { 16struct ext2_inode_info {
@@ -147,9 +156,11 @@ extern struct file_operations ext2_dir_operations;
147/* file.c */ 156/* file.c */
148extern struct inode_operations ext2_file_inode_operations; 157extern struct inode_operations ext2_file_inode_operations;
149extern struct file_operations ext2_file_operations; 158extern struct file_operations ext2_file_operations;
159extern struct file_operations ext2_xip_file_operations;
150 160
151/* inode.c */ 161/* inode.c */
152extern struct address_space_operations ext2_aops; 162extern struct address_space_operations ext2_aops;
163extern struct address_space_operations ext2_aops_xip;
153extern struct address_space_operations ext2_nobh_aops; 164extern struct address_space_operations ext2_nobh_aops;
154 165
155/* namei.c */ 166/* namei.c */
diff --git a/fs/ext2/file.c b/fs/ext2/file.c
index f5e86141ec..a484412fc7 100644
--- a/fs/ext2/file.c
+++ b/fs/ext2/file.c
@@ -55,6 +55,20 @@ struct file_operations ext2_file_operations = {
55 .sendfile = generic_file_sendfile, 55 .sendfile = generic_file_sendfile,
56}; 56};
57 57
58#ifdef CONFIG_EXT2_FS_XIP
59struct file_operations ext2_xip_file_operations = {
60 .llseek = generic_file_llseek,
61 .read = xip_file_read,
62 .write = xip_file_write,
63 .ioctl = ext2_ioctl,
64 .mmap = xip_file_mmap,
65 .open = generic_file_open,
66 .release = ext2_release_file,
67 .fsync = ext2_sync_file,
68 .sendfile = xip_file_sendfile,
69};
70#endif
71
58struct inode_operations ext2_file_inode_operations = { 72struct inode_operations ext2_file_inode_operations = {
59 .truncate = ext2_truncate, 73 .truncate = ext2_truncate,
60#ifdef CONFIG_EXT2_FS_XATTR 74#ifdef CONFIG_EXT2_FS_XATTR
diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c
index 77e0591492..161f156d98 100644
--- a/fs/ext2/ialloc.c
+++ b/fs/ext2/ialloc.c
@@ -612,6 +612,7 @@ got:
612 err = ext2_init_acl(inode, dir); 612 err = ext2_init_acl(inode, dir);
613 if (err) { 613 if (err) {
614 DQUOT_FREE_INODE(inode); 614 DQUOT_FREE_INODE(inode);
615 DQUOT_DROP(inode);
615 goto fail2; 616 goto fail2;
616 } 617 }
617 mark_inode_dirty(inode); 618 mark_inode_dirty(inode);
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index a50d9db4b6..53dceb0c65 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -33,6 +33,7 @@
33#include <linux/mpage.h> 33#include <linux/mpage.h>
34#include "ext2.h" 34#include "ext2.h"
35#include "acl.h" 35#include "acl.h"
36#include "xip.h"
36 37
37MODULE_AUTHOR("Remy Card and others"); 38MODULE_AUTHOR("Remy Card and others");
38MODULE_DESCRIPTION("Second Extended Filesystem"); 39MODULE_DESCRIPTION("Second Extended Filesystem");
@@ -594,6 +595,16 @@ out:
594 if (err) 595 if (err)
595 goto cleanup; 596 goto cleanup;
596 597
598 if (ext2_use_xip(inode->i_sb)) {
599 /*
600 * we need to clear the block
601 */
602 err = ext2_clear_xip_target (inode,
603 le32_to_cpu(chain[depth-1].key));
604 if (err)
605 goto cleanup;
606 }
607
597 if (ext2_splice_branch(inode, iblock, chain, partial, left) < 0) 608 if (ext2_splice_branch(inode, iblock, chain, partial, left) < 0)
598 goto changed; 609 goto changed;
599 610
@@ -691,6 +702,11 @@ struct address_space_operations ext2_aops = {
691 .writepages = ext2_writepages, 702 .writepages = ext2_writepages,
692}; 703};
693 704
705struct address_space_operations ext2_aops_xip = {
706 .bmap = ext2_bmap,
707 .get_xip_page = ext2_get_xip_page,
708};
709
694struct address_space_operations ext2_nobh_aops = { 710struct address_space_operations ext2_nobh_aops = {
695 .readpage = ext2_readpage, 711 .readpage = ext2_readpage,
696 .readpages = ext2_readpages, 712 .readpages = ext2_readpages,
@@ -910,7 +926,9 @@ void ext2_truncate (struct inode * inode)
910 iblock = (inode->i_size + blocksize-1) 926 iblock = (inode->i_size + blocksize-1)
911 >> EXT2_BLOCK_SIZE_BITS(inode->i_sb); 927 >> EXT2_BLOCK_SIZE_BITS(inode->i_sb);
912 928
913 if (test_opt(inode->i_sb, NOBH)) 929 if (mapping_is_xip(inode->i_mapping))
930 xip_truncate_page(inode->i_mapping, inode->i_size);
931 else if (test_opt(inode->i_sb, NOBH))
914 nobh_truncate_page(inode->i_mapping, inode->i_size); 932 nobh_truncate_page(inode->i_mapping, inode->i_size);
915 else 933 else
916 block_truncate_page(inode->i_mapping, 934 block_truncate_page(inode->i_mapping,
@@ -1110,11 +1128,16 @@ void ext2_read_inode (struct inode * inode)
1110 1128
1111 if (S_ISREG(inode->i_mode)) { 1129 if (S_ISREG(inode->i_mode)) {
1112 inode->i_op = &ext2_file_inode_operations; 1130 inode->i_op = &ext2_file_inode_operations;
1113 inode->i_fop = &ext2_file_operations; 1131 if (ext2_use_xip(inode->i_sb)) {
1114 if (test_opt(inode->i_sb, NOBH)) 1132 inode->i_mapping->a_ops = &ext2_aops_xip;
1133 inode->i_fop = &ext2_xip_file_operations;
1134 } else if (test_opt(inode->i_sb, NOBH)) {
1115 inode->i_mapping->a_ops = &ext2_nobh_aops; 1135 inode->i_mapping->a_ops = &ext2_nobh_aops;
1116 else 1136 inode->i_fop = &ext2_file_operations;
1137 } else {
1117 inode->i_mapping->a_ops = &ext2_aops; 1138 inode->i_mapping->a_ops = &ext2_aops;
1139 inode->i_fop = &ext2_file_operations;
1140 }
1118 } else if (S_ISDIR(inode->i_mode)) { 1141 } else if (S_ISDIR(inode->i_mode)) {
1119 inode->i_op = &ext2_dir_inode_operations; 1142 inode->i_op = &ext2_dir_inode_operations;
1120 inode->i_fop = &ext2_dir_operations; 1143 inode->i_fop = &ext2_dir_operations;
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
index 3176b3d3ff..c5513953c8 100644
--- a/fs/ext2/namei.c
+++ b/fs/ext2/namei.c
@@ -34,6 +34,7 @@
34#include "ext2.h" 34#include "ext2.h"
35#include "xattr.h" 35#include "xattr.h"
36#include "acl.h" 36#include "acl.h"
37#include "xip.h"
37 38
38/* 39/*
39 * Couple of helper functions - make the code slightly cleaner. 40 * Couple of helper functions - make the code slightly cleaner.
@@ -127,11 +128,16 @@ static int ext2_create (struct inode * dir, struct dentry * dentry, int mode, st
127 int err = PTR_ERR(inode); 128 int err = PTR_ERR(inode);
128 if (!IS_ERR(inode)) { 129 if (!IS_ERR(inode)) {
129 inode->i_op = &ext2_file_inode_operations; 130 inode->i_op = &ext2_file_inode_operations;
130 inode->i_fop = &ext2_file_operations; 131 if (ext2_use_xip(inode->i_sb)) {
131 if (test_opt(inode->i_sb, NOBH)) 132 inode->i_mapping->a_ops = &ext2_aops_xip;
133 inode->i_fop = &ext2_xip_file_operations;
134 } else if (test_opt(inode->i_sb, NOBH)) {
132 inode->i_mapping->a_ops = &ext2_nobh_aops; 135 inode->i_mapping->a_ops = &ext2_nobh_aops;
133 else 136 inode->i_fop = &ext2_file_operations;
137 } else {
134 inode->i_mapping->a_ops = &ext2_aops; 138 inode->i_mapping->a_ops = &ext2_aops;
139 inode->i_fop = &ext2_file_operations;
140 }
135 mark_inode_dirty(inode); 141 mark_inode_dirty(inode);
136 err = ext2_add_nondir(dentry, inode); 142 err = ext2_add_nondir(dentry, inode);
137 } 143 }
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 661c3d98d9..dcfe331dc4 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -31,6 +31,7 @@
31#include "ext2.h" 31#include "ext2.h"
32#include "xattr.h" 32#include "xattr.h"
33#include "acl.h" 33#include "acl.h"
34#include "xip.h"
34 35
35static void ext2_sync_super(struct super_block *sb, 36static void ext2_sync_super(struct super_block *sb,
36 struct ext2_super_block *es); 37 struct ext2_super_block *es);
@@ -257,7 +258,7 @@ enum {
257 Opt_bsd_df, Opt_minix_df, Opt_grpid, Opt_nogrpid, 258 Opt_bsd_df, Opt_minix_df, Opt_grpid, Opt_nogrpid,
258 Opt_resgid, Opt_resuid, Opt_sb, Opt_err_cont, Opt_err_panic, Opt_err_ro, 259 Opt_resgid, Opt_resuid, Opt_sb, Opt_err_cont, Opt_err_panic, Opt_err_ro,
259 Opt_nouid32, Opt_check, Opt_nocheck, Opt_debug, Opt_oldalloc, Opt_orlov, Opt_nobh, 260 Opt_nouid32, Opt_check, Opt_nocheck, Opt_debug, Opt_oldalloc, Opt_orlov, Opt_nobh,
260 Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl, 261 Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl, Opt_xip,
261 Opt_ignore, Opt_err, 262 Opt_ignore, Opt_err,
262}; 263};
263 264
@@ -286,6 +287,7 @@ static match_table_t tokens = {
286 {Opt_nouser_xattr, "nouser_xattr"}, 287 {Opt_nouser_xattr, "nouser_xattr"},
287 {Opt_acl, "acl"}, 288 {Opt_acl, "acl"},
288 {Opt_noacl, "noacl"}, 289 {Opt_noacl, "noacl"},
290 {Opt_xip, "xip"},
289 {Opt_ignore, "grpquota"}, 291 {Opt_ignore, "grpquota"},
290 {Opt_ignore, "noquota"}, 292 {Opt_ignore, "noquota"},
291 {Opt_ignore, "quota"}, 293 {Opt_ignore, "quota"},
@@ -397,6 +399,13 @@ static int parse_options (char * options,
397 printk("EXT2 (no)acl options not supported\n"); 399 printk("EXT2 (no)acl options not supported\n");
398 break; 400 break;
399#endif 401#endif
402 case Opt_xip:
403#ifdef CONFIG_EXT2_FS_XIP
404 set_opt (sbi->s_mount_opt, XIP);
405#else
406 printk("EXT2 xip option not supported\n");
407#endif
408 break;
400 case Opt_ignore: 409 case Opt_ignore:
401 break; 410 break;
402 default: 411 default:
@@ -640,6 +649,9 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
640 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? 649 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
641 MS_POSIXACL : 0); 650 MS_POSIXACL : 0);
642 651
652 ext2_xip_verify_sb(sb); /* see if bdev supports xip, unset
653 EXT2_MOUNT_XIP if not */
654
643 if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV && 655 if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV &&
644 (EXT2_HAS_COMPAT_FEATURE(sb, ~0U) || 656 (EXT2_HAS_COMPAT_FEATURE(sb, ~0U) ||
645 EXT2_HAS_RO_COMPAT_FEATURE(sb, ~0U) || 657 EXT2_HAS_RO_COMPAT_FEATURE(sb, ~0U) ||
@@ -668,6 +680,13 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
668 680
669 blocksize = BLOCK_SIZE << le32_to_cpu(sbi->s_es->s_log_block_size); 681 blocksize = BLOCK_SIZE << le32_to_cpu(sbi->s_es->s_log_block_size);
670 682
683 if ((ext2_use_xip(sb)) && ((blocksize != PAGE_SIZE) ||
684 (sb->s_blocksize != blocksize))) {
685 if (!silent)
686 printk("XIP: Unsupported blocksize\n");
687 goto failed_mount;
688 }
689
671 /* If the blocksize doesn't match, re-read the thing.. */ 690 /* If the blocksize doesn't match, re-read the thing.. */
672 if (sb->s_blocksize != blocksize) { 691 if (sb->s_blocksize != blocksize) {
673 brelse(bh); 692 brelse(bh);
@@ -916,17 +935,34 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
916{ 935{
917 struct ext2_sb_info * sbi = EXT2_SB(sb); 936 struct ext2_sb_info * sbi = EXT2_SB(sb);
918 struct ext2_super_block * es; 937 struct ext2_super_block * es;
938 unsigned long old_mount_opt = sbi->s_mount_opt;
939 struct ext2_mount_options old_opts;
940 unsigned long old_sb_flags;
941 int err;
942
943 /* Store the old options */
944 old_sb_flags = sb->s_flags;
945 old_opts.s_mount_opt = sbi->s_mount_opt;
946 old_opts.s_resuid = sbi->s_resuid;
947 old_opts.s_resgid = sbi->s_resgid;
919 948
920 /* 949 /*
921 * Allow the "check" option to be passed as a remount option. 950 * Allow the "check" option to be passed as a remount option.
922 */ 951 */
923 if (!parse_options (data, sbi)) 952 if (!parse_options (data, sbi)) {
924 return -EINVAL; 953 err = -EINVAL;
954 goto restore_opts;
955 }
925 956
926 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | 957 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
927 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0); 958 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
928 959
929 es = sbi->s_es; 960 es = sbi->s_es;
961 if (((sbi->s_mount_opt & EXT2_MOUNT_XIP) !=
962 (old_mount_opt & EXT2_MOUNT_XIP)) &&
963 invalidate_inodes(sb))
964 ext2_warning(sb, __FUNCTION__, "busy inodes while remounting "\
965 "xip remain in cache (no functional problem)");
930 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) 966 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
931 return 0; 967 return 0;
932 if (*flags & MS_RDONLY) { 968 if (*flags & MS_RDONLY) {
@@ -946,7 +982,8 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
946 printk("EXT2-fs: %s: couldn't remount RDWR because of " 982 printk("EXT2-fs: %s: couldn't remount RDWR because of "
947 "unsupported optional features (%x).\n", 983 "unsupported optional features (%x).\n",
948 sb->s_id, le32_to_cpu(ret)); 984 sb->s_id, le32_to_cpu(ret));
949 return -EROFS; 985 err = -EROFS;
986 goto restore_opts;
950 } 987 }
951 /* 988 /*
952 * Mounting a RDONLY partition read-write, so reread and 989 * Mounting a RDONLY partition read-write, so reread and
@@ -959,6 +996,12 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
959 } 996 }
960 ext2_sync_super(sb, es); 997 ext2_sync_super(sb, es);
961 return 0; 998 return 0;
999restore_opts:
1000 sbi->s_mount_opt = old_opts.s_mount_opt;
1001 sbi->s_resuid = old_opts.s_resuid;
1002 sbi->s_resgid = old_opts.s_resgid;
1003 sb->s_flags = old_sb_flags;
1004 return err;
962} 1005}
963 1006
964static int ext2_statfs (struct super_block * sb, struct kstatfs * buf) 1007static int ext2_statfs (struct super_block * sb, struct kstatfs * buf)
diff --git a/fs/ext2/symlink.c b/fs/ext2/symlink.c
index 9f7bac01d5..1e67d87cfa 100644
--- a/fs/ext2/symlink.c
+++ b/fs/ext2/symlink.c
@@ -21,11 +21,11 @@
21#include "xattr.h" 21#include "xattr.h"
22#include <linux/namei.h> 22#include <linux/namei.h>
23 23
24static int ext2_follow_link(struct dentry *dentry, struct nameidata *nd) 24static void *ext2_follow_link(struct dentry *dentry, struct nameidata *nd)
25{ 25{
26 struct ext2_inode_info *ei = EXT2_I(dentry->d_inode); 26 struct ext2_inode_info *ei = EXT2_I(dentry->d_inode);
27 nd_set_link(nd, (char *)ei->i_data); 27 nd_set_link(nd, (char *)ei->i_data);
28 return 0; 28 return NULL;
29} 29}
30 30
31struct inode_operations ext2_symlink_inode_operations = { 31struct inode_operations ext2_symlink_inode_operations = {
diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
index 27982b500e..0099462d42 100644
--- a/fs/ext2/xattr.c
+++ b/fs/ext2/xattr.c
@@ -823,7 +823,7 @@ cleanup:
823void 823void
824ext2_xattr_put_super(struct super_block *sb) 824ext2_xattr_put_super(struct super_block *sb)
825{ 825{
826 mb_cache_shrink(ext2_xattr_cache, sb->s_bdev); 826 mb_cache_shrink(sb->s_bdev);
827} 827}
828 828
829 829
diff --git a/fs/ext2/xip.c b/fs/ext2/xip.c
new file mode 100644
index 0000000000..ca7f003123
--- /dev/null
+++ b/fs/ext2/xip.c
@@ -0,0 +1,93 @@
1/*
2 * linux/fs/ext2/xip.c
3 *
4 * Copyright (C) 2005 IBM Corporation
5 * Author: Carsten Otte (cotte@de.ibm.com)
6 */
7
8#include <linux/mm.h>
9#include <linux/fs.h>
10#include <linux/genhd.h>
11#include <linux/buffer_head.h>
12#include <linux/ext2_fs_sb.h>
13#include <linux/ext2_fs.h>
14#include "ext2.h"
15#include "xip.h"
16
17static inline int
18__inode_direct_access(struct inode *inode, sector_t sector,
19 unsigned long *data)
20{
21 BUG_ON(!inode->i_sb->s_bdev->bd_disk->fops->direct_access);
22 return inode->i_sb->s_bdev->bd_disk->fops
23 ->direct_access(inode->i_sb->s_bdev,sector,data);
24}
25
26static inline int
27__ext2_get_sector(struct inode *inode, sector_t offset, int create,
28 sector_t *result)
29{
30 struct buffer_head tmp;
31 int rc;
32
33 memset(&tmp, 0, sizeof(struct buffer_head));
34 rc = ext2_get_block(inode, offset/ (PAGE_SIZE/512), &tmp,
35 create);
36 *result = tmp.b_blocknr;
37
38 /* did we get a sparse block (hole in the file)? */
39 if (!tmp.b_blocknr && !rc) {
40 BUG_ON(create);
41 rc = -ENODATA;
42 }
43
44 return rc;
45}
46
47int
48ext2_clear_xip_target(struct inode *inode, int block)
49{
50 sector_t sector = block * (PAGE_SIZE/512);
51 unsigned long data;
52 int rc;
53
54 rc = __inode_direct_access(inode, sector, &data);
55 if (!rc)
56 clear_page((void*)data);
57 return rc;
58}
59
60void ext2_xip_verify_sb(struct super_block *sb)
61{
62 struct ext2_sb_info *sbi = EXT2_SB(sb);
63
64 if ((sbi->s_mount_opt & EXT2_MOUNT_XIP) &&
65 !sb->s_bdev->bd_disk->fops->direct_access) {
66 sbi->s_mount_opt &= (~EXT2_MOUNT_XIP);
67 ext2_warning(sb, __FUNCTION__,
68 "ignoring xip option - not supported by bdev");
69 }
70}
71
72struct page *
73ext2_get_xip_page(struct address_space *mapping, sector_t offset,
74 int create)
75{
76 int rc;
77 unsigned long data;
78 sector_t sector;
79
80 /* first, retrieve the sector number */
81 rc = __ext2_get_sector(mapping->host, offset, create, &sector);
82 if (rc)
83 goto error;
84
85 /* retrieve address of the target data */
86 rc = __inode_direct_access
87 (mapping->host, sector * (PAGE_SIZE/512), &data);
88 if (!rc)
89 return virt_to_page(data);
90
91 error:
92 return ERR_PTR(rc);
93}
diff --git a/fs/ext2/xip.h b/fs/ext2/xip.h
new file mode 100644
index 0000000000..aa85331d6c
--- /dev/null
+++ b/fs/ext2/xip.h
@@ -0,0 +1,25 @@
1/*
2 * linux/fs/ext2/xip.h
3 *
4 * Copyright (C) 2005 IBM Corporation
5 * Author: Carsten Otte (cotte@de.ibm.com)
6 */
7
8#ifdef CONFIG_EXT2_FS_XIP
9extern void ext2_xip_verify_sb (struct super_block *);
10extern int ext2_clear_xip_target (struct inode *, int);
11
12static inline int ext2_use_xip (struct super_block *sb)
13{
14 struct ext2_sb_info *sbi = EXT2_SB(sb);
15 return (sbi->s_mount_opt & EXT2_MOUNT_XIP);
16}
17struct page* ext2_get_xip_page (struct address_space *, sector_t, int);
18#define mapping_is_xip(map) unlikely(map->a_ops->get_xip_page)
19#else
20#define mapping_is_xip(map) 0
21#define ext2_xip_verify_sb(sb) do { } while (0)
22#define ext2_use_xip(sb) 0
23#define ext2_clear_xip_target(inode, chain) 0
24#define ext2_get_xip_page NULL
25#endif