EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Callback File System Questions

Also by EldoS: CallbackFilter
A component to monitor and control disk activity, track file and directory operations (create, read, write, rename etc.), alter file data, encrypt files, create virtual files.
#3603
Posted: 08/22/2007 02:17:41
by Ronen Abramov (Basic support level)
Joined: 08/22/2007
Posts: 6

Hi!

We are building a front end to a web-based document management system. We’ve decided to wrap it with virtual drive to provide familiar user expirience and are currently evaluating our device driver options – so I’ve downloaded CFS trial. Since we are talking about document management, the locks and access security issues are very important (for example, we’ll want to assess the system with appropriate user’s credentials, which I assume I can do trough impersonation with “GetOriginatorToken”). Also, since the system itself is on a remote server, concurrency and latency issues are also very important. From what I’ve seen so far, it looks very nice, I do have some questions, though:

• “StorageType” property allows me to set the type of the disk to either removable device or in-memory disk, but it doesn’t provide an option for presenting my FS as a regular local disk. Can this be added?
• When “StorageType” property is set to “stVirtualDisk” the driver handles file locks as expected, but when I set it to “stDisk” it doesn’t handle locks at all. Is it by design and can it be changed?
• Is there an option to return custom message from “OnCanFileBeDeleted” (I’ll need it if I want to implement my own locks management, for example)
• Do you support byte range locks?
• Do you support FastIO operations (I assume it’s related to “UseSystemCache” property?)
• Is it possible to add support for directory change notification (IRP_MJ_DIRECTORY_CONTROL /IRP_MN_NOTIFY_CHANGE_DIRECTORY)?
• Sometimes operations take longer than expected, but I don’t want to set global timeout. Is there an option to use asynchronous processing in callbacks? I.e. – suppose I have to download a file from remote location before I can serve it to user. I want to start a download process in different thread in “OnReadFile” and ask the driver to return “STATUS_PENDING” IRP. Then you’ll either call “OnReadFile” again or I can call driver method to signal completion and serve the file.

10x in advance,
Ronen
#3604
Posted: 08/22/2007 03:52:05
by Eugene Mayevski (EldoS Corp.)

The byte range locks are handled internally and there's no way to "export" them, i.e. let your application handle them. We already had questions about this and we have found no way for this.

As for the other questions, the developer will answer.


Sincerely yours
Eugene Mayevski
#3605
Posted: 08/22/2007 07:02:27
by Volodymyr Zinin (EldoS Corp.)

Quote
Since we are talking about document management, the locks and access security issues are very important (for example, we’ll want to assess the system with appropriate user’s credentials, which I assume I can do trough impersonation with “GetOriginatorToken”). Also, since the system itself is on a remote server, concurrency and latency issues are also very important. From what I’ve seen so far, it looks very nice, I do have some questions, though:

Yes, you can use GetOriginatorToken for checking security access. Also we plan to add two callback routines SetFileSecurity/GetFileSecurity.

Quote
• “StorageType” property allows me to set the type of the disk to either removable device or in-memory disk, but it doesn’t provide an option for presenting my FS as a regular local disk. Can this be added?

Set StorageType property as stDisk.

Quote
• When “StorageType” property is set to “stVirtualDisk” the driver handles file locks as expected, but when I set it to “stDisk” it doesn’t handle locks at all. Is it by design and can it be changed?

It’s a bug. We’ll check this now...

Quote
• Is there an option to return custom message from “OnCanFileBeDeleted” (I’ll need it if I want to implement my own locks management, for example)

You can return any win32 error code from this callback. CallbackFS convert it to an appropriate STATUS_... error code and return to the system.
For example ERROR_ACCESS_DENIED -> STATUS_ACCESS_DENIED

Quote
• Do you support byte range locks?

Yes. But this feature is processed internally by CBFS driver. And as Eugene said above it cannot be processed by the user mode callbacks. Because of it a destination file (that opens in the Create/Open callbacks) should be open for nonshare access (without the flags FILE_SHARE_READ | FILE_SHARE_WRITE). One of the reasons of it - the system cache manager can want at any moment to read/write the data of the file when it performs lazy write or read ahead.

Quote
• Do you support FastIO operations (I assume it’s related to “UseSystemCache” property?)

The FastIO operations are processed internally by the driver.
“UseSystemCache” property has no relation to FastIO. It must be set to TRUE if the user mode callbacks implementation uses the system cache (for example perform the write to a file which was open without FILE_FLAG_NO_BUFFERING flag).

Quote
• Is it possible to add support for directory change notification (IRP_MJ_DIRECTORY_CONTROL­ /IRP_MN_NOTIFY_CHANGE_DIR­ECTORY)?

This feature is processed internally by CBFS driver. But it’s possible to add the routine which will inform CBFS driver that a directory was changed.

