From cc7ac0f551d1d50b7532008afdeb3e5919a09a7e Mon Sep 17 00:00:00 2001 From: Michal Mielewczyk Date: Tue, 23 Jul 2024 11:41:02 +0200 Subject: [PATCH] Close block devices in a synchronous manner 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 --- configure.d/1_bdev_release.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.d/1_bdev_release.conf b/configure.d/1_bdev_release.conf index 1425ebf..8a1a643 100644 --- a/configure.d/1_bdev_release.conf +++ b/configure.d/1_bdev_release.conf @@ -41,7 +41,7 @@ apply() { bdev_release(handle)" ;; "4") add_define "cas_bdev_release(handle, mode, holder) \\ - fput(handle)" ;; + __fput_sync(handle)" ;; *) exit 1 esac