bcache: add code comments for journal_read_bucket()
This patch adds more code comments in journal_read_bucket(), this is an effort to make the code to be more understandable. Signed-off-by: Coly Li <colyli@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
7e865eba00
commit
2464b69314
|
@ -100,6 +100,20 @@ reread: left = ca->sb.bucket_size - offset;
|
||||||
|
|
||||||
blocks = set_blocks(j, block_bytes(ca->set));
|
blocks = set_blocks(j, block_bytes(ca->set));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Nodes in 'list' are in linear increasing order of
|
||||||
|
* i->j.seq, the node on head has the smallest (oldest)
|
||||||
|
* journal seq, the node on tail has the biggest
|
||||||
|
* (latest) journal seq.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check from the oldest jset for last_seq. If
|
||||||
|
* i->j.seq < j->last_seq, it means the oldest jset
|
||||||
|
* in list is expired and useless, remove it from
|
||||||
|
* this list. Otherwise, j is a condidate jset for
|
||||||
|
* further following checks.
|
||||||
|
*/
|
||||||
while (!list_empty(list)) {
|
while (!list_empty(list)) {
|
||||||
i = list_first_entry(list,
|
i = list_first_entry(list,
|
||||||
struct journal_replay, list);
|
struct journal_replay, list);
|
||||||
|
@ -109,13 +123,22 @@ reread: left = ca->sb.bucket_size - offset;
|
||||||
kfree(i);
|
kfree(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* iterate list in reverse order (from latest jset) */
|
||||||
list_for_each_entry_reverse(i, list, list) {
|
list_for_each_entry_reverse(i, list, list) {
|
||||||
if (j->seq == i->j.seq)
|
if (j->seq == i->j.seq)
|
||||||
goto next_set;
|
goto next_set;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* if j->seq is less than any i->j.last_seq
|
||||||
|
* in list, j is an expired and useless jset.
|
||||||
|
*/
|
||||||
if (j->seq < i->j.last_seq)
|
if (j->seq < i->j.last_seq)
|
||||||
goto next_set;
|
goto next_set;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 'where' points to first jset in list which
|
||||||
|
* is elder then j.
|
||||||
|
*/
|
||||||
if (j->seq > i->j.seq) {
|
if (j->seq > i->j.seq) {
|
||||||
where = &i->list;
|
where = &i->list;
|
||||||
goto add;
|
goto add;
|
||||||
|
@ -129,6 +152,7 @@ add:
|
||||||
if (!i)
|
if (!i)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
memcpy(&i->j, j, bytes);
|
memcpy(&i->j, j, bytes);
|
||||||
|
/* Add to the location after 'where' points to */
|
||||||
list_add(&i->list, where);
|
list_add(&i->list, where);
|
||||||
ret = 1;
|
ret = 1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue