Skip to content

Conversation

@hsitter
Copy link

@hsitter hsitter commented Aug 7, 2025

seems to fix various deadlock scenarios when writing in windows 11

what appears to happen is that ccflush magically acquires locks if we don't acquire them explicitly. this then results in a deadlock where the ccflush thread is holding the lock and waiting for writing to happen (somewhere inside CcFlushCacheOneRange). meanwhile one of our threads is stuck waiting for the lock (somewhere inside drv_write).

(I am not super sure that is the right thing to do, but looking at ext4fsd it also implements these functions with actual acquire and release. also I don't understand the implications of FSRTL_CACHE_TOP_LEVEL_IRP)

@maharmstone
Copy link
Owner

Nice work. I'll have to double-check, but it certainly sounds plausible. It's also similar to what fastfat does (https://github.com/microsoft/Windows-driver-samples/blob/main/filesys/fastfat/resrcsup.c#L711).

@SandeMC
Copy link

SandeMC commented Sep 19, 2025

Is there any plans to merge this anytime soon? Or at least somebody posting a version of the driver with this fix - it's extremely unbearable.

seems to fix various deadlock scenarios when writing in windows 11

what appears to happen is that ccflush magically acquires locks if we
don't acquire them explicitly. this then results in a deadlock where the
ccflush thread is holding the lock and waiting for writing to happen
(somewhere inside CcFlushCacheOneRange). meanwhile one of our threads is
stuck waiting for the lock (somewhere inside drv_write).
@hsitter hsitter force-pushed the work/sitter/deadlock branch from de0d57f to 0f4eca1 Compare September 19, 2025 16:24
@hsitter
Copy link
Author

hsitter commented Sep 19, 2025

I came to realize that locking blockingly is probably smarter here, I've seen some programs error out otherwise (notably the game guildwars2 throws exceptions consistently with the original revision). Revised the commit accordingly and rebased.

@queenbiscuit311
Copy link

queenbiscuit311 commented Oct 24, 2025

image

I'm trying to build this branch but I just get this error, I can find absolutely zero info about how to get these libraries. it's almost like zstd is missing these 2 libraries specifically, or they've been removed recently? Get this both via cross-compile on linux and in VS 2022, no idea what i'm supposed to do here

@queenbiscuit311
Copy link

queenbiscuit311 commented Oct 24, 2025

Okay, for some reason git submodule update just wouldn't work at all, so it was just leaving the src folders for zlib and zstd empty. I had to clone with recursive and now the libraries are actually there. don't know why i didn't think to actually check the src folder.

@queenbiscuit311
Copy link

Still having a very hard time getting it to build, do you have a binary version you could publish? really doesn't seem like this is getting merged anytime soon

@GiggityGoo-85
Copy link

GiggityGoo-85 commented Oct 25, 2025

Still having a very hard time getting it to build, do you have a binary version you could publish? really doesn't seem like this is getting merged anytime soon

To get it to build I had to edit fileinfo.c, specifically the #ifndef _MSC_VER section to force it to define the various structures to stop getting the "undeclared identifiers" errors since it didn't want to pass the #ifndef _MSC_VER check for some reason. I managed to compile it finally and it seems to work well. At least it doesn't hard lock on large/numerous files anymore, but I did get an occasional crash. The issue was hard to pinpoint and only occurred about twice over a day's worth of shifting large amounts of data around between several drives and partitions. Publishing a binary would be difficult. Windows 11 requires drivers to be signed. In this case, I had to self-sign it since I don't have a developer certificate to sign with. Then you have to enable test mode in Windows to allow self-signed drivers and that has a hard requirement of disabling Secure Boot. Given all that, you'd have to import my certificate and then install the driver, which is basically a security no-no. Even publishing the unsigned driver, you'd have to go through the trouble of creating the manifest to go in the cab file, the cab file itself, sign the .cab and the .sys with your own certificate after creating and importing it to the Trusted Root Authority store and you'd still be in the same position of trusting an unconfirmed binary.

I posted the edited section of fileinfo.c on the issue you opened.

@queenbiscuit311
Copy link

queenbiscuit311 commented Oct 25, 2025

I see. I'll definitely try it out but using test mode isn't exactly feasible for me since most anti-cheats hate it. I really hope that the maintainer merges this pull request because the locking issue is really bad and has caused me to reinstall windows on 4 separate occasions since 24h2 came out before I realized that it had to be this driver causing the issue. Since I have steam and indexing and other programs that are using the btrfs drives, my computer is liable to completely stop functioning randomly if left on for more than like ~a day currently. looking around it seems to manifest differently on different people's setups but i haven't seen anyone on 24h2 and above that says it hasn't affected them. 23h2 also reaches EOL next month so just using that won't be a solution for long, after that the only actively maintained version of windows where this driver won't cause hard system freezes is Windows 10 LTSC

@imshinyu
Copy link

I see. I'll definitely try it out but using test mode isn't exactly feasible for me since most anti-cheats hate it. I really hope that the maintainer merges this pull request because the locking issue is really bad and has caused me to reinstall windows on 4 separate occasions since 24h2 came out before I realized that it had to be this driver causing the issue. Since I have steam and indexing and other programs that are using the btrfs drives, my computer is liable to completely stop functioning randomly if left on for more than like ~a day currently. looking around it seems to manifest differently on different people's setups but i haven't seen anyone on 24h2 and above that says it hasn't affected them. 23h2 also reaches EOL next month so just using that won't be a solution for long, after that the only actively maintained version of windows where this driver won't cause hard system freezes is Windows 10 LTSC

windows 10 pro 22h2 freezes too with this driver when copying large files

@GiggityGoo-85
Copy link

I'll definitely try it out but using test mode isn't exactly feasible for me since most anti-cheats hate it.

My only solution for that was to install those games on a NTFS partition and disable test mode when I want to play those games in particular. So everything for the most part is on BTRFS and then the anti-cheat games are on NTFS and I have bat scripts to enable/disable test mode and initiate a reboot. Not ideal, but it works. Except for games that require Secure Boot like I've heard that Battlefield 6 does. Enabling/disabling Secure Boot for a particular game is a bit onerous.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants