ocfs2_lock_res_free(&oi->ip_inode_lockres);
ocfs2_lock_res_free(&oi->ip_open_lockres);
- ocfs2_metadata_cache_purge(INODE_CACHE(inode));
+ ocfs2_metadata_cache_exit(INODE_CACHE(inode));
mlog_bug_on_msg(INODE_CACHE(inode)->ci_num_cached,
"Clear inode of %llu, inode has %u cache items\n",
/* Clear all other flags. */
oi->ip_flags = 0;
oi->ip_created_trans = 0;
- oi->ip_last_trans = 0;
oi->ip_dir_start_lookup = 0;
oi->ip_blkno = 0ULL;
/* next two are protected by trans_inc_lock */
/* which transaction were we created on? Zero if none. */
unsigned long ip_created_trans;
- /* last transaction we were a part of. */
- unsigned long ip_last_trans;
struct ocfs2_caching_info ip_metadata_cache;
struct inode *inode)
{
spin_lock(&trans_inc_lock);
- OCFS2_I(inode)->ip_last_trans = journal->j_trans_id;
+ INODE_CACHE(inode)->ci_last_trans = journal->j_trans_id;
spin_unlock(&trans_inc_lock);
}
struct ocfs2_journal *journal = OCFS2_SB(inode->i_sb)->journal;
spin_lock(&trans_inc_lock);
- ret = time_after(journal->j_trans_id, OCFS2_I(inode)->ip_last_trans);
+ ret = time_after(journal->j_trans_id,
+ INODE_CACHE(inode)->ci_last_trans);
spin_unlock(&trans_inc_lock);
return ret;
}
*/
const struct ocfs2_caching_operations *ci_ops;
+ /* last transaction we were a part of. */
+ unsigned long ci_last_trans;
+
+ /* Cache structures */
unsigned int ci_flags;
unsigned int ci_num_cached;
union {
ocfs2_extent_map_init(&oi->vfs_inode);
INIT_LIST_HEAD(&oi->ip_io_markers);
oi->ip_created_trans = 0;
- oi->ip_last_trans = 0;
oi->ip_dir_start_lookup = 0;
init_rwsem(&oi->ip_alloc_sem);
}
+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_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)
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);
void ocfs2_metadata_cache_init(struct ocfs2_caching_info *ci,
const struct ocfs2_caching_operations *ops);
void ocfs2_metadata_cache_purge(struct ocfs2_caching_info *ci);
+void ocfs2_metadata_cache_exit(struct ocfs2_caching_info *ci);
u64 ocfs2_metadata_cache_owner(struct ocfs2_caching_info *ci);
struct super_block *ocfs2_metadata_cache_get_super(struct ocfs2_caching_info *ci);