Skip to content

Commit 08b005f

Browse files
committed
xfs: remove kmem_zalloc_greedy
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 <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> --- v2: remove single-page fallback
1 parent d582571 commit 08b005f

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
@@ -25,24 +25,6 @@
2525
#include "kmem.h"
2626
#include "xfs_message.h"
2727

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

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
@@ -361,7 +361,6 @@ xfs_bulkstat(
361361
xfs_agino_t agino; /* inode # in allocation group */
362362
xfs_agnumber_t agno; /* allocation group number */
363363
xfs_btree_cur_t *cur; /* btree cursor for ialloc btree */
364-
size_t irbsize; /* size of irec buffer in bytes */
365364
xfs_inobt_rec_incore_t *irbuf; /* start of irec buffer */
366365
int nirbuf; /* size of irbuf */
367366
int ubcount; /* size of user's buffer */
@@ -388,11 +387,10 @@ xfs_bulkstat(
388387
*ubcountp = 0;
389388
*done = 0;
390389

391-
irbuf = kmem_zalloc_greedy(&irbsize, PAGE_SIZE, PAGE_SIZE * 4);
390+
irbuf = kmem_zalloc_large(PAGE_SIZE * 4, KM_SLEEP);
392391
if (!irbuf)
393392
return -ENOMEM;
394-
395-
nirbuf = irbsize / sizeof(*irbuf);
393+
nirbuf = (PAGE_SIZE * 4) / sizeof(*irbuf);
396394

397395
/*
398396
* Loop over the allocation groups, starting from the last

0 commit comments

Comments
 (0)