]> git.neil.brown.name Git - wiggle.git/commitdiff
merge: avoid including large Unmatched sections in a conflict.
authorNeil Brown <neilb@suse.de>
Tue, 8 May 2012 09:56:38 +0000 (19:56 +1000)
committerNeil Brown <neilb@suse.de>
Tue, 8 May 2012 09:56:38 +0000 (19:56 +1000)
A large Unmatched section can just distract from the real conflict
and doesn't give useful information.
So if we can close the conflict before a big Unmatched,
do so.

Signed-off-by: NeilBrown <neilb@suse.de>
merge2.c
tests/linux/md-resync/merge

index 20b0305547c37cf0b8ffcc68c3f0ac7dfe3f2ede..d87b89c765ddf490cba5ca0f2f966a0c7898ce62 100644 (file)
--- a/merge2.c
+++ b/merge2.c
@@ -181,7 +181,7 @@ static int isolate_conflicts(struct file af, struct file bf, struct file cf,
                                         * it wasn't the first one.  'firstk' allows us
                                         * to track which newline we actually use
                                         */
-                                       int firstk = m[j].al;
+                                       int firstk = m[j].al+1;
                                        if (words) {
                                                m[j].hi = m[j].al;
                                                break;
@@ -192,7 +192,7 @@ static int isolate_conflicts(struct file af, struct file bf, struct file cf,
                                         */
                                        for (k = m[j].al; k > 0; k--)
                                                if (ends_line(af.list[m[j].a+k-1])) {
-                                                       if (firstk == m[j].al)
+                                                       if (firstk >= m[j].al)
                                                                firstk = k;
                                                        newlines++;
                                                        if (newlines >= 3) {
@@ -251,10 +251,10 @@ static int isolate_conflicts(struct file af, struct file bf, struct file cf,
                                                 * it wasn't the first one.  'firstk' allows us
                                                 * to track which newline we actually use
                                                 */
-                                               int firstk = 0;
+                                               int firstk = -1;
                                                for (k = 0 ; k < m[j].al ; k++)
                                                        if (ends_line(af.list[m[j].a+k])) {
-                                                               if (firstk == 0)
+                                                               if (firstk <= 0)
                                                                        firstk = k;
                                                                newlines++;
                                                                if (newlines >= 3) {
@@ -262,6 +262,20 @@ static int isolate_conflicts(struct file af, struct file bf, struct file cf,
                                                                        break;
                                                                }
                                                        }
+                                               if (firstk >= 0 &&
+                                                   m[j+1].type == Unmatched) {
+                                                       /* If this Unmatched exceeds 3 lines, just stop here */
+                                                       int p;
+                                                       int nl = 0;
+                                                       for (p = 0; p < m[j+1].al ; p++)
+                                                               if (ends_line(af.list[m[j+1].a+p])) {
+                                                                       nl++;
+                                                                       if (nl > 3)
+                                                                               break;
+                                                               }
+                                                       if (nl > 3)
+                                                               k = firstk;
+                                               }
                                                if (k < m[j].al)
                                                        m[j].lo = k+1;
                                                else
index 09928a2e21b30b07f7effdccf841d5bb9701d712..fd18d0faa69ae10bdb57330d4f4d25b2c28f7d05 100644 (file)
@@ -1499,6 +1499,19 @@ nomem:
        raid1_shrink_buffers(conf);
        return -ENOMEM;
 }
+|||||||
+       if (!sector_nr)
+               if (init_resync(conf))
+                       return -ENOMEM;
+       /*
+=======
+       if (sector_nr >= max_sector) {
+               close_sync(conf);
+               return 0;
+       }
+
+       /*
+>>>>>>>
 
 static void end_sync_read(struct buffer_head *bh, int uptodate)
 {
@@ -1528,23 +1541,6 @@ static void end_sync_write(struct buffer_head *bh, int uptodate)
                raid1_free_buf(r1_bh);
                sync_request_done(sect, mddev_to_conf(mddev));
                md_done_sync(mddev,size>>9, uptodate);
-|||||||
-       if (!sector_nr)
-               if (init_resync(conf))
-                       return -ENOMEM;
-       /*
-        * If there is non-resync activity waiting for us then
-        * put in a delay to throttle resync.
-=======
-       if (sector_nr >= max_sector) {
-               close_sync(conf);
-               return 0;
-       }
-
-       /*
-        * If there is non-resync activity waiting for us then
-        * put in a delay to throttle resync.
->>>>>>>
        }
 }