aboutsummaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorMark Fasheh2006-10-05 16:48:23 -0700
committerMark Fasheh2006-12-01 18:27:14 -0800
commit123a9643408882620347cc2c82f24e57dab05f44 (patch)
treea36e56e89eb966c5edf213cdc8cc59e78163d903 /fs
parente3a821385984e57d5dd1b0e7292761abb0ea4dd9 (diff)
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>
Diffstat (limited to 'fs')
-rw-r--r--fs/ocfs2/namei.c54
1 files changed, 26 insertions, 28 deletions
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 702f0c30cda4..79f513001a6d 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -655,7 +655,7 @@ static int ocfs2_link(struct dentry *old_dentry,
struct inode *dir,
struct dentry *dentry)
{
- struct ocfs2_journal_handle *handle = NULL;
+ struct ocfs2_journal_handle *handle;
struct inode *inode = old_dentry->d_inode;
int err;
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,
dentry->d_name.len, dentry->d_name.name);
- if (S_ISDIR(inode->i_mode)) {
- err = -EPERM;
- goto bail;
- }
-
- handle = ocfs2_alloc_handle(osb);
- if (handle == NULL) {
- err = -ENOMEM;
- goto bail;
- }
+ if (S_ISDIR(inode->i_mode))
+ return -EPERM;
- err = ocfs2_meta_lock(dir, handle, &parent_fe_bh, 1);
+ err = ocfs2_meta_lock(dir, NULL, &parent_fe_bh, 1);
if (err < 0) {
if (err != -ENOENT)
mlog_errno(err);
- goto bail;
+ return err;
}
if (!dir->i_nlink) {
err = -ENOENT;
- goto bail;
+ goto out;
}
err = ocfs2_check_dir_for_entry(dir, dentry->d_name.name,
dentry->d_name.len);
if (err)
- goto bail;
+ goto out;
err = ocfs2_prepare_dir_for_insert(osb, dir, parent_fe_bh,
dentry->d_name.name,
dentry->d_name.len, &de_bh);
if (err < 0) {
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 != -ENOENT)
mlog_errno(err);
- goto bail;
+ goto out;
}
fe = (struct ocfs2_dinode *) fe_bh->b_data;
if (le16_to_cpu(fe->i_links_count) >= OCFS2_LINK_MAX) {
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)) {
err = PTR_ERR(handle);
handle = NULL;
mlog_errno(err);
- goto bail;
+ goto out_unlock_inode;
}
err = ocfs2_journal_access(handle, inode, fe_bh,
OCFS2_JOURNAL_ACCESS_WRITE);
if (err < 0) {
mlog_errno(err);
- goto bail;
+ goto out_commit;
}
inc_nlink(inode);
@@ -743,7 +735,7 @@ static int ocfs2_link(struct dentry *old_dentry,
le16_add_cpu(&fe->i_links_count, -1);
drop_nlink(inode);
mlog_errno(err);
- goto bail;
+ goto out_commit;
}
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);
drop_nlink(inode);
mlog_errno(err);
- goto bail;
+ goto out_commit;
}
err = ocfs2_dentry_attach_lock(dentry, inode, OCFS2_I(dir)->ip_blkno);
if (err) {
mlog_errno(err);
- goto bail;
+ goto out_commit;
}
atomic_inc(&inode->i_count);
dentry->d_op = &ocfs2_dentry_ops;
d_instantiate(dentry, inode);
-bail:
- if (handle)
- ocfs2_commit_trans(handle);
+
+out_commit:
+ ocfs2_commit_trans(handle);
+out_unlock_inode:
+ ocfs2_meta_unlock(inode, 1);
+
+out:
+ ocfs2_meta_unlock(dir, 1);
+
if (de_bh)
brelse(de_bh);
if (fe_bh)