@@ -1681,9 +1681,9 @@ void ocfs2_rw_unlock(struct inode *inode, int write)
/*
* ocfs2_open_lock always get PR mode lock.
*/
-int ocfs2_open_lock(struct inode *inode)
+int ocfs2_open_lock(struct inode *inode, int ex)
{
- int status = 0;
+ int status = 0, level;
struct ocfs2_lock_res *lockres;
struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
@@ -1696,9 +1696,10 @@ int ocfs2_open_lock(struct inode *inode)
goto out;
lockres = &OCFS2_I(inode)->ip_open_lockres;
+ level = ex ? DLM_LOCK_EX : DLM_LOCK_PR;
status = ocfs2_cluster_lock(OCFS2_SB(inode->i_sb), lockres,
- DLM_LOCK_PR, 0, 0);
+ level, 0, 0);
if (status < 0)
mlog_errno(status);
@@ -110,7 +110,7 @@ int ocfs2_create_new_inode_locks(struct inode *inode);
int ocfs2_drop_inode_locks(struct inode *inode);
int ocfs2_rw_lock(struct inode *inode, int write);
void ocfs2_rw_unlock(struct inode *inode, int write);
-int ocfs2_open_lock(struct inode *inode);
+int ocfs2_open_lock(struct inode *inode, int ex);
int ocfs2_try_open_lock(struct inode *inode, int write);
void ocfs2_open_unlock(struct inode *inode);
int ocfs2_inode_lock_atime(struct inode *inode,
@@ -454,7 +454,7 @@ static int ocfs2_read_locked_inode(struct inode *inode,
0, inode);
if (can_lock) {
- status = ocfs2_open_lock(inode);
+ status = ocfs2_open_lock(inode, 0);
if (status) {
make_bad_inode(inode);
mlog_errno(status);
@@ -922,7 +922,7 @@ static int ocfs2_query_inode_wipe(struct inode *inode,
* Though we call this with the meta data lock held, the
* trylock keeps us from ABBA deadlock.
*/
- status = ocfs2_try_open_lock(inode, 1);
+ status = ocfs2_open_lock(inode, 1);
if (status == -EAGAIN) {
status = 0;
reason = 3;
@@ -997,6 +997,7 @@ static void ocfs2_delete_inode(struct inode *inode)
ocfs2_cleanup_delete_inode(inode, 0);
goto bail_unblock;
}
+
/* Lock down the inode. This gives us an up to date view of
* it's metadata (for verification), and allows us to
* serialize delete_inode on multiple nodes.
@@ -2307,7 +2307,7 @@ int ocfs2_create_inode_in_orphan(struct inode *dir,
}
/* get open lock so that only nodes can't remove it from orphan dir. */
- status = ocfs2_open_lock(inode);
+ status = ocfs2_open_lock(inode, 0);
if (status < 0)
mlog_errno(status);