diff options
-rw-r--r-- | fs/ocfs2/dir.c | 99 | ||||
-rw-r--r-- | fs/ocfs2/dir.h | 30 | ||||
-rw-r--r-- | fs/ocfs2/namei.c | 150 |
3 files changed, 148 insertions, 131 deletions
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c index f2c4098cf337..76ffb5c10b3e 100644 --- a/fs/ocfs2/dir.c +++ b/fs/ocfs2/dir.c | |||
@@ -152,6 +152,11 @@ static void ocfs2_init_dir_trailer(struct inode *inode, | |||
152 | trailer->db_blkno = cpu_to_le64(bh->b_blocknr); | 152 | trailer->db_blkno = cpu_to_le64(bh->b_blocknr); |
153 | } | 153 | } |
154 | 154 | ||
155 | void ocfs2_free_dir_lookup_result(struct ocfs2_dir_lookup_result *res) | ||
156 | { | ||
157 | brelse(res->dl_leaf_bh); | ||
158 | } | ||
159 | |||
155 | /* | 160 | /* |
156 | * bh passed here can be an inode block or a dir data block, depending | 161 | * bh passed here can be an inode block or a dir data block, depending |
157 | * on the inode inline data flag. | 162 | * on the inode inline data flag. |
@@ -483,36 +488,46 @@ cleanup_and_exit: | |||
483 | /* | 488 | /* |
484 | * Try to find an entry of the provided name within 'dir'. | 489 | * Try to find an entry of the provided name within 'dir'. |
485 | * | 490 | * |
486 | * If nothing was found, NULL is returned. Otherwise, a buffer_head | 491 | * If nothing was found, -ENOENT is returned. Otherwise, zero is |
487 | * and pointer to the dir entry are passed back. | 492 | * returned and the struct 'res' will contain information useful to |
493 | * other directory manipulation functions. | ||
488 | * | 494 | * |
489 | * Caller can NOT assume anything about the contents of the | 495 | * Caller can NOT assume anything about the contents of the |
490 | * buffer_head - it is passed back only so that it can be passed into | 496 | * buffer_heads - they are passed back only so that it can be passed into |
491 | * any one of the manipulation functions (add entry, delete entry, | 497 | * any one of the manipulation functions (add entry, delete entry, |
492 | * etc). As an example, bh in the extent directory case is a data | 498 | * etc). As an example, bh in the extent directory case is a data |
493 | * block, in the inline-data case it actually points to an inode. | 499 | * block, in the inline-data case it actually points to an inode. |
494 | */ | 500 | */ |
495 | struct buffer_head *ocfs2_find_entry(const char *name, int namelen, | 501 | int ocfs2_find_entry(const char *name, int namelen, |
496 | struct inode *dir, | 502 | struct inode *dir, struct ocfs2_dir_lookup_result *lookup) |
497 | struct ocfs2_dir_entry **res_dir) | ||
498 | { | 503 | { |
499 | *res_dir = NULL; | 504 | struct buffer_head *bh; |
505 | struct ocfs2_dir_entry *res_dir = NULL; | ||
500 | 506 | ||
501 | if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL) | 507 | if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL) |
502 | return ocfs2_find_entry_id(name, namelen, dir, res_dir); | 508 | bh = ocfs2_find_entry_id(name, namelen, dir, &res_dir); |
509 | else | ||
510 | bh = ocfs2_find_entry_el(name, namelen, dir, &res_dir); | ||
503 | 511 | ||
504 | return ocfs2_find_entry_el(name, namelen, dir, res_dir); | 512 | if (bh == NULL) |
513 | return -ENOENT; | ||
514 | |||
515 | lookup->dl_leaf_bh = bh; | ||
516 | lookup->dl_entry = res_dir; | ||
517 | return 0; | ||
505 | } | 518 | } |
506 | 519 | ||
507 | /* | 520 | /* |
508 | * Update inode number and type of a previously found directory entry. | 521 | * Update inode number and type of a previously found directory entry. |
509 | */ | 522 | */ |
510 | int ocfs2_update_entry(struct inode *dir, handle_t *handle, | 523 | int ocfs2_update_entry(struct inode *dir, handle_t *handle, |
511 | struct buffer_head *de_bh, struct ocfs2_dir_entry *de, | 524 | struct ocfs2_dir_lookup_result *res, |
512 | struct inode *new_entry_inode) | 525 | struct inode *new_entry_inode) |
513 | { | 526 | { |
514 | int ret; | 527 | int ret; |
515 | ocfs2_journal_access_func access = ocfs2_journal_access_db; | 528 | ocfs2_journal_access_func access = ocfs2_journal_access_db; |
529 | struct ocfs2_dir_entry *de = res->dl_entry; | ||
530 | struct buffer_head *de_bh = res->dl_leaf_bh; | ||
516 | 531 | ||
517 | /* | 532 | /* |
518 | * The same code works fine for both inline-data and extent | 533 | * The same code works fine for both inline-data and extent |
@@ -629,13 +644,14 @@ static inline int ocfs2_delete_entry_el(handle_t *handle, | |||
629 | */ | 644 | */ |
630 | int ocfs2_delete_entry(handle_t *handle, | 645 | int ocfs2_delete_entry(handle_t *handle, |
631 | struct inode *dir, | 646 | struct inode *dir, |
632 | struct ocfs2_dir_entry *de_del, | 647 | struct ocfs2_dir_lookup_result *res) |
633 | struct buffer_head *bh) | ||
634 | { | 648 | { |
635 | if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL) | 649 | if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL) |
636 | return ocfs2_delete_entry_id(handle, dir, de_del, bh); | 650 | return ocfs2_delete_entry_id(handle, dir, res->dl_entry, |
651 | res->dl_leaf_bh); | ||
637 | 652 | ||
638 | return ocfs2_delete_entry_el(handle, dir, de_del, bh); | 653 | return ocfs2_delete_entry_el(handle, dir, res->dl_entry, |
654 | res->dl_leaf_bh); | ||
639 | } | 655 | } |
640 | 656 | ||
641 | /* | 657 | /* |
@@ -666,15 +682,15 @@ static inline int ocfs2_dirent_would_fit(struct ocfs2_dir_entry *de, | |||
666 | /* we don't always have a dentry for what we want to add, so people | 682 | /* we don't always have a dentry for what we want to add, so people |
667 | * like orphan dir can call this instead. | 683 | * like orphan dir can call this instead. |
668 | * | 684 | * |
669 | * If you pass me insert_bh, I'll skip the search of the other dir | 685 | * The lookup context must have been filled from |
670 | * blocks and put the record in there. | 686 | * ocfs2_prepare_dir_for_insert. |
671 | */ | 687 | */ |
672 | int __ocfs2_add_entry(handle_t *handle, | 688 | int __ocfs2_add_entry(handle_t *handle, |
673 | struct inode *dir, | 689 | struct inode *dir, |
674 | const char *name, int namelen, | 690 | const char *name, int namelen, |
675 | struct inode *inode, u64 blkno, | 691 | struct inode *inode, u64 blkno, |
676 | struct buffer_head *parent_fe_bh, | 692 | struct buffer_head *parent_fe_bh, |
677 | struct buffer_head *insert_bh) | 693 | struct ocfs2_dir_lookup_result *lookup) |
678 | { | 694 | { |
679 | unsigned long offset; | 695 | unsigned long offset; |
680 | unsigned short rec_len; | 696 | unsigned short rec_len; |
@@ -683,6 +699,7 @@ int __ocfs2_add_entry(handle_t *handle, | |||
683 | struct super_block *sb = dir->i_sb; | 699 | struct super_block *sb = dir->i_sb; |
684 | int retval, status; | 700 | int retval, status; |
685 | unsigned int size = sb->s_blocksize; | 701 | unsigned int size = sb->s_blocksize; |
702 | struct buffer_head *insert_bh = lookup->dl_leaf_bh; | ||
686 | char *data_start = insert_bh->b_data; | 703 | char *data_start = insert_bh->b_data; |
687 | 704 | ||
688 | mlog_entry_void(); | 705 | mlog_entry_void(); |
@@ -1071,31 +1088,22 @@ int ocfs2_find_files_on_disk(const char *name, | |||
1071 | int namelen, | 1088 | int namelen, |
1072 | u64 *blkno, | 1089 | u64 *blkno, |
1073 | struct inode *inode, | 1090 | struct inode *inode, |
1074 | struct buffer_head **dirent_bh, | 1091 | struct ocfs2_dir_lookup_result *lookup) |
1075 | struct ocfs2_dir_entry **dirent) | ||
1076 | { | 1092 | { |
1077 | int status = -ENOENT; | 1093 | int status = -ENOENT; |
1078 | 1094 | ||
1079 | mlog_entry("(name=%.*s, blkno=%p, inode=%p, dirent_bh=%p, dirent=%p)\n", | 1095 | mlog(0, "name=%.*s, blkno=%p, inode=%llu\n", namelen, name, blkno, |
1080 | namelen, name, blkno, inode, dirent_bh, dirent); | 1096 | (unsigned long long)OCFS2_I(inode)->ip_blkno); |
1081 | 1097 | ||
1082 | *dirent_bh = ocfs2_find_entry(name, namelen, inode, dirent); | 1098 | status = ocfs2_find_entry(name, namelen, inode, lookup); |
1083 | if (!*dirent_bh || !*dirent) { | 1099 | if (status) |
1084 | status = -ENOENT; | ||
1085 | goto leave; | 1100 | goto leave; |
1086 | } | ||
1087 | 1101 | ||
1088 | *blkno = le64_to_cpu((*dirent)->inode); | 1102 | *blkno = le64_to_cpu(lookup->dl_entry->inode); |
1089 | 1103 | ||
1090 | status = 0; | 1104 | status = 0; |
1091 | leave: | 1105 | leave: |
1092 | if (status < 0) { | ||
1093 | *dirent = NULL; | ||
1094 | brelse(*dirent_bh); | ||
1095 | *dirent_bh = NULL; | ||
1096 | } | ||
1097 | 1106 | ||
1098 | mlog_exit(status); | ||
1099 | return status; | 1107 | return status; |
1100 | } | 1108 | } |
1101 | 1109 | ||
@@ -1107,11 +1115,10 @@ int ocfs2_lookup_ino_from_name(struct inode *dir, const char *name, | |||
1107 | int namelen, u64 *blkno) | 1115 | int namelen, u64 *blkno) |
1108 | { | 1116 | { |
1109 | int ret; | 1117 | int ret; |
1110 | struct buffer_head *bh = NULL; | 1118 | struct ocfs2_dir_lookup_result lookup = { NULL, }; |
1111 | struct ocfs2_dir_entry *dirent = NULL; | ||
1112 | 1119 | ||
1113 | ret = ocfs2_find_files_on_disk(name, namelen, blkno, dir, &bh, &dirent); | 1120 | ret = ocfs2_find_files_on_disk(name, namelen, blkno, dir, &lookup); |
1114 | brelse(bh); | 1121 | ocfs2_free_dir_lookup_result(&lookup); |
1115 | 1122 | ||
1116 | return ret; | 1123 | return ret; |
1117 | } | 1124 | } |
@@ -1128,20 +1135,18 @@ int ocfs2_check_dir_for_entry(struct inode *dir, | |||
1128 | int namelen) | 1135 | int namelen) |
1129 | { | 1136 | { |
1130 | int ret; | 1137 | int ret; |
1131 | struct buffer_head *dirent_bh = NULL; | 1138 | struct ocfs2_dir_lookup_result lookup = { NULL, }; |
1132 | struct ocfs2_dir_entry *dirent = NULL; | ||
1133 | 1139 | ||
1134 | mlog_entry("dir %llu, name '%.*s'\n", | 1140 | mlog_entry("dir %llu, name '%.*s'\n", |
1135 | (unsigned long long)OCFS2_I(dir)->ip_blkno, namelen, name); | 1141 | (unsigned long long)OCFS2_I(dir)->ip_blkno, namelen, name); |
1136 | 1142 | ||
1137 | ret = -EEXIST; | 1143 | ret = -EEXIST; |
1138 | dirent_bh = ocfs2_find_entry(name, namelen, dir, &dirent); | 1144 | if (ocfs2_find_entry(name, namelen, dir, &lookup) == 0) |
1139 | if (dirent_bh) | ||
1140 | goto bail; | 1145 | goto bail; |
1141 | 1146 | ||
1142 | ret = 0; | 1147 | ret = 0; |
1143 | bail: | 1148 | bail: |
1144 | brelse(dirent_bh); | 1149 | ocfs2_free_dir_lookup_result(&lookup); |
1145 | 1150 | ||
1146 | mlog_exit(ret); | 1151 | mlog_exit(ret); |
1147 | return ret; | 1152 | return ret; |
@@ -1970,12 +1975,18 @@ bail: | |||
1970 | return status; | 1975 | return status; |
1971 | } | 1976 | } |
1972 | 1977 | ||
1978 | /* | ||
1979 | * Get a directory ready for insert. Any directory allocation required | ||
1980 | * happens here. Success returns zero, and enough context in the dir | ||
1981 | * lookup result that ocfs2_add_entry() will be able complete the task | ||
1982 | * with minimal performance impact. | ||
1983 | */ | ||
1973 | int ocfs2_prepare_dir_for_insert(struct ocfs2_super *osb, | 1984 | int ocfs2_prepare_dir_for_insert(struct ocfs2_super *osb, |
1974 | struct inode *dir, | 1985 | struct inode *dir, |
1975 | struct buffer_head *parent_fe_bh, | 1986 | struct buffer_head *parent_fe_bh, |
1976 | const char *name, | 1987 | const char *name, |
1977 | int namelen, | 1988 | int namelen, |
1978 | struct buffer_head **ret_de_bh) | 1989 | struct ocfs2_dir_lookup_result *lookup) |
1979 | { | 1990 | { |
1980 | int ret; | 1991 | int ret; |
1981 | unsigned int blocks_wanted = 1; | 1992 | unsigned int blocks_wanted = 1; |
@@ -1984,8 +1995,6 @@ int ocfs2_prepare_dir_for_insert(struct ocfs2_super *osb, | |||
1984 | mlog(0, "getting ready to insert namelen %d into dir %llu\n", | 1995 | mlog(0, "getting ready to insert namelen %d into dir %llu\n", |
1985 | namelen, (unsigned long long)OCFS2_I(dir)->ip_blkno); | 1996 | namelen, (unsigned long long)OCFS2_I(dir)->ip_blkno); |
1986 | 1997 | ||
1987 | *ret_de_bh = NULL; | ||
1988 | |||
1989 | if (!namelen) { | 1998 | if (!namelen) { |
1990 | ret = -EINVAL; | 1999 | ret = -EINVAL; |
1991 | mlog_errno(ret); | 2000 | mlog_errno(ret); |
@@ -2020,7 +2029,7 @@ int ocfs2_prepare_dir_for_insert(struct ocfs2_super *osb, | |||
2020 | BUG_ON(!bh); | 2029 | BUG_ON(!bh); |
2021 | } | 2030 | } |
2022 | 2031 | ||
2023 | *ret_de_bh = bh; | 2032 | lookup->dl_leaf_bh = bh; |
2024 | bh = NULL; | 2033 | bh = NULL; |
2025 | out: | 2034 | out: |
2026 | brelse(bh); | 2035 | brelse(bh); |
diff --git a/fs/ocfs2/dir.h b/fs/ocfs2/dir.h index c511e2e18e9f..505d3af9bba5 100644 --- a/fs/ocfs2/dir.h +++ b/fs/ocfs2/dir.h | |||
@@ -26,44 +26,48 @@ | |||
26 | #ifndef OCFS2_DIR_H | 26 | #ifndef OCFS2_DIR_H |
27 | #define OCFS2_DIR_H | 27 | #define OCFS2_DIR_H |
28 | 28 | ||
29 | struct buffer_head *ocfs2_find_entry(const char *name, | 29 | struct ocfs2_dir_lookup_result { |
30 | int namelen, | 30 | struct buffer_head *dl_leaf_bh; |
31 | struct inode *dir, | 31 | struct ocfs2_dir_entry *dl_entry; |
32 | struct ocfs2_dir_entry **res_dir); | 32 | }; |
33 | void ocfs2_free_dir_lookup_result(struct ocfs2_dir_lookup_result *res); | ||
34 | |||
35 | int ocfs2_find_entry(const char *name, int namelen, | ||
36 | struct inode *dir, | ||
37 | struct ocfs2_dir_lookup_result *lookup); | ||
33 | int ocfs2_delete_entry(handle_t *handle, | 38 | int ocfs2_delete_entry(handle_t *handle, |
34 | struct inode *dir, | 39 | struct inode *dir, |
35 | struct ocfs2_dir_entry *de_del, | 40 | struct ocfs2_dir_lookup_result *res); |
36 | struct buffer_head *bh); | ||
37 | int __ocfs2_add_entry(handle_t *handle, | 41 | int __ocfs2_add_entry(handle_t *handle, |
38 | struct inode *dir, | 42 | struct inode *dir, |
39 | const char *name, int namelen, | 43 | const char *name, int namelen, |
40 | struct inode *inode, u64 blkno, | 44 | struct inode *inode, u64 blkno, |
41 | struct buffer_head *parent_fe_bh, | 45 | struct buffer_head *parent_fe_bh, |
42 | struct buffer_head *insert_bh); | 46 | struct ocfs2_dir_lookup_result *lookup); |
43 | static inline int ocfs2_add_entry(handle_t *handle, | 47 | static inline int ocfs2_add_entry(handle_t *handle, |
44 | struct dentry *dentry, | 48 | struct dentry *dentry, |
45 | struct inode *inode, u64 blkno, | 49 | struct inode *inode, u64 blkno, |
46 | struct buffer_head *parent_fe_bh, | 50 | struct buffer_head *parent_fe_bh, |
47 | struct buffer_head *insert_bh) | 51 | struct ocfs2_dir_lookup_result *lookup) |
48 | { | 52 | { |
49 | return __ocfs2_add_entry(handle, dentry->d_parent->d_inode, | 53 | return __ocfs2_add_entry(handle, dentry->d_parent->d_inode, |
50 | dentry->d_name.name, dentry->d_name.len, | 54 | dentry->d_name.name, dentry->d_name.len, |
51 | inode, blkno, parent_fe_bh, insert_bh); | 55 | inode, blkno, parent_fe_bh, lookup); |
52 | } | 56 | } |
53 | int ocfs2_update_entry(struct inode *dir, handle_t *handle, | 57 | int ocfs2_update_entry(struct inode *dir, handle_t *handle, |
54 | struct buffer_head *de_bh, struct ocfs2_dir_entry *de, | 58 | struct ocfs2_dir_lookup_result *res, |
55 | struct inode *new_entry_inode); | 59 | struct inode *new_entry_inode); |
56 | 60 | ||
57 | int ocfs2_check_dir_for_entry(struct inode *dir, | 61 | int ocfs2_check_dir_for_entry(struct inode *dir, |
58 | const char *name, | 62 | const char *name, |
59 | int namelen); | 63 | int namelen); |
60 | int ocfs2_empty_dir(struct inode *inode); | 64 | int ocfs2_empty_dir(struct inode *inode); |
65 | |||
61 | int ocfs2_find_files_on_disk(const char *name, | 66 | int ocfs2_find_files_on_disk(const char *name, |
62 | int namelen, | 67 | int namelen, |
63 | u64 *blkno, | 68 | u64 *blkno, |
64 | struct inode *inode, | 69 | struct inode *inode, |
65 | struct buffer_head **dirent_bh, | 70 | struct ocfs2_dir_lookup_result *res); |
66 | struct ocfs2_dir_entry **dirent); | ||
67 | int ocfs2_lookup_ino_from_name(struct inode *dir, const char *name, | 71 | int ocfs2_lookup_ino_from_name(struct inode *dir, const char *name, |
68 | int namelen, u64 *blkno); | 72 | int namelen, u64 *blkno); |
69 | int ocfs2_readdir(struct file *filp, void *dirent, filldir_t filldir); | 73 | int ocfs2_readdir(struct file *filp, void *dirent, filldir_t filldir); |
@@ -74,7 +78,7 @@ int ocfs2_prepare_dir_for_insert(struct ocfs2_super *osb, | |||
74 | struct buffer_head *parent_fe_bh, | 78 | struct buffer_head *parent_fe_bh, |
75 | const char *name, | 79 | const char *name, |
76 | int namelen, | 80 | int namelen, |
77 | struct buffer_head **ret_de_bh); | 81 | struct ocfs2_dir_lookup_result *lookup); |
78 | struct ocfs2_alloc_context; | 82 | struct ocfs2_alloc_context; |
79 | int ocfs2_fill_new_dir(struct ocfs2_super *osb, | 83 | int ocfs2_fill_new_dir(struct ocfs2_super *osb, |
80 | handle_t *handle, | 84 | handle_t *handle, |
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 | ||
85 | static int ocfs2_orphan_add(struct ocfs2_super *osb, | 85 | static 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 | ||
93 | static int ocfs2_create_symlink_data(struct ocfs2_super *osb, | 93 | static 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: | |||
714 | out: | 715 | out: |
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 | ||
2009 | leave: | 2013 | leave: |
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; |