Skip to contentSkip to conversation

ceph: remove unnecessary check for NULL in parse_longname()

PATCH Superseded Luís Henriques 2 participants 3 messages Sep 7, 2023 – Sep 8, 2023 Ceph client

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 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() useless and can be dropped.

Fixes dd66df0053ef ("ceph: add support for encrypted snapshot names")
---
 fs/ceph/crypto.c | 2 --
 1 file changed, 2 deletions(-)
fs/ceph/crypto.c +0 -2
index e4d5cd56a80b..7d0b9b5ccfc6 100644
@@ -249,8 +249,6 @@ 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);
#1 lore raw
Quoted 17 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() useless and can be dropped.

Fixes dd66df0053ef ("ceph: add support for encrypted snapshot names")
---
  fs/ceph/crypto.c | 2 --
  1 file changed, 2 deletions(-)
fs/ceph/crypto.c +0 -0
index e4d5cd56a80b..7d0b9b5ccfc6 100644

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

Quoted 8 lines
fs/ceph/crypto.c +0 -2
@@ -249,8 +249,6 @@ 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);

Luis,

How about moving the error check into the  'if (!dir) {}' ? Because from 'ceph_find_inode()' the return value shouldn't be true here. This err check should for 'ceph_get_inode()' only.

Thanks

- Xiubo

#2 lore raw
Quoted 28 lines · Xiubo Li
Quoted 17 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() useless and can be dropped.

Fixes dd66df0053ef ("ceph: add support for encrypted snapshot names")
---
  fs/ceph/crypto.c | 2 --
  1 file changed, 2 deletions(-)
fs/ceph/crypto.c +0 -0
index e4d5cd56a80b..7d0b9b5ccfc6 100644

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

Quoted 8 lines
fs/ceph/crypto.c +0 -2
@@ -249,8 +249,6 @@ 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);

Luis,

Quoted 3 lines

How about moving the error check into the  'if (!dir) {}' ? Because from 'ceph_find_inode()' the return value shouldn't be true here. This err check should for 'ceph_get_inode()' only.

Yeah, you're right. Thanks, Xiubo. I'll send out v2 shortly.

Cheers,

Signature · 1 line
Luís