diff options
Diffstat (limited to 'fs/ocfs2/dcache.c')
-rw-r--r-- | fs/ocfs2/dcache.c | 39 |
1 files changed, 9 insertions, 30 deletions
diff --git a/fs/ocfs2/dcache.c b/fs/ocfs2/dcache.c index 18a31906316e..014e73978dac 100644 --- a/fs/ocfs2/dcache.c +++ b/fs/ocfs2/dcache.c | |||
@@ -183,9 +183,6 @@ DEFINE_SPINLOCK(dentry_attach_lock); | |||
183 | * The dir cluster lock (held at either PR or EX mode) protects us | 183 | * The dir cluster lock (held at either PR or EX mode) protects us |
184 | * from unlink and rename on other nodes. | 184 | * from unlink and rename on other nodes. |
185 | * | 185 | * |
186 | * The 'create' flag tells us whether we're doing this as a result of | ||
187 | * a file creation. | ||
188 | * | ||
189 | * A dput() can happen asynchronously due to pruning, so we cover | 186 | * A dput() can happen asynchronously due to pruning, so we cover |
190 | * attaching and detaching the dentry lock with a | 187 | * attaching and detaching the dentry lock with a |
191 | * dentry_attach_lock. | 188 | * dentry_attach_lock. |
@@ -199,16 +196,15 @@ DEFINE_SPINLOCK(dentry_attach_lock); | |||
199 | */ | 196 | */ |
200 | int ocfs2_dentry_attach_lock(struct dentry *dentry, | 197 | int ocfs2_dentry_attach_lock(struct dentry *dentry, |
201 | struct inode *inode, | 198 | struct inode *inode, |
202 | u64 parent_blkno, | 199 | u64 parent_blkno) |
203 | int create) | ||
204 | { | 200 | { |
205 | int ret; | 201 | int ret; |
206 | struct dentry *alias; | 202 | struct dentry *alias; |
207 | struct ocfs2_dentry_lock *dl = dentry->d_fsdata; | 203 | struct ocfs2_dentry_lock *dl = dentry->d_fsdata; |
208 | 204 | ||
209 | mlog(0, "Attach \"%.*s\", parent %llu, create %d, fsdata: %p\n", | 205 | mlog(0, "Attach \"%.*s\", parent %llu, fsdata: %p\n", |
210 | dentry->d_name.len, dentry->d_name.name, | 206 | dentry->d_name.len, dentry->d_name.name, |
211 | (unsigned long long)parent_blkno, create, dl); | 207 | (unsigned long long)parent_blkno, dl); |
212 | 208 | ||
213 | /* | 209 | /* |
214 | * Negative dentry. We ignore these for now. | 210 | * Negative dentry. We ignore these for now. |
@@ -242,10 +238,9 @@ int ocfs2_dentry_attach_lock(struct dentry *dentry, | |||
242 | * since we have it pinned, so our reference is safe. | 238 | * since we have it pinned, so our reference is safe. |
243 | */ | 239 | */ |
244 | dl = alias->d_fsdata; | 240 | dl = alias->d_fsdata; |
245 | mlog_bug_on_msg(!dl, "parent %llu, ino %llu, create %d\n", | 241 | mlog_bug_on_msg(!dl, "parent %llu, ino %llu\n", |
246 | (unsigned long long)parent_blkno, | 242 | (unsigned long long)parent_blkno, |
247 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | 243 | (unsigned long long)OCFS2_I(inode)->ip_blkno); |
248 | create); | ||
249 | 244 | ||
250 | mlog_bug_on_msg(dl->dl_parent_blkno != parent_blkno, | 245 | mlog_bug_on_msg(dl->dl_parent_blkno != parent_blkno, |
251 | " \"%.*s\": old parent: %llu, new: %llu\n", | 246 | " \"%.*s\": old parent: %llu, new: %llu\n", |
@@ -284,31 +279,16 @@ out_attach: | |||
284 | spin_unlock(&dentry_attach_lock); | 279 | spin_unlock(&dentry_attach_lock); |
285 | 280 | ||
286 | /* | 281 | /* |
287 | * Creation of a new file means that nobody can possibly have | ||
288 | * this name in the system, which means that acquiry of those | ||
289 | * locks can easily be optimized. | ||
290 | */ | ||
291 | if (create) { | ||
292 | ret = ocfs2_create_new_lock(OCFS2_SB(inode->i_sb), | ||
293 | &dl->dl_lockres, 0); | ||
294 | if (ret) | ||
295 | mlog_errno(ret); | ||
296 | goto out; | ||
297 | } | ||
298 | |||
299 | /* | ||
300 | * This actually gets us our PRMODE level lock. From now on, | 282 | * This actually gets us our PRMODE level lock. From now on, |
301 | * we'll have a notification if one of these names is | 283 | * we'll have a notification if one of these names is |
302 | * destroyed on another node. | 284 | * destroyed on another node. |
303 | */ | 285 | */ |
304 | ret = ocfs2_dentry_lock(dentry, 0); | 286 | ret = ocfs2_dentry_lock(dentry, 0); |
305 | if (ret) { | 287 | if (!ret) |
288 | ocfs2_dentry_unlock(dentry, 0); | ||
289 | else | ||
306 | mlog_errno(ret); | 290 | mlog_errno(ret); |
307 | goto out; | ||
308 | } | ||
309 | ocfs2_dentry_unlock(dentry, 0); | ||
310 | 291 | ||
311 | out: | ||
312 | dput(alias); | 292 | dput(alias); |
313 | 293 | ||
314 | return ret; | 294 | return ret; |
@@ -419,8 +399,7 @@ void ocfs2_dentry_move(struct dentry *dentry, struct dentry *target, | |||
419 | ocfs2_dentry_lock_put(osb, dentry->d_fsdata); | 399 | ocfs2_dentry_lock_put(osb, dentry->d_fsdata); |
420 | 400 | ||
421 | dentry->d_fsdata = NULL; | 401 | dentry->d_fsdata = NULL; |
422 | ret = ocfs2_dentry_attach_lock(dentry, inode, | 402 | ret = ocfs2_dentry_attach_lock(dentry, inode, OCFS2_I(new_dir)->ip_blkno); |
423 | OCFS2_I(new_dir)->ip_blkno, 0); | ||
424 | if (ret) | 403 | if (ret) |
425 | mlog_errno(ret); | 404 | mlog_errno(ret); |
426 | 405 | ||