When reporting an IOMAP_INLINE extent, always report the maximum possible size for the inline data. Previously, we've been reporting the file size for reads and the maximum size for writes, but this was unnecessary as the iomap code will happily handle the end-of-file case for us.
Also, slightly tidy up the error handling. Signed-off-by: Andreas Gruenbacher <[email protected]> --- fs/gfs2/bmap.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index ed8b67b21718..84ad0fe787ea 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -866,12 +866,11 @@ static int __gfs2_iomap_get(struct inode *inode, loff_t pos, loff_t length, mp->mp_bh[0] = dibh; if (gfs2_is_stuffed(ip)) { - if (flags & IOMAP_WRITE) { - loff_t max_size = gfs2_max_stuffed_size(ip); + loff_t max_size = gfs2_max_stuffed_size(ip); + if (flags & IOMAP_WRITE) { if (pos + length > max_size) goto unstuff; - iomap->length = max_size; } else { if (pos >= size) { if (flags & IOMAP_REPORT) { @@ -883,10 +882,10 @@ static int __gfs2_iomap_get(struct inode *inode, loff_t pos, loff_t length, goto hole_found; } } - iomap->length = size; } iomap->addr = (ip->i_no_addr << inode->i_blkbits) + sizeof(struct gfs2_dinode); + iomap->length = max_size; iomap->type = IOMAP_INLINE; iomap->inline_data = dibh->b_data + sizeof(struct gfs2_dinode); goto out; @@ -935,9 +934,11 @@ static int __gfs2_iomap_get(struct inode *inode, loff_t pos, loff_t length, do_alloc: if (flags & IOMAP_REPORT) { - if (pos >= size) + if (pos >= size) { ret = -ENOENT; - else if (height == ip->i_height) + goto unlock; + } + if (height == ip->i_height) ret = gfs2_hole_size(inode, lblock, len, mp, iomap); else iomap->length = size - pos; -- 2.26.3
