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

看板DFBSD_submit作者時間21年前 (2004/04/21 12:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/17 (看更多)
: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@backplane.com>
文章代碼(AID): #10XV8700 (DFBSD_submit)
討論串 (同標題文章)
文章代碼(AID): #10XV8700 (DFBSD_submit)