[Devel] [PATCH RH8 1/8] ploop: Fix prealloc_md_pages() defaults
Kirill Tkhai
ktkhai at virtuozzo.com
Tue May 11 11:45:49 MSK 2021
Here should be BAT_ENTRY_NONE
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
drivers/md/dm-ploop-bat.c | 2 +-
drivers/md/dm-ploop-map.c | 10 +++++++++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/md/dm-ploop-bat.c b/drivers/md/dm-ploop-bat.c
index 5ebb05438e2a..1c2357a21673 100644
--- a/drivers/md/dm-ploop-bat.c
+++ b/drivers/md/dm-ploop-bat.c
@@ -107,7 +107,7 @@ int prealloc_md_pages(struct rb_root *root, unsigned int nr_bat_entries,
if (!md)
return -ENOMEM;
addr = kmap_atomic(md->page);
- memset(addr, 0, PAGE_SIZE);
+ memset32(addr, BAT_ENTRY_NONE, PAGE_SIZE / 4);
kunmap_atomic(addr);
__md_page_insert(root, md);
diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index 9dcfe138dc54..bba578e8c219 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -709,6 +709,7 @@ static int ploop_prepare_bat_update(struct ploop *ploop, unsigned int page_nr,
struct ploop_index_wb *piwb)
{
unsigned int i, off, last, *bat_entries;
+ bool is_last_page = true;
struct md_page *md;
struct page *page;
struct bio *bio;
@@ -739,8 +740,10 @@ static int ploop_prepare_bat_update(struct ploop *ploop, unsigned int page_nr,
/* Last and first index in copied page */
last = ploop->nr_bat_entries - off;
- if (last > PAGE_SIZE / sizeof(map_index_t))
+ if (last > PAGE_SIZE / sizeof(map_index_t)) {
last = PAGE_SIZE / sizeof(map_index_t);
+ is_last_page = false;
+ }
i = 0;
if (!page_nr)
i = PLOOP_MAP_OFFSET;
@@ -751,6 +754,11 @@ static int ploop_prepare_bat_update(struct ploop *ploop, unsigned int page_nr,
continue;
to[i] = 0;
}
+ if (is_last_page) {
+ /* Fill tail of page with 0 */
+ for (i = last; i < PAGE_SIZE / sizeof(map_index_t); i++)
+ to[i] = 0;
+ }
kunmap_atomic(to);
kunmap_atomic(bat_entries);
More information about the Devel
mailing list