Commit d68d0c6c authored by Andreas Gruenbacher's avatar Andreas Gruenbacher

gfs2: Use memcpy_{from,to}_page where appropriate

Replace kmap_local_page() + memcpy() + kunmap_local() sequences with
memcpy_{from,to}_page() where we are not doing anything else with the
mapped page.
Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
parent b0c21c6d
...@@ -488,7 +488,6 @@ int gfs2_internal_read(struct gfs2_inode *ip, char *buf, loff_t *pos, ...@@ -488,7 +488,6 @@ int gfs2_internal_read(struct gfs2_inode *ip, char *buf, loff_t *pos,
unsigned copied = 0; unsigned copied = 0;
unsigned amt; unsigned amt;
struct page *page; struct page *page;
void *p;
do { do {
page = read_cache_page(mapping, index, gfs2_read_folio, NULL); page = read_cache_page(mapping, index, gfs2_read_folio, NULL);
...@@ -497,12 +496,10 @@ int gfs2_internal_read(struct gfs2_inode *ip, char *buf, loff_t *pos, ...@@ -497,12 +496,10 @@ int gfs2_internal_read(struct gfs2_inode *ip, char *buf, loff_t *pos,
continue; continue;
return PTR_ERR(page); return PTR_ERR(page);
} }
p = kmap_local_page(page);
amt = size - copied; amt = size - copied;
if (offset + size > PAGE_SIZE) if (offset + size > PAGE_SIZE)
amt = PAGE_SIZE - offset; amt = PAGE_SIZE - offset;
memcpy(buf + copied, p + offset, amt); memcpy_from_page(buf + copied, page, offset, amt);
kunmap_local(p);
put_page(page); put_page(page);
copied += amt; copied += amt;
index++; index++;
......
...@@ -697,14 +697,12 @@ static void gfs2_before_commit(struct gfs2_sbd *sdp, unsigned int limit, ...@@ -697,14 +697,12 @@ static void gfs2_before_commit(struct gfs2_sbd *sdp, unsigned int limit,
lock_buffer(bd2->bd_bh); lock_buffer(bd2->bd_bh);
if (buffer_escaped(bd2->bd_bh)) { if (buffer_escaped(bd2->bd_bh)) {
void *kaddr; void *p;
page = mempool_alloc(gfs2_page_pool, GFP_NOIO); page = mempool_alloc(gfs2_page_pool, GFP_NOIO);
ptr = page_address(page); p = page_address(page);
kaddr = kmap_local_page(bd2->bd_bh->b_page); memcpy_from_page(p, page, bh_offset(bd2->bd_bh), bd2->bd_bh->b_size);
memcpy(ptr, kaddr + bh_offset(bd2->bd_bh), *(__be32 *)p = 0;
bd2->bd_bh->b_size);
kunmap_local(kaddr);
*(__be32 *)ptr = 0;
clear_buffer_escaped(bd2->bd_bh); clear_buffer_escaped(bd2->bd_bh);
unlock_buffer(bd2->bd_bh); unlock_buffer(bd2->bd_bh);
brelse(bd2->bd_bh); brelse(bd2->bd_bh);
......
...@@ -712,7 +712,6 @@ static int gfs2_write_buf_to_page(struct gfs2_inode *ip, unsigned long index, ...@@ -712,7 +712,6 @@ static int gfs2_write_buf_to_page(struct gfs2_inode *ip, unsigned long index,
struct address_space *mapping = inode->i_mapping; struct address_space *mapping = inode->i_mapping;
struct page *page; struct page *page;
struct buffer_head *bh; struct buffer_head *bh;
void *kaddr;
u64 blk; u64 blk;
unsigned bsize = sdp->sd_sb.sb_bsize, bnum = 0, boff = 0; unsigned bsize = sdp->sd_sb.sb_bsize, bnum = 0, boff = 0;
unsigned to_write = bytes, pg_off = off; unsigned to_write = bytes, pg_off = off;
...@@ -764,9 +763,7 @@ static int gfs2_write_buf_to_page(struct gfs2_inode *ip, unsigned long index, ...@@ -764,9 +763,7 @@ static int gfs2_write_buf_to_page(struct gfs2_inode *ip, unsigned long index,
} }
/* Write to the page, now that we have setup the buffer(s) */ /* Write to the page, now that we have setup the buffer(s) */
kaddr = kmap_local_page(page); memcpy_to_page(page, off, buf, bytes);
memcpy(kaddr + off, buf, bytes);
kunmap_local(kaddr);
flush_dcache_page(page); flush_dcache_page(page);
unlock_page(page); unlock_page(page);
put_page(page); put_page(page);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment