[haiku-commits] Change in haiku[master]: bfs: CheckVisitor only deleted nodes on specific errors

  • From: Gerrit <review@xxxxxxxxxxxxxxxxxxx>
  • To: waddlesplash <waddlesplash@xxxxxxxxx>, haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 13 Jun 2020 16:39:24 +0000

From Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>:

Axel Dörfler has uploaded this change for review. ( 
https://review.haiku-os.org/c/haiku/+/2914 ;)


Change subject: bfs: CheckVisitor only deleted nodes on specific errors
......................................................................

bfs: CheckVisitor only deleted nodes on specific errors

* This should prevent erroneously deleting any files in low memory
  situations.
---
M src/add-ons/kernel/file_systems/bfs/CheckVisitor.cpp
1 file changed, 15 insertions(+), 8 deletions(-)



  git pull ssh://git.haiku-os.org:22/haiku refs/changes/14/2914/1

diff --git a/src/add-ons/kernel/file_systems/bfs/CheckVisitor.cpp 
b/src/add-ons/kernel/file_systems/bfs/CheckVisitor.cpp
index 63bafa5..40b4635 100644
--- a/src/add-ons/kernel/file_systems/bfs/CheckVisitor.cpp
+++ b/src/add-ons/kernel/file_systems/bfs/CheckVisitor.cpp
@@ -336,7 +336,8 @@
 CheckVisitor::OpenInodeFailed(status_t reason, ino_t id, Inode* parent,
                char* treeName, TreeIterator* iterator)
 {
-       FATAL(("Could not open inode at %" B_PRIdOFF "\n", id));
+       FATAL(("Could not open inode at %" B_PRIdOFF ": %s\n", id,
+               strerror(reason)));

        if (treeName != NULL)
                strlcpy(Control().name, treeName, B_FILE_NAME_LENGTH);
@@ -346,13 +347,19 @@
        Control().inode = id;
        Control().errors = BFS_COULD_NOT_OPEN;

-       // remove inode from the tree if we can
-       if (parent != NULL && iterator != NULL
-               && (Control().flags & BFS_REMOVE_INVALID) != 0) {
-               Control().status = _RemoveInvalidNode(parent, iterator->Tree(), 
NULL,
-                       treeName);
-       } else
-               Control().status = B_ERROR;
+       // TODO: check other error codes; B_IO_ERROR might be a temporary
+       // issue, so it should be guarded by a force mode
+       if (reason == B_BAD_VALUE || reason == B_BAD_DATA || reason == 
B_IO_ERROR) {
+               // Remove inode from the tree if we can
+               if (parent != NULL && iterator != NULL
+                       && (Control().flags & BFS_REMOVE_INVALID) != 0) {
+                       Control().status = _RemoveInvalidNode(parent, 
iterator->Tree(),
+                               NULL, treeName);
+               } else
+                       Control().status = B_ERROR;
+       } else {
+               Control().status = B_OK;
+       }

        return B_OK;
 }

--
To view, visit https://review.haiku-os.org/c/haiku/+/2914
To unsubscribe, or for help writing mail filters, visit 
https://review.haiku-os.org/settings

Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: I21b1d042e5f7e03a5abfaaa567b6c679b95e3188
Gerrit-Change-Number: 2914
Gerrit-PatchSet: 1
Gerrit-Owner: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Gerrit-MessageType: newchange

Other related posts:

  • » [haiku-commits] Change in haiku[master]: bfs: CheckVisitor only deleted nodes on specific errors - Gerrit