Skip to contentSkip to conversation

ceph: remove unnecessary check for NULL in parse_longname()

PATCH In review Luís Henriques 2 participants 2 messages Sep 8, 2023 – Sep 11, 2023 Ceph client

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ceph: remove unnecessary check for NULL in parse_longname()

Function ceph_get_inode() never returns NULL; instead it returns an ERR_PTR() if something fails. Thus, the check for NULL in parse_longname() is useless and can be dropped. Instead, move there the debug code that does the error checking so that it's only executed if ceph_get_inode() is called.

Fixes dd66df0053ef ("ceph: add support for encrypted snapshot names")

---
Changes since v2:
As suggested by Xiubo, moved the error checking into the 'if (!dir)' block.

 fs/ceph/crypto.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
fs/ceph/crypto.c +2 -4
index e4d5cd56a80b..e1f31b86fd48 100644
@@ -249,11 +249,9 @@ static struct inode *parse_longname(const struct inode *parent,
 	if (!dir) {
 		/* This can happen if we're not mounting cephfs on the root */
 		dir = ceph_get_inode(parent->i_sb, vino, NULL);
-		if (!dir)
-			dir = ERR_PTR(-ENOENT);
+		if (IS_ERR(dir))
+			dout("Can't find inode %s (%s)\n", inode_number, name);
 	}
-	if (IS_ERR(dir))
-		dout("Can't find inode %s (%s)\n", inode_number, name);
 
 out:
 	kfree(inode_number);
#1 lore raw
Quoted 26 lines · Luís Henriques

Function ceph_get_inode() never returns NULL; instead it returns an ERR_PTR() if something fails. Thus, the check for NULL in parse_longname() is useless and can be dropped. Instead, move there the debug code that does the error checking so that it's only executed if ceph_get_inode() is called.

Fixes dd66df0053ef ("ceph: add support for encrypted snapshot names")

---
Changes since v2:
As suggested by Xiubo, moved the error checking into the 'if (!dir)' block.

  fs/ceph/crypto.c | 6 ++----
  1 file changed, 2 insertions(+), 4 deletions(-)
fs/ceph/crypto.c +0 -0
index e4d5cd56a80b..e1f31b86fd48 100644
@@ -249,11 +249,9 @@ static struct inode *parse_longname(const struct inode *parent,
  	if (!dir) {
  		/* This can happen if we're not mounting cephfs on the root */
  		dir = ceph_get_inode(parent->i_sb, vino, NULL);

fs/ceph/crypto.c static struct inode *parse_longname(const struct inode *parent, · line 257

Quoted 10 lines
fs/ceph/crypto.c +2 -4
-		if (!dir)
-			dir = ERR_PTR(-ENOENT);
+		if (IS_ERR(dir))
+			dout("Can't find inode %s (%s)\n", inode_number, name);
  	}
-	if (IS_ERR(dir))
-		dout("Can't find inode %s (%s)\n", inode_number, name);
 
  out:
  	kfree(inode_number);

LGTM.

Applied to the testing branch and will run the tests.

Thanks Luis.