[PATCH 15/20] btrfs: Go readonly on missing ref in btrfs_get_parent()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Mark Fasheh <mfasheh@xxxxxxxx>

btrfs_get_parent() searches the btree for a ref to the current object. From
there it can compute the parent objectid from which it can return a dentry.
if the reference is not found in the tree however, we BUG(). I believe a
more appropriate response would be to go read-only as this seems like a
corruption.

Signed-off-by: Mark Fasheh <mfasheh@xxxxxxxx>
---
 fs/btrfs/export.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/export.c b/fs/btrfs/export.c
index 1b8dc33..a335169 100644
--- a/fs/btrfs/export.c
+++ b/fs/btrfs/export.c
@@ -193,7 +193,13 @@ static struct dentry *btrfs_get_parent(struct dentry *child)
 	if (ret < 0)
 		goto fail;
 
-	BUG_ON(ret == 0);
+	if (ret == 0) {
+		/* Missing ref, should go readonly. */
+		ret = -ENOENT;
+		btrfs_std_error(root->fs_info, ret);
+		goto fail;
+	}
+
 	if (path->slots[0] == 0) {
 		ret = -ENOENT;
 		goto fail;
-- 
1.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux