|
@@ -4250,10 +4250,11 @@ out:
|
|
static int ocfs2_reflink(struct dentry *old_dentry, struct inode *dir,
|
|
static int ocfs2_reflink(struct dentry *old_dentry, struct inode *dir,
|
|
struct dentry *new_dentry, bool preserve)
|
|
struct dentry *new_dentry, bool preserve)
|
|
{
|
|
{
|
|
- int error;
|
|
|
|
|
|
+ int error, had_lock;
|
|
struct inode *inode = d_inode(old_dentry);
|
|
struct inode *inode = d_inode(old_dentry);
|
|
struct buffer_head *old_bh = NULL;
|
|
struct buffer_head *old_bh = NULL;
|
|
struct inode *new_orphan_inode = NULL;
|
|
struct inode *new_orphan_inode = NULL;
|
|
|
|
+ struct ocfs2_lock_holder oh;
|
|
|
|
|
|
if (!ocfs2_refcount_tree(OCFS2_SB(inode->i_sb)))
|
|
if (!ocfs2_refcount_tree(OCFS2_SB(inode->i_sb)))
|
|
return -EOPNOTSUPP;
|
|
return -EOPNOTSUPP;
|
|
@@ -4295,6 +4296,14 @@ static int ocfs2_reflink(struct dentry *old_dentry, struct inode *dir,
|
|
goto out;
|
|
goto out;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ had_lock = ocfs2_inode_lock_tracker(new_orphan_inode, NULL, 1,
|
|
|
|
+ &oh);
|
|
|
|
+ if (had_lock < 0) {
|
|
|
|
+ error = had_lock;
|
|
|
|
+ mlog_errno(error);
|
|
|
|
+ goto out;
|
|
|
|
+ }
|
|
|
|
+
|
|
/* If the security isn't preserved, we need to re-initialize them. */
|
|
/* If the security isn't preserved, we need to re-initialize them. */
|
|
if (!preserve) {
|
|
if (!preserve) {
|
|
error = ocfs2_init_security_and_acl(dir, new_orphan_inode,
|
|
error = ocfs2_init_security_and_acl(dir, new_orphan_inode,
|
|
@@ -4302,14 +4311,15 @@ static int ocfs2_reflink(struct dentry *old_dentry, struct inode *dir,
|
|
if (error)
|
|
if (error)
|
|
mlog_errno(error);
|
|
mlog_errno(error);
|
|
}
|
|
}
|
|
-out:
|
|
|
|
if (!error) {
|
|
if (!error) {
|
|
error = ocfs2_mv_orphaned_inode_to_new(dir, new_orphan_inode,
|
|
error = ocfs2_mv_orphaned_inode_to_new(dir, new_orphan_inode,
|
|
new_dentry);
|
|
new_dentry);
|
|
if (error)
|
|
if (error)
|
|
mlog_errno(error);
|
|
mlog_errno(error);
|
|
}
|
|
}
|
|
|
|
+ ocfs2_inode_unlock_tracker(new_orphan_inode, 1, &oh, had_lock);
|
|
|
|
|
|
|
|
+out:
|
|
if (new_orphan_inode) {
|
|
if (new_orphan_inode) {
|
|
/*
|
|
/*
|
|
* We need to open_unlock the inode no matter whether we
|
|
* We need to open_unlock the inode no matter whether we
|