Nice range comparison.

MFC after:	3 days
This commit is contained in:
Pawel Jakub Dawidek 2012-02-11 16:41:52 +00:00
parent e65d028196
commit 86b914642c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=231525

View File

@ -128,15 +128,13 @@ bool
rangelock_islocked(struct rangelocks *rls, off_t offset, off_t length)
{
struct rlock *rl;
off_t end;
PJDLOG_ASSERT(rls->rls_magic == RANGELOCKS_MAGIC);
end = offset + length;
TAILQ_FOREACH(rl, &rls->rls_locks, rl_next) {
if (rl->rl_start >= offset && rl->rl_start < offset + length)
break;
else if (rl->rl_end > offset && rl->rl_end <= offset + length)
break;
else if (rl->rl_start < offset && rl->rl_end > offset + length)
if (rl->rl_start < end && rl->rl_end > offset)
break;
}
return (rl != NULL);