Skip to contentSkip to conversation

gfs2: Convert function bh_get to use iomap

PATCH New Bob Peterson 2 participants 2 messages Feb 11, 2022 – May 17, 2022 GFS2 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gfs2: Convert function bh_get to use iomap

Before this patch, function bh_get used block_map to figure out the block it needed to read in from the quota_change file. This patch changes it to use iomap directly to make it more efficient.

---
 fs/gfs2/quota.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
fs/gfs2/quota.c +11 -4
index dc77080a82bb..91bc3affe460 100644
@@ -368,8 +368,8 @@ static int bh_get(struct gfs2_quota_data *qd)
 	struct gfs2_inode *ip = GFS2_I(sdp->sd_qc_inode);
 	unsigned int block, offset;
 	struct buffer_head *bh;
+	struct iomap iomap = { };
 	int error;
-	struct buffer_head bh_map = { .b_state = 0, .b_blocknr = 0 };
 
 	mutex_lock(&sdp->sd_quota_mutex);
 
@@ -381,11 +381,18 @@ static int bh_get(struct gfs2_quota_data *qd)
 	block = qd->qd_slot / sdp->sd_qc_per_block;
 	offset = qd->qd_slot % sdp->sd_qc_per_block;
 
-	bh_map.b_size = BIT(ip->i_inode.i_blkbits);
-	error = gfs2_block_map(&ip->i_inode, block, &bh_map, 0);
+	error = gfs2_iomap_get(sdp->sd_qc_inode,
+			       (loff_t)block << sdp->sd_qc_inode->i_blkbits,
+			       sdp->sd_sb.sb_bsize, &iomap);
 	if (error)
 		goto fail;
-	error = gfs2_meta_read(ip->i_gl, bh_map.b_blocknr, DIO_WAIT, 0, &bh);
+	if (iomap.addr == IOMAP_NULL_ADDR) {
+		error = -ENOENT;
+		goto fail;
+	}
+
+	error = gfs2_meta_read(ip->i_gl, iomap.addr >> sdp->sd_qc_inode->i_blkbits,
+			       DIO_WAIT, 0, &bh);
 	if (error)
 		goto fail;
 	error = -EIO;
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/1 gfs2: Convert function bh_get to use iomap

Quoted 3 lines · Bob Peterson

Before this patch, function bh_get used block_map to figure out the block it needed to read in from the quota_change file. This patch changes it to use iomap directly to make it more efficient.

Thanks, I've applied this with minor cleanups.

There are still a few other users of gfs2_block_map around that should be converted as well.

Andreas

Quoted 44 lines
---
 fs/gfs2/quota.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
fs/gfs2/quota.c +11 -5
index dc77080a82bb..91bc3affe460 100644
@@ -368,8 +368,8 @@ static int bh_get(struct gfs2_quota_data *qd)
        struct gfs2_inode *ip = GFS2_I(sdp->sd_qc_inode);
        unsigned int block, offset;
        struct buffer_head *bh;
+       struct iomap iomap = { };
        int error;
-       struct buffer_head bh_map = { .b_state = 0, .b_blocknr = 0 };
 
        mutex_lock(&sdp->sd_quota_mutex);
 
@@ -381,11 +381,18 @@ static int bh_get(struct gfs2_quota_data *qd)
        block = qd->qd_slot / sdp->sd_qc_per_block;
        offset = qd->qd_slot % sdp->sd_qc_per_block;
 
-       bh_map.b_size = BIT(ip->i_inode.i_blkbits);
-       error = gfs2_block_map(&ip->i_inode, block, &bh_map, 0);
+       error = gfs2_iomap_get(sdp->sd_qc_inode,
+                              (loff_t)block << sdp->sd_qc_inode->i_blkbits,
+                              sdp->sd_sb.sb_bsize, &iomap);
        if (error)
                goto fail;
-       error = gfs2_meta_read(ip->i_gl, bh_map.b_blocknr, DIO_WAIT, 0, &bh);
+       if (iomap.addr == IOMAP_NULL_ADDR) {
+               error = -ENOENT;
+               goto fail;
+       }
+
+       error = gfs2_meta_read(ip->i_gl, iomap.addr >> sdp->sd_qc_inode->i_blkbits,
+                              DIO_WAIT, 0, &bh);
        if (error)
                goto fail;
        error = -EIO;
--

2.34.1