[ARVADOS] updated: 8cc51c761385bd6acc5dbaf7e95994e916ca0d0d

Git user git at public.curoverse.com
Tue May 16 13:14:09 EDT 2017


Summary of changes:
 services/keepstore/volume.go | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

       via  8cc51c761385bd6acc5dbaf7e95994e916ca0d0d (commit)
      from  74544f439360e3ece1d7609d76eb47bb4cf41faf (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 8cc51c761385bd6acc5dbaf7e95994e916ca0d0d
Author: Tom Clegg <tom at curoverse.com>
Date:   Tue May 16 13:11:45 2017 -0400

    11644: Replace linear search with map for looking up mounts by UUID.

diff --git a/services/keepstore/volume.go b/services/keepstore/volume.go
index 0b4bec4..d23fcc8 100644
--- a/services/keepstore/volume.go
+++ b/services/keepstore/volume.go
@@ -302,6 +302,7 @@ func (*VolumeMount) generateUUID() string {
 // (where writables are all Volumes v where v.Writable()==true).
 type RRVolumeManager struct {
 	mounts    []*VolumeMount
+	mountMap  map[string]*VolumeMount
 	readables []Volume
 	writables []Volume
 	counter   uint32
@@ -313,6 +314,7 @@ func MakeRRVolumeManager(volumes []Volume) *RRVolumeManager {
 	vm := &RRVolumeManager{
 		iostats: make(map[Volume]*ioStats),
 	}
+	vm.mountMap = make(map[string]*VolumeMount)
 	for _, v := range volumes {
 		mnt := &VolumeMount{
 			UUID:     (*VolumeMount)(nil).generateUUID(),
@@ -328,6 +330,7 @@ func MakeRRVolumeManager(volumes []Volume) *RRVolumeManager {
 		}
 		vm.iostats[v] = &ioStats{}
 		vm.mounts = append(vm.mounts, mnt)
+		vm.mountMap[mnt.UUID] = mnt
 		vm.readables = append(vm.readables, v)
 		if v.Writable() {
 			vm.writables = append(vm.writables, v)
@@ -341,12 +344,11 @@ func (vm *RRVolumeManager) Mounts() []*VolumeMount {
 }
 
 func (vm *RRVolumeManager) Lookup(uuid string, needWrite bool) Volume {
-	for _, mnt := range vm.mounts {
-		if mnt.UUID == uuid && (!needWrite || !mnt.ReadOnly) {
-			return mnt.volume
-		}
+	if mnt, ok := vm.mountMap[uuid]; ok && (!needWrite || !mnt.ReadOnly) {
+		return mnt.volume
+	} else {
+		return nil
 	}
-	return nil
 }
 
 // AllReadable returns an array of all readable volumes

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list