bcache: set largest seq to ja->seq[bucket_index] in journal_read_bucket()
authorColy Li <colyli@suse.de>
Fri, 28 Jun 2019 11:59:51 +0000 (19:59 +0800)
committerJens Axboe <axboe@kernel.dk>
Fri, 28 Jun 2019 13:39:17 +0000 (07:39 -0600)
In journal_read_bucket() when setting ja->seq[bucket_index], there might
be potential case that a later non-maximum overwrites a better sequence
number to ja->seq[bucket_index]. This patch adds a check to make sure
that ja->seq[bucket_index] will be only set a new value if it is bigger
then current value.

Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/md/bcache/journal.c

index 98ee467ec3f75578c0cabcea2c5b9166dfb26de6..3d321bffddc95918b6aff5dc058299a8263681ae 100644 (file)
@@ -156,7 +156,8 @@ add:
                        list_add(&i->list, where);
                        ret = 1;
 
-                       ja->seq[bucket_index] = j->seq;
+                       if (j->seq > ja->seq[bucket_index])
+                               ja->seq[bucket_index] = j->seq;
 next_set:
                        offset  += blocks * ca->sb.block_size;
                        len     -= blocks * ca->sb.block_size;