[Devel] [PATCH rh8] ploop: kmap_atomic() is overkill

Kirill Tkhai ktkhai at virtuozzo.com
Tue Mar 17 12:30:19 MSK 2020


There are no interrupt context or preemption disabled,
so atomicity is not needed.

This is not complete list, but we do not touch other places
for now.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/md/dm-ploop-bat.c |   20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/md/dm-ploop-bat.c b/drivers/md/dm-ploop-bat.c
index cea14556278a..2a8057cfde4c 100644
--- a/drivers/md/dm-ploop-bat.c
+++ b/drivers/md/dm-ploop-bat.c
@@ -26,10 +26,10 @@ static int ploop_read_bat(struct ploop *ploop, struct bio *bio)
 			if (i + nr_copy > ploop->nr_bat_entries)
 				nr_copy = ploop->nr_bat_entries - i;
 
-			addr = kmap_atomic(bio->bi_io_vec[page].bv_page);
+			addr = kmap(bio->bi_io_vec[page].bv_page);
 			memcpy(&ploop->bat_entries[i], addr + off,
 				nr_copy * sizeof(map_index_t));
-			kunmap_atomic(addr);
+			kunmap(bio->bi_io_vec[page].bv_page);
 			i += nr_copy;
 
 			if (i >= ploop->nr_bat_entries)
@@ -113,6 +113,7 @@ int ploop_read_metadata(struct dm_target *ti, struct ploop *ploop)
 	unsigned int bat_clusters, offset_clusters, cluster_log;
 	struct ploop_pvd_header *m_hdr = NULL;
 	unsigned long size;
+	struct page *page;
 	struct bio *bio;
 	int ret;
 	void *data;
@@ -127,7 +128,8 @@ int ploop_read_metadata(struct dm_target *ti, struct ploop *ploop)
 	if (ret < 0)
 		goto out;
 
-	m_hdr = kmap_atomic(bio->bi_io_vec[0].bv_page);
+	page = bio->bi_io_vec[0].bv_page;
+	m_hdr = kmap(page);
 
 	ret = -ENOTSUPP;
 	if (strncmp(m_hdr->m_Sig, "WithouFreSpacExt", 16))
@@ -169,7 +171,7 @@ int ploop_read_metadata(struct dm_target *ti, struct ploop *ploop)
 	memcpy(data, m_hdr, sizeof(*m_hdr));
 	ploop->hdr = data;
 	ploop->bat_entries = data + sizeof(*m_hdr);
-	kunmap_atomic(m_hdr);
+	kunmap(page);
 	m_hdr = NULL;
 
 	ret = ploop_read_bat(ploop, bio);
@@ -179,7 +181,7 @@ int ploop_read_metadata(struct dm_target *ti, struct ploop *ploop)
 	ret = ploop_assign_hb_and_levels(ploop, bat_clusters);
 out:
 	if (m_hdr)
-		kunmap_atomic(m_hdr);
+		kunmap(page);
 	free_bio_with_pages(ploop, bio);
 	return ret;
 }
@@ -192,7 +194,7 @@ static int ploop_delta_check_header(struct ploop *ploop, struct page *page,
 	u64 size, delta_size;
 	int ret = -EPROTO;
 
-	hdr = kmap_atomic(page);
+	hdr = kmap(page);
 
 	if (memcmp(hdr->m_Sig, ploop->hdr->m_Sig, sizeof(hdr->m_Sig)) ||
 	    hdr->m_Sectors != ploop->hdr->m_Sectors ||
@@ -216,7 +218,7 @@ static int ploop_delta_check_header(struct ploop *ploop, struct page *page,
 	*last_page_len = bytes ? : PAGE_SIZE;
 	ret = 0;
 out:
-	kunmap_atomic(hdr);
+	kunmap(page);
 	return ret;
 }
 
@@ -271,9 +273,9 @@ int ploop_read_delta_metadata(struct ploop *ploop, struct file *file,
 			len = last_page_len;
 		}
 
-		from = kmap_atomic(page);
+		from = kmap(page);
 		memcpy(*d_hdr + (i << PAGE_SHIFT), from, len);
-		kunmap_atomic(from);
+		kunmap(page);
 	}
 
 	delta_bat_entries = *d_hdr + PLOOP_MAP_OFFSET * sizeof(map_index_t);




More information about the Devel mailing list