Skip to contentSkip to conversation

gfs2: Fix rounding error in gfs2_iomap_page_prepare

PATCH New Andreas Gruenbacher 1 participant 1 message Jun 14, 2019 GFS2 file system

lore
Share & tools
lore

Andreas Gruenbacher

author maintainer
#0 lore raw

PATCH 1/1 gfs2: Fix rounding error in gfs2_iomap_page_prepare

The pos and len arguments to the iomap page_prepare callback are not block aligned, so we need to take that into account when computing the number of blocks.

Fixes d0a22a4b03b8 ("gfs2: Fix iomap write page reclaim deadlock")
---
 fs/gfs2/bmap.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/gfs2/bmap.c +4 -1
index f42718dd292f..8bae7531e883 100644
@@ -994,9 +994,12 @@ static void gfs2_write_unlock(struct inode *inode)
 static int gfs2_iomap_page_prepare(struct inode *inode, loff_t pos,
 				   unsigned len, struct iomap *iomap)
 {
+	unsigned int blockmask = i_blocksize(inode) - 1;
 	struct gfs2_sbd *sdp = GFS2_SB(inode);
+	unsigned int blocks;
 
-	return gfs2_trans_begin(sdp, RES_DINODE + (len >> inode->i_blkbits), 0);
+	blocks = ((pos & blockmask) + len + blockmask) >> inode->i_blkbits;
+	return gfs2_trans_begin(sdp, RES_DINODE + blocks, 0);
 }
 
 static void gfs2_iomap_page_done(struct inode *inode, loff_t pos,
Signature · 1 line
2.20.1