Quote
• Sometimes operations take longer than expected, but I don’t want to set global timeout. Is there an option to use asynchronous processing in callbacks? I.e. – suppose I have to download a file from remote location before I can serve it to user. I want to start a download process in different thread in “OnReadFile” and ask the driver to return “STATUS_PENDING” IRP. Then you’ll either call “OnReadFile” again or I can call driver method to signal completion and serve the file.

You can perform the download in a different thread but the callbacks must be processed only synchronously. They are called only when really it is necessary to process them synchronously (i.e. in situations when it’s impossible to return STATUS_PENDING result).
#3608
Posted: 08/22/2007 18:59:08
by Ronen Abramov (Basic support level)
Joined: 08/22/2007
Posts: 6

Hi!

Thank you for quick reply!

Quote
Vladimir Zinin wrote:
Yes, you can use GetOriginatorToken for checking security access. Also we plan to add two callback routines SetFileSecurity/GetFileSe­curity.

That sounds very interesting. Can you elaborate a bit on the functionality and expected timeframe?

Quote
Vladimir Zinin wrote:
Set StorageType property as stDisk.

"stDisk" gives me a removable drive (at least on my Vista machine), which produces some unwanted side effects (For example - Office won't store it's auto recovery files on removable disk, also lazy-writes policy is different on removable disks). I need to simulate a local non-removable drive.

Quote
Vladimir Zinin wrote:
The FastIO operations are processed internally by the driver.
“UseSystemCache” property has no relation to FastIO. It must be set to TRUE if the user mode callbacks implementation uses the system cache (for example perform the write to a file which was open without FILE_FLAG_NO_BUFFERING flag).

Does “UseSystemCache” property tells the driver not to use the Cache Manager? You don't "CcInitializeCacheMap"? Coz that's where I figured the problem would be, and if you don't use Cache Manager, you don't get FastIO. I might be wrong, though - to be honest my device driver skills are a bit rusty :-)

Quote
Vladimir Zinin wrote:
This feature is processed internally by CBFS driver. But it’s possible to add the routine which will inform CBFS driver that a directory was changed.

That would be very usefull! As I mentioned - we are building a redirector type of thingy, so we'll need to provide notifications of changes on the server.

Quote
Vladimir Zinin wrote:
You can perform the download in a different thread but the callbacks must be processed only synchronously. They are called only when really it is necessary to process them synchronously (i.e. in situations when it’s impossible to return STATUS_PENDING result).

I'm not sure I got that correctly. Let me give you a real-life scenario:
I recieve an "OnOpenFile" callback for a file that's not cached locally yet. I begin to download it in a background worker thread. Immidiately after that I recieve an "OnReadFile" callback that asks me for 10 bytes from the end of the file. But the file hasn't finished downloading yet, and it'll only finish in 90 seconds or so. What should I do? Return 0 in "BytesRead"? I need for the client to keep waiting until the file is downloaded, and I don't want to use global timeout property to handle this - that would be obviously wrong.
I'm looking forward to your answer!

