aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_inode.c
diff options
context:
space:
mode:
authorDavid Chinner <david@fromorbit.com>2008-10-30 02:36:14 -0400
committerLachlan McIlroy <lachlan@sgi.com>2008-10-30 02:36:14 -0400
commitbf904248a2adb3f3be4eb4fb1837ce3bb28cca76 (patch)
tree288306924f640f19d881166a3b50fa59b6e9e7e7 /fs/xfs/xfs_inode.c
parent8290c35f87304a6b73d4fd17b03580b4f7425de8 (diff)
[XFS] Combine the XFS and Linux inodes
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() SGI-PV: 988141 SGI-Modid: xfs-linux-melb:xfs-kern:32323a Signed-off-by: David Chinner <david@fromorbit.com> Signed-off-by: Lachlan McIlroy <lachlan@sgi.com> Signed-off-by: Christoph Hellwig <hch@infradead.org>
Diffstat (limited to 'fs/xfs/xfs_inode.c')
-rw-r--r--fs/xfs/xfs_inode.c43
1 files changed, 32 insertions, 11 deletions
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index bc33762abc49..99d9118c4a41 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -813,6 +813,16 @@ xfs_inode_alloc(
813 ASSERT(!spin_is_locked(&ip->i_flags_lock)); 813 ASSERT(!spin_is_locked(&ip->i_flags_lock));
814 ASSERT(list_empty(&ip->i_reclaim)); 814 ASSERT(list_empty(&ip->i_reclaim));
815 815
816 /*
817 * initialise the VFS inode here to get failures
818 * out of the way early.
819 */
820 if (!inode_init_always(mp->m_super, VFS_I(ip))) {
821 kmem_zone_free(xfs_inode_zone, ip);
822 return NULL;
823 }
824
825 /* initialise the xfs inode */
816 ip->i_ino = ino; 826 ip->i_ino = ino;
817 ip->i_mount = mp; 827 ip->i_mount = mp;
818 ip->i_blkno = 0; 828 ip->i_blkno = 0;
@@ -1086,6 +1096,7 @@ xfs_ialloc(
1086 uint flags; 1096 uint flags;
1087 int error; 1097 int error;
1088 timespec_t tv; 1098 timespec_t tv;
1099 int filestreams = 0;
1089 1100
1090 /* 1101 /*
1091 * Call the space management code to pick 1102 * Call the space management code to pick
@@ -1093,9 +1104,8 @@ xfs_ialloc(
1093 */ 1104 */
1094 error = xfs_dialloc(tp, pip ? pip->i_ino : 0, mode, okalloc, 1105 error = xfs_dialloc(tp, pip ? pip->i_ino : 0, mode, okalloc,
1095 ialloc_context, call_again, &ino); 1106 ialloc_context, call_again, &ino);
1096 if (error != 0) { 1107 if (error)
1097 return error; 1108 return error;
1098 }
1099 if (*call_again || ino == NULLFSINO) { 1109 if (*call_again || ino == NULLFSINO) {
1100 *ipp = NULL; 1110 *ipp = NULL;
1101 return 0; 1111 return 0;
@@ -1109,9 +1119,8 @@ xfs_ialloc(
1109 */ 1119 */
1110 error = xfs_trans_iget(tp->t_mountp, tp, ino, 1120 error = xfs_trans_iget(tp->t_mountp, tp, ino,
1111 XFS_IGET_CREATE, XFS_ILOCK_EXCL, &ip); 1121 XFS_IGET_CREATE, XFS_ILOCK_EXCL, &ip);
1112 if (error != 0) { 1122 if (error)
1113 return error; 1123 return error;
1114 }
1115 ASSERT(ip != NULL); 1124 ASSERT(ip != NULL);
1116 1125
1117 ip->i_d.di_mode = (__uint16_t)mode; 1126 ip->i_d.di_mode = (__uint16_t)mode;
@@ -1192,13 +1201,12 @@ xfs_ialloc(
1192 flags |= XFS_ILOG_DEV; 1201 flags |= XFS_ILOG_DEV;
1193 break; 1202 break;
1194 case S_IFREG: 1203 case S_IFREG:
1195 if (pip && xfs_inode_is_filestream(pip)) { 1204 /*
1196 error = xfs_filestream_associate(pip, ip); 1205 * we can't set up filestreams until after the VFS inode
1197 if (error < 0) 1206 * is set up properly.
1198 return -error; 1207 */
1199 if (!error) 1208 if (pip && xfs_inode_is_filestream(pip))
1200 xfs_iflags_set(ip, XFS_IFILESTREAM); 1209 filestreams = 1;
1201 }
1202 /* fall through */ 1210 /* fall through */
1203 case S_IFDIR: 1211 case S_IFDIR:
1204 if (pip && (pip->i_d.di_flags & XFS_DIFLAG_ANY)) { 1212 if (pip && (pip->i_d.di_flags & XFS_DIFLAG_ANY)) {
@@ -1264,6 +1272,15 @@ xfs_ialloc(
1264 /* now that we have an i_mode we can setup inode ops and unlock */ 1272 /* now that we have an i_mode we can setup inode ops and unlock */
1265 xfs_setup_inode(ip); 1273 xfs_setup_inode(ip);
1266 1274
1275 /* now we have set up the vfs inode we can associate the filestream */
1276 if (filestreams) {
1277 error = xfs_filestream_associate(pip, ip);
1278 if (error < 0)
1279 return -error;
1280 if (!error)
1281 xfs_iflags_set(ip, XFS_IFILESTREAM);
1282 }
1283
1267 *ipp = ip; 1284 *ipp = ip;
1268 return 0; 1285 return 0;
1269} 1286}
@@ -2650,6 +2667,10 @@ xfs_idestroy_fork(
2650 * It must free the inode itself and any buffers allocated for 2667 * It must free the inode itself and any buffers allocated for
2651 * if_extents/if_data and if_broot. It must also free the lock 2668 * if_extents/if_data and if_broot. It must also free the lock
2652 * associated with the inode. 2669 * associated with the inode.
2670 *
2671 * Note: because we don't initialise everything on reallocation out
2672 * of the zone, we must ensure we nullify everything correctly before
2673 * freeing the structure.
2653 */ 2674 */
2654void 2675void
2655xfs_idestroy( 2676xfs_idestroy(