diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/xfs/xfs_inode.c | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 7f7be5f98f52..d1f76da6f8bf 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c | |||
@@ -1028,6 +1028,11 @@ xfs_dinode_calc_crc( | |||
1028 | 1028 | ||
1029 | /* | 1029 | /* |
1030 | * Read the disk inode attributes into the in-core inode structure. | 1030 | * Read the disk inode attributes into the in-core inode structure. |
1031 | * | ||
1032 | * If we are initialising a new inode and we are not utilising the | ||
1033 | * XFS_MOUNT_IKEEP inode cluster mode, we can simple build the new inode core | ||
1034 | * with a random generation number. If we are keeping inodes around, we need to | ||
1035 | * read the inode cluster to get the existing generation number off disk. | ||
1031 | */ | 1036 | */ |
1032 | int | 1037 | int |
1033 | xfs_iread( | 1038 | xfs_iread( |
@@ -1047,6 +1052,22 @@ xfs_iread( | |||
1047 | if (error) | 1052 | if (error) |
1048 | return error; | 1053 | return error; |
1049 | 1054 | ||
1055 | /* shortcut IO on inode allocation if possible */ | ||
1056 | if ((iget_flags & XFS_IGET_CREATE) && | ||
1057 | !(mp->m_flags & XFS_MOUNT_IKEEP)) { | ||
1058 | /* initialise the on-disk inode core */ | ||
1059 | memset(&ip->i_d, 0, sizeof(ip->i_d)); | ||
1060 | ip->i_d.di_magic = XFS_DINODE_MAGIC; | ||
1061 | ip->i_d.di_gen = prandom_u32(); | ||
1062 | if (xfs_sb_version_hascrc(&mp->m_sb)) { | ||
1063 | ip->i_d.di_version = 3; | ||
1064 | ip->i_d.di_ino = ip->i_ino; | ||
1065 | uuid_copy(&ip->i_d.di_uuid, &mp->m_sb.sb_uuid); | ||
1066 | } else | ||
1067 | ip->i_d.di_version = 2; | ||
1068 | return 0; | ||
1069 | } | ||
1070 | |||
1050 | /* | 1071 | /* |
1051 | * Get pointers to the on-disk inode and the buffer containing it. | 1072 | * Get pointers to the on-disk inode and the buffer containing it. |
1052 | */ | 1073 | */ |
@@ -1133,17 +1154,16 @@ xfs_iread( | |||
1133 | xfs_buf_set_ref(bp, XFS_INO_REF); | 1154 | xfs_buf_set_ref(bp, XFS_INO_REF); |
1134 | 1155 | ||
1135 | /* | 1156 | /* |
1136 | * Use xfs_trans_brelse() to release the buffer containing the | 1157 | * Use xfs_trans_brelse() to release the buffer containing the on-disk |
1137 | * on-disk inode, because it was acquired with xfs_trans_read_buf() | 1158 | * inode, because it was acquired with xfs_trans_read_buf() in |
1138 | * in xfs_imap_to_bp() above. If tp is NULL, this is just a normal | 1159 | * xfs_imap_to_bp() above. If tp is NULL, this is just a normal |
1139 | * brelse(). If we're within a transaction, then xfs_trans_brelse() | 1160 | * brelse(). If we're within a transaction, then xfs_trans_brelse() |
1140 | * will only release the buffer if it is not dirty within the | 1161 | * will only release the buffer if it is not dirty within the |
1141 | * transaction. It will be OK to release the buffer in this case, | 1162 | * transaction. It will be OK to release the buffer in this case, |
1142 | * because inodes on disk are never destroyed and we will be | 1163 | * because inodes on disk are never destroyed and we will be locking the |
1143 | * locking the new in-core inode before putting it in the hash | 1164 | * new in-core inode before putting it in the cache where other |
1144 | * table where other processes can find it. Thus we don't have | 1165 | * processes can find it. Thus we don't have to worry about the inode |
1145 | * to worry about the inode being changed just because we released | 1166 | * being changed just because we released the buffer. |
1146 | * the buffer. | ||
1147 | */ | 1167 | */ |
1148 | out_brelse: | 1168 | out_brelse: |
1149 | xfs_trans_brelse(tp, bp); | 1169 | xfs_trans_brelse(tp, bp); |