Skip to contentSkip to conversation

devtmpfs: Calling delete_path() only when necessary

PATCH In review Axel Lin 4 participants 11 messages Nov 16, 2013 – Dec 10, 2013 Driver core

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 devtmpfs: Calling delete_path() only when necessary

The deleted variable is always 1 in current code.
Initialize deleted variable to be 0, so delete_path() will be called only when necessary.

---
 drivers/base/devtmpfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/devtmpfs.c +1 -1
index 0f38201..25798db 100644
@@ -299,7 +299,7 @@ static int handle_remove(const char *nodename, struct device *dev)
 {
 	struct path parent;
 	struct dentry *dentry;
-	int deleted = 1;
+	int deleted = 0;
 	int err;
 
 	dentry = kern_path_locked(nodename, &parent);
Signature · 1 line
1.8.1.2
#1 lore raw
Quoted 5 lines · Axel Lin

The deleted variable is always 1 in current code.
Initialize deleted variable to be 0, so delete_path() will be called only when necessary.

I'm not seeing this in linux-next, or a reply on the web archive. Assuming nobody's objected to this, you might want to forward it to [email protected].

That said, you could describe what it _does_ a little more?

Thanks,

Rob

author
#2 lore raw

2013/12/4 Rob Landley <[email protected]>:

Quoted 7 lines · Axel Lin
Quoted 6 lines

The deleted variable is always 1 in current code.
Initialize deleted variable to be 0, so delete_path() will be called only when
necessary.

Quoted 8 lines
Quoted 1 line

I'm not seeing this in linux-next, or a reply on the web archive. Assuming nobody's objected to this, you might want to forward it to [email protected].

That said, you could describe what it _does_ a little more?

I was expecting Greg to pick up this patch.

I thought the description is pretty clear.
What the patch does is changing the init value of deleted variable to 0. The intention of this change is to avoid unnecessary delete_path() call.

Hi Greg,
Would you pick up this patch?
If a re-send or a v2 is required, please just let me know.

Thanks,
Axel

#3 lore raw
Quoted 19 lines · Axel Lin

2013/12/4 Rob Landley <[email protected]>:

Quoted 7 lines · Axel Lin
Quoted 6 lines

The deleted variable is always 1 in current code.
Initialize deleted variable to be 0, so delete_path() will be called only when
necessary.

Quoted 8 lines
Quoted 1 line

I'm not seeing this in linux-next, or a reply on the web archive. Assuming nobody's objected to this, you might want to forward it to [email protected].

That said, you could describe what it _does_ a little more?

I was expecting Greg to pick up this patch.

Quoted 7 lines

I thought the description is pretty clear.
What the patch does is changing the init value of deleted variable to 0. The intention of this change is to avoid unnecessary delete_path() call.

Hi Greg,
Would you pick up this patch?
If a re-send or a v2 is required, please just let me know.

It's in my queue to get to, sorry, it's huge and slowly going down, it's not lost...

greg k-h

#4 lore raw
In reply to Axel Lin
Quoted 15 lines · Axel Lin

2013/12/4 Rob Landley <[email protected]>:

Quoted 14 lines · Axel Lin
Quoted 7 lines

The deleted variable is always 1 in current code.
Initialize deleted variable to be 0, so delete_path() will be called only when
necessary.

I'm not seeing this in linux-next, or a reply on the web archive. Assuming nobody's objected to this, you might want to forward it to [email protected].

Quoted 7 lines
Quoted 1 line

That said, you could describe what it _does_ a little more?

I was expecting Greg to pick up this patch.

I thought the description is pretty clear.
What the patch does is changing the init value of deleted variable to 0. The intention of this change is to avoid unnecessary delete_path() call.

I agree the logic is a bit odd here, but are you seeing an "unnecessary" delete_path() call happening? The code has always been like this from what I can tell...

thanks,

greg k-h

author
#5 lore raw

2013/12/9 Greg Kroah-Hartman <[email protected]>:

Quoted 20 lines · Axel Lin
Quoted 19 lines

2013/12/4 Rob Landley <[email protected]>:

Quoted 7 lines · Axel Lin
Quoted 6 lines

The deleted variable is always 1 in current code.
Initialize deleted variable to be 0, so delete_path() will be called only when
necessary.

Quoted 8 lines
Quoted 1 line

I'm not seeing this in linux-next, or a reply on the web archive. Assuming nobody's objected to this, you might want to forward it to [email protected].

That said, you could describe what it _does_ a little more?

I was expecting Greg to pick up this patch.

Quoted 7 lines
Quoted 3 lines

I thought the description is pretty clear.
What the patch does is changing the init value of deleted variable to 0. The intention of this change is to avoid unnecessary delete_path() call.

I agree the logic is a bit odd here, but are you seeing an "unnecessary" delete_path() call happening? The code has always been like this from what I can tell...

Honestly, I havn't see the "unnecessary" delete_path() call happening druing my test. I look at the code when I was debugging a hangup issue.
(In the end, I think the issue is not related to the devtmpfs code.) But I found the logic for the deleted variable looks odd.
There are below possible (unlikely) case:
When strchr(nodename, '/') != 0 and
1. If dentry->d_inode is NULL
2. vfs_getattr returns error
3. vfs_unlink returns error except -ENOENT.

In these cases, delete_path() will fail anyway.

Although this is a unlikely case, and I know the code is there since initial commit. But I think it's still good to fix it.

Regards,
Axel

#6 lore raw
Quoted 39 lines · Axel Lin

2013/12/9 Greg Kroah-Hartman <[email protected]>:

Quoted 20 lines · Axel Lin
Quoted 19 lines

2013/12/4 Rob Landley <[email protected]>:

Quoted 7 lines · Axel Lin
Quoted 6 lines

The deleted variable is always 1 in current code.
Initialize deleted variable to be 0, so delete_path() will be called only when
necessary.

Quoted 8 lines
Quoted 1 line

I'm not seeing this in linux-next, or a reply on the web archive. Assuming nobody's objected to this, you might want to forward it to [email protected].

That said, you could describe what it _does_ a little more?

I was expecting Greg to pick up this patch.

Quoted 7 lines
Quoted 3 lines

I thought the description is pretty clear.
What the patch does is changing the init value of deleted variable to 0. The intention of this change is to avoid unnecessary delete_path() call.

I agree the logic is a bit odd here, but are you seeing an "unnecessary" delete_path() call happening? The code has always been like this from what I can tell...

Honestly, I havn't see the "unnecessary" delete_path() call happening druing my test. I look at the code when I was debugging a hangup issue.
(In the end, I think the issue is not related to the devtmpfs code.) But I found the logic for the deleted variable looks odd.
There are below possible (unlikely) case:
When strchr(nodename, '/') != 0 and
1. If dentry->d_inode is NULL
2. vfs_getattr returns error
3. vfs_unlink returns error except -ENOENT.

Quoted 4 lines

In these cases, delete_path() will fail anyway.

Although this is a unlikely case, and I know the code is there since initial commit. But I think it's still good to fix it.

Have you tested your patch to verify nothing breaks?

author
#7 lore raw

2013/12/9 Greg Kroah-Hartman <[email protected]>:

Quoted 40 lines · Axel Lin
Quoted 39 lines

2013/12/9 Greg Kroah-Hartman <[email protected]>:

Quoted 20 lines · Axel Lin
Quoted 19 lines

2013/12/4 Rob Landley <[email protected]>:

Quoted 7 lines · Axel Lin
Quoted 6 lines

The deleted variable is always 1 in current code.
Initialize deleted variable to be 0, so delete_path() will be called only when
necessary.

Quoted 8 lines
Quoted 1 line

I'm not seeing this in linux-next, or a reply on the web archive. Assuming nobody's objected to this, you might want to forward it to [email protected].

That said, you could describe what it _does_ a little more?

I was expecting Greg to pick up this patch.

Quoted 7 lines
Quoted 3 lines

I thought the description is pretty clear.
What the patch does is changing the init value of deleted variable to 0. The intention of this change is to avoid unnecessary delete_path() call.

I agree the logic is a bit odd here, but are you seeing an "unnecessary" delete_path() call happening? The code has always been like this from what I can tell...

Honestly, I havn't see the "unnecessary" delete_path() call happening druing my test. I look at the code when I was debugging a hangup issue.
(In the end, I think the issue is not related to the devtmpfs code.) But I found the logic for the deleted variable looks odd.
There are below possible (unlikely) case:
When strchr(nodename, '/') != 0 and
1. If dentry->d_inode is NULL
2. vfs_getattr returns error
3. vfs_unlink returns error except -ENOENT.

Quoted 6 lines
Quoted 4 lines

In these cases, delete_path() will fail anyway.

Although this is a unlikely case, and I know the code is there since initial commit. But I think it's still good to fix it.

Have you tested your patch to verify nothing breaks?

Yes. I have this patch in my local build image since the day I sent the patch. Regards,
Axel

author
#8 lore raw

2013/12/9 Axel Lin <[email protected]>:

Quoted 41 lines

2013/12/9 Greg Kroah-Hartman <[email protected]>:

Quoted 40 lines · Axel Lin
Quoted 39 lines

2013/12/9 Greg Kroah-Hartman <[email protected]>:

Quoted 20 lines · Axel Lin
Quoted 19 lines

2013/12/4 Rob Landley <[email protected]>:

Quoted 7 lines · Axel Lin
Quoted 6 lines

The deleted variable is always 1 in current code.
Initialize deleted variable to be 0, so delete_path() will be called only when
necessary.

Quoted 8 lines
Quoted 1 line

I'm not seeing this in linux-next, or a reply on the web archive. Assuming nobody's objected to this, you might want to forward it to [email protected].

That said, you could describe what it _does_ a little more?

I was expecting Greg to pick up this patch.

Quoted 7 lines
Quoted 3 lines

I thought the description is pretty clear.
What the patch does is changing the init value of deleted variable to 0. The intention of this change is to avoid unnecessary delete_path() call.

I agree the logic is a bit odd here, but are you seeing an "unnecessary" delete_path() call happening? The code has always been like this from what I can tell...

Honestly, I havn't see the "unnecessary" delete_path() call happening druing my test. I look at the code when I was debugging a hangup issue.
(In the end, I think the issue is not related to the devtmpfs code.) But I found the logic for the deleted variable looks odd.
There are below possible (unlikely) case:
When strchr(nodename, '/') != 0 and
1. If dentry->d_inode is NULL
2. vfs_getattr returns error
3. vfs_unlink returns error except -ENOENT.

Quoted 7 lines
Quoted 6 lines
Quoted 4 lines

In these cases, delete_path() will fail anyway.

Although this is a unlikely case, and I know the code is there since initial commit. But I think it's still good to fix it.

Have you tested your patch to verify nothing breaks?

Yes. I have this patch in my local build image since the day I sent the patch.

Hi Greg,
If you want more testing for this patch to ensure nothing break, I think maybe Fengguang can also help to test it.

Hi, Fengguang
Can you help to add this patch to your test systems? It's a one-line change, you can find the patch at
https://patchwork.kernel.org/patch/3192361/

Regards,
Axel

#9 lore raw
Quoted 4 lines

Hi, Fengguang
Can you help to add this patch to your test systems? It's a one-line change, you can find the patch at
https://patchwork.kernel.org/patch/3192361/

Hi Axel,

Do you have a public git tree? If not, I'd like to take this chance to encourage you to setup one. The best work flow is to create a branch, apply the patch and tell me the git URL and branch name to test.

Thanks,
Fengguang

#10 lore raw
Quoted 10 lines · Fengguang Wu
Quoted 4 lines

Hi, Fengguang
Can you help to add this patch to your test systems? It's a one-line change, you can find the patch at
https://patchwork.kernel.org/patch/3192361/

Hi Axel,

Do you have a public git tree? If not, I'd like to take this chance to encourage you to setup one. The best work flow is to create a branch, apply the patch and tell me the git URL and branch name to test.

Unless you have a bunch of devices added and removed from the system dynamically, you really aren't going to hit this codepath, so I don't think your automated system really is going to help out much here, sorry.

greg k-h