
fput() doesn't wait for all references on the disk to be unclaimed but instead it only schedules a worker that is supposed to cleanup resources once the device is released. During cache initialization we open device at least twice - to check its properties and then to actually use it as cache. But since we use the async fput() after the probe, the device might still be in use once we try to open it for the second time (the second open returns -EBUSY). Using synchronous __fput_sync() to close the device fixes the issue __fput_sync() exists in the kernel API longer than bdev_file_open_by_path() and the presence of the latter is the condition to use the synchronous put so it is perfectly safe to get rid of fput() from the configure framework Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
51 lines
1.2 KiB
Bash
51 lines
1.2 KiB
Bash
#!/bin/bash
|
|
#
|
|
# Copyright(c) 2012-2022 Intel Corporation
|
|
# Copyright(c) 2024 Huawei Technologies
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
#
|
|
|
|
. $(dirname $3)/conf_framework.sh
|
|
|
|
|
|
check() {
|
|
cur_name=$(basename $2)
|
|
config_file_path=$1
|
|
if compile_module $cur_name "blkdev_put(NULL, FMODE_READ);" "linux/blkdev.h"
|
|
then
|
|
echo $cur_name 1 >> $config_file_path
|
|
elif compile_module $cur_name "blkdev_put(NULL, NULL);" "linux/blkdev.h"
|
|
then
|
|
echo $cur_name 2 >> $config_file_path
|
|
elif compile_module $cur_name "bdev_release(NULL);" "linux/blkdev.h"
|
|
then
|
|
echo $cur_name 3 >> $config_file_path
|
|
elif compile_module $cur_name "bdev_file_open_by_path(NULL, 0, NULL, NULL);" "linux/blkdev.h"
|
|
then
|
|
echo $cur_name 4 >> $config_file_path
|
|
else
|
|
echo $cur_name X >> $config_file_path
|
|
fi
|
|
}
|
|
|
|
apply() {
|
|
case "$1" in
|
|
"1")
|
|
add_define "cas_bdev_release(handle, mode, holder) \\
|
|
blkdev_put((struct block_device *)handle, mode)" ;;
|
|
"2")
|
|
add_define "cas_bdev_release(handle, mode, holder) \\
|
|
blkdev_put((struct block_device *)handle, holder)" ;;
|
|
"3")
|
|
add_define "cas_bdev_release(handle, mode, holder) \\
|
|
bdev_release(handle)" ;;
|
|
"4")
|
|
add_define "cas_bdev_release(handle, mode, holder) \\
|
|
__fput_sync(handle)" ;;
|
|
*)
|
|
exit 1
|
|
esac
|
|
}
|
|
|
|
conf_run $@
|