Skip to content

Commit 0185496

Browse files
djwonggregkh
authored andcommitted
xfs: remove kmem_zalloc_greedy
[ Upstream commit 08b005f1333154ae5b404ca28766e0ffb9f1c150 ] The sole remaining caller of kmem_zalloc_greedy is bulkstat, which uses it to grab 1-4 pages for staging of inobt records. The infinite loop in the greedy allocation function is causing hangs[1] in generic/269, so just get rid of the greedy allocator in favor of kmem_zalloc_large. This makes bulkstat somewhat more likely to ENOMEM if there's really no pages to spare, but eliminates a source of hangs. [1] http://lkml.kernel.org/r/20170301044634.rgidgdqqiiwsmfpj%40XZHOUW.usersys.redhat.com Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 088b9a4 commit 0185496

3 files changed

Lines changed: 2 additions & 24 deletions

File tree

fs/xfs/kmem.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,6 @@
2424
#include "kmem.h"
2525
#include "xfs_message.h"
2626

27-
/*
28-
* Greedy allocation. May fail and may return vmalloced memory.
29-
*/
30-
void *
31-
kmem_zalloc_greedy(size_t *size, size_t minsize, size_t maxsize)
32-
{
33-
void *ptr;
34-
size_t kmsize = maxsize;
35-
36-
while (!(ptr = vzalloc(kmsize))) {
37-
if ((kmsize >>= 1) <= minsize)
38-
kmsize = minsize;
39-
}
40-
if (ptr)
41-
*size = kmsize;
42-
return ptr;
43-
}
44-
4527
void *
4628
kmem_alloc(size_t size, xfs_km_flags_t flags)
4729
{

fs/xfs/kmem.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ static inline void kmem_free(const void *ptr)
6969
}
7070

7171

72-
extern void *kmem_zalloc_greedy(size_t *, size_t, size_t);
73-
7472
static inline void *
7573
kmem_zalloc(size_t size, xfs_km_flags_t flags)
7674
{

fs/xfs/xfs_itable.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,6 @@ xfs_bulkstat(
351351
xfs_agino_t agino; /* inode # in allocation group */
352352
xfs_agnumber_t agno; /* allocation group number */
353353
xfs_btree_cur_t *cur; /* btree cursor for ialloc btree */
354-
size_t irbsize; /* size of irec buffer in bytes */
355354
xfs_inobt_rec_incore_t *irbuf; /* start of irec buffer */
356355
int nirbuf; /* size of irbuf */
357356
int ubcount; /* size of user's buffer */
@@ -378,11 +377,10 @@ xfs_bulkstat(
378377
*ubcountp = 0;
379378
*done = 0;
380379

381-
irbuf = kmem_zalloc_greedy(&irbsize, PAGE_SIZE, PAGE_SIZE * 4);
380+
irbuf = kmem_zalloc_large(PAGE_SIZE * 4, KM_SLEEP);
382381
if (!irbuf)
383382
return -ENOMEM;
384-
385-
nirbuf = irbsize / sizeof(*irbuf);
383+
nirbuf = (PAGE_SIZE * 4) / sizeof(*irbuf);
386384

387385
/*
388386
* Loop over the allocation groups, starting from the last

0 commit comments

Comments
 (0)