Simplify lbd a bit, as logical block shift cannot be zero

This commit is contained in:
Tom Marshall 2021-05-17 10:33:58 -07:00
parent 32b0c7556d
commit d3d581ecb6
1 changed files with 5 additions and 11 deletions

View File

@ -258,6 +258,7 @@ lbd_ctr(struct lbd* lbd,
void* percpu)
{
u32 nr_pages = DIV_ROUND_UP(lblk_size(&kparams->params), PAGE_SIZE);
BUG_ON(nr_pages == 1);
memset(lbd, 0, sizeof(struct lbd));
INIT_LIST_HEAD(&lbd->lru_list);
@ -279,14 +280,9 @@ lbd_ctr(struct lbd* lbd,
if (!cbd_alloc_pagev(lbd->pagev, nr_pages)) {
return false;
}
if (nr_pages == 1) {
lbd->buf = page_address(lbd->pagev[0]);
}
else {
lbd->buf = vmap(lbd->pagev, nr_pages, VM_MAP, PAGE_KERNEL);
if (!lbd->buf) {
return false;
}
lbd->buf = vmap(lbd->pagev, nr_pages, VM_MAP, PAGE_KERNEL);
if (!lbd->buf) {
return false;
}
lbd->c_len = 0;
@ -311,9 +307,7 @@ lbd_dtr(struct lbd* lbd)
printk(KERN_ERR "%s: lbatviewcache_put failed\n", __func__);
}
lbd->c_len = 0;
if (nr_pages != 1) {
vunmap(lbd->buf);
}
vunmap(lbd->buf);
lbd->buf = NULL;
if (lbd->pagev) {
cbd_free_pagev(lbd->pagev, nr_pages);