[RHEL8,COMMIT] ploop: Zero tail of tail page

Submitted by Konstantin Khorenko on Dec. 15, 2020, 5:12 p.m.

Details

Message ID 202012151712.0BFHCIXP4029304@finist-co8.sw.ru
State New
Series "ploop: Zero tail of tail page"
Headers show

Commit Message

Konstantin Khorenko Dec. 15, 2020, 5:12 p.m.
The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.1
------>
commit 0497d745e201c4eb6f894c87afb55044f075708d
Author: Kirill Tkhai <ktkhai@virtuozzo.com>
Date:   Tue Dec 15 20:12:18 2020 +0300

    ploop: Zero tail of tail page
    
    In case of BAT ends in middle of page, zero its tail.
    Otherwise, garbage is there.
    
    https://jira.sw.ru/browse/PSBM-123639
    Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 drivers/md/dm-ploop-bat.c | 5 +++++
 drivers/md/dm-ploop.h     | 1 +
 2 files changed, 6 insertions(+)

Patch hide | download patch | download mbox

diff --git a/drivers/md/dm-ploop-bat.c b/drivers/md/dm-ploop-bat.c
index d6b687806118..da18dd2e4638 100644
--- a/drivers/md/dm-ploop-bat.c
+++ b/drivers/md/dm-ploop-bat.c
@@ -168,6 +168,11 @@  static int ploop_read_bat(struct ploop *ploop, struct bio *bio)
 			from = kmap(bio->bi_io_vec[page].bv_page);
 			memcpy(to, from, nr_copy * sizeof(map_index_t));
 			kunmap(bio->bi_io_vec[page].bv_page);
+			if (unlikely(nr_copy < BAT_ENTRIES_PER_PAGE)) {
+				memset(from + nr_copy, 0, sizeof(map_index_t) *
+				       (BAT_ENTRIES_PER_PAGE - nr_copy));
+			}
+
 			ret = parse_bat_entries(ploop, to, md->bat_levels,
 						nr_copy, id);
 			kunmap(md->page);
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index dc5362f01e21..a025df4bf328 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -6,6 +6,7 @@ 
 
 #define PLOOP_MAP_OFFSET 16
 typedef u32 map_index_t;
+#define BAT_ENTRIES_PER_PAGE (PAGE_SIZE / sizeof(map_index_t))
 
 #define SIGNATURE_DISK_IN_USE           0x746F6E59