Skip to content

Commit

Permalink
Close block devices in a synchronous manner
Browse files Browse the repository at this point in the history
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

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
  • Loading branch information
mmichal10 committed Jul 23, 2024
1 parent eb97598 commit 3079f60
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion configure.d/1_bdev_release.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ check() {
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"
elif compile_module $cur_name "bdev_file_open_by_path(NULL, 0, NULL, NULL);__fput_sync(NULL);" "linux/blkdev.h"
then
echo $cur_name 4 >> $config_file_path
elif compile_module $cur_name "bdev_file_open_by_path(NULL, 0, NULL, NULL);" "linux/blkdev.h"
then
echo $cur_name 5 >> $config_file_path
else
echo $cur_name X >> $config_file_path
fi
Expand All @@ -40,6 +43,9 @@ apply() {
add_define "cas_bdev_release(handle, mode, holder) \\
bdev_release(handle)" ;;
"4")
add_define "cas_bdev_release(handle, mode, holder) \\
__fput_sync(handle)" ;;
"5")
add_define "cas_bdev_release(handle, mode, holder) \\
fput(handle)" ;;
*)
Expand Down

0 comments on commit 3079f60

Please sign in to comment.