From: Greg Farnum Date: Tue, 27 Apr 2010 00:10:52 +0000 (-0700) Subject: mds: fnctl. add get_waiting_overlaps function; fix get_overlapped locks X-Git-Tag: v0.22~346^2~33 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e41056ac5a740c3eb74e7f967e43d8dcd4cb15aa;p=ceph.git mds: fnctl. add get_waiting_overlaps function; fix get_overlapped locks so that it won't do bad things if there aren't any. --- diff --git a/src/mds/mdstypes.h b/src/mds/mdstypes.h index bf5c73977adf..cc4c23e1e3ba 100644 --- a/src/mds/mdstypes.h +++ b/src/mds/mdstypes.h @@ -582,8 +582,8 @@ private: list& overlaps) { multimap<__u64, ceph_filelock>::iterator iter = get_last_before(lock.start + lock.length - 1, held_locks); - bool cont = true; - do { + bool cont = iter != held_locks.end(); + while(cont) { if (share_space(iter, lock)) { overlaps.push_front(&iter->second); } @@ -592,7 +592,26 @@ private: cont = false; } else if (held_locks.begin() == iter) cont = false; else --iter; - } while (cont); + } + return !overlaps.empty(); + } + + /** + * Get a list of all waiting locks that overlap with the given lock's range. + * lock: specifies the range to compare with + * overlaps: an empty list, to be filled + * Returns: true if at least one waiting_lock overlaps + */ + bool get_waiting_overlaps(ceph_filelock& lock, + list& overlaps) { + multimap<__u64, ceph_filelock>::iterator iter = + get_last_before(lock.start + lock.length - 1, waiting_locks); + bool cont = iter != held_locks.end(); + while(cont) { + if (share_space(iter, lock)) overlaps.push_front(&iter->second); + if (held_locks.begin() == iter) cont = false; + --iter; + } return !overlaps.empty(); }