diff options
author | Bob Peterson <rpeterso@redhat.com> | 2020-08-19 16:24:48 +0200 |
---|---|---|
committer | Andreas Gruenbacher <agruenba@redhat.com> | 2020-10-15 14:29:04 +0200 |
commit | a6645745d45da5b3dd3ff616a3e44f7651eda9f9 (patch) | |
tree | 3662e5ba687b0d8fe99d2869b295d940cd717250 /fs/gfs2/bmap.c | |
parent | gfs2: Only set PageChecked if we have a transaction (diff) | |
download | linux-a6645745d45da5b3dd3ff616a3e44f7651eda9f9.tar.xz linux-a6645745d45da5b3dd3ff616a3e44f7651eda9f9.zip |
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>
Diffstat (limited to 'fs/gfs2/bmap.c')
-rw-r--r-- | fs/gfs2/bmap.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index ed425d30e636..62d9081d1e26 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -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; |