[Devel] [PATCH RHEL8 COMMIT] ploop: Use kvec in ploop_delta_check_header()
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Jul 2 22:43:33 MSK 2021
The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.6.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.el8
------>
commit 0f3bafd465c9a8f4f1c75ae18febb23391a5db8e
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date: Fri Jul 2 22:43:32 2021 +0300
ploop: Use kvec in ploop_delta_check_header()
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
==========================
Parallel async BAT pages submission and improvements
[1-15]:
https://jira.sw.ru/browse/PSBM-124550
[16-22]:
following improvements
Kirill Tkhai (22):
ploop: Remove absolet comment
ploop: Add md and piwb cross pointers
ploop: Add @md argument to locate_new_cluster_and_attach_pio()
ploop: Refactoring in process_one_discard_pio()
ploop: Pass type argument to ploop_prepare_bat_update()
ploop: Move md is busy check to delay_if_md_busy()
ploop: Introduce batch list for md pages writeback
ploop: Check for md dirty instead of md piwb
ploop: Reread piwb after ploop_prepare_bat_update()
ploop: Change argument in ploop_prepare_bat_update()
ploop: Return md from ploop_prepare_reloc_index_wb()
ploop: Change arguments and rename ploop_reset_bat_update()
ploop: Allow parallel wb of md pages
ploop: Async md writeback
ploop: Rename ploop_submit_index_wb_sync()
ploop: Resubmit pios from main kwork
ploop: Rename process_delta_wb()
ploop: Do fsync after bat page write
ploop: Do not iterate excess clusters in notify_delta_merged()
ploop: Use kvec in ploop_delta_check_header()
ploop: Add argument to ploop_read_delta_metadata()
ploop: Underline clu and page is u32
---
drivers/md/dm-ploop-bat.c | 71 ++++++++++++++---------------------------------
1 file changed, 21 insertions(+), 50 deletions(-)
diff --git a/drivers/md/dm-ploop-bat.c b/drivers/md/dm-ploop-bat.c
index ad9c3a171dc9..ae6b4628d813 100644
--- a/drivers/md/dm-ploop-bat.c
+++ b/drivers/md/dm-ploop-bat.c
@@ -314,15 +314,13 @@ int ploop_setup_metadata(struct ploop *ploop, struct page *page)
return ret;
}
-static int ploop_delta_check_header(struct ploop *ploop, struct page *page,
- unsigned int *nr_pages, unsigned int *last_page_len)
+static int ploop_delta_check_header(struct ploop *ploop,
+ struct ploop_pvd_header *d_hdr,
+ u32 *delta_nr_be_ret)
{
unsigned int bytes, delta_nr_be, offset_clusters, bat_clusters;
- struct ploop_pvd_header *d_hdr;
int ret = -EPROTO;
- d_hdr = kmap(page);
-
if (memcmp(d_hdr->m_Sig, ploop->m_Sig, sizeof(d_hdr->m_Sig)) ||
d_hdr->m_Sectors != ploop->m_Sectors ||
d_hdr->m_Type != ploop->m_Type)
@@ -337,12 +335,9 @@ static int ploop_delta_check_header(struct ploop *ploop, struct page *page,
bat_clusters != offset_clusters)
goto out;
- *nr_pages = DIV_ROUND_UP(bytes, PAGE_SIZE);
- bytes &= ~PAGE_MASK;
- *last_page_len = bytes ? : PAGE_SIZE;
+ *delta_nr_be_ret = delta_nr_be;
ret = 0;
out:
- kunmap(page);
return ret;
}
@@ -363,69 +358,45 @@ int convert_bat_entries(u32 *bat_entries, u32 count)
int ploop_read_delta_metadata(struct ploop *ploop, struct file *file,
void **d_hdr)
{
- unsigned int i, last_page_len, size, nr_pages = 1;
- unsigned int *delta_bat_entries;
+ u32 size, delta_nr_be, *delta_bat_entries;
struct iov_iter iter;
- struct bio_vec bvec;
- struct page *page;
+ struct kvec kvec;
ssize_t len;
- void *from;
loff_t pos;
int ret;
- page = alloc_page(GFP_KERNEL);
- if (!page)
- return -ENOMEM;
-
size = (PLOOP_MAP_OFFSET + ploop->nr_bat_entries) * sizeof(map_index_t);
*d_hdr = vzalloc(size);
if (!*d_hdr) {
ret = -ENOMEM;
- goto out_put_page;
+ goto out;
}
- for (i = 0; i < nr_pages; i++) {
- bvec.bv_page = page;
- bvec.bv_len = PAGE_SIZE;
- bvec.bv_offset = 0;
+ kvec.iov_base = *d_hdr;
+ kvec.iov_len = size;
- iov_iter_bvec(&iter, READ, &bvec, 1, bvec.bv_len);
- pos = i << PAGE_SHIFT;
-
- len = vfs_iter_read(file, &iter, &pos, 0);
- if (len != PAGE_SIZE) {
- ret = len < 0 ? (int)len : -ENODATA;
- goto out_vfree;
- }
+ iov_iter_kvec(&iter, READ, &kvec, 1, kvec.iov_len);
+ pos = 0;
- if (i == 0) {
- /* First page with header. Updates nr_pages. */
- ret = ploop_delta_check_header(ploop, page,
- &nr_pages, &last_page_len);
- if (ret)
- goto out_vfree;
- }
-
- if (i + 1 == nr_pages) {
- /* Last page, possible, incomplete */
- len = last_page_len;
- }
-
- from = kmap(page);
- memcpy(*d_hdr + (i << PAGE_SHIFT), from, len);
- kunmap(page);
+ len = vfs_iter_read(file, &iter, &pos, 0);
+ if (len != size) {
+ ret = len < 0 ? (int)len : -ENODATA;
+ goto out_vfree;
}
+ ret = ploop_delta_check_header(ploop, *d_hdr, &delta_nr_be);
+ if (ret)
+ goto out_vfree;
+
delta_bat_entries = *d_hdr + PLOOP_MAP_OFFSET * sizeof(map_index_t);
- ret = convert_bat_entries(delta_bat_entries, ploop->nr_bat_entries);
+ ret = convert_bat_entries(delta_bat_entries, delta_nr_be);
out_vfree:
if (ret) {
vfree(*d_hdr);
*d_hdr = NULL;
}
-out_put_page:
- put_page(page);
+out:
return ret;
}
More information about the Devel
mailing list