diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ocfs2/dcache.c | 39 | ||||
-rw-r--r-- | fs/ocfs2/dcache.h | 2 | ||||
-rw-r--r-- | fs/ocfs2/namei.c | 10 |
3 files changed, 14 insertions, 37 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 | ||
diff --git a/fs/ocfs2/dcache.h b/fs/ocfs2/dcache.h index e53abe766cab..c091c34d9883 100644 --- a/fs/ocfs2/dcache.h +++ b/fs/ocfs2/dcache.h | |||
@@ -42,7 +42,7 @@ struct ocfs2_dentry_lock { | |||
42 | }; | 42 | }; |
43 | 43 | ||
44 | int ocfs2_dentry_attach_lock(struct dentry *dentry, struct inode *inode, | 44 | int ocfs2_dentry_attach_lock(struct dentry *dentry, struct inode *inode, |
45 | u64 parent_blkno, int create); | 45 | u64 parent_blkno); |
46 | 46 | ||
47 | void ocfs2_dentry_lock_put(struct ocfs2_super *osb, | 47 | void ocfs2_dentry_lock_put(struct ocfs2_super *osb, |
48 | struct ocfs2_dentry_lock *dl); | 48 | struct ocfs2_dentry_lock *dl); |
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index 5a942e0123ea..6fa978874c33 100644 --- a/fs/ocfs2/namei.c +++ b/fs/ocfs2/namei.c | |||
@@ -217,7 +217,7 @@ bail_add: | |||
217 | dentry = ret; | 217 | dentry = ret; |
218 | 218 | ||
219 | status = ocfs2_dentry_attach_lock(dentry, inode, | 219 | status = ocfs2_dentry_attach_lock(dentry, inode, |
220 | OCFS2_I(dir)->ip_blkno, 0); | 220 | OCFS2_I(dir)->ip_blkno); |
221 | if (status) { | 221 | if (status) { |
222 | mlog_errno(status); | 222 | mlog_errno(status); |
223 | ret = ERR_PTR(status); | 223 | ret = ERR_PTR(status); |
@@ -441,7 +441,7 @@ static int ocfs2_mknod(struct inode *dir, | |||
441 | } | 441 | } |
442 | 442 | ||
443 | status = ocfs2_dentry_attach_lock(dentry, inode, | 443 | status = ocfs2_dentry_attach_lock(dentry, inode, |
444 | OCFS2_I(dir)->ip_blkno, 1); | 444 | OCFS2_I(dir)->ip_blkno); |
445 | if (status) { | 445 | if (status) { |
446 | mlog_errno(status); | 446 | mlog_errno(status); |
447 | goto leave; | 447 | goto leave; |
@@ -754,8 +754,7 @@ static int ocfs2_link(struct dentry *old_dentry, | |||
754 | goto bail; | 754 | goto bail; |
755 | } | 755 | } |
756 | 756 | ||
757 | err = ocfs2_dentry_attach_lock(dentry, inode, OCFS2_I(dir)->ip_blkno, | 757 | err = ocfs2_dentry_attach_lock(dentry, inode, OCFS2_I(dir)->ip_blkno); |
758 | 0); | ||
759 | if (err) { | 758 | if (err) { |
760 | mlog_errno(err); | 759 | mlog_errno(err); |
761 | goto bail; | 760 | goto bail; |
@@ -1716,8 +1715,7 @@ static int ocfs2_symlink(struct inode *dir, | |||
1716 | goto bail; | 1715 | goto bail; |
1717 | } | 1716 | } |
1718 | 1717 | ||
1719 | status = ocfs2_dentry_attach_lock(dentry, inode, | 1718 | status = ocfs2_dentry_attach_lock(dentry, inode, OCFS2_I(dir)->ip_blkno); |
1720 | OCFS2_I(dir)->ip_blkno, 1); | ||
1721 | if (status) { | 1719 | if (status) { |
1722 | mlog_errno(status); | 1720 | mlog_errno(status); |
1723 | goto bail; | 1721 | goto bail; |