linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Return best entry, if it is the first one
@ 2016-11-10 15:01 Goldwyn Rodrigues
  2016-11-10 15:01 ` [PATCH] btrfs-progs: Fix extents after finding all errors Goldwyn Rodrigues
  2016-11-11 12:34 ` [PATCH] Return best entry, if it is the first one David Sterba
  0 siblings, 2 replies; 4+ messages in thread
From: Goldwyn Rodrigues @ 2016-11-10 15:01 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Goldwyn Rodrigues

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>
---
 cmds-check.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/cmds-check.c b/cmds-check.c
index 368c1c5..779870a 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -8184,11 +8184,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.
@@ -8196,6 +8191,12 @@ static struct extent_entry *find_most_right_entry(struct list_head *entries)
 		if (entry->broken == entry->count)
 			continue;
 
+		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.
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-11-30 15:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-10 15:01 [PATCH] Return best entry, if it is the first one Goldwyn Rodrigues
2016-11-10 15:01 ` [PATCH] btrfs-progs: Fix extents after finding all errors Goldwyn Rodrigues
2016-11-30 15:32   ` David Sterba
2016-11-11 12:34 ` [PATCH] Return best entry, if it is the first one David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).