Skip to contentSkip to conversation

gfs2: iomap inline data handling cleanup

PATCH New Andreas Gruenbacher 1 participant 1 message Jul 31, 2021 GFS2 file system

lore
Share & tools
lore

Andreas Gruenbacher

author maintainer
#0 lore raw

PATCH 1/1 gfs2: iomap inline data handling cleanup

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.

---
 fs/gfs2/bmap.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
fs/gfs2/bmap.c +7 -6
index ed8b67b21718..84ad0fe787ea 100644
@@ -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;
Signature · 1 line
2.26.3