ocfs2: don't pass handle to ocfs2_meta_lock() in ocfs2_link()
Take and drop the locks directly. Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
This commit is contained in:
parent
e3a8213859
commit
123a964340
@ -655,7 +655,7 @@ static int ocfs2_link(struct dentry *old_dentry,
|
|||||||
struct inode *dir,
|
struct inode *dir,
|
||||||
struct dentry *dentry)
|
struct dentry *dentry)
|
||||||
{
|
{
|
||||||
struct ocfs2_journal_handle *handle = NULL;
|
struct ocfs2_journal_handle *handle;
|
||||||
struct inode *inode = old_dentry->d_inode;
|
struct inode *inode = old_dentry->d_inode;
|
||||||
int err;
|
int err;
|
||||||
struct buffer_head *fe_bh = NULL;
|
struct buffer_head *fe_bh = NULL;
|
||||||
@ -668,68 +668,60 @@ static int ocfs2_link(struct dentry *old_dentry,
|
|||||||
old_dentry->d_name.len, old_dentry->d_name.name,
|
old_dentry->d_name.len, old_dentry->d_name.name,
|
||||||
dentry->d_name.len, dentry->d_name.name);
|
dentry->d_name.len, dentry->d_name.name);
|
||||||
|
|
||||||
if (S_ISDIR(inode->i_mode)) {
|
if (S_ISDIR(inode->i_mode))
|
||||||
err = -EPERM;
|
return -EPERM;
|
||||||
goto bail;
|
|
||||||
}
|
|
||||||
|
|
||||||
handle = ocfs2_alloc_handle(osb);
|
err = ocfs2_meta_lock(dir, NULL, &parent_fe_bh, 1);
|
||||||
if (handle == NULL) {
|
|
||||||
err = -ENOMEM;
|
|
||||||
goto bail;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = ocfs2_meta_lock(dir, handle, &parent_fe_bh, 1);
|
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
if (err != -ENOENT)
|
if (err != -ENOENT)
|
||||||
mlog_errno(err);
|
mlog_errno(err);
|
||||||
goto bail;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dir->i_nlink) {
|
if (!dir->i_nlink) {
|
||||||
err = -ENOENT;
|
err = -ENOENT;
|
||||||
goto bail;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ocfs2_check_dir_for_entry(dir, dentry->d_name.name,
|
err = ocfs2_check_dir_for_entry(dir, dentry->d_name.name,
|
||||||
dentry->d_name.len);
|
dentry->d_name.len);
|
||||||
if (err)
|
if (err)
|
||||||
goto bail;
|
goto out;
|
||||||
|
|
||||||
err = ocfs2_prepare_dir_for_insert(osb, dir, parent_fe_bh,
|
err = ocfs2_prepare_dir_for_insert(osb, dir, parent_fe_bh,
|
||||||
dentry->d_name.name,
|
dentry->d_name.name,
|
||||||
dentry->d_name.len, &de_bh);
|
dentry->d_name.len, &de_bh);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
mlog_errno(err);
|
mlog_errno(err);
|
||||||
goto bail;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ocfs2_meta_lock(inode, handle, &fe_bh, 1);
|
err = ocfs2_meta_lock(inode, NULL, &fe_bh, 1);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
if (err != -ENOENT)
|
if (err != -ENOENT)
|
||||||
mlog_errno(err);
|
mlog_errno(err);
|
||||||
goto bail;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
fe = (struct ocfs2_dinode *) fe_bh->b_data;
|
fe = (struct ocfs2_dinode *) fe_bh->b_data;
|
||||||
if (le16_to_cpu(fe->i_links_count) >= OCFS2_LINK_MAX) {
|
if (le16_to_cpu(fe->i_links_count) >= OCFS2_LINK_MAX) {
|
||||||
err = -EMLINK;
|
err = -EMLINK;
|
||||||
goto bail;
|
goto out_unlock_inode;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle = ocfs2_start_trans(osb, handle, OCFS2_LINK_CREDITS);
|
handle = ocfs2_start_trans(osb, NULL, OCFS2_LINK_CREDITS);
|
||||||
if (IS_ERR(handle)) {
|
if (IS_ERR(handle)) {
|
||||||
err = PTR_ERR(handle);
|
err = PTR_ERR(handle);
|
||||||
handle = NULL;
|
handle = NULL;
|
||||||
mlog_errno(err);
|
mlog_errno(err);
|
||||||
goto bail;
|
goto out_unlock_inode;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ocfs2_journal_access(handle, inode, fe_bh,
|
err = ocfs2_journal_access(handle, inode, fe_bh,
|
||||||
OCFS2_JOURNAL_ACCESS_WRITE);
|
OCFS2_JOURNAL_ACCESS_WRITE);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
mlog_errno(err);
|
mlog_errno(err);
|
||||||
goto bail;
|
goto out_commit;
|
||||||
}
|
}
|
||||||
|
|
||||||
inc_nlink(inode);
|
inc_nlink(inode);
|
||||||
@ -743,7 +735,7 @@ static int ocfs2_link(struct dentry *old_dentry,
|
|||||||
le16_add_cpu(&fe->i_links_count, -1);
|
le16_add_cpu(&fe->i_links_count, -1);
|
||||||
drop_nlink(inode);
|
drop_nlink(inode);
|
||||||
mlog_errno(err);
|
mlog_errno(err);
|
||||||
goto bail;
|
goto out_commit;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ocfs2_add_entry(handle, dentry, inode,
|
err = ocfs2_add_entry(handle, dentry, inode,
|
||||||
@ -753,21 +745,27 @@ static int ocfs2_link(struct dentry *old_dentry,
|
|||||||
le16_add_cpu(&fe->i_links_count, -1);
|
le16_add_cpu(&fe->i_links_count, -1);
|
||||||
drop_nlink(inode);
|
drop_nlink(inode);
|
||||||
mlog_errno(err);
|
mlog_errno(err);
|
||||||
goto bail;
|
goto out_commit;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ocfs2_dentry_attach_lock(dentry, inode, OCFS2_I(dir)->ip_blkno);
|
err = ocfs2_dentry_attach_lock(dentry, inode, OCFS2_I(dir)->ip_blkno);
|
||||||
if (err) {
|
if (err) {
|
||||||
mlog_errno(err);
|
mlog_errno(err);
|
||||||
goto bail;
|
goto out_commit;
|
||||||
}
|
}
|
||||||
|
|
||||||
atomic_inc(&inode->i_count);
|
atomic_inc(&inode->i_count);
|
||||||
dentry->d_op = &ocfs2_dentry_ops;
|
dentry->d_op = &ocfs2_dentry_ops;
|
||||||
d_instantiate(dentry, inode);
|
d_instantiate(dentry, inode);
|
||||||
bail:
|
|
||||||
if (handle)
|
out_commit:
|
||||||
ocfs2_commit_trans(handle);
|
ocfs2_commit_trans(handle);
|
||||||
|
out_unlock_inode:
|
||||||
|
ocfs2_meta_unlock(inode, 1);
|
||||||
|
|
||||||
|
out:
|
||||||
|
ocfs2_meta_unlock(dir, 1);
|
||||||
|
|
||||||
if (de_bh)
|
if (de_bh)
|
||||||
brelse(de_bh);
|
brelse(de_bh);
|
||||||
if (fe_bh)
|
if (fe_bh)
|
||||||
|
Loading…
Reference in New Issue
Block a user