[PATCH] acpi bridge hotadd: Allow ACPI .add and .start operations to be done independ...
[powerpc.git] / fs / ext2 / inode.c
index b890be0..53dceb0 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/mpage.h>
 #include "ext2.h"
 #include "acl.h"
+#include "xip.h"
 
 MODULE_AUTHOR("Remy Card and others");
 MODULE_DESCRIPTION("Second Extended Filesystem");
@@ -52,6 +53,19 @@ static inline int ext2_inode_is_fast_symlink(struct inode *inode)
                inode->i_blocks - ea_blocks == 0);
 }
 
+/*
+ * Called at each iput().
+ *
+ * The inode may be "bad" if ext2_read_inode() saw an error from
+ * ext2_get_inode(), so we need to check that to avoid freeing random disk
+ * blocks.
+ */
+void ext2_put_inode(struct inode *inode)
+{
+       if (!is_bad_inode(inode))
+               ext2_discard_prealloc(inode);
+}
+
 /*
  * Called at the last iput() if i_nlink is zero.
  */
@@ -581,6 +595,16 @@ out:
        if (err)
                goto cleanup;
 
+       if (ext2_use_xip(inode->i_sb)) {
+               /*
+                * we need to clear the block
+                */
+               err = ext2_clear_xip_target (inode,
+                       le32_to_cpu(chain[depth-1].key));
+               if (err)
+                       goto cleanup;
+       }
+
        if (ext2_splice_branch(inode, iblock, chain, partial, left) < 0)
                goto changed;
 
@@ -678,6 +702,11 @@ struct address_space_operations ext2_aops = {
        .writepages             = ext2_writepages,
 };
 
+struct address_space_operations ext2_aops_xip = {
+       .bmap                   = ext2_bmap,
+       .get_xip_page           = ext2_get_xip_page,
+};
+
 struct address_space_operations ext2_nobh_aops = {
        .readpage               = ext2_readpage,
        .readpages              = ext2_readpages,
@@ -897,7 +926,9 @@ void ext2_truncate (struct inode * inode)
        iblock = (inode->i_size + blocksize-1)
                                        >> EXT2_BLOCK_SIZE_BITS(inode->i_sb);
 
-       if (test_opt(inode->i_sb, NOBH))
+       if (mapping_is_xip(inode->i_mapping))
+               xip_truncate_page(inode->i_mapping, inode->i_size);
+       else if (test_opt(inode->i_sb, NOBH))
                nobh_truncate_page(inode->i_mapping, inode->i_size);
        else
                block_truncate_page(inode->i_mapping,
@@ -1097,11 +1128,16 @@ void ext2_read_inode (struct inode * inode)
 
        if (S_ISREG(inode->i_mode)) {
                inode->i_op = &ext2_file_inode_operations;
-               inode->i_fop = &ext2_file_operations;
-               if (test_opt(inode->i_sb, NOBH))
+               if (ext2_use_xip(inode->i_sb)) {
+                       inode->i_mapping->a_ops = &ext2_aops_xip;
+                       inode->i_fop = &ext2_xip_file_operations;
+               } else if (test_opt(inode->i_sb, NOBH)) {
                        inode->i_mapping->a_ops = &ext2_nobh_aops;
-               else
+                       inode->i_fop = &ext2_file_operations;
+               } else {
                        inode->i_mapping->a_ops = &ext2_aops;
+                       inode->i_fop = &ext2_file_operations;
+               }
        } else if (S_ISDIR(inode->i_mode)) {
                inode->i_op = &ext2_dir_inode_operations;
                inode->i_fop = &ext2_dir_operations;