Skip to contentSkip to conversation

gfs2: Minor PAGE_SIZE arithmetic cleanups

PATCH New Andreas Gruenbacher 1 participant 2 messages Sep 3, 2019 – Sep 4, 2019 GFS2 file system

lore
Share & tools
lore

Andreas Gruenbacher

author maintainer
#0 lore raw

PATCH 1/1 gfs2: Minor PAGE_SIZE arithmetic cleanups

Replace divisions by PAGE_SIZE with shifts by PAGE_SHIFT and similar.

---
 fs/gfs2/aops.c  | 4 ++--
 fs/gfs2/file.c  | 2 +-
 fs/gfs2/quota.c | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
fs/gfs2/aops.c +2 -2
index f42048cc5454..b9fe975d7625 100644
@@ -243,7 +243,7 @@ static int gfs2_write_jdata_pagevec(struct address_space *mapping,
 {
 	struct inode *inode = mapping->host;
 	struct gfs2_sbd *sdp = GFS2_SB(inode);
-	unsigned nrblocks = nr_pages * (PAGE_SIZE/inode->i_sb->s_blocksize);
+	unsigned nrblocks = nr_pages * (PAGE_SIZE >> inode->i_blkbits);
 	int i;
 	int ret;
 
@@ -552,7 +552,7 @@ int gfs2_internal_read(struct gfs2_inode *ip, char *buf, loff_t *pos,
                        unsigned size)
 {
 	struct address_space *mapping = ip->i_inode.i_mapping;
-	unsigned long index = *pos / PAGE_SIZE;
+	unsigned long index = *pos >> PAGE_SHIFT;
 	unsigned offset = *pos & (PAGE_SIZE - 1);
 	unsigned copied = 0;
 	unsigned amt;
fs/gfs2/file.c +1 -1
index 99e2c8cd5eaa..997b326247e2 100644
@@ -1049,7 +1049,7 @@ static long __gfs2_fallocate(struct file *file, int mode, loff_t offset, loff_t
 			rblocks += data_blocks ? data_blocks : 1;
 
 		error = gfs2_trans_begin(sdp, rblocks,
-					 PAGE_SIZE/sdp->sd_sb.sb_bsize);
+					 PAGE_SIZE >> inode->i_blkbits);
 		if (error)
 			goto out_trans_fail;
 
fs/gfs2/quota.c +1 -1
index 69c4b77f127b..f95606f2157a 100644
@@ -774,7 +774,7 @@ static int gfs2_write_disk_quota(struct gfs2_inode *ip, struct gfs2_quota *qp,
 	nbytes = sizeof(struct gfs2_quota);
 
 	pg_beg = loc >> PAGE_SHIFT;
-	pg_off = loc % PAGE_SIZE;
+	pg_off = loc & (PAGE_SIZE - 1);
 
 	/* If the quota straddles a page boundary, split the write in two */
 	if ((pg_off + nbytes) > PAGE_SIZE) {
Signature · 1 line
2.20.1
author maintainer
#1 lore raw

PATCH 1/1 gfs2: Minor PAGE_SIZE arithmetic cleanups

fs/gfs2/quota.c static int gfs2_write_disk_quota(struct gfs2_inode *ip, struct gfs2_quota *qp, · line 777

Quoted 10 lines · Andreas Gruenbacher
fs/gfs2/quota.c +1 -1
index 69c4b77f127b..f95606f2157a 100644
@@ -774,7 +774,7 @@ static int gfs2_write_disk_quota(struct gfs2_inode *ip, struct gfs2_quota *qp,
        nbytes = sizeof(struct gfs2_quota);
 
        pg_beg = loc >> PAGE_SHIFT;
-       pg_off = loc % PAGE_SIZE;
+       pg_off = loc & (PAGE_SIZE - 1);

Should have used offset_in_page() here. I'm fixing that.

Andreas