All of lore.kernel.org
 help / color / mirror / Atom feed
From: Goldwyn Rodrigues <rgoldwyn@suse.de>
To: linux-btrfs@vger.kernel.org
Cc: Goldwyn Rodrigues <rgoldwyn@suse.com>
Subject: [PATCH] Return best entry, if it is the first one
Date: Thu, 10 Nov 2016 09:01:46 -0600	[thread overview]
Message-ID: <20161110150147.19766-1-rgoldwyn@suse.de> (raw)

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


             reply	other threads:[~2016-11-10 15:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-10 15:01 Goldwyn Rodrigues [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161110150147.19766-1-rgoldwyn@suse.de \
    --to=rgoldwyn@suse.de \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=rgoldwyn@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.