Commit 0027dd5b authored by Mark Fasheh's avatar Mark Fasheh

ocfs2: Remove special casing for inode creation in ocfs2_dentry_attach_lock()

We can't use LKM_LOCAL for new dentry locks because an unlink and subsequent
re-create of a name/inode pair may result in the lock still being mastered
somewhere in the cluster.
Signed-off-by: default avatarMark Fasheh <mark.fasheh@oracle.com>
parent 1ba9da2f
...@@ -183,9 +183,6 @@ DEFINE_SPINLOCK(dentry_attach_lock); ...@@ -183,9 +183,6 @@ DEFINE_SPINLOCK(dentry_attach_lock);
* The dir cluster lock (held at either PR or EX mode) protects us * The dir cluster lock (held at either PR or EX mode) protects us
* from unlink and rename on other nodes. * from unlink and rename on other nodes.
* *
* The 'create' flag tells us whether we're doing this as a result of
* a file creation.
*
* A dput() can happen asynchronously due to pruning, so we cover * A dput() can happen asynchronously due to pruning, so we cover
* attaching and detaching the dentry lock with a * attaching and detaching the dentry lock with a
* dentry_attach_lock. * dentry_attach_lock.
...@@ -199,16 +196,15 @@ DEFINE_SPINLOCK(dentry_attach_lock); ...@@ -199,16 +196,15 @@ DEFINE_SPINLOCK(dentry_attach_lock);
*/ */
int ocfs2_dentry_attach_lock(struct dentry *dentry, int ocfs2_dentry_attach_lock(struct dentry *dentry,
struct inode *inode, struct inode *inode,
u64 parent_blkno, u64 parent_blkno)
int create)
{ {
int ret; int ret;
struct dentry *alias; struct dentry *alias;
struct ocfs2_dentry_lock *dl = dentry->d_fsdata; struct ocfs2_dentry_lock *dl = dentry->d_fsdata;
mlog(0, "Attach \"%.*s\", parent %llu, create %d, fsdata: %p\n", mlog(0, "Attach \"%.*s\", parent %llu, fsdata: %p\n",
dentry->d_name.len, dentry->d_name.name, dentry->d_name.len, dentry->d_name.name,
(unsigned long long)parent_blkno, create, dl); (unsigned long long)parent_blkno, dl);
/* /*
* Negative dentry. We ignore these for now. * Negative dentry. We ignore these for now.
...@@ -242,10 +238,9 @@ int ocfs2_dentry_attach_lock(struct dentry *dentry, ...@@ -242,10 +238,9 @@ int ocfs2_dentry_attach_lock(struct dentry *dentry,
* since we have it pinned, so our reference is safe. * since we have it pinned, so our reference is safe.
*/ */
dl = alias->d_fsdata; dl = alias->d_fsdata;
mlog_bug_on_msg(!dl, "parent %llu, ino %llu, create %d\n", mlog_bug_on_msg(!dl, "parent %llu, ino %llu\n",
(unsigned long long)parent_blkno, (unsigned long long)parent_blkno,
(unsigned long long)OCFS2_I(inode)->ip_blkno, (unsigned long long)OCFS2_I(inode)->ip_blkno);
create);
mlog_bug_on_msg(dl->dl_parent_blkno != parent_blkno, mlog_bug_on_msg(dl->dl_parent_blkno != parent_blkno,
" \"%.*s\": old parent: %llu, new: %llu\n", " \"%.*s\": old parent: %llu, new: %llu\n",
...@@ -283,32 +278,17 @@ out_attach: ...@@ -283,32 +278,17 @@ out_attach:
dl->dl_count++; dl->dl_count++;
spin_unlock(&dentry_attach_lock); spin_unlock(&dentry_attach_lock);
/*
* Creation of a new file means that nobody can possibly have
* this name in the system, which means that acquiry of those
* locks can easily be optimized.
*/
if (create) {
ret = ocfs2_create_new_lock(OCFS2_SB(inode->i_sb),
&dl->dl_lockres, 0);
if (ret)
mlog_errno(ret);
goto out;
}
/* /*
* This actually gets us our PRMODE level lock. From now on, * This actually gets us our PRMODE level lock. From now on,
* we'll have a notification if one of these names is * we'll have a notification if one of these names is
* destroyed on another node. * destroyed on another node.
*/ */
ret = ocfs2_dentry_lock(dentry, 0); ret = ocfs2_dentry_lock(dentry, 0);
if (ret) { if (!ret)
ocfs2_dentry_unlock(dentry, 0);
else
mlog_errno(ret); mlog_errno(ret);
goto out;
}
ocfs2_dentry_unlock(dentry, 0);
out:
dput(alias); dput(alias);
return ret; return ret;
...@@ -419,8 +399,7 @@ void ocfs2_dentry_move(struct dentry *dentry, struct dentry *target, ...@@ -419,8 +399,7 @@ void ocfs2_dentry_move(struct dentry *dentry, struct dentry *target,
ocfs2_dentry_lock_put(osb, dentry->d_fsdata); ocfs2_dentry_lock_put(osb, dentry->d_fsdata);
dentry->d_fsdata = NULL; dentry->d_fsdata = NULL;
ret = ocfs2_dentry_attach_lock(dentry, inode, ret = ocfs2_dentry_attach_lock(dentry, inode, OCFS2_I(new_dir)->ip_blkno);
OCFS2_I(new_dir)->ip_blkno, 0);
if (ret) if (ret)
mlog_errno(ret); mlog_errno(ret);
......
...@@ -42,7 +42,7 @@ struct ocfs2_dentry_lock { ...@@ -42,7 +42,7 @@ struct ocfs2_dentry_lock {
}; };
int ocfs2_dentry_attach_lock(struct dentry *dentry, struct inode *inode, int ocfs2_dentry_attach_lock(struct dentry *dentry, struct inode *inode,
u64 parent_blkno, int create); u64 parent_blkno);
void ocfs2_dentry_lock_put(struct ocfs2_super *osb, void ocfs2_dentry_lock_put(struct ocfs2_super *osb,
struct ocfs2_dentry_lock *dl); struct ocfs2_dentry_lock *dl);
......
...@@ -217,7 +217,7 @@ bail_add: ...@@ -217,7 +217,7 @@ bail_add:
dentry = ret; dentry = ret;
status = ocfs2_dentry_attach_lock(dentry, inode, status = ocfs2_dentry_attach_lock(dentry, inode,
OCFS2_I(dir)->ip_blkno, 0); OCFS2_I(dir)->ip_blkno);
if (status) { if (status) {
mlog_errno(status); mlog_errno(status);
ret = ERR_PTR(status); ret = ERR_PTR(status);
...@@ -441,7 +441,7 @@ static int ocfs2_mknod(struct inode *dir, ...@@ -441,7 +441,7 @@ static int ocfs2_mknod(struct inode *dir,
} }
status = ocfs2_dentry_attach_lock(dentry, inode, status = ocfs2_dentry_attach_lock(dentry, inode,
OCFS2_I(dir)->ip_blkno, 1); OCFS2_I(dir)->ip_blkno);
if (status) { if (status) {
mlog_errno(status); mlog_errno(status);
goto leave; goto leave;
...@@ -754,8 +754,7 @@ static int ocfs2_link(struct dentry *old_dentry, ...@@ -754,8 +754,7 @@ static int ocfs2_link(struct dentry *old_dentry,
goto bail; goto bail;
} }
err = ocfs2_dentry_attach_lock(dentry, inode, OCFS2_I(dir)->ip_blkno, err = ocfs2_dentry_attach_lock(dentry, inode, OCFS2_I(dir)->ip_blkno);
0);
if (err) { if (err) {
mlog_errno(err); mlog_errno(err);
goto bail; goto bail;
...@@ -1716,8 +1715,7 @@ static int ocfs2_symlink(struct inode *dir, ...@@ -1716,8 +1715,7 @@ static int ocfs2_symlink(struct inode *dir,
goto bail; goto bail;
} }
status = ocfs2_dentry_attach_lock(dentry, inode, status = ocfs2_dentry_attach_lock(dentry, inode, OCFS2_I(dir)->ip_blkno);
OCFS2_I(dir)->ip_blkno, 1);
if (status) { if (status) {
mlog_errno(status); mlog_errno(status);
goto bail; goto bail;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment