DragonFly BSD
DragonFly submit List (threaded) for 2004-04
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: [patch] POSIX advisory mode lock panic fix by Dfly


From: Matthew Dillon <dillon@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 20 Apr 2004 12:34:33 -0700 (PDT)

:I'll get a new patch implementing this behavior of an unconditional 
:up/downgrade of the count in lf_alloc() and lf_free(). By ``main 
:switch'', are you referring to the F_[SETLK|GETLK|UNLCK] switch, or the 
:overlap switches found in lf_setlock and lf_clearlock (I'm assuming the 
:latter). More to come later :)
:
:Kind regards,
:
:Devon H. O'Dell

    Yah, the F_XXX switch.   F_SETLK can simply check the count prior to
    setting the lock, and F_UNLCK would have to check it for the split
    case.  What I recommend is something like this (pseudo code):

    res_exceeded = (check if resource is exceeded)

    F_SETLK:
	if (res_exceeded) {
		... fail ...
	} else {
		set the lock normally
	}
	break;
    F_UNLCK:
	/* 
	 * Note: if res_exceeded is non-zero the unlock will fail if it
	 * involves splitting an existing lock structure.
	 */
	error = dotheunlock(..., res_exceeded); 
	break;

    Alternatively as a performance optimization you can write a procedure
    which calculates whether the resource has been exceeded and just embed
    a call to that procedure in just the F_SETLK and F_UNLCK cases.

    F_SETLK:
	if (lf_res_exceeded(ucred)) {
		... fail ...
	} else {
		set the lock normally.
	}
	break;
    F_UNLCK:
	...
	error = dotheunlock(..., lf_res_exceeded(ucred))
	break;

    Again, this is all pseudo code.  Remember that the idea is not 
    necessarily to hit the resource limit 'on the mark', but simply to ensure
    that the resource limit is nominally adhered to.

					-Matt
					Matthew Dillon 
					<dillon@xxxxxxxxxxxxx>



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]