19362: Move non-S3 collection-addressed reqs to sitefs code path.
[arvados.git] / sdk / go / arvados / fs_base.go
index 2ad4d1f859f1141035c04cb4180c5ef623d1fa04..b0096140cecec46bc50831a3e78abfcf1394c61d 100644 (file)
@@ -631,7 +631,15 @@ func (fs *fileSystem) Rename(oldname, newname string) error {
        }
        locked := map[sync.Locker]bool{}
        for i := len(needLock) - 1; i >= 0; i-- {
-               if n := needLock[i]; !locked[n] {
+               n := needLock[i]
+               if fs, ok := n.(FileSystem); ok {
+                       // Lock the fs's root dir directly, not
+                       // through the fs. Otherwise our "locked" map
+                       // would not reliably prevent double-locking
+                       // the fs's root dir.
+                       n = fs.rootnode()
+               }
+               if !locked[n] {
                        n.Lock()
                        defer n.Unlock()
                        locked[n] = true