Commit 47460d65 authored by Joel Becker's avatar Joel Becker

ocfs2: Make the ocfs2_caching_info structure self-contained.

We want to use the ocfs2_caching_info structure in places that are not
inodes.  To do that, it can no longer rely on referencing the inode
directly.

This patch moves the flags to ocfs2_caching_info->ci_flags, stores
pointers to the parent's locks on the ocfs2_caching_info, and renames
the constants and flags to reflect its independant state.
Signed-off-by: default avatarJoel Becker <joel.becker@oracle.com>
parent 8379e7c4
......@@ -1118,7 +1118,8 @@ void ocfs2_clear_inode(struct inode *inode)
"Clear inode of %llu, inode has %u cache items\n",
(unsigned long long)oi->ip_blkno, oi->ip_metadata_cache.ci_num_cached);
mlog_bug_on_msg(!(oi->ip_flags & OCFS2_INODE_CACHE_INLINE),
mlog_bug_on_msg(!(oi->ip_metadata_cache.ci_flags &
OCFS2_CACHE_FL_INLINE),
"Clear inode of %llu, inode has a bad flag\n",
(unsigned long long)oi->ip_blkno);
......@@ -1145,7 +1146,7 @@ void ocfs2_clear_inode(struct inode *inode)
(unsigned long long)oi->ip_blkno, oi->ip_open_count);
/* Clear all other flags. */
oi->ip_flags = OCFS2_INODE_CACHE_INLINE;
oi->ip_flags = 0;
oi->ip_created_trans = 0;
oi->ip_last_trans = 0;
oi->ip_dir_start_lookup = 0;
......
......@@ -106,8 +106,6 @@ struct ocfs2_inode_info
#define OCFS2_INODE_MAYBE_ORPHANED 0x00000020
/* Does someone have the file open O_DIRECT */
#define OCFS2_INODE_OPEN_DIRECT 0x00000040
/* Indicates that the metadata cache should be used as an array. */
#define OCFS2_INODE_CACHE_INLINE 0x00000080
static inline struct ocfs2_inode_info *OCFS2_I(struct inode *inode)
{
......
......@@ -51,17 +51,36 @@
/* For struct ocfs2_blockcheck_stats */
#include "blockcheck.h"
/* Caching of metadata buffers */
/* Most user visible OCFS2 inodes will have very few pieces of
* metadata, but larger files (including bitmaps, etc) must be taken
* into account when designing an access scheme. We allow a small
* amount of inlined blocks to be stored on an array and grow the
* structure into a rb tree when necessary. */
#define OCFS2_INODE_MAX_CACHE_ARRAY 2
#define OCFS2_CACHE_INFO_MAX_ARRAY 2
/* Flags for ocfs2_caching_info */
enum ocfs2_caching_info_flags {
/* Indicates that the metadata cache is using the inline array */
OCFS2_CACHE_FL_INLINE = 1<<1,
};
struct ocfs2_caching_info {
/*
* The parent structure provides the locks, but because the
* parent structure can differ, struct ocfs2_caching_info needs
* its own pointers to them.
*/
spinlock_t *ci_lock;
struct mutex *ci_io_mutex;
unsigned int ci_flags;
unsigned int ci_num_cached;
union {
sector_t ci_array[OCFS2_INODE_MAX_CACHE_ARRAY];
sector_t ci_array[OCFS2_CACHE_INFO_MAX_ARRAY];
struct rb_root ci_tree;
} ci_cache;
};
......
......@@ -1683,7 +1683,8 @@ static void ocfs2_inode_init_once(void *data)
ocfs2_lock_res_init_once(&oi->ip_inode_lockres);
ocfs2_lock_res_init_once(&oi->ip_open_lockres);
ocfs2_metadata_cache_init(&oi->vfs_inode);
ocfs2_metadata_cache_init(&oi->ip_metadata_cache, &oi->ip_lock,
&oi->ip_io_mutex);
inode_init_once(&oi->vfs_inode);
}
......
This diff is collapsed.
......@@ -29,7 +29,9 @@
int __init init_ocfs2_uptodate_cache(void);
void exit_ocfs2_uptodate_cache(void);
void ocfs2_metadata_cache_init(struct inode *inode);
void ocfs2_metadata_cache_init(struct ocfs2_caching_info *ci,
spinlock_t *cache_lock,
struct mutex *io_mutex);
void ocfs2_metadata_cache_purge(struct inode *inode);
int ocfs2_buffer_uptodate(struct inode *inode,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment