Skip to content

Commit dd700d9

Browse files
Eric SandeenBen Myers
authored andcommitted
xfs: fallback to vmalloc for large buffers in xfs_attrlist_by_handle
Shamelessly copied from dchinner's: ad650f5 xfs: fallback to vmalloc for large buffers in xfs_attrmulti_attr_get xfsdump uses for a large buffer for extended attributes, which has a kmalloc'd shadow buffer in the kernel. This can fail after the system has been running for some time as it is a high order allocation. Add a fallback to vmalloc so that it doesn't require contiguous memory and so won't randomly fail while xfsdump is running. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Mark Tinguely <tinguely@sgi.com> Signed-off-by: Ben Myers <bpm@sgi.com>
1 parent 742ae1e commit dd700d9

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

fs/xfs/xfs_ioctl.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,12 @@ xfs_attrlist_by_handle(
422422
if (IS_ERR(dentry))
423423
return PTR_ERR(dentry);
424424

425-
kbuf = kzalloc(al_hreq.buflen, GFP_KERNEL);
426-
if (!kbuf)
427-
goto out_dput;
425+
kbuf = kmem_zalloc(al_hreq.buflen, KM_SLEEP | KM_MAYFAIL);
426+
if (!kbuf) {
427+
kbuf = kmem_zalloc_large(al_hreq.buflen);
428+
if (!kbuf)
429+
goto out_dput;
430+
}
428431

429432
cursor = (attrlist_cursor_kern_t *)&al_hreq.pos;
430433
error = -xfs_attr_list(XFS_I(dentry->d_inode), kbuf, al_hreq.buflen,
@@ -436,7 +439,10 @@ xfs_attrlist_by_handle(
436439
error = -EFAULT;
437440

438441
out_kfree:
439-
kfree(kbuf);
442+
if (is_vmalloc_addr(kbuf))
443+
kmem_free_large(kbuf);
444+
else
445+
kmem_free(kbuf);
440446
out_dput:
441447
dput(dentry);
442448
return error;

0 commit comments

Comments
 (0)