Skip to contentSkip to conversation

lustre: fix inode refcount problem with fhandle access

PATCH New NeilBrown 2 participants 2 messages Jul 25, 2018 – Jul 29, 2018 Staging

lore
Share & tools
lore

NeilBrown

author
#0 lore raw

PATCH 1/1 lustre: fix inode refcount problem with fhandle access

ll_iget_for_nfs() currently calls d_obtain_alias() twice. This decrements the refcount on the inode twice, and increments it on the dentry twice.
In each case, only once is correct.
The result is that the refcounts are wrong and warnings result.

Also, if the first d_obtain_alias() returns an error, iput() is called. As the comment at the second d_obtain_alias() explains, this is incorrect.

---
 drivers/staging/lustre/lustre/llite/llite_nfs.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)
drivers/staging/lustre/lustre/llite/llite_nfs.c +7 -13
index 14172688d55f..9efb20e91476 100644
@@ -150,10 +150,8 @@ ll_iget_for_nfs(struct super_block *sb,
 	}
 
 	result = d_obtain_alias(inode);
-	if (IS_ERR(result)) {
-		iput(inode);
+	if (IS_ERR(result))
 		return result;
-	}
 
 	/**
 	 * In case d_obtain_alias() found a disconnected dentry, always update
@@ -168,16 +166,12 @@ ll_iget_for_nfs(struct super_block *sb,
 		spin_unlock(&lli->lli_lock);
 	}
 
-	/* N.B. d_obtain_alias() drops inode ref on error */
-	result = d_obtain_alias(inode);
-	if (!IS_ERR(result)) {
-		/*
-		 * Need to signal to the ll_intent_file_open that
-		 * we came from NFS and so opencache needs to be
-		 * enabled for this one
-		 */
-		ll_d2d(result)->lld_nfs_dentry = 1;
-	}
+	/*
+	 * Need to signal to the ll_intent_file_open that
+	 * we came from NFS and so opencache needs to be
+	 * enabled for this one
+	 */
+	ll_d2d(result)->lld_nfs_dentry = 1;
 
 	return result;
 }
Signature · 9 lines
2.14.0.rc0.dirty

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180725/0c66be35/attachment.sig>
#1 lore raw

PATCH 1/1 lustre: fix inode refcount problem with fhandle access

Quoted 10 lines

ll_iget_for_nfs() currently calls d_obtain_alias() twice. This decrements the refcount on the inode twice, and increments it on the dentry twice.
In each case, only once is correct.
The result is that the refcounts are wrong and warnings result.

Also, if the first d_obtain_alias() returns an error, iput() is called. As the comment at the second d_obtain_alias() explains, this is incorrect.

Fixed my problems!!! Thank you.

Quoted 49 lines
---
 drivers/staging/lustre/lustre/llite/llite_nfs.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)
drivers/staging/lustre/lustre/llite/llite_nfs.c +7 -13
index 14172688d55f..9efb20e91476 100644
@@ -150,10 +150,8 @@ ll_iget_for_nfs(struct super_block *sb,
 	}
 
 	result = d_obtain_alias(inode);
-	if (IS_ERR(result)) {
-		iput(inode);
+	if (IS_ERR(result))
 		return result;
-	}
 
 	/**
 	 * In case d_obtain_alias() found a disconnected dentry, always update
@@ -168,16 +166,12 @@ ll_iget_for_nfs(struct super_block *sb,
 		spin_unlock(&lli->lli_lock);
 	}
 
-	/* N.B. d_obtain_alias() drops inode ref on error */
-	result = d_obtain_alias(inode);
-	if (!IS_ERR(result)) {
-		/*
-		 * Need to signal to the ll_intent_file_open that
-		 * we came from NFS and so opencache needs to be
-		 * enabled for this one
-		 */
-		ll_d2d(result)->lld_nfs_dentry = 1;
-	}
+	/*
+	 * Need to signal to the ll_intent_file_open that
+	 * we came from NFS and so opencache needs to be
+	 * enabled for this one
+	 */
+	ll_d2d(result)->lld_nfs_dentry = 1;
 
 	return result;
 }
Signature · 1 line
2.14.0.rc0.dirty