summaryrefslogtreecommitdiff
path: root/cmds-check.c
diff options
context:
space:
mode:
authorGoldwyn Rodrigues <rgoldwyn@suse.de>2016-11-10 09:01:46 -0600
committerDavid Sterba <dsterba@suse.com>2016-11-23 10:49:31 +0100
commitbecd520b5cc5a9cbb8ca70250c8ebf09bae28eb0 (patch)
treec3f93885ecaf0583ac4407ce97ecc39677db2f42 /cmds-check.c
parentd6ab2fdca495b98e497f21f277dadba834e2199b (diff)
btrfs-progs: return best entry, if it is the first one
The find_most_right_entry() tends to miss on the best entry if it is the first one on the list and there are only two entries in the list. So, we assign both prev and best to entry. To do this, the selection process (rather the rejection) has to be performed earlier to skip on broken==count. Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'cmds-check.c')
-rw-r--r--cmds-check.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/cmds-check.c b/cmds-check.c
index 57c43005..e28ad2f7 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -6808,11 +6808,6 @@ static struct extent_entry *find_most_right_entry(struct list_head *entries)
struct extent_entry *entry, *best = NULL, *prev = NULL;
list_for_each_entry(entry, entries, list) {
- if (!prev) {
- prev = entry;
- continue;
- }
-
/*
* If there are as many broken entries as entries then we know
* not to trust this particular entry.
@@ -6821,6 +6816,16 @@ static struct extent_entry *find_most_right_entry(struct list_head *entries)
continue;
/*
+ * Special case, when there are only two entries and 'best' is
+ * the first one
+ */
+ if (!prev) {
+ best = entry;
+ prev = entry;
+ continue;
+ }
+
+ /*
* If our current entry == best then we can't be sure our best
* is really the best, so we need to keep searching.
*/