diff options
Diffstat (limited to 'fs/ext2/inode.c')
-rw-r--r-- | fs/ext2/inode.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index 03978ec2a91c..c62006805427 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c | |||
@@ -1181,22 +1181,33 @@ void ext2_get_inode_flags(struct ext2_inode_info *ei) | |||
1181 | ei->i_flags |= EXT2_DIRSYNC_FL; | 1181 | ei->i_flags |= EXT2_DIRSYNC_FL; |
1182 | } | 1182 | } |
1183 | 1183 | ||
1184 | void ext2_read_inode (struct inode * inode) | 1184 | struct inode *ext2_iget (struct super_block *sb, unsigned long ino) |
1185 | { | 1185 | { |
1186 | struct ext2_inode_info *ei = EXT2_I(inode); | 1186 | struct ext2_inode_info *ei; |
1187 | ino_t ino = inode->i_ino; | ||
1188 | struct buffer_head * bh; | 1187 | struct buffer_head * bh; |
1189 | struct ext2_inode * raw_inode = ext2_get_inode(inode->i_sb, ino, &bh); | 1188 | struct ext2_inode *raw_inode; |
1189 | struct inode *inode; | ||
1190 | long ret = -EIO; | ||
1190 | int n; | 1191 | int n; |
1191 | 1192 | ||
1193 | inode = iget_locked(sb, ino); | ||
1194 | if (!inode) | ||
1195 | return ERR_PTR(-ENOMEM); | ||
1196 | if (!(inode->i_state & I_NEW)) | ||
1197 | return inode; | ||
1198 | |||
1199 | ei = EXT2_I(inode); | ||
1192 | #ifdef CONFIG_EXT2_FS_POSIX_ACL | 1200 | #ifdef CONFIG_EXT2_FS_POSIX_ACL |
1193 | ei->i_acl = EXT2_ACL_NOT_CACHED; | 1201 | ei->i_acl = EXT2_ACL_NOT_CACHED; |
1194 | ei->i_default_acl = EXT2_ACL_NOT_CACHED; | 1202 | ei->i_default_acl = EXT2_ACL_NOT_CACHED; |
1195 | #endif | 1203 | #endif |
1196 | ei->i_block_alloc_info = NULL; | 1204 | ei->i_block_alloc_info = NULL; |
1197 | 1205 | ||
1198 | if (IS_ERR(raw_inode)) | 1206 | raw_inode = ext2_get_inode(inode->i_sb, ino, &bh); |
1207 | if (IS_ERR(raw_inode)) { | ||
1208 | ret = PTR_ERR(raw_inode); | ||
1199 | goto bad_inode; | 1209 | goto bad_inode; |
1210 | } | ||
1200 | 1211 | ||
1201 | inode->i_mode = le16_to_cpu(raw_inode->i_mode); | 1212 | inode->i_mode = le16_to_cpu(raw_inode->i_mode); |
1202 | inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low); | 1213 | inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low); |
@@ -1220,6 +1231,7 @@ void ext2_read_inode (struct inode * inode) | |||
1220 | if (inode->i_nlink == 0 && (inode->i_mode == 0 || ei->i_dtime)) { | 1231 | if (inode->i_nlink == 0 && (inode->i_mode == 0 || ei->i_dtime)) { |
1221 | /* this inode is deleted */ | 1232 | /* this inode is deleted */ |
1222 | brelse (bh); | 1233 | brelse (bh); |
1234 | ret = -ESTALE; | ||
1223 | goto bad_inode; | 1235 | goto bad_inode; |
1224 | } | 1236 | } |
1225 | inode->i_blocks = le32_to_cpu(raw_inode->i_blocks); | 1237 | inode->i_blocks = le32_to_cpu(raw_inode->i_blocks); |
@@ -1286,11 +1298,12 @@ void ext2_read_inode (struct inode * inode) | |||
1286 | } | 1298 | } |
1287 | brelse (bh); | 1299 | brelse (bh); |
1288 | ext2_set_inode_flags(inode); | 1300 | ext2_set_inode_flags(inode); |
1289 | return; | 1301 | unlock_new_inode(inode); |
1302 | return inode; | ||
1290 | 1303 | ||
1291 | bad_inode: | 1304 | bad_inode: |
1292 | make_bad_inode(inode); | 1305 | iget_failed(inode); |
1293 | return; | 1306 | return ERR_PTR(ret); |
1294 | } | 1307 | } |
1295 | 1308 | ||
1296 | static int ext2_update_inode(struct inode * inode, int do_sync) | 1309 | static int ext2_update_inode(struct inode * inode, int do_sync) |