Merge branch 'for-2.6.35' of git://linux-nfs.org/~bfields/linux
[safe/jmp/linux-2.6] / fs / ocfs2 / uptodate.c
index 1c829e4..a0a120e 100644 (file)
 #include <linux/highmem.h>
 #include <linux/buffer_head.h>
 #include <linux/rbtree.h>
-#ifndef CONFIG_OCFS2_COMPAT_JBD
-# include <linux/jbd2.h>
-#else
-# include <linux/jbd.h>
-#endif
 
 #define MLOG_MASK_PREFIX ML_UPTODATE
 
@@ -118,16 +113,34 @@ void ocfs2_metadata_cache_io_unlock(struct ocfs2_caching_info *ci)
 }
 
 
+static void ocfs2_metadata_cache_reset(struct ocfs2_caching_info *ci,
+                                      int clear)
+{
+       ci->ci_flags |= OCFS2_CACHE_FL_INLINE;
+       ci->ci_num_cached = 0;
+
+       if (clear) {
+               ci->ci_created_trans = 0;
+               ci->ci_last_trans = 0;
+       }
+}
+
 void ocfs2_metadata_cache_init(struct ocfs2_caching_info *ci,
                               const struct ocfs2_caching_operations *ops)
 {
        BUG_ON(!ops);
 
        ci->ci_ops = ops;
-       ci->ci_flags |= OCFS2_CACHE_FL_INLINE;
-       ci->ci_num_cached = 0;
+       ocfs2_metadata_cache_reset(ci, 1);
 }
 
+void ocfs2_metadata_cache_exit(struct ocfs2_caching_info *ci)
+{
+       ocfs2_metadata_cache_purge(ci);
+       ocfs2_metadata_cache_reset(ci, 1);
+}
+
+
 /* No lock taken here as 'root' is not expected to be visible to other
  * processes. */
 static unsigned int ocfs2_purge_copied_metadata_tree(struct rb_root *root)
@@ -177,7 +190,7 @@ void ocfs2_metadata_cache_purge(struct ocfs2_caching_info *ci)
        if (tree)
                root = ci->ci_cache.ci_tree;
 
-       ocfs2_metadata_cache_init(ci, ci->ci_ops);
+       ocfs2_metadata_cache_reset(ci, 0);
        ocfs2_metadata_cache_unlock(ci);
 
        purged = ocfs2_purge_copied_metadata_tree(&root);
@@ -254,8 +267,8 @@ static int ocfs2_buffer_cached(struct ocfs2_caching_info *ci,
 }
 
 /* Warning: even if it returns true, this does *not* guarantee that
- * the block is stored in our inode metadata cache. 
- * 
+ * the block is stored in our inode metadata cache.
+ *
  * This can be called under lock_buffer()
  */
 int ocfs2_buffer_uptodate(struct ocfs2_caching_info *ci,