From b584d06cf5d63c0af8a641ca543c28986ec5cf81 Mon Sep 17 00:00:00 2001 From: Arne Jansen Date: Thu, 17 Sep 2015 09:57:35 +0200 Subject: 6253 F_GETLK doesn't always return lock owner Reviewed by: Marcel Telka Reviewed by: Simon Klinkert Approved by: Dan McDonald --- usr/src/uts/common/os/flock.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'usr/src') diff --git a/usr/src/uts/common/os/flock.c b/usr/src/uts/common/os/flock.c index 5dad4abb61..9671b7664d 100644 --- a/usr/src/uts/common/os/flock.c +++ b/usr/src/uts/common/os/flock.c @@ -2099,6 +2099,25 @@ flk_get_first_blocking_lock(lock_descriptor_t *request) } while (lock->l_vnode == vp); } + if (blocker == NULL && request->l_flock.l_type == F_RDLCK) { + /* + * No active lock is blocking this request, but if a read + * lock is requested, it may also get blocked by a waiting + * writer. So search all sleeping locks and see if there is + * a writer waiting. + */ + SET_LOCK_TO_FIRST_SLEEP_VP(gp, lock, vp); + if (lock) { + do { + if (BLOCKS(lock, request)) { + blocker = lock; + break; + } + lock = lock->l_next; + } while (lock->l_vnode == vp); + } + } + if (blocker) { report_blocker(blocker, request); } else -- cgit v1.2.3