Skip to content

Commit 5abea70

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
xfs: remove xfs_buf_get_maps
xfs_buf_get_maps has a single caller, and can just be open coded there. When doing that, stop handling the allocation failure as we always pass __GFP_NOFAIL to the slab allocator, and use the proper kcalloc helper for array allocations. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Carlos Maiolino <[email protected]> Signed-off-by: Carlos Maiolino <[email protected]>
1 parent 1ec1207 commit 5abea70

File tree

1 file changed

+6
-27
lines changed

1 file changed

+6
-27
lines changed

fs/xfs/xfs_buf.c

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -88,26 +88,6 @@ xfs_buf_stale(
8888
spin_unlock(&bp->b_lock);
8989
}
9090

91-
static int
92-
xfs_buf_get_maps(
93-
struct xfs_buf *bp,
94-
int map_count)
95-
{
96-
ASSERT(bp->b_maps == NULL);
97-
bp->b_map_count = map_count;
98-
99-
if (map_count == 1) {
100-
bp->b_maps = &bp->__b_map;
101-
return 0;
102-
}
103-
104-
bp->b_maps = kzalloc(map_count * sizeof(struct xfs_buf_map),
105-
GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL);
106-
if (!bp->b_maps)
107-
return -ENOMEM;
108-
return 0;
109-
}
110-
11191
static void
11292
xfs_buf_free_maps(
11393
struct xfs_buf *bp)
@@ -317,15 +297,14 @@ xfs_buf_alloc(
317297
bp->b_target = target;
318298
bp->b_mount = target->bt_mount;
319299
bp->b_flags = flags;
320-
321-
error = xfs_buf_get_maps(bp, nmaps);
322-
if (error) {
323-
kmem_cache_free(xfs_buf_cache, bp);
324-
return error;
325-
}
326-
327300
bp->b_rhash_key = map[0].bm_bn;
328301
bp->b_length = 0;
302+
bp->b_map_count = nmaps;
303+
if (nmaps == 1)
304+
bp->b_maps = &bp->__b_map;
305+
else
306+
bp->b_maps = kcalloc(nmaps, sizeof(struct xfs_buf_map),
307+
GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL);
329308
for (i = 0; i < nmaps; i++) {
330309
bp->b_maps[i].bm_bn = map[i].bm_bn;
331310
bp->b_maps[i].bm_len = map[i].bm_len;

0 commit comments

Comments
 (0)