From: David S. <dav...@gm...> - 2007-03-21 14:22:56
|
On 3/21/07, Miklos Szeredi <mi...@sz...> wrote: > > During a single fuse request, I stat() one or more paths (that are not > > handled by my filesystem) to determine information that will allow the > > fuse request to proceed, return -EACCES, etc. Depending on what's > > going on, different functions may stat the same path more than once. > > > > I'd like to cache the results of stat()ing a few paths on a > > per-fuse-request basis. The private_data member of the fuse_context > > seems to be the logical place for this, as follows: > > > > - At the beginning of each function that handles a fuse operation > > (getattr, create, etc.) allocate memory and initialize private_data to > > my struct which will hold the stat info. > > > > - As request processing proceeds, that private_data pointer can be > > obtained from the context (by any function) and read from / written to > > > > - Before the function that is handling the operation returns, it frees > > up the memory allocated for the private_data struct. > > You shouln't use the private_data field for this. > > If you really want some per-request context, and your filesystem is > multithreaded, then just create a thread local storage for yourself > with pthread_key_create(). If the filesystem is single threaded, just > use a global variable. Ah, OK. Thanks for the clarification. Other members of the fuse_context (e.g. pid) are thread/request specific, though, right? (I am assuming that one request is handled by one and only 1 thread -- is that incorrect?) Thanks, David |