Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting Windows Cache Manager to work with Dokan.NET #365

Open
lostmsu opened this issue Jan 4, 2025 · 6 comments
Open

Getting Windows Cache Manager to work with Dokan.NET #365

lostmsu opened this issue Jan 4, 2025 · 6 comments

Comments

@lostmsu
Copy link
Contributor

lostmsu commented Jan 4, 2025

It looks like in order to tap into the cache manager PFILE_OBJECT is required, but IDokanOperations and IDokanFileInfo don't have that exposed.

@LTRData
Copy link
Contributor

LTRData commented Jan 4, 2025

A pointer to FILE_OBJECT can only be used in kernel mode because that memory is only accessible in kernel mode. Therefore, it cannot be directly exposed to file systems implemented in user mode. Other workarounds would be needed to modify things that needs to be modified in the FILE_OBJECT structure.

So, more specifically, what is it that you want to do with the FILE_OBJECT structure?

@lostmsu
Copy link
Contributor Author

lostmsu commented Jan 4, 2025

@LTRData I just wanted to see if it was possible to tap into Windows caching system as suggested here: dokan-dev/dokany#1214

E.g. be able to call CcInitializeCacheMap etc

@LTRData
Copy link
Contributor

LTRData commented Jan 4, 2025

Yes, that would need several changes in the driver to work together with user mode implementation. There was a discussion about it here dokan-dev/dokany#1047 where @Liryna mentioned some ideas about how it could be implemented. However, as mentioned there, keeping cache invalidation correct and robust is not really a trivial task.

@lostmsu
Copy link
Contributor Author

lostmsu commented Jan 5, 2025

My particular scenario is remote-mounting immutable filesystems ( e.g. a disk image, btw, thanks for https://www.nuget.org/packages/LTRData.DiscUtils.Wim ). So no invalidation should be required except upon the unmount

@Liryna
Copy link
Member

Liryna commented Jan 5, 2025

Windows Cache Manager support can only be implemented in Dokan driver (using CcInitializeCacheMap and other Cc* APIs). It would be the best and does handle cache invalidation if the userland implementation usex the existing API but yes it must do it correctly or data corruption can happen.

The other solution is the userland filesystem implementation to build (read ahead) and own the cache so it can be faster at completing requests.
This is not the fastest compared to Windows Cache Manager since Windows Cache Manager in some case IIRC fetch data directly from the cache without even asking Dokan driver.
Userland caching has the same complexity with the cache invalidation.

@lostmsu In your scenario if the content is immutable, maybe loading the content in userland memory is acceptable ?

@lostmsu
Copy link
Contributor Author

lostmsu commented Jan 5, 2025

Unfortunately no, the whole scenario is about streaming only what's really needed.

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

No branches or pull requests

3 participants