dm writecache: add unlikely for returned value of rb_next/prev

In functions writecache_discard() and writecache_find_entry() there is a
high probablity that the pointer of structure rb_node won't equal NULL.
Add unlikely for the pointer node NULL.

Signed-off-by: Huaisheng Ye <yehs1@lenovo.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
This commit is contained in:
Huaisheng Ye 2019-04-12 11:28:14 -04:00 committed by Mike Snitzer
parent 09f2d65630
commit 84420b1e5d
1 changed files with 2 additions and 2 deletions

View File

@ -571,7 +571,7 @@ static struct wc_entry *writecache_find_entry(struct dm_writecache *wc,
node = rb_prev(&e->rb_node); node = rb_prev(&e->rb_node);
else else
node = rb_next(&e->rb_node); node = rb_next(&e->rb_node);
if (!node) if (unlikely(!node))
return e; return e;
e2 = container_of(node, struct wc_entry, rb_node); e2 = container_of(node, struct wc_entry, rb_node);
if (read_original_sector(wc, e2) != block) if (read_original_sector(wc, e2) != block)
@ -804,7 +804,7 @@ static void writecache_discard(struct dm_writecache *wc, sector_t start, sector_
writecache_free_entry(wc, e); writecache_free_entry(wc, e);
} }
if (!node) if (unlikely(!node))
break; break;
e = container_of(node, struct wc_entry, rb_node); e = container_of(node, struct wc_entry, rb_node);