Skip to content

Commit d68d0c6

Browse files
author
Andreas Gruenbacher
committed
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: Andreas Gruenbacher <agruenba@redhat.com>
1 parent b0c21c6 commit d68d0c6

3 files changed

Lines changed: 7 additions & 15 deletions

File tree

fs/gfs2/aops.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,6 @@ int gfs2_internal_read(struct gfs2_inode *ip, char *buf, loff_t *pos,
488488
unsigned copied = 0;
489489
unsigned amt;
490490
struct page *page;
491-
void *p;
492491

493492
do {
494493
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,
497496
continue;
498497
return PTR_ERR(page);
499498
}
500-
p = kmap_local_page(page);
501499
amt = size - copied;
502500
if (offset + size > PAGE_SIZE)
503501
amt = PAGE_SIZE - offset;
504-
memcpy(buf + copied, p + offset, amt);
505-
kunmap_local(p);
502+
memcpy_from_page(buf + copied, page, offset, amt);
506503
put_page(page);
507504
copied += amt;
508505
index++;

fs/gfs2/lops.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -697,14 +697,12 @@ static void gfs2_before_commit(struct gfs2_sbd *sdp, unsigned int limit,
697697
lock_buffer(bd2->bd_bh);
698698

699699
if (buffer_escaped(bd2->bd_bh)) {
700-
void *kaddr;
700+
void *p;
701+
701702
page = mempool_alloc(gfs2_page_pool, GFP_NOIO);
702-
ptr = page_address(page);
703-
kaddr = kmap_local_page(bd2->bd_bh->b_page);
704-
memcpy(ptr, kaddr + bh_offset(bd2->bd_bh),
705-
bd2->bd_bh->b_size);
706-
kunmap_local(kaddr);
707-
*(__be32 *)ptr = 0;
703+
p = page_address(page);
704+
memcpy_from_page(p, page, bh_offset(bd2->bd_bh), bd2->bd_bh->b_size);
705+
*(__be32 *)p = 0;
708706
clear_buffer_escaped(bd2->bd_bh);
709707
unlock_buffer(bd2->bd_bh);
710708
brelse(bd2->bd_bh);

fs/gfs2/quota.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,6 @@ static int gfs2_write_buf_to_page(struct gfs2_inode *ip, unsigned long index,
712712
struct address_space *mapping = inode->i_mapping;
713713
struct page *page;
714714
struct buffer_head *bh;
715-
void *kaddr;
716715
u64 blk;
717716
unsigned bsize = sdp->sd_sb.sb_bsize, bnum = 0, boff = 0;
718717
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,
764763
}
765764

766765
/* Write to the page, now that we have setup the buffer(s) */
767-
kaddr = kmap_local_page(page);
768-
memcpy(kaddr + off, buf, bytes);
769-
kunmap_local(kaddr);
766+
memcpy_to_page(page, off, buf, bytes);
770767
flush_dcache_page(page);
771768
unlock_page(page);
772769
put_page(page);

0 commit comments

Comments
 (0)