Regards,
Ronen Abramov
Software Architect
[URL=http://www.comverse.com]Comverse[/URL]
#3609
Posted: 08/23/2007 05:43:21
by Volodymyr Zinin (EldoS Corp.)

Quote
That sounds very interesting. Can you elaborate a bit on the functionality and expected timeframe?

The two addition callbacks SetFileSecurity/GetFileSecurity will be called when someone in the system will set or request a file security information. For details you can see the documentation for IRP_MJ_SET_SECURITY/ IRP_MJ_GET_SECURITY/ SetSecurityInfo/ GetSecurityInfo in MSDN.
The algorithm for the security support is next:
In the Create/Open callbacks call CbFsGetOriginatorToken function from CBFS API. Obtain the rights for the opened file and compare its with the “originator token” (for example use for it AccessCheck function from the system security API).
In the new SetFileSecurity/GetFileSecurity callbacks set/get file security must be performed.

We are going to implement the new callbacks during a week. Also the addition file data streams feature (like in NTFS) will be added.

Quote
"stDisk" gives me a removable drive (at least on my Vista machine), which produces some unwanted side effects (For example - Office won't store it's auto recovery files on removable disk, also lazy-writes policy is different on removable disks). I need to simulate a local non-removable drive.

Try to set StorageCharacteristics property to 0.

Quote
Does “UseSystemCache” property tells the driver not to use the Cache Manager? You don't "CcInitializeCacheMap"? Coz that's where I figured the problem would be, and if you don't use Cache Manager, you don't get FastIO. I might be wrong, though - to be honest my device driver skills are a bit rusty Smile

No. The driver always uses the Cache Manager features (and FastIO too). But in the case if UseSystemCache property is set to TRUE, the driver performs additional work to avoid dead locks in the system.

Quote
> But it’s possible to add the routine which will inform CBFS driver that a directory was changed.

That would be very usefull! As I mentioned - we are building a redirector type of thingy, so we'll need to provide notifications of changes on the server.

We are going to add it shortly. It will be released together with the above-stated features.

Quote
I'm not sure I got that correctly. Let me give you a real-life scenario: I recieve an "OnOpenFile" callback for a file that's not cached locally yet. I begin to download it in a background worker thread. Immidiately after that I recieve an "OnReadFile" callback that asks me for 10 bytes from the end of the file. But the file hasn't finished downloading yet, and it'll only finish in 90 seconds or so. What should I do? Return 0 in "BytesRead"? I need for the client to keep waiting until the file is downloaded, and I don't want to use global timeout property to handle this - that would be obviously wrong. I'm looking forward to your answer!

You can turn off the timeout (set it to 0). Also there is no necessity to download whole file, you can read only those part that the read callback requests.
If the requested data cannot be read some error code must be returned.
#3612
Posted: 08/23/2007 09:05:46
by Ronen Abramov (Basic support level)
Joined: 08/22/2007
Posts: 6

Quote
Vladimir Zinin wrote:
You can turn off the timeout (set it to 0). Also there is no necessity to download whole file, you can read only those part that the read callback requests.
If the requested data cannot be read some error code must be returned.


  • I dont't want to disable the timeout completely. If I have a problem in my code that will leave the user hanging. Furthermore - if I do disable timeout, the application that is opening the file and the windows explorer are stuck (not responding) for the duration of the operation
  • I can't return the part that the callback is requesting in the above example - it's still on the server and I'll only get it in 90 second. (I can't do seek operations on the server)
  • I don't want to return error coz there isn't one. It just takes time to complete, that's all - it a comlpetely normal thing.

I need a way to:

  • Change/disable timeout for this particular operation - which is also problematic, since it hangs the windows explorer.
  • Or, better yet, to tell driver to wait internally for X seconds and the call "OnReadFile" again


Regards,
Ronen.
#3616
Posted: 08/24/2007 02:49:51
by Volodymyr Zinin (EldoS Corp.)

The file system implementation in windows does not allow to postpone some file operations. Sure it’s possible inside CBFS to realize the asynchronous callbacks processing mechanism, but it will not give any advantage since while any request sent to a callback is not processed, access to the file (to which the request has been sent) from other programs will be blocked. And frequently the reason of this blocking is not CBFS, but some system component (the system cache manager, some driver filter which places above the CBFS file system driver).

Quote
* Or, better yet, to tell driver to wait internally for X seconds and the call "OnReadFile" again

It's possible to make such changes to the timeout processing mechanism. But the restrictions that described above will stay.
#3620
Posted: 08/25/2007 15:13:23
by Ronen Abramov (Basic support level)
Joined: 08/22/2007
Posts: 6

In that case I think I found a bug. If I understood the manual correctly, when I set "SerializeCallbacks" to false, callbacks for each file are called on a separate thread. Which means that in theory I can do all the work in "OnReadFile", even if it takes several minutes and this shouldn't affect access to other files/my virtual disk. In reality, however, when I am inside "OnReadFile" callback, I can't create new folders in Windows Explorer. Browsing and file creation/modification works fine, and creating folders from command prompt is also working, but when I try to create folder from Windows Explorer it get's stuck untill I return from the "OnReadFile" callback. (I've tried it with your VMounter example - I've added the following line to "OnReadFile":
Code
if (FileInfo.FileName == "\\TestFile_2.txt")
                Thread.Sleep(30000);
and then tried to open the file from explorer and then create a new directory immidiately after that.
By the way - if I try to open the "TestFile_2.txt" from command prompt and then create a new folder in Windows Explorer it still gets stuck.

Regards,
Ronen.
#3622
Posted: 08/26/2007 13:10:04
by Eugene Mayevski (EldoS Corp.)

There's no bug there - nobody promised you that each callback is called in a separate thread.


Sincerely yours
Eugene Mayevski
#3627
Posted: 08/27/2007 02:51:44
by Ronen Abramov (Basic support level)
Joined: 08/22/2007
Posts: 6

Actually, you did. Or at least your documentation did:
Quote
... However if there are two pending operations for different files, the callbacks can be called in two ways - either serialized (as described above) or in parallel from two different threads. The default behaviour is to call the callbacks in parallel, and this can be changed to sequential call using SerializeCallbacks property...
([URL=http://eldos.com/documentation/cbfs/ref_gen_thread_safety.html]Thread safety[/URL])


Regards,
Ronen
Also by EldoS: Solid File System
A virtual file system that offers a feature-rich storage for application documents and data with built-in compression and encryption.

Reply

Statistics

Topic viewed 24375 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!