James Carlson wrote:

>Rich.Brown at Sun.COM writes:
>  
>
>>     The first two new flags to be defined:
>>     #define CC_WOULDBLOCK   0x1     /* set upon return by monitor */
>>     #define CC_DONTBLOCK    0x2     /* set by caller */
>>
>>     The caller sets CC_DONTBLOCK in cc_flags to direct the monitor not to
>>     perform an operation that might block.  In the case where a monitor would
>>     perform a blocking operation and CC_DONTBLOCK is set, the monitor
>>     sets CC_WOULDBLOCK in the cc_flags and returns EAGAIN to the caller.
>>    
>>
>
>I'm not sure I understand how this is intended to be used.
>  
>
It is intended to be used by callers that do not want to block inside a 
monitor while waiting for a delegation to be returned.

>What exactly is the caller supposed to do when he gets CC_WOULDBLOCK?
>  
>
I'm not certain that there is a general rule to follow here, however, I 
can give you examples of what NFS does.  Each version of the NFS server 
will use the CC_DONTBLOCK flag on calls to VOP_READ, VOP_WRITE, 
VOP_SETATTR, and (in the case of v4) VOP_OPEN.  When a monitor on a 
delegated file detects a conflict in one of the ops, it will issue a 
recall of the delegation and then check to see if the CC_DONTBLOCK flag 
is set.  If it is set, it will then set the CC_WOULDBLOCK flag and 
return EAGAIN.  When the NFSv2 server gets this, it will simply drop the 
response, causing the client to reissue the request.  When the NFSv3 
server gets the EAGAIN w/CC_WOULDBLOCK, it will return the error 
NFS3ERR_JUKEBOX to the client.  The NFSv3 client knows to retry when it 
sees this error.  The NFSv4 server will return NFS4ERR_DELAY when it 
gets this error from the monitor.

>How long should he wait before trying again?  Or is it always possible
>to detect this case and defer the operation until at can be run
>without CC_DONTBLOCK?
>
>  
>
The way the NFSv2&v3 server currently work is to use cross calls into 
the NFSv4 server to check if a file is delegated.  If so, the delegation 
is recalled and the v2 & v3 server do what is described above.  The 
reason for this fast track is to allow us to remove those cross calls 
from the v2 & v3 server and have all conflict detection handled by the 
monitors.

The point is, the only caller that will use these flags are ones that 
are built to handle it.  That is, if they get EAGAIN, they have a 
mechanism for retrying.

I hope this helped.

Jim


Reply via email to