diff options
Diffstat (limited to 'fs/ocfs2')
-rw-r--r-- | fs/ocfs2/dcache.c | 15 | ||||
-rw-r--r-- | fs/ocfs2/dir.c | 4 | ||||
-rw-r--r-- | fs/ocfs2/export.c | 9 | ||||
-rw-r--r-- | fs/ocfs2/journal.h | 5 | ||||
-rw-r--r-- | fs/ocfs2/namei.c | 4 | ||||
-rw-r--r-- | fs/ocfs2/suballoc.c | 21 | ||||
-rw-r--r-- | fs/ocfs2/symlink.c | 77 |
7 files changed, 75 insertions, 60 deletions
diff --git a/fs/ocfs2/dcache.c b/fs/ocfs2/dcache.c index 7d604480557a..b574431a031d 100644 --- a/fs/ocfs2/dcache.c +++ b/fs/ocfs2/dcache.c | |||
@@ -290,6 +290,21 @@ out_attach: | |||
290 | else | 290 | else |
291 | mlog_errno(ret); | 291 | mlog_errno(ret); |
292 | 292 | ||
293 | /* | ||
294 | * In case of error, manually free the allocation and do the iput(). | ||
295 | * We need to do this because error here means no d_instantiate(), | ||
296 | * which means iput() will not be called during dput(dentry). | ||
297 | */ | ||
298 | if (ret < 0 && !alias) { | ||
299 | ocfs2_lock_res_free(&dl->dl_lockres); | ||
300 | BUG_ON(dl->dl_count != 1); | ||
301 | spin_lock(&dentry_attach_lock); | ||
302 | dentry->d_fsdata = NULL; | ||
303 | spin_unlock(&dentry_attach_lock); | ||
304 | kfree(dl); | ||
305 | iput(inode); | ||
306 | } | ||
307 | |||
293 | dput(alias); | 308 | dput(alias); |
294 | 309 | ||
295 | return ret; | 310 | return ret; |
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c index e71160cda110..c5752305627c 100644 --- a/fs/ocfs2/dir.c +++ b/fs/ocfs2/dir.c | |||
@@ -2697,7 +2697,7 @@ static int ocfs2_dx_dir_index_block(struct inode *dir, | |||
2697 | u32 *num_dx_entries, | 2697 | u32 *num_dx_entries, |
2698 | struct buffer_head *dirent_bh) | 2698 | struct buffer_head *dirent_bh) |
2699 | { | 2699 | { |
2700 | int ret, namelen, i; | 2700 | int ret = 0, namelen, i; |
2701 | char *de_buf, *limit; | 2701 | char *de_buf, *limit; |
2702 | struct ocfs2_dir_entry *de; | 2702 | struct ocfs2_dir_entry *de; |
2703 | struct buffer_head *dx_leaf_bh; | 2703 | struct buffer_head *dx_leaf_bh; |
@@ -2934,7 +2934,7 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh, | |||
2934 | */ | 2934 | */ |
2935 | BUG_ON(alloc > 2); | 2935 | BUG_ON(alloc > 2); |
2936 | 2936 | ||
2937 | ret = ocfs2_reserve_clusters(osb, alloc, &data_ac); | 2937 | ret = ocfs2_reserve_clusters(osb, alloc + dx_alloc, &data_ac); |
2938 | if (ret) { | 2938 | if (ret) { |
2939 | mlog_errno(ret); | 2939 | mlog_errno(ret); |
2940 | goto out; | 2940 | goto out; |
diff --git a/fs/ocfs2/export.c b/fs/ocfs2/export.c index de3da8eb558c..15713cbb865c 100644 --- a/fs/ocfs2/export.c +++ b/fs/ocfs2/export.c | |||
@@ -100,7 +100,8 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb, | |||
100 | 100 | ||
101 | /* If the inode allocator bit is clear, this inode must be stale */ | 101 | /* If the inode allocator bit is clear, this inode must be stale */ |
102 | if (!set) { | 102 | if (!set) { |
103 | mlog(0, "inode %llu suballoc bit is clear\n", blkno); | 103 | mlog(0, "inode %llu suballoc bit is clear\n", |
104 | (unsigned long long)blkno); | ||
104 | status = -ESTALE; | 105 | status = -ESTALE; |
105 | goto unlock_nfs_sync; | 106 | goto unlock_nfs_sync; |
106 | } | 107 | } |
@@ -114,7 +115,7 @@ check_err: | |||
114 | if (status < 0) { | 115 | if (status < 0) { |
115 | if (status == -ESTALE) { | 116 | if (status == -ESTALE) { |
116 | mlog(0, "stale inode ino: %llu generation: %u\n", | 117 | mlog(0, "stale inode ino: %llu generation: %u\n", |
117 | blkno, handle->ih_generation); | 118 | (unsigned long long)blkno, handle->ih_generation); |
118 | } | 119 | } |
119 | result = ERR_PTR(status); | 120 | result = ERR_PTR(status); |
120 | goto bail; | 121 | goto bail; |
@@ -129,8 +130,8 @@ check_err: | |||
129 | check_gen: | 130 | check_gen: |
130 | if (handle->ih_generation != inode->i_generation) { | 131 | if (handle->ih_generation != inode->i_generation) { |
131 | iput(inode); | 132 | iput(inode); |
132 | mlog(0, "stale inode ino: %llu generation: %u\n", blkno, | 133 | mlog(0, "stale inode ino: %llu generation: %u\n", |
133 | handle->ih_generation); | 134 | (unsigned long long)blkno, handle->ih_generation); |
134 | result = ERR_PTR(-ESTALE); | 135 | result = ERR_PTR(-ESTALE); |
135 | goto bail; | 136 | goto bail; |
136 | } | 137 | } |
diff --git a/fs/ocfs2/journal.h b/fs/ocfs2/journal.h index 619dd7f6c053..eb7b76331eb7 100644 --- a/fs/ocfs2/journal.h +++ b/fs/ocfs2/journal.h | |||
@@ -437,8 +437,9 @@ static inline int ocfs2_unlink_credits(struct super_block *sb) | |||
437 | } | 437 | } |
438 | 438 | ||
439 | /* dinode + orphan dir dinode + inode alloc dinode + orphan dir entry + | 439 | /* dinode + orphan dir dinode + inode alloc dinode + orphan dir entry + |
440 | * inode alloc group descriptor + orphan dir index leaf */ | 440 | * inode alloc group descriptor + orphan dir index root + |
441 | #define OCFS2_DELETE_INODE_CREDITS (3 * OCFS2_INODE_UPDATE_CREDITS + 3) | 441 | * orphan dir index leaf */ |
442 | #define OCFS2_DELETE_INODE_CREDITS (3 * OCFS2_INODE_UPDATE_CREDITS + 4) | ||
442 | 443 | ||
443 | /* dinode update, old dir dinode update, new dir dinode update, old | 444 | /* dinode update, old dir dinode update, new dir dinode update, old |
444 | * dir dir entry, new dir dir entry, dir entry update for renaming | 445 | * dir dir entry, new dir dir entry, dir entry update for renaming |
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index 2220f93f668b..33464c6b60a2 100644 --- a/fs/ocfs2/namei.c +++ b/fs/ocfs2/namei.c | |||
@@ -1025,10 +1025,8 @@ static int ocfs2_rename(struct inode *old_dir, | |||
1025 | struct inode *orphan_dir = NULL; | 1025 | struct inode *orphan_dir = NULL; |
1026 | struct ocfs2_dinode *newfe = NULL; | 1026 | struct ocfs2_dinode *newfe = NULL; |
1027 | char orphan_name[OCFS2_ORPHAN_NAMELEN + 1]; | 1027 | char orphan_name[OCFS2_ORPHAN_NAMELEN + 1]; |
1028 | struct buffer_head *orphan_entry_bh = NULL; | ||
1029 | struct buffer_head *newfe_bh = NULL; | 1028 | struct buffer_head *newfe_bh = NULL; |
1030 | struct buffer_head *old_inode_bh = NULL; | 1029 | struct buffer_head *old_inode_bh = NULL; |
1031 | struct buffer_head *insert_entry_bh = NULL; | ||
1032 | struct ocfs2_super *osb = NULL; | 1030 | struct ocfs2_super *osb = NULL; |
1033 | u64 newfe_blkno, old_de_ino; | 1031 | u64 newfe_blkno, old_de_ino; |
1034 | handle_t *handle = NULL; | 1032 | handle_t *handle = NULL; |
@@ -1455,8 +1453,6 @@ bail: | |||
1455 | brelse(old_inode_bh); | 1453 | brelse(old_inode_bh); |
1456 | brelse(old_dir_bh); | 1454 | brelse(old_dir_bh); |
1457 | brelse(new_dir_bh); | 1455 | brelse(new_dir_bh); |
1458 | brelse(orphan_entry_bh); | ||
1459 | brelse(insert_entry_bh); | ||
1460 | 1456 | ||
1461 | mlog_exit(status); | 1457 | mlog_exit(status); |
1462 | 1458 | ||
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c index b4ca5911caaf..8439f6b324b9 100644 --- a/fs/ocfs2/suballoc.c +++ b/fs/ocfs2/suballoc.c | |||
@@ -2197,26 +2197,29 @@ static int ocfs2_get_suballoc_slot_bit(struct ocfs2_super *osb, u64 blkno, | |||
2197 | struct buffer_head *inode_bh = NULL; | 2197 | struct buffer_head *inode_bh = NULL; |
2198 | struct ocfs2_dinode *inode_fe; | 2198 | struct ocfs2_dinode *inode_fe; |
2199 | 2199 | ||
2200 | mlog_entry("blkno: %llu\n", blkno); | 2200 | mlog_entry("blkno: %llu\n", (unsigned long long)blkno); |
2201 | 2201 | ||
2202 | /* dirty read disk */ | 2202 | /* dirty read disk */ |
2203 | status = ocfs2_read_blocks_sync(osb, blkno, 1, &inode_bh); | 2203 | status = ocfs2_read_blocks_sync(osb, blkno, 1, &inode_bh); |
2204 | if (status < 0) { | 2204 | if (status < 0) { |
2205 | mlog(ML_ERROR, "read block %llu failed %d\n", blkno, status); | 2205 | mlog(ML_ERROR, "read block %llu failed %d\n", |
2206 | (unsigned long long)blkno, status); | ||
2206 | goto bail; | 2207 | goto bail; |
2207 | } | 2208 | } |
2208 | 2209 | ||
2209 | inode_fe = (struct ocfs2_dinode *) inode_bh->b_data; | 2210 | inode_fe = (struct ocfs2_dinode *) inode_bh->b_data; |
2210 | if (!OCFS2_IS_VALID_DINODE(inode_fe)) { | 2211 | if (!OCFS2_IS_VALID_DINODE(inode_fe)) { |
2211 | mlog(ML_ERROR, "invalid inode %llu requested\n", blkno); | 2212 | mlog(ML_ERROR, "invalid inode %llu requested\n", |
2213 | (unsigned long long)blkno); | ||
2212 | status = -EINVAL; | 2214 | status = -EINVAL; |
2213 | goto bail; | 2215 | goto bail; |
2214 | } | 2216 | } |
2215 | 2217 | ||
2216 | if (le16_to_cpu(inode_fe->i_suballoc_slot) != OCFS2_INVALID_SLOT && | 2218 | if (le16_to_cpu(inode_fe->i_suballoc_slot) != (u16)OCFS2_INVALID_SLOT && |
2217 | (u32)le16_to_cpu(inode_fe->i_suballoc_slot) > osb->max_slots - 1) { | 2219 | (u32)le16_to_cpu(inode_fe->i_suballoc_slot) > osb->max_slots - 1) { |
2218 | mlog(ML_ERROR, "inode %llu has invalid suballoc slot %u\n", | 2220 | mlog(ML_ERROR, "inode %llu has invalid suballoc slot %u\n", |
2219 | blkno, (u32)le16_to_cpu(inode_fe->i_suballoc_slot)); | 2221 | (unsigned long long)blkno, |
2222 | (u32)le16_to_cpu(inode_fe->i_suballoc_slot)); | ||
2220 | status = -EINVAL; | 2223 | status = -EINVAL; |
2221 | goto bail; | 2224 | goto bail; |
2222 | } | 2225 | } |
@@ -2251,7 +2254,8 @@ static int ocfs2_test_suballoc_bit(struct ocfs2_super *osb, | |||
2251 | u64 bg_blkno; | 2254 | u64 bg_blkno; |
2252 | int status; | 2255 | int status; |
2253 | 2256 | ||
2254 | mlog_entry("blkno: %llu bit: %u\n", blkno, (unsigned int)bit); | 2257 | mlog_entry("blkno: %llu bit: %u\n", (unsigned long long)blkno, |
2258 | (unsigned int)bit); | ||
2255 | 2259 | ||
2256 | alloc_fe = (struct ocfs2_dinode *)alloc_bh->b_data; | 2260 | alloc_fe = (struct ocfs2_dinode *)alloc_bh->b_data; |
2257 | if ((bit + 1) > ocfs2_bits_per_group(&alloc_fe->id2.i_chain)) { | 2261 | if ((bit + 1) > ocfs2_bits_per_group(&alloc_fe->id2.i_chain)) { |
@@ -2266,7 +2270,8 @@ static int ocfs2_test_suballoc_bit(struct ocfs2_super *osb, | |||
2266 | status = ocfs2_read_group_descriptor(suballoc, alloc_fe, bg_blkno, | 2270 | status = ocfs2_read_group_descriptor(suballoc, alloc_fe, bg_blkno, |
2267 | &group_bh); | 2271 | &group_bh); |
2268 | if (status < 0) { | 2272 | if (status < 0) { |
2269 | mlog(ML_ERROR, "read group %llu failed %d\n", bg_blkno, status); | 2273 | mlog(ML_ERROR, "read group %llu failed %d\n", |
2274 | (unsigned long long)bg_blkno, status); | ||
2270 | goto bail; | 2275 | goto bail; |
2271 | } | 2276 | } |
2272 | 2277 | ||
@@ -2300,7 +2305,7 @@ int ocfs2_test_inode_bit(struct ocfs2_super *osb, u64 blkno, int *res) | |||
2300 | struct inode *inode_alloc_inode; | 2305 | struct inode *inode_alloc_inode; |
2301 | struct buffer_head *alloc_bh = NULL; | 2306 | struct buffer_head *alloc_bh = NULL; |
2302 | 2307 | ||
2303 | mlog_entry("blkno: %llu", blkno); | 2308 | mlog_entry("blkno: %llu", (unsigned long long)blkno); |
2304 | 2309 | ||
2305 | status = ocfs2_get_suballoc_slot_bit(osb, blkno, &suballoc_slot, | 2310 | status = ocfs2_get_suballoc_slot_bit(osb, blkno, &suballoc_slot, |
2306 | &suballoc_bit); | 2311 | &suballoc_bit); |
diff --git a/fs/ocfs2/symlink.c b/fs/ocfs2/symlink.c index ed0a0cfd68d2..579dd1b1110f 100644 --- a/fs/ocfs2/symlink.c +++ b/fs/ocfs2/symlink.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <linux/slab.h> | 39 | #include <linux/slab.h> |
40 | #include <linux/pagemap.h> | 40 | #include <linux/pagemap.h> |
41 | #include <linux/utsname.h> | 41 | #include <linux/utsname.h> |
42 | #include <linux/namei.h> | ||
42 | 43 | ||
43 | #define MLOG_MASK_PREFIX ML_NAMEI | 44 | #define MLOG_MASK_PREFIX ML_NAMEI |
44 | #include <cluster/masklog.h> | 45 | #include <cluster/masklog.h> |
@@ -54,26 +55,6 @@ | |||
54 | 55 | ||
55 | #include "buffer_head_io.h" | 56 | #include "buffer_head_io.h" |
56 | 57 | ||
57 | static char *ocfs2_page_getlink(struct dentry * dentry, | ||
58 | struct page **ppage); | ||
59 | static char *ocfs2_fast_symlink_getlink(struct inode *inode, | ||
60 | struct buffer_head **bh); | ||
61 | |||
62 | /* get the link contents into pagecache */ | ||
63 | static char *ocfs2_page_getlink(struct dentry * dentry, | ||
64 | struct page **ppage) | ||
65 | { | ||
66 | struct page * page; | ||
67 | struct address_space *mapping = dentry->d_inode->i_mapping; | ||
68 | page = read_mapping_page(mapping, 0, NULL); | ||
69 | if (IS_ERR(page)) | ||
70 | goto sync_fail; | ||
71 | *ppage = page; | ||
72 | return kmap(page); | ||
73 | |||
74 | sync_fail: | ||
75 | return (char*)page; | ||
76 | } | ||
77 | 58 | ||
78 | static char *ocfs2_fast_symlink_getlink(struct inode *inode, | 59 | static char *ocfs2_fast_symlink_getlink(struct inode *inode, |
79 | struct buffer_head **bh) | 60 | struct buffer_head **bh) |
@@ -128,40 +109,55 @@ out: | |||
128 | return ret; | 109 | return ret; |
129 | } | 110 | } |
130 | 111 | ||
131 | static void *ocfs2_follow_link(struct dentry *dentry, | 112 | static void *ocfs2_fast_follow_link(struct dentry *dentry, |
132 | struct nameidata *nd) | 113 | struct nameidata *nd) |
133 | { | 114 | { |
134 | int status; | 115 | int status = 0; |
135 | char *link; | 116 | int len; |
117 | char *target, *link = ERR_PTR(-ENOMEM); | ||
136 | struct inode *inode = dentry->d_inode; | 118 | struct inode *inode = dentry->d_inode; |
137 | struct page *page = NULL; | ||
138 | struct buffer_head *bh = NULL; | 119 | struct buffer_head *bh = NULL; |
139 | 120 | ||
140 | if (ocfs2_inode_is_fast_symlink(inode)) | 121 | mlog_entry_void(); |
141 | link = ocfs2_fast_symlink_getlink(inode, &bh); | 122 | |
142 | else | 123 | BUG_ON(!ocfs2_inode_is_fast_symlink(inode)); |
143 | link = ocfs2_page_getlink(dentry, &page); | 124 | target = ocfs2_fast_symlink_getlink(inode, &bh); |
144 | if (IS_ERR(link)) { | 125 | if (IS_ERR(target)) { |
145 | status = PTR_ERR(link); | 126 | status = PTR_ERR(target); |
146 | mlog_errno(status); | 127 | mlog_errno(status); |
147 | goto bail; | 128 | goto bail; |
148 | } | 129 | } |
149 | 130 | ||
150 | status = vfs_follow_link(nd, link); | 131 | /* Fast symlinks can't be large */ |
132 | len = strlen(target); | ||
133 | link = kzalloc(len + 1, GFP_NOFS); | ||
134 | if (!link) { | ||
135 | status = -ENOMEM; | ||
136 | mlog_errno(status); | ||
137 | goto bail; | ||
138 | } | ||
139 | |||
140 | memcpy(link, target, len); | ||
141 | nd_set_link(nd, link); | ||
151 | 142 | ||
152 | bail: | 143 | bail: |
153 | if (page) { | ||
154 | kunmap(page); | ||
155 | page_cache_release(page); | ||
156 | } | ||
157 | brelse(bh); | 144 | brelse(bh); |
158 | 145 | ||
159 | return ERR_PTR(status); | 146 | mlog_exit(status); |
147 | return status ? ERR_PTR(status) : link; | ||
148 | } | ||
149 | |||
150 | static void ocfs2_fast_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie) | ||
151 | { | ||
152 | char *link = cookie; | ||
153 | |||
154 | kfree(link); | ||
160 | } | 155 | } |
161 | 156 | ||
162 | const struct inode_operations ocfs2_symlink_inode_operations = { | 157 | const struct inode_operations ocfs2_symlink_inode_operations = { |
163 | .readlink = page_readlink, | 158 | .readlink = page_readlink, |
164 | .follow_link = ocfs2_follow_link, | 159 | .follow_link = page_follow_link_light, |
160 | .put_link = page_put_link, | ||
165 | .getattr = ocfs2_getattr, | 161 | .getattr = ocfs2_getattr, |
166 | .setattr = ocfs2_setattr, | 162 | .setattr = ocfs2_setattr, |
167 | .setxattr = generic_setxattr, | 163 | .setxattr = generic_setxattr, |
@@ -171,7 +167,8 @@ const struct inode_operations ocfs2_symlink_inode_operations = { | |||
171 | }; | 167 | }; |
172 | const struct inode_operations ocfs2_fast_symlink_inode_operations = { | 168 | const struct inode_operations ocfs2_fast_symlink_inode_operations = { |
173 | .readlink = ocfs2_readlink, | 169 | .readlink = ocfs2_readlink, |
174 | .follow_link = ocfs2_follow_link, | 170 | .follow_link = ocfs2_fast_follow_link, |
171 | .put_link = ocfs2_fast_put_link, | ||
175 | .getattr = ocfs2_getattr, | 172 | .getattr = ocfs2_getattr, |
176 | .setattr = ocfs2_setattr, | 173 | .setattr = ocfs2_setattr, |
177 | .setxattr = generic_setxattr, | 174 | .setxattr = generic_setxattr, |