XFS: Combine Linux and XFS inodes
Subsystems (2)
cover XFS: Combine Linux and XFS inodes
XFS currently has to deal with two separate inode lifecycles which makes for complexity in inode lookups and reclaim. We also have the problem of not always having a linux inode around when it might be useful to have it.
To avoid these lifecycle problems, this series embedѕ the linux inode inside the struct xfs_inode and changes the way we reference the two inodes. We can no longer check for a null linux inode - instead we have to check to see if it is valid or not by checking either the linux inode or xfs inode state flags. While this means that inodes waiting for reclaim use more memory, this is not the common state for inodes and they will soon be completely freed so the additional memeory use in this state is only temporary.
This combining of the inodes simplifies the inode and reclaim logic, making it possible to do reclaim via radix tree tags (an upcoming patch series) and to be able to use RCU locking on the radix trees. The fact that we don't have a simple mechanism to determine the reclaim state of the inode makes RCU locking very complex, and this complexity is removed by having a combined inode structure.
This patch series also changes the way XFS caches inodes. It no longer uses the linux inode cache as the primary lookup cache - instead we rely solely on the XFS inode caches. This avoids the inode_lock in lookups that hit the cache - we should get much better parallelism out of inode lookup than we currently do now.
In future, we should also be able to cull duplicate fields out of the xfs and linux inodes reducing the overall memory usage of the active inode cache. This provides scope for continuing to reduce the memory footprint of the XFS inode cache.
PATCH 1/3 Inode: Allow external initialisers
To allow XFS to combine the XFS and linux inodes into a single structure, we need to drive inode lookup from the XFS inode cache, not the generic inode cache. This means that we need initialise a struct inode from a context outside alloc_inode() as it is no longer used by XFS.
Factor and export the struct inode initialisation code from alloc_inode() to inode_init_always() as a counterpart to inode_init_once(). i.e. we have to call this init function for each inode instantiation (always), as opposed inode_init_once() which is only called on slab object instantiation (once).
--- fs/inode.c | 152 +++++++++++++++++++++++++++++----------------------- include/linux/fs.h | 1 + 2 files changed, 85 insertions(+), 68 deletions(-)
fs/inode.c +78 -62
@@ -108,84 +108,100 @@ static void wake_up_inode(struct inode *inode)wake_up_bit (&inode->i_state, __I_LOCK); } -static struct inode *alloc_inode (struct super_block *sb) +/** +* inode_init_always - perform inode structure intialisation +* @sb - superblock inode belongs to. +* @inode - inode to initialise +* +* These are initializations that need to be done on every inode +* allocation as the fields are not initialised by slab allocation. +*/ +struct inode *inode_init_always (struct super_block *sb,struct inode *inode) {static const struct address_space_operations empty_aops;static struct inode_operations empty_iops;static const struct file_operations empty_fops; -struct inode *inode; - -if (sb->s_op->alloc_inode) - inode = sb->s_op->alloc_inode (sb); -else - inode = (struct inode *)kmem_cache_alloc (inode_cachep,GFP_KERNEL ); -if (inode) { -struct address_space *const mapping = &inode->i_data; - - inode->i_sb = sb; - inode->i_blkbits = sb->s_blocksize_bits; - inode->i_flags =0 ; -atomic_set (&inode->i_count,1 ); - inode->i_op = &empty_iops; - inode->i_fop = &empty_fops; - inode->i_nlink =1 ; -atomic_set (&inode->i_writecount,0 ); - inode->i_size =0 ; - inode->i_blocks =0 ; - inode->i_bytes =0 ; - inode->i_generation =0 ; +struct address_space *const mapping = &inode->i_data; + + inode->i_sb = sb; + inode->i_blkbits = sb->s_blocksize_bits; + inode->i_flags =0 ; +atomic_set (&inode->i_count,1 ); + inode->i_op = &empty_iops; + inode->i_fop = &empty_fops; + inode->i_nlink =1 ; +atomic_set (&inode->i_writecount,0 ); + inode->i_size =0 ; + inode->i_blocks =0 ; + inode->i_bytes =0 ; + inode->i_generation =0 ;#ifdef CONFIG_QUOTA -memset (&inode->i_dquot,0 ,sizeof (inode->i_dquot)); +memset (&inode->i_dquot,0 ,sizeof (inode->i_dquot));#endif - inode->i_pipe =NULL ; - inode->i_bdev =NULL ; - inode->i_cdev =NULL ; - inode->i_rdev =0 ; - inode->dirtied_when =0 ; -if (security_inode_alloc (inode)) { -if (inode->i_sb->s_op->destroy_inode) - inode->i_sb->s_op->destroy_inode (inode); -else -kmem_cache_free (inode_cachep, (inode)); -return NULL ; - } + inode->i_pipe =NULL ; + inode->i_bdev =NULL ; + inode->i_cdev =NULL ; + inode->i_rdev =0 ; + inode->dirtied_when =0 ; +if (security_inode_alloc (inode)) { +if (inode->i_sb->s_op->destroy_inode) + inode->i_sb->s_op->destroy_inode (inode); +else +kmem_cache_free (inode_cachep, (inode)); +return NULL ; + } -spin_lock_init (&inode->i_lock); -lockdep_set_class (&inode->i_lock, &sb->s_type->i_lock_key); +spin_lock_init (&inode->i_lock); +lockdep_set_class (&inode->i_lock, &sb->s_type->i_lock_key); -mutex_init (&inode->i_mutex); -lockdep_set_class (&inode->i_mutex, &sb->s_type->i_mutex_key); +mutex_init (&inode->i_mutex); +lockdep_set_class (&inode->i_mutex, &sb->s_type->i_mutex_key); -init_rwsem (&inode->i_alloc_sem); -lockdep_set_class (&inode->i_alloc_sem, &sb->s_type->i_alloc_sem_key); +init_rwsem (&inode->i_alloc_sem); +lockdep_set_class (&inode->i_alloc_sem, &sb->s_type->i_alloc_sem_key); - mapping->a_ops = &empty_aops; - mapping->host = inode; - mapping->flags =0 ; -mapping_set_gfp_mask (mapping,GFP_HIGHUSER_PAGECACHE ); - mapping->assoc_mapping =NULL ; - mapping->backing_dev_info = &default_backing_dev_info; - mapping->writeback_index =0 ; + mapping->a_ops = &empty_aops; + mapping->host = inode; + mapping->flags =0 ; +mapping_set_gfp_mask (mapping,GFP_HIGHUSER_PAGECACHE ); + mapping->assoc_mapping =NULL ; + mapping->backing_dev_info = &default_backing_dev_info; + mapping->writeback_index =0 ; -/* -* If the block_device provides a backing_dev_info for client -* inodes then use that. Otherwise the inode share the bdev's -* backing_dev_info. -*/ -if (sb->s_bdev) { -struct backing_dev_info *bdi; +/* +* If the block_device provides a backing_dev_info for client +* inodes then use that. Otherwise the inode share the bdev's +* backing_dev_info. +*/ +if (sb->s_bdev) { +struct backing_dev_info *bdi; - bdi = sb->s_bdev->bd_inode_backing_dev_info; -if (!bdi) - bdi = sb->s_bdev->bd_inode->i_mapping->backing_dev_info; - mapping->backing_dev_info = bdi; - } - inode->i_private =NULL ; - inode->i_mapping = mapping; + bdi = sb->s_bdev->bd_inode_backing_dev_info; +if (!bdi) + bdi = sb->s_bdev->bd_inode->i_mapping->backing_dev_info; + mapping->backing_dev_info = bdi; } + inode->i_private =NULL ; + inode->i_mapping = mapping; +return inode; } +EXPORT_SYMBOL (inode_init_always); + +static struct inode *alloc_inode (struct super_block *sb) +{ +struct inode *inode; + +if (sb->s_op->alloc_inode) + inode = sb->s_op->alloc_inode (sb); +else + inode =kmem_cache_alloc (inode_cachep,GFP_KERNEL ); + +if (inode) +return inode_init_always (sb, inode); +return NULL ; +}void destroy_inode (struct inode *inode) {
include/linux/fs.h +1 -0
@@ -1811,6 +1811,7 @@ extern loff_t default_llseek(struct file *file, loff_t offset, int origin);extern loff_t vfs_llseek (struct file *file,loff_t offset,int origin); +extern struct inode *inode_init_always (struct super_block *,struct inode *);extern void inode_init_once (struct inode *);extern void iput (struct inode *);extern struct inode *igrab (struct inode *);
Signature · 1 line
1.5.6
PATCH 2/3 Inode: Allow external list initialisation
In reply to Dave ChinnerTo allow XFS to combine the XFS and linux inodes into a single structure, we need to drive inode lookup from the XFS inode cache, not the generic inode cache. This means that we need initialise a struct inode from a context outside alloc_inode() as it is no longer used by XFS.
After inode allocation and initialisation, we need to add the inode to the superblock list, the in-use list, hash it and do some accounting. This all needs to be done with the inode_lock held and there are already several places in fs/inode.c that do this list manipulation. Factor out the common code, add a locking wrapper and export the function so ti can be called from XFS.
--- fs/inode.c | 67 +++++++++++++++++++++++++++++++++++---------------- include/linux/fs.h | 1 + 2 files changed, 47 insertions(+), 21 deletions(-)
fs/inode.c +46 -21
@@ -550,6 +550,49 @@ repeat:return node ? inode :NULL ; } +static unsigned long hash (struct super_block *sb,unsigned long hashval) +{ +unsigned long tmp; + + tmp = (hashval * (unsigned long )sb) ^ (GOLDEN_RATIO_PRIME + hashval) / +L1_CACHE_BYTES ; + tmp = tmp ^ ((tmp ^GOLDEN_RATIO_PRIME ) >>I_HASHBITS ); +return tmp &I_HASHMASK ; +} + +static inline void +__inode_add_to_lists (struct super_block *sb,struct hlist_head *head, +struct inode *inode) +{ + inodes_stat.nr_inodes++; +list_add (&inode->i_list, &inode_in_use); +list_add (&inode->i_sb_list, &sb->s_inodes); +if (head) +hlist_add_head (&inode->i_hash, head); +} + +/** +* inode_add_to_lists - add a new inode to relevant lists +* @sb - superblock inode belongs to. +* @inode - inode to mark in use +* +* When an inode is allocated it needs to be accounted for, added to the in use +* list, the owning superblock and the inode hash. This needs to be done under +* the inode_lock, so export a function to do this rather than the inode lock +* itself. We calculate the hash list to add to here so it is all internal +* which requires the caller to have already set up the inode number in the +* inode to add. +*/ +void inode_add_to_lists (struct super_block *sb,struct inode *inode) +{ +struct hlist_head *head = inode_hashtable +hash (sb, inode->i_ino); + +spin_lock (&inode_lock); +__inode_add_to_lists (sb, head, inode); +spin_unlock (&inode_lock); +} +EXPORT_SYMBOL_GPL (inode_add_to_lists); +/** * new_inode - obtain an inode * @sb: superblock
@@ -577,9 +620,7 @@ struct inode *new_inode(struct super_block *sb) inode =alloc_inode (sb);if (inode) {spin_lock (&inode_lock); - inodes_stat.nr_inodes++; -list_add (&inode->i_list, &inode_in_use); -list_add (&inode->i_sb_list, &sb->s_inodes); +__inode_add_to_lists (sb,NULL , inode); inode->i_ino = ++last_ino; inode->i_state =0 ;spin_unlock (&inode_lock);
@@ -638,10 +679,7 @@ static struct inode * get_new_inode(struct super_block *sb, struct hlist_head *hif (set (inode, data)) goto set_failed; - inodes_stat.nr_inodes++; -list_add (&inode->i_list, &inode_in_use); -list_add (&inode->i_sb_list, &sb->s_inodes); -hlist_add_head (&inode->i_hash, head); +__inode_add_to_lists (sb, head, inode); inode->i_state =I_LOCK |I_NEW ;spin_unlock (&inode_lock);
@@ -687,10 +725,7 @@ static struct inode * get_new_inode_fast(struct super_block *sb, struct hlist_he old =find_inode_fast (sb, head, ino);if (!old) { inode->i_ino = ino; - inodes_stat.nr_inodes++; -list_add (&inode->i_list, &inode_in_use); -list_add (&inode->i_sb_list, &sb->s_inodes); -hlist_add_head (&inode->i_hash, head); +__inode_add_to_lists (sb, head, inode); inode->i_state =I_LOCK |I_NEW ;spin_unlock (&inode_lock);
@@ -714,16 +749,6 @@ static struct inode * get_new_inode_fast(struct super_block *sb, struct hlist_hereturn inode; } -static unsigned long hash (struct super_block *sb,unsigned long hashval) -{ -unsigned long tmp; - - tmp = (hashval * (unsigned long )sb) ^ (GOLDEN_RATIO_PRIME + hashval) / -L1_CACHE_BYTES ; - tmp = tmp ^ ((tmp ^GOLDEN_RATIO_PRIME ) >>I_HASHBITS ); -return tmp &I_HASHMASK ; -} -/** * iunique - get a unique inode number * @sb: superblock
include/linux/fs.h +1 -0
@@ -1813,6 +1813,7 @@ extern loff_t vfs_llseek(struct file *file, loff_t offset, int origin);extern struct inode *inode_init_always (struct super_block *,struct inode *);extern void inode_init_once (struct inode *); +extern void inode_add_to_lists (struct super_block *,struct inode *);extern void iput (struct inode *);extern struct inode *igrab (struct inode *);extern ino_t iunique (struct super_block *,ino_t );
Signature · 1 line
1.5.6
PATCH 3/3 XFS: Combine the XFS and Linux inodes V2
In reply to Dave ChinnerTo avoid issues with different lifecycles of XFS and Linux inodes, embedd the linux inode inside the XFS inode. This means that the linux inode has the same lifecycle as the XFS inode, even when it has been released by the OS. XFS inodes don't live much longer than this (a short stint in reclaim at most), so there isn't significant memory usage penalties here.
Version 2
o remove unused commented out code from xfs_iget().
o kill useless cast in VFS_I()
--- fs/xfs/linux-2.6/xfs_iops.c | 17 +++- fs/xfs/linux-2.6/xfs_super.c | 48 +++++------- fs/xfs/linux-2.6/xfs_vnode.c | 6 +- fs/xfs/xfs_iget.c | 167 +++++++++--------------------------------- fs/xfs/xfs_inode.c | 43 ++++++++--- fs/xfs/xfs_inode.h | 9 ++- fs/xfs/xfs_vnodeops.c | 13 +--- 7 files changed, 109 insertions(+), 194 deletions(-)
fs/xfs/linux-2.6/xfs_iops.c +13 -4
@@ -64,14 +64,14 @@ xfs_synchronize_atime( {struct inode *inode =VFS_I (ip); -if (inode) { +if (!(inode->i_state &I_CLEAR )) { ip->i_d.di_atime.t_sec = (__int32_t )inode->i_atime.tv_sec; ip->i_d.di_atime.t_nsec = (__int32_t )inode->i_atime.tv_nsec; } }/* -* If the linux inode exists, mark it dirty. +* If the linux inode is valid, mark it dirty. * Used when commiting a dirty inode into a transaction so that * the inode will get written back by the linux code */
@@ -81,7 +81,7 @@ xfs_mark_inode_dirty_sync( {struct inode *inode =VFS_I (ip); -if (inode) +if (!(inode->i_state & (I_WILL_FREE |I_FREEING |I_CLEAR )))mark_inode_dirty_sync (inode); }
@@ -766,12 +766,21 @@ xfs_diflags_to_iflags(* When reading existing inodes from disk this is called directly * from xfs_iget, when creating a new inode it is called from * xfs_ialloc after setting up the inode. +* +* We are always called with an uninitialised linux inode here. +* We need to initialise the necessary fields and take a reference +* on it. */ void xfs_setup_inode (struct xfs_inode *ip) { -struct inode *inode = ip->i_vnode; +struct inode *inode = &ip->i_vnode; + + inode->i_ino = ip->i_ino; + inode->i_state =I_NEW |I_LOCK ; +inode_add_to_lists (ip->i_mount->m_super, inode); +ASSERT (atomic_read (&inode->i_count) ==1 ); inode->i_mode = ip->i_d.di_mode; inode->i_nlink = ip->i_d.di_nlink;
fs/xfs/linux-2.6/xfs_super.c +19 -29
121 lines not on this page · raw message
fs/xfs/linux-2.6/xfs_vnode.c +1 -5
@@ -90,11 +90,7 @@ vn_ioerror(*/ static inline int xfs_icount (struct xfs_inode *ip) { -struct inode *inode =VFS_I (ip); - -if (!inode) -return atomic_read (&inode->i_count); -return -1 ; +return atomic_read (&VFS_I (ip)->i_count); }#define KTRACE_ENTER (ip, vk, s, line, ra) \
fs/xfs/xfs_iget.c +35 -132
251 lines not on this page · raw message
fs/xfs/xfs_inode.c +32 -11
87 lines not on this page · raw message
fs/xfs/xfs_inode.h +6 -3
@@ -195,7 +195,6 @@ typedef struct xfs_inode {/* Inode linking and identification information. */ struct xfs_mount *i_mount;/* fs mount struct ptr */ struct list_head i_reclaim;/* reclaim list */ -struct inode *i_vnode;/* vnode backpointer */ struct xfs_dquot *i_udquot;/* user dquot */ struct xfs_dquot *i_gdquot;/* group dquot */
@@ -229,6 +228,10 @@ typedef struct xfs_inode {xfs_fsize_t i_size;/* in-memory size */ xfs_fsize_t i_new_size;/* size when write completes */ atomic_t i_iocount;/* outstanding I/O count */ + +/* VFS inode */ +struct inode i_vnode;/* embedded VFS inode */ +/* Trace buffers per inode. */ #ifdef XFS_INODE_TRACE struct ktrace *i_trace;/* general inode trace */
@@ -256,13 +259,13 @@ typedef struct xfs_inode {/* Convert from vfs inode to xfs inode */ static inline struct xfs_inode *XFS_I (struct inode *inode) { -return (struct xfs_inode *)inode->i_private; + return container_of(inode, struct xfs_inode, i_vnode); }/* convert from xfs inode to vfs inode */ static inline struct inode *VFS_I (struct xfs_inode *ip) { -return (struct inode *)ip->i_vnode; +return &ip->i_vnode; }/*
fs/xfs/xfs_vnodeops.c +3 -10
@@ -2800,6 +2800,7 @@ xfs_reclaim(if (!ip->i_update_core && (ip->i_itemp ==NULL )) {xfs_ilock (ip,XFS_ILOCK_EXCL );xfs_iflock (ip); +xfs_iflags_set (ip,XFS_IRECLAIMABLE );return xfs_finish_reclaim (ip,1 ,XFS_IFLUSH_DELWRI_ELSE_SYNC ); }else {xfs_mount_t *mp = ip->i_mount;
@@ -2808,8 +2809,6 @@ xfs_reclaim(XFS_MOUNT_ILOCK (mp);spin_lock (&ip->i_flags_lock);__xfs_iflags_set (ip,XFS_IRECLAIMABLE ); -VFS_I (ip)->i_private =NULL ; - ip->i_vnode =NULL ;spin_unlock (&ip->i_flags_lock);list_add_tail (&ip->i_reclaim, &mp->m_del_inodes);XFS_MOUNT_IUNLOCK (mp);
@@ -2824,10 +2823,6 @@ xfs_finish_reclaim( int sync_mode) {xfs_perag_t *pag =xfs_get_perag (ip->i_mount, ip->i_ino); -struct inode *vp =VFS_I (ip); - -if (vp &&VN_BAD (vp)) - goto reclaim;/* The hash lock here protects a thread in xfs_iget_core from * racing with us on linking the inode back with a vnode.
@@ -2837,7 +2832,7 @@ xfs_finish_reclaim(write_lock (&pag->pag_ici_lock);spin_lock (&ip->i_flags_lock);if (__xfs_iflags_test (ip,XFS_IRECLAIM ) || - (!__xfs_iflags_test (ip,XFS_IRECLAIMABLE ) && vp ==NULL )) { + !__xfs_iflags_test (ip,XFS_IRECLAIMABLE )) {spin_unlock (&ip->i_flags_lock);write_unlock (&pag->pag_ici_lock);if (locked) {
@@ -2871,15 +2866,13 @@ xfs_finish_reclaim(* In the case of a forced shutdown we rely on xfs_iflush() to * wait for the inode to be unpinned before returning an error. */ -if (xfs_iflush (ip, sync_mode) ==0 ) { +if (!VN_BAD (VFS_I (ip)) &&xfs_iflush (ip, sync_mode) ==0 ) {/* synchronize with xfs_iflush_done */ xfs_iflock (ip);xfs_ifunlock (ip); }xfs_iunlock (ip,XFS_ILOCK_EXCL ); - - reclaim:xfs_ireclaim (ip);return 0 ; }
Signature · 1 line
1.5.6
Re: [PATCH 3/3] XFS: Combine the XFS and Linux inodes V2
Quoted 2 lines · Dave Chinner
+ * we need to provide an empty inode free function to prevent
+ * the generic code from trying to free ouuur combined inode.
^^^^ spelling?
fs/xfs/linux-2.6/xfs_super.c xfsaild_stop( · line 885
Quoted 9 lines
fs/xfs/linux-2.6/xfs_super.c +2
-5- -STATIC void -xfs_fs_inode_init_once ( -void *vnode) + struct inode *inode) { -inode_init_once ((struct inode *)vnode); +return ; }
No need for a no-argument return at the end of the function.
fs/xfs/linux-2.6/xfs_vnode.c vn_ioerror( · line 94
Quoted 9 lines
static inline int
xfs_icount(struct xfs_inode *ip){fs/xfs/linux-2.6/xfs_vnode.c +1
-5-struct inode *inode =VFS_I (ip); - -if (!inode) -return atomic_read (&inode->i_count); -return -1 ; +return atomic_read (&VFS_I (ip)->i_count); }
At this point we can just kill this helper - there's only one caller anyway.
fs/xfs/xfs_vnodeops.c xfs_finish_reclaim( · line 2869
Quoted 2 lines
fs/xfs/xfs_vnodeops.c +1
-1-if (xfs_iflush (ip, sync_mode) ==0 ) { +if (!VN_BAD (VFS_I (ip)) &&xfs_iflush (ip, sync_mode) ==0 ) {
Why don't you switch to is_bad_inode directly instead of fixing this up in a later patch?
Re: [PATCH 3/3] XFS: Combine the XFS and Linux inodes V2
Quoted 5 lines · Christoph Hellwig
Quoted 2 lines · Dave Chinner
+ * we need to provide an empty inode free function to prevent
+ * the generic code from trying to free ouuur combined inode.^^^^ spelling?
Damn keeey repeat.... ;)
Quoted 10 lines
Review
Quoted 8 lines
(quoted diff) +2
-4-STATIC void -xfs_fs_inode_init_once( - void *vnode) + struct inode *inode) { - inode_init_once((struct inode *)vnode); + return; }No need for a no-argument return at the end of the function.
Ok. Will fix.
Quoted 4 lines
Quoted 4 lines
static inline int
xfs_icount(struct xfs_inode *ip){(quoted diff) +0
-2- struct inode *inode = VFS_I(ip); -
Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +1
-3- if (!inode) - return atomic_read(&inode->i_count); - return -1; + return atomic_read(&VFS_I(ip)->i_count); }At this point we can just kill this helper - there's only one caller anyway.
Killed.
Quoted 6 lines
Review
Quoted 3 lines
(quoted diff) +1
-1- if (xfs_iflush(ip, sync_mode) == 0) { + if (!VN_BAD(VFS_I(ip)) && xfs_iflush(ip, sync_mode) == 0) {Why don't you switch to
is_bad_inodedirectly instead of fixing this up in a later patch?
Fixed.
Updated patch below.
Cheers,
Dave.
Signature · 27 lines
Dave Chinner [email protected] XFS: Combine the XFS and Linux inodes V3 To avoid issues with different lifecycles of XFS and Linux inodes, embedd the linux inode inside the XFS inode. This means that the linux inode has the same lifecycle as the XFS inode, even when it has been released by the OS. XFS inodes don't live much longer than this (a short stint in reclaim at most), so there isn't significant memory usage penalties here. Version 3 o kill xfs_icount() Version 2 o remove unused commented out code from xfs_iget(). o kill useless cast in VFS_I() --- fs/xfs/linux-2.6/xfs_iops.c | 17 +++- fs/xfs/linux-2.6/xfs_super.c | 48 +++++-------- fs/xfs/linux-2.6/xfs_vnode.c | 15 +---- fs/xfs/xfs_iget.c | 167 +++++++++--------------------------------- fs/xfs/xfs_inode.c | 43 ++++++++--- fs/xfs/xfs_inode.h | 9 ++- fs/xfs/xfs_vnodeops.c | 13 +--- 7 files changed, 108 insertions(+), 204 deletions(-)
fs/xfs/linux-2.6/xfs_iops.c +13 -4
@@ -64,14 +64,14 @@ xfs_synchronize_atime( {struct inode *inode =VFS_I (ip); -if (inode) { +if (!(inode->i_state &I_CLEAR )) { ip->i_d.di_atime.t_sec = (__int32_t )inode->i_atime.tv_sec; ip->i_d.di_atime.t_nsec = (__int32_t )inode->i_atime.tv_nsec; } }/* -* If the linux inode exists, mark it dirty. +* If the linux inode is valid, mark it dirty. * Used when commiting a dirty inode into a transaction so that * the inode will get written back by the linux code */
@@ -81,7 +81,7 @@ xfs_mark_inode_dirty_sync( {struct inode *inode =VFS_I (ip); -if (inode) +if (!(inode->i_state & (I_WILL_FREE |I_FREEING |I_CLEAR )))mark_inode_dirty_sync (inode); }
@@ -766,12 +766,21 @@ xfs_diflags_to_iflags(* When reading existing inodes from disk this is called directly * from xfs_iget, when creating a new inode it is called from * xfs_ialloc after setting up the inode. +* +* We are always called with an uninitialised linux inode here. +* We need to initialise the necessary fields and take a reference +* on it. */ void xfs_setup_inode (struct xfs_inode *ip) { -struct inode *inode = ip->i_vnode; +struct inode *inode = &ip->i_vnode; + + inode->i_ino = ip->i_ino; + inode->i_state =I_NEW |I_LOCK ; +inode_add_to_lists (ip->i_mount->m_super, inode); +ASSERT (atomic_read (&inode->i_count) ==1 ); inode->i_mode = ip->i_d.di_mode; inode->i_nlink = ip->i_d.di_nlink;
fs/xfs/linux-2.6/xfs_super.c +18 -30
127 lines not on this page · raw message
fs/xfs/linux-2.6/xfs_vnode.c +1 -14
@@ -84,25 +84,12 @@ vn_ioerror(#ifdef XFS_INODE_TRACE -/* -* Reference count of Linux inode if present, -1 if the xfs_inode -* has no associated Linux inode. -*/ -static inline int xfs_icount (struct xfs_inode *ip) -{ -struct inode *inode =VFS_I (ip); - -if (!inode) -return atomic_read (&inode->i_count); -return -1 ; -} -#define KTRACE_ENTER (ip, vk, s, line, ra) \ ktrace_enter( (ip)->i_trace, \/* 0 */ (void *)(__psint_t)(vk), \/* 1 */ (void *)(s), \/* 2 */ (void *)(__psint_t ) line, \ -/* 3 */ (void *)(__psint_t )xfs_icount (ip), \ +/* 3 */ (void *)(__psint_t )atomic_read (&VFS_I (ip)->i_count) \ /* 4 */ (void *)(ra), \/* 5 */ NULL , \ /* 6 */ (void *)(__psint_t)current_cpu(), \
fs/xfs/xfs_iget.c +35 -132
251 lines not on this page · raw message
fs/xfs/xfs_inode.c +32 -11
87 lines not on this page · raw message
fs/xfs/xfs_inode.h +6 -3
@@ -195,7 +195,6 @@ typedef struct xfs_inode {/* Inode linking and identification information. */ struct xfs_mount *i_mount;/* fs mount struct ptr */ struct list_head i_reclaim;/* reclaim list */ -struct inode *i_vnode;/* vnode backpointer */ struct xfs_dquot *i_udquot;/* user dquot */ struct xfs_dquot *i_gdquot;/* group dquot */
@@ -229,6 +228,10 @@ typedef struct xfs_inode {xfs_fsize_t i_size;/* in-memory size */ xfs_fsize_t i_new_size;/* size when write completes */ atomic_t i_iocount;/* outstanding I/O count */ + +/* VFS inode */ +struct inode i_vnode;/* embedded VFS inode */ +/* Trace buffers per inode. */ #ifdef XFS_INODE_TRACE struct ktrace *i_trace;/* general inode trace */
@@ -256,13 +259,13 @@ typedef struct xfs_inode {/* Convert from vfs inode to xfs inode */ static inline struct xfs_inode *XFS_I (struct inode *inode) { -return (struct xfs_inode *)inode->i_private; + return container_of(inode, struct xfs_inode, i_vnode); }/* convert from xfs inode to vfs inode */ static inline struct inode *VFS_I (struct xfs_inode *ip) { -return (struct inode *)ip->i_vnode; +return &ip->i_vnode; }/*
fs/xfs/xfs_vnodeops.c +3 -10
@@ -2800,6 +2800,7 @@ xfs_reclaim(if (!ip->i_update_core && (ip->i_itemp ==NULL )) {xfs_ilock (ip,XFS_ILOCK_EXCL );xfs_iflock (ip); +xfs_iflags_set (ip,XFS_IRECLAIMABLE );return xfs_finish_reclaim (ip,1 ,XFS_IFLUSH_DELWRI_ELSE_SYNC ); }else {xfs_mount_t *mp = ip->i_mount;
@@ -2808,8 +2809,6 @@ xfs_reclaim(XFS_MOUNT_ILOCK (mp);spin_lock (&ip->i_flags_lock);__xfs_iflags_set (ip,XFS_IRECLAIMABLE ); -VFS_I (ip)->i_private =NULL ; - ip->i_vnode =NULL ;spin_unlock (&ip->i_flags_lock);list_add_tail (&ip->i_reclaim, &mp->m_del_inodes);XFS_MOUNT_IUNLOCK (mp);
@@ -2824,10 +2823,6 @@ xfs_finish_reclaim( int sync_mode) {xfs_perag_t *pag =xfs_get_perag (ip->i_mount, ip->i_ino); -struct inode *vp =VFS_I (ip); - -if (vp &&VN_BAD (vp)) - goto reclaim;/* The hash lock here protects a thread in xfs_iget_core from * racing with us on linking the inode back with a vnode.
@@ -2837,7 +2832,7 @@ xfs_finish_reclaim(write_lock (&pag->pag_ici_lock);spin_lock (&ip->i_flags_lock);if (__xfs_iflags_test (ip,XFS_IRECLAIM ) || - (!__xfs_iflags_test (ip,XFS_IRECLAIMABLE ) && vp ==NULL )) { + !__xfs_iflags_test (ip,XFS_IRECLAIMABLE )) {spin_unlock (&ip->i_flags_lock);write_unlock (&pag->pag_ici_lock);if (locked) {
@@ -2871,15 +2866,13 @@ xfs_finish_reclaim(* In the case of a forced shutdown we rely on xfs_iflush() to * wait for the inode to be unpinned before returning an error. */ -if (xfs_iflush (ip, sync_mode) ==0 ) { +if (!is_bad_inode (VFS_I (ip)) &&xfs_iflush (ip, sync_mode) ==0 ) {/* synchronize with xfs_iflush_done */ xfs_iflock (ip);xfs_ifunlock (ip); }xfs_iunlock (ip,XFS_ILOCK_EXCL ); - - reclaim:xfs_ireclaim (ip);return 0 ; }