diff options
Diffstat (limited to 'fs/ocfs2/namei.c')
-rw-r--r-- | fs/ocfs2/namei.c | 57 |
1 files changed, 42 insertions, 15 deletions
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index d2f03355d127..729259016c18 100644 --- a/fs/ocfs2/namei.c +++ b/fs/ocfs2/namei.c | |||
@@ -250,9 +250,8 @@ static int ocfs2_mknod(struct inode *dir, | |||
250 | goto leave; | 250 | goto leave; |
251 | } | 251 | } |
252 | 252 | ||
253 | /* are we making a directory? If so, reserve a cluster for his | 253 | /* Reserve a cluster if creating an extent based directory. */ |
254 | * 1st extent. */ | 254 | if (S_ISDIR(mode) && !ocfs2_supports_inline_data(osb)) { |
255 | if (S_ISDIR(mode)) { | ||
256 | status = ocfs2_reserve_clusters(osb, 1, &data_ac); | 255 | status = ocfs2_reserve_clusters(osb, 1, &data_ac); |
257 | if (status < 0) { | 256 | if (status < 0) { |
258 | if (status != -ENOSPC) | 257 | if (status != -ENOSPC) |
@@ -449,10 +448,21 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb, | |||
449 | cpu_to_le32(CURRENT_TIME.tv_nsec); | 448 | cpu_to_le32(CURRENT_TIME.tv_nsec); |
450 | fe->i_dtime = 0; | 449 | fe->i_dtime = 0; |
451 | 450 | ||
452 | fel = &fe->id2.i_list; | 451 | /* |
453 | fel->l_tree_depth = 0; | 452 | * If supported, directories start with inline data. |
454 | fel->l_next_free_rec = 0; | 453 | */ |
455 | fel->l_count = cpu_to_le16(ocfs2_extent_recs_per_inode(osb->sb)); | 454 | if (S_ISDIR(mode) && ocfs2_supports_inline_data(osb)) { |
455 | u16 feat = le16_to_cpu(fe->i_dyn_features); | ||
456 | |||
457 | fe->i_dyn_features = cpu_to_le16(feat | OCFS2_INLINE_DATA_FL); | ||
458 | |||
459 | fe->id2.i_data.id_count = cpu_to_le16(ocfs2_max_inline_data(osb->sb)); | ||
460 | } else { | ||
461 | fel = &fe->id2.i_list; | ||
462 | fel->l_tree_depth = 0; | ||
463 | fel->l_next_free_rec = 0; | ||
464 | fel->l_count = cpu_to_le16(ocfs2_extent_recs_per_inode(osb->sb)); | ||
465 | } | ||
456 | 466 | ||
457 | status = ocfs2_journal_dirty(handle, *new_fe_bh); | 467 | status = ocfs2_journal_dirty(handle, *new_fe_bh); |
458 | if (status < 0) { | 468 | if (status < 0) { |
@@ -950,7 +960,7 @@ static int ocfs2_rename(struct inode *old_dir, | |||
950 | struct buffer_head *old_inode_bh = NULL; | 960 | struct buffer_head *old_inode_bh = NULL; |
951 | struct buffer_head *insert_entry_bh = NULL; | 961 | struct buffer_head *insert_entry_bh = NULL; |
952 | struct ocfs2_super *osb = NULL; | 962 | struct ocfs2_super *osb = NULL; |
953 | u64 newfe_blkno; | 963 | u64 newfe_blkno, old_de_ino; |
954 | handle_t *handle = NULL; | 964 | handle_t *handle = NULL; |
955 | struct buffer_head *old_dir_bh = NULL; | 965 | struct buffer_head *old_dir_bh = NULL; |
956 | struct buffer_head *new_dir_bh = NULL; | 966 | struct buffer_head *new_dir_bh = NULL; |
@@ -1061,12 +1071,13 @@ static int ocfs2_rename(struct inode *old_dir, | |||
1061 | } | 1071 | } |
1062 | } | 1072 | } |
1063 | 1073 | ||
1064 | status = -ENOENT; | 1074 | status = ocfs2_lookup_ino_from_name(old_dir, old_dentry->d_name.name, |
1065 | old_de_bh = ocfs2_find_entry(old_dentry->d_name.name, | 1075 | old_dentry->d_name.len, |
1066 | old_dentry->d_name.len, | 1076 | &old_de_ino); |
1067 | old_dir, &old_de); | 1077 | if (status) { |
1068 | if (!old_de_bh) | 1078 | status = -ENOENT; |
1069 | goto bail; | 1079 | goto bail; |
1080 | } | ||
1070 | 1081 | ||
1071 | /* | 1082 | /* |
1072 | * Check for inode number is _not_ due to possible IO errors. | 1083 | * Check for inode number is _not_ due to possible IO errors. |
@@ -1074,8 +1085,10 @@ static int ocfs2_rename(struct inode *old_dir, | |||
1074 | * and merrily kill the link to whatever was created under the | 1085 | * and merrily kill the link to whatever was created under the |
1075 | * same name. Goodbye sticky bit ;-< | 1086 | * same name. Goodbye sticky bit ;-< |
1076 | */ | 1087 | */ |
1077 | if (le64_to_cpu(old_de->inode) != OCFS2_I(old_inode)->ip_blkno) | 1088 | if (old_de_ino != OCFS2_I(old_inode)->ip_blkno) { |
1089 | status = -ENOENT; | ||
1078 | goto bail; | 1090 | goto bail; |
1091 | } | ||
1079 | 1092 | ||
1080 | /* check if the target already exists (in which case we need | 1093 | /* check if the target already exists (in which case we need |
1081 | * to delete it */ | 1094 | * to delete it */ |
@@ -1250,7 +1263,21 @@ static int ocfs2_rename(struct inode *old_dir, | |||
1250 | } else | 1263 | } else |
1251 | mlog_errno(status); | 1264 | mlog_errno(status); |
1252 | 1265 | ||
1253 | /* now that the name has been added to new_dir, remove the old name */ | 1266 | /* |
1267 | * Now that the name has been added to new_dir, remove the old name. | ||
1268 | * | ||
1269 | * We don't keep any directory entry context around until now | ||
1270 | * because the insert might have changed the type of directory | ||
1271 | * we're dealing with. | ||
1272 | */ | ||
1273 | old_de_bh = ocfs2_find_entry(old_dentry->d_name.name, | ||
1274 | old_dentry->d_name.len, | ||
1275 | old_dir, &old_de); | ||
1276 | if (!old_de_bh) { | ||
1277 | status = -EIO; | ||
1278 | goto bail; | ||
1279 | } | ||
1280 | |||
1254 | status = ocfs2_delete_entry(handle, old_dir, old_de, old_de_bh); | 1281 | status = ocfs2_delete_entry(handle, old_dir, old_de, old_de_bh); |
1255 | if (status < 0) { | 1282 | if (status < 0) { |
1256 | mlog_errno(status); | 1283 | mlog_errno(status); |