Merge tag 'gfs2-v5.2.fixes2' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2...
[linux-block.git] / fs / gfs2 / bmap.c
index f42718dd292f445c0bfe9da0b5e8703facb24d3b..93ea1d529aa398e68937f3d10fd84b7d2ff7fbdc 100644 (file)
@@ -1,10 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (C) Sistina Software, Inc.  1997-2003 All rights reserved.
  * Copyright (C) 2004-2006 Red Hat, Inc.  All rights reserved.
- *
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU General Public License version 2.
  */
 
 #include <linux/spinlock.h>
@@ -994,9 +991,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,