Skip to content

Commit 7dfbcbe

Browse files
sandeenBen Myers
authored andcommitted
xfs: fallback to vmalloc for large buffers in xfs_compat_attrlist_by_handle
Shamelessly copied from dchinner's: ad650f5 xfs: fallback to vmalloc for large buffers in xfs_attrmulti_attr_get xfsdump uses 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. This was done for xfs_attrlist_by_handle but xfs_compat_attrlist_by_handle (the 32-bit version) needs the same attention. 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 dd700d9 commit 7dfbcbe

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

fs/xfs/xfs_ioctl32.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,12 @@ xfs_compat_attrlist_by_handle(
373373
return PTR_ERR(dentry);
374374

375375
error = -ENOMEM;
376-
kbuf = kmalloc(al_hreq.buflen, GFP_KERNEL);
377-
if (!kbuf)
378-
goto out_dput;
376+
kbuf = kmem_zalloc(al_hreq.buflen, KM_SLEEP | KM_MAYFAIL);
377+
if (!kbuf) {
378+
kbuf = kmem_zalloc_large(al_hreq.buflen);
379+
if (!kbuf)
380+
goto out_dput;
381+
}
379382

380383
cursor = (attrlist_cursor_kern_t *)&al_hreq.pos;
381384
error = -xfs_attr_list(XFS_I(dentry->d_inode), kbuf, al_hreq.buflen,
@@ -387,7 +390,10 @@ xfs_compat_attrlist_by_handle(
387390
error = -EFAULT;
388391

389392
out_kfree:
390-
kfree(kbuf);
393+
if (is_vmalloc_addr(kbuf))
394+
kmem_free_large(kbuf);
395+
else
396+
kmem_free(kbuf);
391397
out_dput:
392398
dput(dentry);
393399
return error;

0 commit comments

Comments
 (0)