Skip to content

Commit c360abb

Browse files
AstralBobAndreas Gruenbacher
authored andcommitted
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. Signed-off-by: Bob Peterson <[email protected]> Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent 5fcff61 commit c360abb

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

fs/gfs2/quota.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,12 @@ static void slot_put(struct gfs2_quota_data *qd)
365365
static int bh_get(struct gfs2_quota_data *qd)
366366
{
367367
struct gfs2_sbd *sdp = qd->qd_gl->gl_name.ln_sbd;
368-
struct gfs2_inode *ip = GFS2_I(sdp->sd_qc_inode);
368+
struct inode *inode = sdp->sd_qc_inode;
369+
struct gfs2_inode *ip = GFS2_I(inode);
369370
unsigned int block, offset;
370371
struct buffer_head *bh;
372+
struct iomap iomap = { };
371373
int error;
372-
struct buffer_head bh_map = { .b_state = 0, .b_blocknr = 0 };
373374

374375
mutex_lock(&sdp->sd_quota_mutex);
375376

@@ -381,11 +382,17 @@ static int bh_get(struct gfs2_quota_data *qd)
381382
block = qd->qd_slot / sdp->sd_qc_per_block;
382383
offset = qd->qd_slot % sdp->sd_qc_per_block;
383384

384-
bh_map.b_size = BIT(ip->i_inode.i_blkbits);
385-
error = gfs2_block_map(&ip->i_inode, block, &bh_map, 0);
385+
error = gfs2_iomap_get(inode,
386+
(loff_t)block << inode->i_blkbits,
387+
i_blocksize(inode), &iomap);
386388
if (error)
387389
goto fail;
388-
error = gfs2_meta_read(ip->i_gl, bh_map.b_blocknr, DIO_WAIT, 0, &bh);
390+
error = -ENOENT;
391+
if (iomap.type != IOMAP_MAPPED)
392+
goto fail;
393+
394+
error = gfs2_meta_read(ip->i_gl, iomap.addr >> inode->i_blkbits,
395+
DIO_WAIT, 0, &bh);
389396
if (error)
390397
goto fail;
391398
error = -EIO;

0 commit comments

Comments
 (0)