Commit b664de12 authored by Ian Kent's avatar Ian Kent Committed by Suren Baghdasaryan
Browse files

UPSTREAM: kernfs: don't create a negative dentry if inactive node exists

It's been reported that doing stress test for module insertion and
removal can result in an ENOENT from libkmod for a valid module.

In kernfs_iop_lookup() a negative dentry is created if there's no kernfs
node associated with the dentry or the node is inactive.

But inactive kernfs nodes are meant to be invisible to the VFS and
creating a negative dentry for these can have unexpected side effects
when the node transitions to an active state.

The point of creating negative dentries is to avoid the expensive
alloc/free cycle that occurs if there are frequent lookups for kernfs
attributes that don't exist. So kernfs nodes that are not yet active
should not result in a negative dentry being created so when they
transition to an active state VFS lookups can create an associated
dentry is a natural way.

It's also been reported that https://github.com/osandov/blktests.git


test block/001 hangs during the test. It was suggested that recent
changes to blktests might have caused it but applying this patch
resolved the problem without change to blktests.

Fixes: c7e7c042 ("kernfs: use VFS negative dentry caching")
Tested-by: default avatarYi Zhang <yi.zhang@redhat.com>
ACKed-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarIan Kent <raven@themaw.net>
Link: https://lore.kernel.org/r/163330943316.19450.15056895533949392922.stgit@mickey.themaw.net


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>

(cherry picked from commit 410d591a)

Bug: 320903885
Bug: 219424218
Bug: 206126556
Change-Id: Idac756d48eee6e1b88e2c0defb606ce247a1e7a2
Signed-off-by: default avatarSuren Baghdasaryan <surenb@google.com>
parent 50fb8e9e
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment