Skip to content

Commit a664574

Browse files
AstralBobagruenba
authored andcommitted
gfs2: simplify gfs2_block_map
Function gfs2_block_map had a lot of redundancy between its create and no_create paths. This patch simplifies the code to eliminate the redundancy. Signed-off-by: Bob Peterson <rpeterso@redhat.com> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
1 parent 6302d6f commit a664574

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

‎fs/gfs2/bmap.c‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,22 +1292,18 @@ int gfs2_block_map(struct inode *inode, sector_t lblock,
12921292
loff_t length = bh_map->b_size;
12931293
struct metapath mp = { .mp_aheight = 1, };
12941294
struct iomap iomap = { };
1295+
int flags = create ? IOMAP_WRITE : 0;
12951296
int ret;
12961297

12971298
clear_buffer_mapped(bh_map);
12981299
clear_buffer_new(bh_map);
12991300
clear_buffer_boundary(bh_map);
13001301
trace_gfs2_bmap(ip, bh_map, lblock, create, 1);
13011302

1302-
if (create) {
1303-
ret = gfs2_iomap_get(inode, pos, length, IOMAP_WRITE, &iomap, &mp);
1304-
if (!ret && iomap.type == IOMAP_HOLE)
1305-
ret = gfs2_iomap_alloc(inode, &iomap, &mp);
1306-
release_metapath(&mp);
1307-
} else {
1308-
ret = gfs2_iomap_get(inode, pos, length, 0, &iomap, &mp);
1309-
release_metapath(&mp);
1310-
}
1303+
ret = gfs2_iomap_get(inode, pos, length, flags, &iomap, &mp);
1304+
if (create && !ret && iomap.type == IOMAP_HOLE)
1305+
ret = gfs2_iomap_alloc(inode, &iomap, &mp);
1306+
release_metapath(&mp);
13111307
if (ret)
13121308
goto out;
13131309

0 commit comments

Comments
 (0)