]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Fix linux_destroy_dev() behaviour when there are still files open from
authorkib <kib@FreeBSD.org>
Sun, 30 Dec 2018 15:46:45 +0000 (15:46 +0000)
committerkib <kib@FreeBSD.org>
Sun, 30 Dec 2018 15:46:45 +0000 (15:46 +0000)
commit855498f6718967f982b6ea980db99b0f567da2ae
tree911a69f10f6381c8e2e388ddcf3591d4650a10a5
parent75010b9ec7383db3c352e3c129c9860d81ddf122
Fix linux_destroy_dev() behaviour when there are still files open from
the destroying cdev.

Currently linux_destroy_dev() waits for the reference count on the
linux cdev to drain, and each open file hold the reference.
Practically it means that linux_destroy_dev() is blocked until all
userspace processes that have the cdev open, exit.  FreeBSD devfs does
not have such problem, because device refcount only prevents freeing
of the cdev memory, and separate 'active methods' counter blocks
destroy_dev() until all threads leave the cdevsw methods.  After that,
attempts to enter cdevsw methods are refused with an error.

Implement somewhat similar mechanism for LinuxKPI cdevs.  Demote cdev
refcount to only mean a hold on the linux cdev memory.  Add sirefs
count to track both number of threads inside the cdev methods, and for
single-bit indicator that cdev is being destroyed.  In the later case,
the call is redirected to the dummy cdev.

Reviewed by: markj
Discussed with: hselasky
Tested by: zeising
MFC after: 1 week
Sponsored by: Mellanox Technologies
Differential revision: https://reviews.freebsd.org/D18606
sys/compat/linuxkpi/common/include/linux/cdev.h
sys/compat/linuxkpi/common/src/linux_compat.c