mirror of
https://github.com/kdave/btrfs-progs
synced 2025-02-17 02:06:51 +00:00
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>
This commit is contained in:
parent
d6ab2fdca4
commit
becd520b5c
15
cmds-check.c
15
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.
|
||||
@ -6820,6 +6815,16 @@ static struct extent_entry *find_most_right_entry(struct list_head *entries)
|
||||
if (entry->broken == entry->count)
|
||||
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.
|
||||
|
Loading…
Reference in New Issue
Block a user