[PATCH v2 0/2] xfs: a few fixes and cleanups to GETFSMAP

Darrick J. Wong
2020-10-05T18:21:31Z

Hi all,

This quick series cleans up a few warts in the XFS GETFSMAP ioctl
implementation. The first patch prevents an integer overflow when
counting the mappings. The second patch improves performance of the
ioctl by formatting reverse mappings to an in-kernel buffer and then
copying the entire buffer to userspace (instead of copying the records
one by one). That eliminates an indirect call and a lot of overhead
from copying things to userspace, which is a bit expensive. It also
fixes a deadlock when formatting rt fsmappings into a mmap region
backed by sparse file on the rt device.

v2: constrain the in-kernel memory buffer size

If you're going to start using this mess, you probably ought to just
pull from my git trees, which are linked below.

This is an extraordinary way to destroy everything. Enjoy!
Comments and questions are, as always, welcome.

--D

kernel git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=getfsmap-cleanups-5.10
---
fs/xfs/xfs_fsmap.c | 48 ++++++++++-------
fs/xfs/xfs_fsmap.h | 6 --
fs/xfs/xfs_ioctl.c | 146 +++++++++++++++++++++++++++++++++++-----------------
3 files changed, 128 insertions(+), 72 deletions(-)