mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-28 22:54:05 +08:00
RDMA/rnbd: Fix compilation error when CONFIG_MODULES is disabled
module_is_live function is only defined when CONFIG_MODULES is enabled.
Use try_module_get instead to check whether the module is being removed.
When module unload and manuall unmapping is happening in parallel, we can
try removing the symlink twice: rnbd_client_exit
vs. rnbd_clt_unmap_dev_store.
This is probably not the best way to deal with this race in general, but
for now this fixes the compilation issue when CONFIG_MODULES is disabled
and has no functional impact. Regression tests passed.
Fixes: 1eb54f8f5d
("block/rnbd: client: sysfs interface functions")
Link: https://lore.kernel.org/r/20200521185909.457245-1-danil.kipnis@cloud.ionos.com
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Suggested-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
Signed-off-by: Danil Kipnis <danil.kipnis@cloud.ionos.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
This commit is contained in:
parent
63a3345c2d
commit
cdb685cb91
@ -428,12 +428,15 @@ static struct attribute *rnbd_dev_attrs[] = {
|
||||
void rnbd_clt_remove_dev_symlink(struct rnbd_clt_dev *dev)
|
||||
{
|
||||
/*
|
||||
* The module_is_live() check is crucial and helps to avoid annoying
|
||||
* sysfs warning raised in sysfs_remove_link(), when the whole sysfs
|
||||
* path was just removed, see rnbd_close_sessions().
|
||||
* The module unload rnbd_client_exit path is racing with unmapping of
|
||||
* the last single device from the sysfs manually
|
||||
* i.e. rnbd_clt_unmap_dev_store() leading to a sysfs warning because
|
||||
* of sysfs link already was removed already.
|
||||
*/
|
||||
if (strlen(dev->blk_symlink_name) && module_is_live(THIS_MODULE))
|
||||
if (strlen(dev->blk_symlink_name) && try_module_get(THIS_MODULE)) {
|
||||
sysfs_remove_link(rnbd_devs_kobj, dev->blk_symlink_name);
|
||||
module_put(THIS_MODULE);
|
||||
}
|
||||
}
|
||||
|
||||
static struct kobj_type rnbd_dev_ktype = {
|
||||
|
Loading…
Reference in New Issue
Block a user