aboutsummaryrefslogtreecommitdiff
path: root/weed/util/bounded_tree/bounded_tree.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-10-13 11:21:13 -0700
committerChris Lu <chris.lu@gmail.com>2020-10-13 11:21:13 -0700
commit9b4f7fed14aa23115b896cc19c909b6c8f8db336 (patch)
tree910adfb5a8758388797b05f19f4b002e934e308c /weed/util/bounded_tree/bounded_tree.go
parent3f7d1d1bf146eaeac3ddcd96e3d8de088bdf97ce (diff)
downloadseaweedfs-9b4f7fed14aa23115b896cc19c909b6c8f8db336.tar.xz
seaweedfs-9b4f7fed14aa23115b896cc19c909b6c8f8db336.zip
mount: report filer IO error
related to https://github.com/chrislusf/seaweedfs/issues/1530
Diffstat (limited to 'weed/util/bounded_tree/bounded_tree.go')
-rw-r--r--weed/util/bounded_tree/bounded_tree.go26
1 files changed, 17 insertions, 9 deletions
diff --git a/weed/util/bounded_tree/bounded_tree.go b/weed/util/bounded_tree/bounded_tree.go
index 0182aeba1..7d4dfb99a 100644
--- a/weed/util/bounded_tree/bounded_tree.go
+++ b/weed/util/bounded_tree/bounded_tree.go
@@ -34,7 +34,7 @@ type VisitNodeFunc func(path util.FullPath) (childDirectories []string, err erro
// No action if the directory has been visited before or does not exist.
// A leaf node, which has no children, represents a directory not visited.
// A non-leaf node or a non-existing node represents a directory already visited, or does not need to visit.
-func (t *BoundedTree) EnsureVisited(p util.FullPath, visitFn VisitNodeFunc) {
+func (t *BoundedTree) EnsureVisited(p util.FullPath, visitFn VisitNodeFunc) (visitErr error){
t.Lock()
defer t.Unlock()
@@ -46,12 +46,17 @@ func (t *BoundedTree) EnsureVisited(p util.FullPath, visitFn VisitNodeFunc) {
}
components := p.Split()
// fmt.Printf("components %v %d\n", components, len(components))
- if canDelete := t.ensureVisited(t.root, t.baseDir, components, 0, visitFn); canDelete {
+ canDelete, err := t.ensureVisited(t.root, t.baseDir, components, 0, visitFn)
+ if err != nil {
+ return err
+ }
+ if canDelete {
t.root = nil
}
+ return nil
}
-func (t *BoundedTree) ensureVisited(n *Node, currentPath util.FullPath, components []string, i int, visitFn VisitNodeFunc) (canDeleteNode bool) {
+func (t *BoundedTree) ensureVisited(n *Node, currentPath util.FullPath, components []string, i int, visitFn VisitNodeFunc) (canDeleteNode bool, visitErr error) {
// println("ensureVisited", currentPath, i)
@@ -73,12 +78,12 @@ func (t *BoundedTree) ensureVisited(n *Node, currentPath util.FullPath, componen
children, err := visitFn(filerPath)
if err != nil {
glog.V(0).Infof("failed to visit %s: %v", currentPath, err)
- return
+ return false, err
}
if len(children) == 0 {
// fmt.Printf(" canDelete %v without children\n", currentPath)
- return true
+ return true, nil
}
n.Children = make(map[string]*Node)
@@ -103,19 +108,22 @@ func (t *BoundedTree) ensureVisited(n *Node, currentPath util.FullPath, componen
}
// fmt.Printf(" ensureVisited %v %v\n", currentPath, toVisitNode.Name)
-
- if canDelete := t.ensureVisited(toVisitNode, currentPath.Child(components[i]), components, i+1, visitFn); canDelete {
+ canDelete, childVisitErr := t.ensureVisited(toVisitNode, currentPath.Child(components[i]), components, i+1, visitFn)
+ if childVisitErr != nil {
+ return false, childVisitErr
+ }
+ if canDelete {
// fmt.Printf(" delete %v %v\n", currentPath, components[i])
delete(n.Children, components[i])
if len(n.Children) == 0 {
// fmt.Printf(" canDelete %v\n", currentPath)
- return true
+ return true, nil
}
}
- return false
+ return false, nil
}