mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 20:22:09 +00:00
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>
This commit is contained in:
parent
6302d6f43e
commit
a6645745d4
@ -1292,6 +1292,7 @@ int gfs2_block_map(struct inode *inode, sector_t lblock,
|
||||
loff_t length = bh_map->b_size;
|
||||
struct metapath mp = { .mp_aheight = 1, };
|
||||
struct iomap iomap = { };
|
||||
int flags = create ? IOMAP_WRITE : 0;
|
||||
int ret;
|
||||
|
||||
clear_buffer_mapped(bh_map);
|
||||
@ -1299,15 +1300,10 @@ int gfs2_block_map(struct inode *inode, sector_t lblock,
|
||||
clear_buffer_boundary(bh_map);
|
||||
trace_gfs2_bmap(ip, bh_map, lblock, create, 1);
|
||||
|
||||
if (create) {
|
||||
ret = gfs2_iomap_get(inode, pos, length, IOMAP_WRITE, &iomap, &mp);
|
||||
if (!ret && iomap.type == IOMAP_HOLE)
|
||||
ret = gfs2_iomap_alloc(inode, &iomap, &mp);
|
||||
release_metapath(&mp);
|
||||
} else {
|
||||
ret = gfs2_iomap_get(inode, pos, length, 0, &iomap, &mp);
|
||||
release_metapath(&mp);
|
||||
}
|
||||
ret = gfs2_iomap_get(inode, pos, length, flags, &iomap, &mp);
|
||||
if (create && !ret && iomap.type == IOMAP_HOLE)
|
||||
ret = gfs2_iomap_alloc(inode, &iomap, &mp);
|
||||
release_metapath(&mp);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user