aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/namei.c
diff options
context:
space:
mode:
authorMark Fasheh <mfasheh@suse.com>2008-11-12 18:43:34 -0500
committerMark Fasheh <mfasheh@suse.com>2009-04-03 14:39:15 -0400
commit4a12ca3a00a244e1fd1e673d151ea38b71e11d55 (patch)
tree84e30310a7d93ead9910f761e19d3fe73c5861b3 /fs/ocfs2/namei.c
parent59b526a30722f29e5dba6210a6e0fc34e3149b94 (diff)
ocfs2: Introduce dir lookup helper struct
Many directory manipulation calls pass around a tuple of dirent, and it's containing buffer_head. Dir indexing has a bit more state, but instead of adding yet more arguments to functions, we introduce 'struct ocfs2_dir_lookup_result'. In this patch, it simply holds the same tuple, but future patches will add more state. Signed-off-by: Mark Fasheh <mfasheh@suse.com> Acked-by: Joel Becker <joel.becker@oracle.com>
Diffstat (limited to 'fs/ocfs2/namei.c')
-rw-r--r--fs/ocfs2/namei.c150
1 files changed, 77 insertions, 73 deletions
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 4b11762f249e..d3a5a09d88ff 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -80,14 +80,14 @@ static int ocfs2_prepare_orphan_dir(struct ocfs2_super *osb,
80 struct inode **ret_orphan_dir, 80 struct inode **ret_orphan_dir,
81 struct inode *inode, 81 struct inode *inode,
82 char *name, 82 char *name,
83 struct buffer_head **de_bh); 83 struct ocfs2_dir_lookup_result *lookup);
84 84
85static int ocfs2_orphan_add(struct ocfs2_super *osb, 85static int ocfs2_orphan_add(struct ocfs2_super *osb,
86 handle_t *handle, 86 handle_t *handle,
87 struct inode *inode, 87 struct inode *inode,
88 struct ocfs2_dinode *fe, 88 struct ocfs2_dinode *fe,
89 char *name, 89 char *name,
90 struct buffer_head *de_bh, 90 struct ocfs2_dir_lookup_result *lookup,
91 struct inode *orphan_dir_inode); 91 struct inode *orphan_dir_inode);
92 92
93static int ocfs2_create_symlink_data(struct ocfs2_super *osb, 93static int ocfs2_create_symlink_data(struct ocfs2_super *osb,
@@ -228,7 +228,6 @@ static int ocfs2_mknod(struct inode *dir,
228 struct ocfs2_super *osb; 228 struct ocfs2_super *osb;
229 struct ocfs2_dinode *dirfe; 229 struct ocfs2_dinode *dirfe;
230 struct buffer_head *new_fe_bh = NULL; 230 struct buffer_head *new_fe_bh = NULL;
231 struct buffer_head *de_bh = NULL;
232 struct inode *inode = NULL; 231 struct inode *inode = NULL;
233 struct ocfs2_alloc_context *inode_ac = NULL; 232 struct ocfs2_alloc_context *inode_ac = NULL;
234 struct ocfs2_alloc_context *data_ac = NULL; 233 struct ocfs2_alloc_context *data_ac = NULL;
@@ -239,6 +238,7 @@ static int ocfs2_mknod(struct inode *dir,
239 .enable = 1, 238 .enable = 1,
240 }; 239 };
241 int did_quota_inode = 0; 240 int did_quota_inode = 0;
241 struct ocfs2_dir_lookup_result lookup = { NULL, };
242 242
243 mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry, mode, 243 mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry, mode,
244 (unsigned long)dev, dentry->d_name.len, 244 (unsigned long)dev, dentry->d_name.len,
@@ -274,7 +274,7 @@ static int ocfs2_mknod(struct inode *dir,
274 /* get a spot inside the dir. */ 274 /* get a spot inside the dir. */
275 status = ocfs2_prepare_dir_for_insert(osb, dir, parent_fe_bh, 275 status = ocfs2_prepare_dir_for_insert(osb, dir, parent_fe_bh,
276 dentry->d_name.name, 276 dentry->d_name.name,
277 dentry->d_name.len, &de_bh); 277 dentry->d_name.len, &lookup);
278 if (status < 0) { 278 if (status < 0) {
279 mlog_errno(status); 279 mlog_errno(status);
280 goto leave; 280 goto leave;
@@ -394,7 +394,7 @@ static int ocfs2_mknod(struct inode *dir,
394 394
395 status = ocfs2_add_entry(handle, dentry, inode, 395 status = ocfs2_add_entry(handle, dentry, inode,
396 OCFS2_I(inode)->ip_blkno, parent_fe_bh, 396 OCFS2_I(inode)->ip_blkno, parent_fe_bh,
397 de_bh); 397 &lookup);
398 if (status < 0) { 398 if (status < 0) {
399 mlog_errno(status); 399 mlog_errno(status);
400 goto leave; 400 goto leave;
@@ -423,11 +423,12 @@ leave:
423 mlog(0, "Disk is full\n"); 423 mlog(0, "Disk is full\n");
424 424
425 brelse(new_fe_bh); 425 brelse(new_fe_bh);
426 brelse(de_bh);
427 brelse(parent_fe_bh); 426 brelse(parent_fe_bh);
428 kfree(si.name); 427 kfree(si.name);
429 kfree(si.value); 428 kfree(si.value);
430 429
430 ocfs2_free_dir_lookup_result(&lookup);
431
431 if ((status < 0) && inode) { 432 if ((status < 0) && inode) {
432 clear_nlink(inode); 433 clear_nlink(inode);
433 iput(inode); 434 iput(inode);
@@ -608,9 +609,9 @@ static int ocfs2_link(struct dentry *old_dentry,
608 int err; 609 int err;
609 struct buffer_head *fe_bh = NULL; 610 struct buffer_head *fe_bh = NULL;
610 struct buffer_head *parent_fe_bh = NULL; 611 struct buffer_head *parent_fe_bh = NULL;
611 struct buffer_head *de_bh = NULL;
612 struct ocfs2_dinode *fe = NULL; 612 struct ocfs2_dinode *fe = NULL;
613 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); 613 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
614 struct ocfs2_dir_lookup_result lookup = { NULL, };
614 615
615 mlog_entry("(inode=%lu, old='%.*s' new='%.*s')\n", inode->i_ino, 616 mlog_entry("(inode=%lu, old='%.*s' new='%.*s')\n", inode->i_ino,
616 old_dentry->d_name.len, old_dentry->d_name.name, 617 old_dentry->d_name.len, old_dentry->d_name.name,
@@ -638,7 +639,7 @@ static int ocfs2_link(struct dentry *old_dentry,
638 639
639 err = ocfs2_prepare_dir_for_insert(osb, dir, parent_fe_bh, 640 err = ocfs2_prepare_dir_for_insert(osb, dir, parent_fe_bh,
640 dentry->d_name.name, 641 dentry->d_name.name,
641 dentry->d_name.len, &de_bh); 642 dentry->d_name.len, &lookup);
642 if (err < 0) { 643 if (err < 0) {
643 mlog_errno(err); 644 mlog_errno(err);
644 goto out; 645 goto out;
@@ -688,7 +689,7 @@ static int ocfs2_link(struct dentry *old_dentry,
688 689
689 err = ocfs2_add_entry(handle, dentry, inode, 690 err = ocfs2_add_entry(handle, dentry, inode,
690 OCFS2_I(inode)->ip_blkno, 691 OCFS2_I(inode)->ip_blkno,
691 parent_fe_bh, de_bh); 692 parent_fe_bh, &lookup);
692 if (err) { 693 if (err) {
693 le16_add_cpu(&fe->i_links_count, -1); 694 le16_add_cpu(&fe->i_links_count, -1);
694 drop_nlink(inode); 695 drop_nlink(inode);
@@ -714,10 +715,11 @@ out_unlock_inode:
714out: 715out:
715 ocfs2_inode_unlock(dir, 1); 716 ocfs2_inode_unlock(dir, 1);
716 717
717 brelse(de_bh);
718 brelse(fe_bh); 718 brelse(fe_bh);
719 brelse(parent_fe_bh); 719 brelse(parent_fe_bh);
720 720
721 ocfs2_free_dir_lookup_result(&lookup);
722
721 mlog_exit(err); 723 mlog_exit(err);
722 724
723 return err; 725 return err;
@@ -766,10 +768,9 @@ static int ocfs2_unlink(struct inode *dir,
766 struct buffer_head *fe_bh = NULL; 768 struct buffer_head *fe_bh = NULL;
767 struct buffer_head *parent_node_bh = NULL; 769 struct buffer_head *parent_node_bh = NULL;
768 handle_t *handle = NULL; 770 handle_t *handle = NULL;
769 struct ocfs2_dir_entry *dirent = NULL;
770 struct buffer_head *dirent_bh = NULL;
771 char orphan_name[OCFS2_ORPHAN_NAMELEN + 1]; 771 char orphan_name[OCFS2_ORPHAN_NAMELEN + 1];
772 struct buffer_head *orphan_entry_bh = NULL; 772 struct ocfs2_dir_lookup_result lookup = { NULL, };
773 struct ocfs2_dir_lookup_result orphan_insert = { NULL, };
773 774
774 mlog_entry("(0x%p, 0x%p, '%.*s')\n", dir, dentry, 775 mlog_entry("(0x%p, 0x%p, '%.*s')\n", dir, dentry,
775 dentry->d_name.len, dentry->d_name.name); 776 dentry->d_name.len, dentry->d_name.name);
@@ -791,8 +792,8 @@ static int ocfs2_unlink(struct inode *dir,
791 } 792 }
792 793
793 status = ocfs2_find_files_on_disk(dentry->d_name.name, 794 status = ocfs2_find_files_on_disk(dentry->d_name.name,
794 dentry->d_name.len, &blkno, 795 dentry->d_name.len, &blkno, dir,
795 dir, &dirent_bh, &dirent); 796 &lookup);
796 if (status < 0) { 797 if (status < 0) {
797 if (status != -ENOENT) 798 if (status != -ENOENT)
798 mlog_errno(status); 799 mlog_errno(status);
@@ -836,8 +837,7 @@ static int ocfs2_unlink(struct inode *dir,
836 837
837 if (inode_is_unlinkable(inode)) { 838 if (inode_is_unlinkable(inode)) {
838 status = ocfs2_prepare_orphan_dir(osb, &orphan_dir, inode, 839 status = ocfs2_prepare_orphan_dir(osb, &orphan_dir, inode,
839 orphan_name, 840 orphan_name, &orphan_insert);
840 &orphan_entry_bh);
841 if (status < 0) { 841 if (status < 0) {
842 mlog_errno(status); 842 mlog_errno(status);
843 goto leave; 843 goto leave;
@@ -863,7 +863,7 @@ static int ocfs2_unlink(struct inode *dir,
863 863
864 if (inode_is_unlinkable(inode)) { 864 if (inode_is_unlinkable(inode)) {
865 status = ocfs2_orphan_add(osb, handle, inode, fe, orphan_name, 865 status = ocfs2_orphan_add(osb, handle, inode, fe, orphan_name,
866 orphan_entry_bh, orphan_dir); 866 &orphan_insert, orphan_dir);
867 if (status < 0) { 867 if (status < 0) {
868 mlog_errno(status); 868 mlog_errno(status);
869 goto leave; 869 goto leave;
@@ -871,7 +871,7 @@ static int ocfs2_unlink(struct inode *dir,
871 } 871 }
872 872
873 /* delete the name from the parent dir */ 873 /* delete the name from the parent dir */
874 status = ocfs2_delete_entry(handle, dir, dirent, dirent_bh); 874 status = ocfs2_delete_entry(handle, dir, &lookup);
875 if (status < 0) { 875 if (status < 0) {
876 mlog_errno(status); 876 mlog_errno(status);
877 goto leave; 877 goto leave;
@@ -916,9 +916,10 @@ leave:
916 } 916 }
917 917
918 brelse(fe_bh); 918 brelse(fe_bh);
919 brelse(dirent_bh);
920 brelse(parent_node_bh); 919 brelse(parent_node_bh);
921 brelse(orphan_entry_bh); 920
921 ocfs2_free_dir_lookup_result(&orphan_insert);
922 ocfs2_free_dir_lookup_result(&lookup);
922 923
923 mlog_exit(status); 924 mlog_exit(status);
924 925
@@ -1004,8 +1005,8 @@ static int ocfs2_rename(struct inode *old_dir,
1004 struct inode *new_dir, 1005 struct inode *new_dir,
1005 struct dentry *new_dentry) 1006 struct dentry *new_dentry)
1006{ 1007{
1007 int status = 0, rename_lock = 0, parents_locked = 0; 1008 int status = 0, rename_lock = 0, parents_locked = 0, target_exists = 0;
1008 int old_child_locked = 0, new_child_locked = 0; 1009 int old_child_locked = 0, new_child_locked = 0, update_dot_dot = 0;
1009 struct inode *old_inode = old_dentry->d_inode; 1010 struct inode *old_inode = old_dentry->d_inode;
1010 struct inode *new_inode = new_dentry->d_inode; 1011 struct inode *new_inode = new_dentry->d_inode;
1011 struct inode *orphan_dir = NULL; 1012 struct inode *orphan_dir = NULL;
@@ -1020,13 +1021,13 @@ static int ocfs2_rename(struct inode *old_dir,
1020 handle_t *handle = NULL; 1021 handle_t *handle = NULL;
1021 struct buffer_head *old_dir_bh = NULL; 1022 struct buffer_head *old_dir_bh = NULL;
1022 struct buffer_head *new_dir_bh = NULL; 1023 struct buffer_head *new_dir_bh = NULL;
1023 struct ocfs2_dir_entry *old_inode_dot_dot_de = NULL, *old_de = NULL,
1024 *new_de = NULL;
1025 struct buffer_head *new_de_bh = NULL, *old_de_bh = NULL; // bhs for above
1026 struct buffer_head *old_inode_de_bh = NULL; // if old_dentry is a dir,
1027 // this is the 1st dirent bh
1028 nlink_t old_dir_nlink = old_dir->i_nlink; 1024 nlink_t old_dir_nlink = old_dir->i_nlink;
1029 struct ocfs2_dinode *old_di; 1025 struct ocfs2_dinode *old_di;
1026 struct ocfs2_dir_lookup_result old_inode_dot_dot_res = { NULL, };
1027 struct ocfs2_dir_lookup_result target_lookup_res = { NULL, };
1028 struct ocfs2_dir_lookup_result old_entry_lookup = { NULL, };
1029 struct ocfs2_dir_lookup_result orphan_insert = { NULL, };
1030 struct ocfs2_dir_lookup_result target_insert = { NULL, };
1030 1031
1031 /* At some point it might be nice to break this function up a 1032 /* At some point it might be nice to break this function up a
1032 * bit. */ 1033 * bit. */
@@ -1108,9 +1109,10 @@ static int ocfs2_rename(struct inode *old_dir,
1108 if (S_ISDIR(old_inode->i_mode)) { 1109 if (S_ISDIR(old_inode->i_mode)) {
1109 u64 old_inode_parent; 1110 u64 old_inode_parent;
1110 1111
1112 update_dot_dot = 1;
1111 status = ocfs2_find_files_on_disk("..", 2, &old_inode_parent, 1113 status = ocfs2_find_files_on_disk("..", 2, &old_inode_parent,
1112 old_inode, &old_inode_de_bh, 1114 old_inode,
1113 &old_inode_dot_dot_de); 1115 &old_inode_dot_dot_res);
1114 if (status) { 1116 if (status) {
1115 status = -EIO; 1117 status = -EIO;
1116 goto bail; 1118 goto bail;
@@ -1151,8 +1153,8 @@ static int ocfs2_rename(struct inode *old_dir,
1151 * to delete it */ 1153 * to delete it */
1152 status = ocfs2_find_files_on_disk(new_dentry->d_name.name, 1154 status = ocfs2_find_files_on_disk(new_dentry->d_name.name,
1153 new_dentry->d_name.len, 1155 new_dentry->d_name.len,
1154 &newfe_blkno, new_dir, &new_de_bh, 1156 &newfe_blkno, new_dir,
1155 &new_de); 1157 &target_lookup_res);
1156 /* The only error we allow here is -ENOENT because the new 1158 /* The only error we allow here is -ENOENT because the new
1157 * file not existing is perfectly valid. */ 1159 * file not existing is perfectly valid. */
1158 if ((status < 0) && (status != -ENOENT)) { 1160 if ((status < 0) && (status != -ENOENT)) {
@@ -1161,8 +1163,10 @@ static int ocfs2_rename(struct inode *old_dir,
1161 mlog_errno(status); 1163 mlog_errno(status);
1162 goto bail; 1164 goto bail;
1163 } 1165 }
1166 if (status == 0)
1167 target_exists = 1;
1164 1168
1165 if (!new_de && new_inode) { 1169 if (!target_exists && new_inode) {
1166 /* 1170 /*
1167 * Target was unlinked by another node while we were 1171 * Target was unlinked by another node while we were
1168 * waiting to get to ocfs2_rename(). There isn't 1172 * waiting to get to ocfs2_rename(). There isn't
@@ -1175,7 +1179,7 @@ static int ocfs2_rename(struct inode *old_dir,
1175 1179
1176 /* In case we need to overwrite an existing file, we blow it 1180 /* In case we need to overwrite an existing file, we blow it
1177 * away first */ 1181 * away first */
1178 if (new_de) { 1182 if (target_exists) {
1179 /* VFS didn't think there existed an inode here, but 1183 /* VFS didn't think there existed an inode here, but
1180 * someone else in the cluster must have raced our 1184 * someone else in the cluster must have raced our
1181 * rename to create one. Today we error cleanly, in 1185 * rename to create one. Today we error cleanly, in
@@ -1216,8 +1220,8 @@ static int ocfs2_rename(struct inode *old_dir,
1216 1220
1217 newfe = (struct ocfs2_dinode *) newfe_bh->b_data; 1221 newfe = (struct ocfs2_dinode *) newfe_bh->b_data;
1218 1222
1219 mlog(0, "aha rename over existing... new_de=%p new_blkno=%llu " 1223 mlog(0, "aha rename over existing... new_blkno=%llu "
1220 "newfebh=%p bhblocknr=%llu\n", new_de, 1224 "newfebh=%p bhblocknr=%llu\n",
1221 (unsigned long long)newfe_blkno, newfe_bh, newfe_bh ? 1225 (unsigned long long)newfe_blkno, newfe_bh, newfe_bh ?
1222 (unsigned long long)newfe_bh->b_blocknr : 0ULL); 1226 (unsigned long long)newfe_bh->b_blocknr : 0ULL);
1223 1227
@@ -1225,7 +1229,7 @@ static int ocfs2_rename(struct inode *old_dir,
1225 status = ocfs2_prepare_orphan_dir(osb, &orphan_dir, 1229 status = ocfs2_prepare_orphan_dir(osb, &orphan_dir,
1226 new_inode, 1230 new_inode,
1227 orphan_name, 1231 orphan_name,
1228 &orphan_entry_bh); 1232 &orphan_insert);
1229 if (status < 0) { 1233 if (status < 0) {
1230 mlog_errno(status); 1234 mlog_errno(status);
1231 goto bail; 1235 goto bail;
@@ -1243,7 +1247,7 @@ static int ocfs2_rename(struct inode *old_dir,
1243 status = ocfs2_prepare_dir_for_insert(osb, new_dir, new_dir_bh, 1247 status = ocfs2_prepare_dir_for_insert(osb, new_dir, new_dir_bh,
1244 new_dentry->d_name.name, 1248 new_dentry->d_name.name,
1245 new_dentry->d_name.len, 1249 new_dentry->d_name.len,
1246 &insert_entry_bh); 1250 &target_insert);
1247 if (status < 0) { 1251 if (status < 0) {
1248 mlog_errno(status); 1252 mlog_errno(status);
1249 goto bail; 1253 goto bail;
@@ -1258,7 +1262,7 @@ static int ocfs2_rename(struct inode *old_dir,
1258 goto bail; 1262 goto bail;
1259 } 1263 }
1260 1264
1261 if (new_de) { 1265 if (target_exists) {
1262 if (S_ISDIR(new_inode->i_mode)) { 1266 if (S_ISDIR(new_inode->i_mode)) {
1263 if (!ocfs2_empty_dir(new_inode) || 1267 if (!ocfs2_empty_dir(new_inode) ||
1264 new_inode->i_nlink != 2) { 1268 new_inode->i_nlink != 2) {
@@ -1277,7 +1281,7 @@ static int ocfs2_rename(struct inode *old_dir,
1277 (newfe->i_links_count == cpu_to_le16(1))){ 1281 (newfe->i_links_count == cpu_to_le16(1))){
1278 status = ocfs2_orphan_add(osb, handle, new_inode, 1282 status = ocfs2_orphan_add(osb, handle, new_inode,
1279 newfe, orphan_name, 1283 newfe, orphan_name,
1280 orphan_entry_bh, orphan_dir); 1284 &orphan_insert, orphan_dir);
1281 if (status < 0) { 1285 if (status < 0) {
1282 mlog_errno(status); 1286 mlog_errno(status);
1283 goto bail; 1287 goto bail;
@@ -1285,8 +1289,8 @@ static int ocfs2_rename(struct inode *old_dir,
1285 } 1289 }
1286 1290
1287 /* change the dirent to point to the correct inode */ 1291 /* change the dirent to point to the correct inode */
1288 status = ocfs2_update_entry(new_dir, handle, new_de_bh, 1292 status = ocfs2_update_entry(new_dir, handle, &target_lookup_res,
1289 new_de, old_inode); 1293 old_inode);
1290 if (status < 0) { 1294 if (status < 0) {
1291 mlog_errno(status); 1295 mlog_errno(status);
1292 goto bail; 1296 goto bail;
@@ -1307,7 +1311,7 @@ static int ocfs2_rename(struct inode *old_dir,
1307 /* if the name was not found in new_dir, add it now */ 1311 /* if the name was not found in new_dir, add it now */
1308 status = ocfs2_add_entry(handle, new_dentry, old_inode, 1312 status = ocfs2_add_entry(handle, new_dentry, old_inode,
1309 OCFS2_I(old_inode)->ip_blkno, 1313 OCFS2_I(old_inode)->ip_blkno,
1310 new_dir_bh, insert_entry_bh); 1314 new_dir_bh, &target_insert);
1311 } 1315 }
1312 1316
1313 old_inode->i_ctime = CURRENT_TIME; 1317 old_inode->i_ctime = CURRENT_TIME;
@@ -1334,15 +1338,13 @@ static int ocfs2_rename(struct inode *old_dir,
1334 * because the insert might have changed the type of directory 1338 * because the insert might have changed the type of directory
1335 * we're dealing with. 1339 * we're dealing with.
1336 */ 1340 */
1337 old_de_bh = ocfs2_find_entry(old_dentry->d_name.name, 1341 status = ocfs2_find_entry(old_dentry->d_name.name,
1338 old_dentry->d_name.len, 1342 old_dentry->d_name.len, old_dir,
1339 old_dir, &old_de); 1343 &old_entry_lookup);
1340 if (!old_de_bh) { 1344 if (status)
1341 status = -EIO;
1342 goto bail; 1345 goto bail;
1343 }
1344 1346
1345 status = ocfs2_delete_entry(handle, old_dir, old_de, old_de_bh); 1347 status = ocfs2_delete_entry(handle, old_dir, &old_entry_lookup);
1346 if (status < 0) { 1348 if (status < 0) {
1347 mlog_errno(status); 1349 mlog_errno(status);
1348 goto bail; 1350 goto bail;
@@ -1353,9 +1355,10 @@ static int ocfs2_rename(struct inode *old_dir,
1353 new_inode->i_ctime = CURRENT_TIME; 1355 new_inode->i_ctime = CURRENT_TIME;
1354 } 1356 }
1355 old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME; 1357 old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME;
1356 if (old_inode_de_bh) { 1358
1357 status = ocfs2_update_entry(old_inode, handle, old_inode_de_bh, 1359 if (update_dot_dot) {
1358 old_inode_dot_dot_de, new_dir); 1360 status = ocfs2_update_entry(old_inode, handle,
1361 &old_inode_dot_dot_res, new_dir);
1359 old_dir->i_nlink--; 1362 old_dir->i_nlink--;
1360 if (new_inode) { 1363 if (new_inode) {
1361 new_inode->i_nlink--; 1364 new_inode->i_nlink--;
@@ -1429,13 +1432,17 @@ bail:
1429 1432
1430 if (new_inode) 1433 if (new_inode)
1431 iput(new_inode); 1434 iput(new_inode);
1435
1436 ocfs2_free_dir_lookup_result(&target_lookup_res);
1437 ocfs2_free_dir_lookup_result(&old_entry_lookup);
1438 ocfs2_free_dir_lookup_result(&old_inode_dot_dot_res);
1439 ocfs2_free_dir_lookup_result(&orphan_insert);
1440 ocfs2_free_dir_lookup_result(&target_insert);
1441
1432 brelse(newfe_bh); 1442 brelse(newfe_bh);
1433 brelse(old_inode_bh); 1443 brelse(old_inode_bh);
1434 brelse(old_dir_bh); 1444 brelse(old_dir_bh);
1435 brelse(new_dir_bh); 1445 brelse(new_dir_bh);
1436 brelse(new_de_bh);
1437 brelse(old_de_bh);
1438 brelse(old_inode_de_bh);
1439 brelse(orphan_entry_bh); 1446 brelse(orphan_entry_bh);
1440 brelse(insert_entry_bh); 1447 brelse(insert_entry_bh);
1441 1448
@@ -1558,7 +1565,6 @@ static int ocfs2_symlink(struct inode *dir,
1558 struct inode *inode = NULL; 1565 struct inode *inode = NULL;
1559 struct super_block *sb; 1566 struct super_block *sb;
1560 struct buffer_head *new_fe_bh = NULL; 1567 struct buffer_head *new_fe_bh = NULL;
1561 struct buffer_head *de_bh = NULL;
1562 struct buffer_head *parent_fe_bh = NULL; 1568 struct buffer_head *parent_fe_bh = NULL;
1563 struct ocfs2_dinode *fe = NULL; 1569 struct ocfs2_dinode *fe = NULL;
1564 struct ocfs2_dinode *dirfe; 1570 struct ocfs2_dinode *dirfe;
@@ -1572,6 +1578,7 @@ static int ocfs2_symlink(struct inode *dir,
1572 .enable = 1, 1578 .enable = 1,
1573 }; 1579 };
1574 int did_quota = 0, did_quota_inode = 0; 1580 int did_quota = 0, did_quota_inode = 0;
1581 struct ocfs2_dir_lookup_result lookup = { NULL, };
1575 1582
1576 mlog_entry("(0x%p, 0x%p, symname='%s' actual='%.*s')\n", dir, 1583 mlog_entry("(0x%p, 0x%p, symname='%s' actual='%.*s')\n", dir,
1577 dentry, symname, dentry->d_name.len, dentry->d_name.name); 1584 dentry, symname, dentry->d_name.len, dentry->d_name.name);
@@ -1605,7 +1612,7 @@ static int ocfs2_symlink(struct inode *dir,
1605 1612
1606 status = ocfs2_prepare_dir_for_insert(osb, dir, parent_fe_bh, 1613 status = ocfs2_prepare_dir_for_insert(osb, dir, parent_fe_bh,
1607 dentry->d_name.name, 1614 dentry->d_name.name,
1608 dentry->d_name.len, &de_bh); 1615 dentry->d_name.len, &lookup);
1609 if (status < 0) { 1616 if (status < 0) {
1610 mlog_errno(status); 1617 mlog_errno(status);
1611 goto bail; 1618 goto bail;
@@ -1744,7 +1751,7 @@ static int ocfs2_symlink(struct inode *dir,
1744 1751
1745 status = ocfs2_add_entry(handle, dentry, inode, 1752 status = ocfs2_add_entry(handle, dentry, inode,
1746 le64_to_cpu(fe->i_blkno), parent_fe_bh, 1753 le64_to_cpu(fe->i_blkno), parent_fe_bh,
1747 de_bh); 1754 &lookup);
1748 if (status < 0) { 1755 if (status < 0) {
1749 mlog_errno(status); 1756 mlog_errno(status);
1750 goto bail; 1757 goto bail;
@@ -1772,9 +1779,9 @@ bail:
1772 1779
1773 brelse(new_fe_bh); 1780 brelse(new_fe_bh);
1774 brelse(parent_fe_bh); 1781 brelse(parent_fe_bh);
1775 brelse(de_bh);
1776 kfree(si.name); 1782 kfree(si.name);
1777 kfree(si.value); 1783 kfree(si.value);
1784 ocfs2_free_dir_lookup_result(&lookup);
1778 if (inode_ac) 1785 if (inode_ac)
1779 ocfs2_free_alloc_context(inode_ac); 1786 ocfs2_free_alloc_context(inode_ac);
1780 if (data_ac) 1787 if (data_ac)
@@ -1826,7 +1833,7 @@ static int ocfs2_prepare_orphan_dir(struct ocfs2_super *osb,
1826 struct inode **ret_orphan_dir, 1833 struct inode **ret_orphan_dir,
1827 struct inode *inode, 1834 struct inode *inode,
1828 char *name, 1835 char *name,
1829 struct buffer_head **de_bh) 1836 struct ocfs2_dir_lookup_result *lookup)
1830{ 1837{
1831 struct inode *orphan_dir_inode; 1838 struct inode *orphan_dir_inode;
1832 struct buffer_head *orphan_dir_bh = NULL; 1839 struct buffer_head *orphan_dir_bh = NULL;
@@ -1857,7 +1864,7 @@ static int ocfs2_prepare_orphan_dir(struct ocfs2_super *osb,
1857 1864
1858 status = ocfs2_prepare_dir_for_insert(osb, orphan_dir_inode, 1865 status = ocfs2_prepare_dir_for_insert(osb, orphan_dir_inode,
1859 orphan_dir_bh, name, 1866 orphan_dir_bh, name,
1860 OCFS2_ORPHAN_NAMELEN, de_bh); 1867 OCFS2_ORPHAN_NAMELEN, lookup);
1861 if (status < 0) { 1868 if (status < 0) {
1862 ocfs2_inode_unlock(orphan_dir_inode, 1); 1869 ocfs2_inode_unlock(orphan_dir_inode, 1);
1863 1870
@@ -1884,7 +1891,7 @@ static int ocfs2_orphan_add(struct ocfs2_super *osb,
1884 struct inode *inode, 1891 struct inode *inode,
1885 struct ocfs2_dinode *fe, 1892 struct ocfs2_dinode *fe,
1886 char *name, 1893 char *name,
1887 struct buffer_head *de_bh, 1894 struct ocfs2_dir_lookup_result *lookup,
1888 struct inode *orphan_dir_inode) 1895 struct inode *orphan_dir_inode)
1889{ 1896{
1890 struct buffer_head *orphan_dir_bh = NULL; 1897 struct buffer_head *orphan_dir_bh = NULL;
@@ -1922,7 +1929,7 @@ static int ocfs2_orphan_add(struct ocfs2_super *osb,
1922 status = __ocfs2_add_entry(handle, orphan_dir_inode, name, 1929 status = __ocfs2_add_entry(handle, orphan_dir_inode, name,
1923 OCFS2_ORPHAN_NAMELEN, inode, 1930 OCFS2_ORPHAN_NAMELEN, inode,
1924 OCFS2_I(inode)->ip_blkno, 1931 OCFS2_I(inode)->ip_blkno,
1925 orphan_dir_bh, de_bh); 1932 orphan_dir_bh, lookup);
1926 if (status < 0) { 1933 if (status < 0) {
1927 mlog_errno(status); 1934 mlog_errno(status);
1928 goto leave; 1935 goto leave;
@@ -1955,8 +1962,7 @@ int ocfs2_orphan_del(struct ocfs2_super *osb,
1955 char name[OCFS2_ORPHAN_NAMELEN + 1]; 1962 char name[OCFS2_ORPHAN_NAMELEN + 1];
1956 struct ocfs2_dinode *orphan_fe; 1963 struct ocfs2_dinode *orphan_fe;
1957 int status = 0; 1964 int status = 0;
1958 struct buffer_head *target_de_bh = NULL; 1965 struct ocfs2_dir_lookup_result lookup = { NULL, };
1959 struct ocfs2_dir_entry *target_de = NULL;
1960 1966
1961 mlog_entry_void(); 1967 mlog_entry_void();
1962 1968
@@ -1971,17 +1977,15 @@ int ocfs2_orphan_del(struct ocfs2_super *osb,
1971 OCFS2_ORPHAN_NAMELEN); 1977 OCFS2_ORPHAN_NAMELEN);
1972 1978
1973 /* find it's spot in the orphan directory */ 1979 /* find it's spot in the orphan directory */
1974 target_de_bh = ocfs2_find_entry(name, OCFS2_ORPHAN_NAMELEN, 1980 status = ocfs2_find_entry(name, OCFS2_ORPHAN_NAMELEN, orphan_dir_inode,
1975 orphan_dir_inode, &target_de); 1981 &lookup);
1976 if (!target_de_bh) { 1982 if (status) {
1977 status = -ENOENT;
1978 mlog_errno(status); 1983 mlog_errno(status);
1979 goto leave; 1984 goto leave;
1980 } 1985 }
1981 1986
1982 /* remove it from the orphan directory */ 1987 /* remove it from the orphan directory */
1983 status = ocfs2_delete_entry(handle, orphan_dir_inode, target_de, 1988 status = ocfs2_delete_entry(handle, orphan_dir_inode, &lookup);
1984 target_de_bh);
1985 if (status < 0) { 1989 if (status < 0) {
1986 mlog_errno(status); 1990 mlog_errno(status);
1987 goto leave; 1991 goto leave;
@@ -2007,7 +2011,7 @@ int ocfs2_orphan_del(struct ocfs2_super *osb,
2007 } 2011 }
2008 2012
2009leave: 2013leave:
2010 brelse(target_de_bh); 2014 ocfs2_free_dir_lookup_result(&lookup);
2011 2015
2012 mlog_exit(status); 2016 mlog_exit(status);
2013 return status; 2017 return status;