[Ocfs2-commits] jlbec commits r2244 - branches/alloc_inode/fs/ocfs2
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Sat May 14 00:04:21 CDT 2005
Author: jlbec
Date: 2005-05-14 00:04:19 -0500 (Sat, 14 May 2005)
New Revision: 2244
Modified:
branches/alloc_inode/fs/ocfs2/extent_map.c
branches/alloc_inode/fs/ocfs2/inode.c
branches/alloc_inode/fs/ocfs2/inode.h
branches/alloc_inode/fs/ocfs2/namei.c
branches/alloc_inode/fs/ocfs2/ocfs2.h
branches/alloc_inode/fs/ocfs2/super.c
Log:
o First pass, add an alloc_inode().
o Use the ocfs2_inode_info to check ip_blkno, thus solving the
find_actor() bug.
Modified: branches/alloc_inode/fs/ocfs2/extent_map.c
===================================================================
--- branches/alloc_inode/fs/ocfs2/extent_map.c 2005-05-14 04:24:10 UTC (rev 2243)
+++ branches/alloc_inode/fs/ocfs2/extent_map.c 2005-05-14 05:04:19 UTC (rev 2244)
@@ -261,7 +261,7 @@
{
int ret;
u64 blkno;
- struct ocfs2_extent_map *em = &OCFS_I(inode)->ip_map;
+ struct ocfs2_extent_map *em = &OCFS2_I(inode)->ip_map;
struct ocfs2_extent_map_entry *ent;
struct buffer_head *bh = NULL;
ocfs2_extent_block *eb;
@@ -355,7 +355,7 @@
struct ocfs2_em_insert_context *ctxt)
{
int ret;
- struct ocfs2_extent_map *em = &OCFS_I(inode)->ip_map;
+ struct ocfs2_extent_map *em = &OCFS2_I(inode)->ip_map;
struct ocfs2_extent_map_entry *old_ent;
ctxt->need_left = 0;
@@ -461,13 +461,13 @@
struct ocfs2_em_insert_context ctxt = {0, };
if ((rec->e_cpos + rec->e_clusters) >
- OCFS_I(inode)->ip_map.em_clusters)
+ OCFS2_I(inode)->ip_map.em_clusters)
return -EBADR;
/* Zero e_clusters means a truncated tail record. It better be EOF */
if (!rec->e_clusters) {
if ((rec->e_cpos + rec->e_clusters) !=
- OCFS_I(inode)->ip_map.em_clusters)
+ OCFS2_I(inode)->ip_map.em_clusters)
return -EBADR;
/* Ignore the truncated tail */
@@ -541,7 +541,7 @@
u32 new_clusters)
{
int ret;
- struct ocfs2_extent_map *em = &OCFS_I(inode)->ip_map;
+ struct ocfs2_extent_map *em = &OCFS2_I(inode)->ip_map;
struct ocfs2_extent_map_entry *ent;
ocfs2_extent_rec *old;
@@ -614,7 +614,7 @@
int *tree_depth)
{
int ret = -ENOENT;
- struct ocfs2_extent_map *em = &OCFS_I(inode)->ip_map;
+ struct ocfs2_extent_map *em = &OCFS2_I(inode)->ip_map;
struct ocfs2_extent_map_entry *ent;
*rec = NULL;
@@ -632,7 +632,7 @@
em->em_clusters = OCFS_I(inode)->ip_clusters ;
}
- ent = ocfs2_extent_map_lookup(&OCFS_I(inode)->ip_map, cpos, 1,
+ ent = ocfs2_extent_map_lookup(&OCFS2_I(inode)->ip_map, cpos, 1,
NULL, NULL);
if (ent) {
@@ -651,7 +651,7 @@
{
int ret;
u32 coff, ccount;
- struct ocfs2_extent_map *em = &OCFS_I(inode)->ip_map;
+ struct ocfs2_extent_map *em = &OCFS2_I(inode)->ip_map;
struct ocfs2_extent_map_entry *ent = NULL;
*p_cpos = ccount = 0;
@@ -705,7 +705,7 @@
u32 cpos, clusters;
int bpc = ocfs2_clusters_to_blocks(inode->i_sb, 1);
struct ocfs2_extent_map_entry *ent = NULL;
- struct ocfs2_extent_map *em = &OCFS_I(inode)->ip_map;
+ struct ocfs2_extent_map *em = &OCFS2_I(inode)->ip_map;
ocfs2_extent_rec *rec;
*p_blkno = 0;
@@ -758,7 +758,7 @@
int ocfs2_extent_map_init(struct inode *inode)
{
- struct ocfs2_extent_map *em = &OCFS_I(inode)->ip_map;
+ struct ocfs2_extent_map *em = &OCFS2_I(inode)->ip_map;
em->em_extents = RB_ROOT;
em->em_clusters = 0;
@@ -773,7 +773,7 @@
struct ocfs2_extent_map_entry **tail_ent)
{
struct rb_node *node, *next;
- struct ocfs2_extent_map *em = &OCFS_I(inode)->ip_map;
+ struct ocfs2_extent_map *em = &OCFS2_I(inode)->ip_map;
struct ocfs2_extent_map_entry *ent;
*free_head = NULL;
@@ -836,7 +836,7 @@
int ocfs2_extent_map_drop(struct inode *inode, u32 new_clusters)
{
struct rb_node *free_head = NULL;
- struct ocfs2_extent_map *em = &OCFS_I(inode)->ip_map;
+ struct ocfs2_extent_map *em = &OCFS2_I(inode)->ip_map;
struct ocfs2_extent_map_entry *ent;
spin_lock(&OCFS_I(inode)->ip_lock);
@@ -875,7 +875,7 @@
ent->e_rec.e_clusters =
new_clusters - ent->e_rec.e_cpos;
- OCFS_I(inode)->ip_map.em_clusters = new_clusters;
+ OCFS2_I(inode)->ip_map.em_clusters = new_clusters;
spin_unlock(&OCFS_I(inode)->ip_lock);
Modified: branches/alloc_inode/fs/ocfs2/inode.c
===================================================================
--- branches/alloc_inode/fs/ocfs2/inode.c 2005-05-14 04:24:10 UTC (rev 2243)
+++ branches/alloc_inode/fs/ocfs2/inode.c 2005-05-14 05:04:19 UTC (rev 2244)
@@ -55,17 +55,16 @@
extern struct address_space_operations ocfs_aops;
-typedef struct _ocfs_find_inode_args
+struct ocfs2_find_inode_args
{
u64 blkno;
unsigned long ino;
u32 flags;
-}
-ocfs_find_inode_args;
+};
-static int ocfs_read_locked_inode(struct inode *inode, ocfs_find_inode_args *args);
+static int ocfs_read_locked_inode(struct inode *inode, struct ocfs2_find_inode_args *args);
static int ocfs_init_locked_inode(struct inode * inode, void * opaque);
-static int ocfs_find_actor (struct inode *inode, void *opaque);
+static int ocfs2_find_actor (struct inode *inode, void *opaque);
static int ocfs_truncate_for_delete(ocfs_super *osb,
struct inode *inode,
struct buffer_head *fe_bh);
@@ -76,12 +75,12 @@
*/
struct inode *ocfs_ilookup(ocfs_super *osb, u64 blkno)
{
- ocfs_find_inode_args args;
+ struct ocfs2_find_inode_args args;
args.blkno = blkno;
args.flags = 0;
args.ino = ino_from_blkno(osb->sb, blkno);
- return ilookup5(osb->sb, args.ino, ocfs_find_actor, &args);
+ return ilookup5(osb->sb, args.ino, ocfs2_find_actor, &args);
}
/*
@@ -92,7 +91,7 @@
{
struct inode *inode = NULL;
struct super_block *sb = osb->sb;
- ocfs_find_inode_args args;
+ struct ocfs2_find_inode_args args;
u32 flags = 0;
mlog_entry("(blkno = %"MLFu64")\n", blkno);
@@ -109,7 +108,7 @@
args.flags = flags;
args.ino = ino_from_blkno(sb, blkno);
- inode = iget5_locked (sb, args.ino, ocfs_find_actor,
+ inode = iget5_locked (sb, args.ino, ocfs2_find_actor,
ocfs_init_locked_inode, &args);
/* inode was *not* in the inode cache. 2.6.x requires
* us to do our own read_inode call and unlock it
@@ -149,30 +148,26 @@
* not found? : get_new_inode -> OCFS_INIT_LOCKED_INODE
*/
-static int ocfs_find_actor(struct inode *inode, void *opaque)
+static int ocfs2_find_actor(struct inode *inode, void *opaque)
{
- ocfs_find_inode_args *args = NULL;
+ struct ocfs2_find_inode_args *args = NULL;
int ret = 0;
mlog_entry ("(0x%p, %lu, 0x%p)\n", inode, inode->i_ino, opaque);
args = opaque;
- /* XXX: Can this actually ever be passed in as NULL? */
- if (inode == NULL)
- goto bail;
+ mlog_bug_on_msg(!inode, "No inode in find actor!\n");
if (!inode->u.generic_ip) {
mlog(ML_ERROR, "inode %lu has no generic_ip (is_bad_inode = "
"%d)!\n", inode->i_ino, is_bad_inode(inode));
- if (args)
- mlog(ML_ERROR, "args-blkno = %"MLFu64", "
- "args->ino = %lu, args->flags = 0x%x\n",
+ mlog(ML_ERROR, "args-blkno = %"MLFu64", "
+ "args->ino = %lu, args->flags = 0x%x\n",
args->blkno, args->ino, args->flags);
- BUG();
}
- if (OCFS_I(inode)->ip_blkno != args->blkno)
+ if (OCFS2_I(inode)->ip_blkno != args->blkno)
goto bail;
ret = 1;
@@ -188,10 +183,12 @@
*/
static int ocfs_init_locked_inode(struct inode * inode, void * opaque)
{
- ocfs_find_inode_args *args = opaque;
+ struct ocfs2_find_inode_args *args = opaque;
+
mlog_entry("inode = %p, opaque = %p\n", inode, opaque);
inode->i_ino = args->ino;
+ OCFS2_I(inode)->ip_blkno = args->blkno;
mlog_exit(0);
return 0;
@@ -367,7 +364,7 @@
return status;
} /* ocfs_populate_inode */
-static int ocfs_read_locked_inode(struct inode *inode, ocfs_find_inode_args *args)
+static int ocfs_read_locked_inode(struct inode *inode, struct ocfs2_find_inode_args *args)
{
struct super_block *sb;
ocfs_super *osb;
@@ -727,10 +724,10 @@
} /* ocfs_delete_inode */
/*
- * ocfs_clear_inode()
+ * ocfs2_clear_inode()
*
*/
-void ocfs_clear_inode (struct inode *inode)
+void ocfs2_clear_inode(struct inode *inode)
{
int status;
ocfs_super *osb;
@@ -780,9 +777,12 @@
OCFS_I(inode)->ip_flags &= ~OCFS_INODE_INITIALIZED;
+ OCFS2_I(inode)->ip_blkno = 0ULL;
+
/* clean out the inode private ... why?! */
memset(inode->u.generic_ip, 0, sizeof(ocfs_inode_private));
+
bail:
if (inode && inode->u.generic_ip) {
kmem_cache_free(ocfs2_inode_cache, inode->u.generic_ip);
@@ -790,7 +790,7 @@
}
mlog_exit_void ();
-} /* ocfs_clear_inode */
+}
/*
* TODO: this should probably be merged into ocfs_get_block
Modified: branches/alloc_inode/fs/ocfs2/inode.h
===================================================================
--- branches/alloc_inode/fs/ocfs2/inode.h 2005-05-14 04:24:10 UTC (rev 2243)
+++ branches/alloc_inode/fs/ocfs2/inode.h 2005-05-14 05:04:19 UTC (rev 2244)
@@ -30,7 +30,7 @@
struct buffer_head *ocfs_bread(struct inode * inode, int block,
int *err, int reada);
-void ocfs_clear_inode(struct inode *inode);
+void ocfs2_clear_inode(struct inode *inode);
void ocfs_delete_inode(struct inode *inode);
struct inode *ocfs_iget(ocfs_super *osb, u64 feoff);
struct inode *ocfs_ilookup(ocfs_super *osb, u64 feoff);
Modified: branches/alloc_inode/fs/ocfs2/namei.c
===================================================================
--- branches/alloc_inode/fs/ocfs2/namei.c 2005-05-14 04:24:10 UTC (rev 2243)
+++ branches/alloc_inode/fs/ocfs2/namei.c 2005-05-14 05:04:19 UTC (rev 2244)
@@ -333,8 +333,8 @@
goto leave;
}
- inode = new_inode (dir->i_sb);
- if (IS_ERR (inode)) {
+ inode = new_inode(dir->i_sb);
+ if (IS_ERR(inode)) {
status = PTR_ERR(inode);
mlog(ML_ERROR, "new_inode failed!\n");
goto leave;
@@ -412,6 +412,7 @@
fe = (ocfs2_dinode *)new_fe_bh->b_data;
+ OCFS2_I(inode)->ip_blkno = fe->i_blkno;
if (ocfs_populate_inode(inode, fe, 1) < 0) {
mlog(ML_ERROR, "populate inode failed! bh->b_blocknr=%llu, "
"i_blkno=%"MLFu64", i_ino=%lu\n",
@@ -1581,6 +1582,7 @@
fe = (ocfs2_dinode *) new_fe_bh->b_data;
+ OCFS2_I(inode)->ip_blkno = fe->i_blkno;
if (ocfs_populate_inode (inode, fe, 1) < 0) {
mlog(ML_ERROR, "populate inode failed! bh->b_blocknr=%llu, "
"i_blkno=%"MLFu64", i_ino=%lu\n",
Modified: branches/alloc_inode/fs/ocfs2/ocfs2.h
===================================================================
--- branches/alloc_inode/fs/ocfs2/ocfs2.h 2005-05-14 04:24:10 UTC (rev 2243)
+++ branches/alloc_inode/fs/ocfs2/ocfs2.h 2005-05-14 05:04:19 UTC (rev 2244)
@@ -26,6 +26,57 @@
#ifndef OCFS2_H
#define OCFS2_H
+/* OCFS2 Inode Private Data */
+struct ocfs2_inode_info
+{
+ u64 ip_blkno;
+
+ ocfs2_lock_res ip_meta_lockres;
+ ocfs2_lock_res ip_data_lockres;
+
+ /* protects allocation changes on this inode. */
+ struct rw_semaphore ip_alloc_sem;
+
+ /* These fields are protected by ip_lock */
+ spinlock_t ip_lock;
+ u32 ip_open_cnt;
+ u32 ip_clusters;
+ loff_t ip_mmu_private;
+ struct ocfs2_extent_map ip_map;
+ struct list_head ip_io_markers;
+ int ip_orphaned_slot;
+
+ struct semaphore ip_io_sem;
+
+ /* Used by the journalling code to attach an inode to a
+ * handle. These are protected by ip_io_sem in order to lock
+ * out other I/O to the inode until we either commit or
+ * abort. */
+ struct list_head ip_handle_list;
+ struct _ocfs_journal_handle *ip_handle;
+
+ atomic_t ip_clean_buffer_seq;
+ u32 ip_flags; /* see below */
+
+ /* protected by recovery_lock. */
+ struct inode *ip_next_orphan;
+
+ u32 ip_dir_start_lookup;
+
+ /* 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 inode vfs_inode;
+};
+
+static inline struct ocfs2_inode_info *OCFS2_I(struct inode *inode)
+{
+ return container_of(inode, struct ocfs2_inode_info, vfs_inode);
+}
+
static inline u64 ocfs2_clusters_to_blocks(struct super_block *sb,
u32 clusters)
{
@@ -90,3 +141,4 @@
#define ocfs2_test_bit ext2_test_bit
#define ocfs2_find_next_zero_bit ext2_find_next_zero_bit
#endif /* OCFS2_H */
+
Modified: branches/alloc_inode/fs/ocfs2/super.c
===================================================================
--- branches/alloc_inode/fs/ocfs2/super.c 2005-05-14 04:24:10 UTC (rev 2243)
+++ branches/alloc_inode/fs/ocfs2/super.c 2005-05-14 05:04:19 UTC (rev 2244)
@@ -74,6 +74,7 @@
kmem_cache_t *ocfs2_inode_cache = NULL;
kmem_cache_t *ocfs2_lock_cache = NULL;
+kmem_cache_t *ocfs2_inode_cachep = NULL;
MODULE_AUTHOR("Oracle");
MODULE_LICENSE("GPL");
@@ -99,17 +100,20 @@
static int ocfs_initialize_osb(ocfs_super *osb, struct buffer_head *bh);
static int ocfs2_get_sector(struct super_block *sb, struct buffer_head **bh, int block, int sect_size);
static void ocfs_write_super(struct super_block * sb);
+static struct inode *ocfs2_alloc_inode(struct super_block *sb);
+static void ocfs2_destroy_inode(struct inode *inode);
static unsigned long long ocfs2_max_file_offset(unsigned int blockshift);
static struct super_operations ocfs_sops = {
- .statfs = ocfs_statfs,
- .clear_inode = ocfs_clear_inode,
- .delete_inode = ocfs_delete_inode,
- .sync_fs = ocfs_sync_fs,
- .write_super = ocfs_write_super,
- .put_super = ocfs_put_super,
-
+ .statfs = ocfs_statfs,
+ .alloc_inode = ocfs2_alloc_inode,
+ .destroy_inode = ocfs2_destroy_inode,
+ .clear_inode = ocfs2_clear_inode,
+ .delete_inode = ocfs_delete_inode,
+ .sync_fs = ocfs_sync_fs,
+ .write_super = ocfs_write_super,
+ .put_super = ocfs_put_super,
};
struct dentry *ocfs_get_parent(struct dentry *child);
@@ -244,6 +248,23 @@
return status;
} /* ocfs_release_system_inodes */
+/* We're allocating fs objects, use GFP_NOFS */
+static struct inode *ocfs2_alloc_inode(struct super_block *sb)
+{
+ struct ocfs2_inode_info *oi;
+
+ oi = kmem_cache_alloc(ocfs2_inode_cachep, SLAB_NOFS);
+ if (!oi)
+ return NULL;
+
+ return &oi->vfs_inode;
+}
+
+static void ocfs2_destroy_inode(struct inode *inode)
+{
+ kmem_cache_free(ocfs2_inode_cachep, OCFS2_I(inode));
+}
+
/* From xfs_super.c:xfs_max_file_offset
* Copyright (c) 2000-2004 Silicon Graphics, Inc.
*/
@@ -520,12 +541,47 @@
return status;
} /* ocfs_statfs */
+static void init_once(void *foo, kmem_cache_t *cachep, unsigned long flags)
+{
+ struct ocfs2_inode_info *oi = foo;
+
+ if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
+ SLAB_CTOR_CONSTRUCTOR) {
+ oi->ip_flags = 0;
+ atomic_set(&oi->ip_clean_buffer_seq, 0);
+ oi->ip_open_cnt = 0;
+ spin_lock_init(&oi->ip_lock);
+ ocfs2_extent_map_init(&oi->vfs_inode);
+ INIT_LIST_HEAD(&oi->ip_handle_list);
+ INIT_LIST_HEAD(&oi->ip_io_markers);
+ oi->ip_handle = NULL;
+ oi->ip_next_orphan = NULL;
+
+ init_rwsem(&oi->ip_alloc_sem);
+ init_MUTEX(&(oi->ip_io_sem));
+
+ oi->ip_blkno = 0;
+ oi->ip_clusters = 0;
+ oi->ip_mmu_private = 0LL;
+
+ oi->ip_flags |= OCFS_INODE_INITIALIZED;
+ inode_init_once(&oi->vfs_inode);
+ }
+}
+
/*
* ocfs_initialize_mem_caches()
*
*/
static int ocfs_initialize_mem_caches(void)
{
+ ocfs2_inode_cachep = kmem_cache_create("ocfs2_inode_cache",
+ sizeof(struct ocfs2_inode_info),
+ 0, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT,
+ init_once, NULL);
+ if (!ocfs2_inode_cachep)
+ return -ENOMEM;
+
ocfs2_inode_cache = kmem_cache_create("ocfs2_inode",
sizeof(ocfs_inode_private), 0,
SLAB_NO_REAP|SLAB_HWCACHE_ALIGN,
@@ -549,6 +605,8 @@
*/
static void ocfs_free_mem_caches(void)
{
+ if (ocfs2_inode_cachep)
+ kmem_cache_destroy(ocfs2_inode_cachep);
if (ocfs2_inode_cache)
kmem_cache_destroy(ocfs2_inode_cache);
if (ocfs2_lock_cache)
More information about the Ocfs2-commits
mailing list