EldoS | Feel safer!

Software components for data protection, secure storage and transfer

File attribute caching issue

Also by EldoS: SecureBlackbox
200+ components and classes for digital security, signing, encryption and secure networking.
Posted: 03/24/2009 14:19:00
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

OK, but what about calling NotifyDirectoryChange for every GetFileInfo request?
Posted: 03/24/2009 14:29:19
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

Never mind! I just tried that and it caused bad things to happen.
Posted: 03/24/2009 15:31:38
by Volodymyr Zinin (Team)

It is better to call NotifyDirectoryChange as far as possible, right after a file has been changed not through CallbackFS. And it's preferable to call it not from the callbacks (so the NotifyDirectoryChange will be called synchronously). In this case representation of the file via CallbackFS will be in an actual state all the time.
Calling the function from the callbacks in you case seems doesn't help because it will be called asynchronously, but you need the immediate result. Try to disable the meta data cache (see the function DisableMetaDataCache for details). At least this resolve the problem for currently non-opened (via CallbackFS) files. For files that are already opened you can try (in a case if a file is modified from outside) to call NotifyDirectoryChange from OnOpen/OnRead/OnWrite/... callbacks and finish the callback with an error. Later you will obtain OnGetFileInfo callback and in it specify a new iformation for the file.
Posted: 03/24/2009 16:48:05
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

Thank you for all the good information you have provided.

We are investigating ways of calling the NotifyDirectoryChange function at a more appropriate time rather than in the OnRead callback.

We are not too hot on the idea of messing with the MetaDataCache, so that solution we probably will not investigate.

I have already implemented the throwing of an error in the OnRead callback after issuing the NotifyDirectoryChange and that works fine, the only problem with it is that the user of the application gets an error the first time he tries to read the file, but then everything works OK after that. That is not too much of an inconvenience, but we would like it to be more transparent and not have to annoy the user with that first error. I will let you know whether we succeed. At this point it really is up to us to find the appropriate place in our code to issue the NotifyDirectoryChange.

Again, thank you for all your time and energy on helping us with this problem, I will let you know soon what the outcome of our investigations is.
Posted: 03/25/2009 17:01:12
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

We identified a good place to call the NotifyDirectoryChange and now the application works the way we want it to. If an outside entity changes the size of the object in our database system, the Windows system gets notified and the next time a Windows application tries to read the file it reads the correct number of bytes.

Thank you again for all your help, you rock!
Posted: 03/26/2009 15:33:16
by Brendan Lelieveld-Amiro (Standard support level)
Joined: 02/04/2009
Posts: 7

Hi Schipper

Is it possible to tell me where is the best place you find ?

Posted: 03/26/2009 17:21:27
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

Well, what we did may or may not apply to your application.

In the OnGetFileInfo callback we call a routine from our database system that gets the database system's information for the virtual file and passes it to Windows.

In our database system we also have a file cache, like the Windows file cache, so our system has the size of the file from the last time we cached it and also the latest file size. If those two are different, we call NotifyDirectoryChange, because it means that since the last time we cached the file, someone changed it.

The call actually is within the GetFileInfo callback, but that does not seem to be a problem, as it seems to take effect right away, even though Vladimir said it was done asynchronously, I could not see evidence of that.

I hope this helps you. Please let me know if you'd like me to explain it any further.
Posted: 03/27/2009 08:49:31
by Brendan Lelieveld-Amiro (Standard support level)
Joined: 02/04/2009
Posts: 7

Hi Schipper

So still you are calling NotifyDirectoryChange from a callback function.
I also calling it in the same way with no error.

thanks for explanation.
Posted: 04/02/2009 13:37:30
by Kurt Griffiths (Standard support level)
Joined: 12/08/2008
Posts: 34

We were calling NotifyDirectoryChange on a background worker thread to fix this, but I noticed there is a DisableMetaDataCache call in CBFS 2.5. Would that be another solution to this problem?
Posted: 04/03/2009 01:41:55
by Volodymyr Zinin (Team)

It's preferable to use NotifyDirectoryChange instead of DisableMetaDataCache. The meta data cache significantly decrease quantity of the GetFileInformation callback for files that are reopened.
Also by EldoS: BizCrypto
Components for BizTalk® and SQL Server® Integration Services that let you securely store and transfer information in your business automation solutions.



Topic viewed 24838 times

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


Back to top

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

Got it!