Skip to content

Commit

Permalink
bcache: set largest seq to ja->seq[bucket_index] in journal_read_buck…
Browse files Browse the repository at this point in the history
…et()

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>
  • Loading branch information
Coly Li authored and Jens Axboe committed Jun 28, 2019
1 parent 2464b69 commit a231f07
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/md/bcache/journal.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ reread: left = ca->sb.bucket_size - offset;
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;
Expand Down

0 comments on commit a231f07

Please sign in to comment.