public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCHSET v29.2 6/8] xfs: support in-memory btrees
@ 2024-02-01 19:39 Darrick J. Wong
  2024-02-01 19:57 ` [PATCH 1/5] xfs: teach buftargs to maintain their own buffer hashtable Darrick J. Wong
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Darrick J. Wong @ 2024-02-01 19:39 UTC (permalink / raw)
  To: djwong; +Cc: Christoph Hellwig, hch, linux-xfs, willy

Hi all,

Online repair of the reverse-mapping btrees presens some unique
challenges.  To construct a new reverse mapping btree, we must scan the
entire filesystem, but we cannot afford to quiesce the entire filesystem
for the potentially lengthy scan.

For rmap btrees, therefore, we relax our requirements of totally atomic
repairs.  Instead, repairs will scan all inodes, construct a new reverse
mapping dataset, format a new btree, and commit it before anyone trips
over the corruption.  This is exactly the same strategy as was used in
the quotacheck and nlink scanners.

Unfortunately, the xfarray cannot perform key-based lookups and is
therefore unsuitable for supporting live updates.  Luckily, we already a
data structure that maintains an indexed rmap recordset -- the existing
rmap btree code!  Hence we port the existing btree and buffer target
code to be able to create a btree using the xfile we developed earlier.
Live hooks keep the in-memory btree up to date for any resources that
have already been scanned.

This approach is not maximally memory efficient, but we can use the same
rmap code that we do everywhere else, which provides improved stability
without growing the code base even more.  Note that in-memory btree
blocks are always page sized.

This patchset modifies the kernel xfs buffer cache to be capable of
using a xfile (aka a shmem file) as a backing device.  It then augments
the btree code to support creating btree cursors with buffers that come
from a buftarg other than the data device (namely an xfile-backed
buftarg).  For the userspace xfs buffer cache, we instead use a memfd or
an O_TMPFILE file as a backing device.

If you're going to start using this code, I strongly recommend pulling
from my git trees, which are linked below.

This has been running on the djcloud for months with no problems.  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=in-memory-btrees

xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=in-memory-btrees
---
Commits in this patchset:
 * xfs: teach buftargs to maintain their own buffer hashtable
 * xfs: support in-memory buffer cache targets
 * xfs: add a xfs_btree_ptrs_equal helper
 * xfs: support in-memory btrees
 * xfs: launder in-memory btree buffers before transaction commit
---
 .../filesystems/xfs/xfs-online-fsck-design.rst     |    5 
 fs/xfs/Kconfig                                     |    8 
 fs/xfs/Makefile                                    |    2 
 fs/xfs/libxfs/xfs_ag.c                             |    6 
 fs/xfs/libxfs/xfs_ag.h                             |    4 
 fs/xfs/libxfs/xfs_btree.c                          |  286 ++++++++++++++--
 fs/xfs/libxfs/xfs_btree.h                          |    7 
 fs/xfs/libxfs/xfs_btree_mem.c                      |  347 ++++++++++++++++++++
 fs/xfs/libxfs/xfs_btree_mem.h                      |   75 ++++
 fs/xfs/scrub/scrub.c                               |    5 
 fs/xfs/scrub/scrub.h                               |    3 
 fs/xfs/xfs_buf.c                                   |  214 ++++++++----
 fs/xfs/xfs_buf.h                                   |   17 +
 fs/xfs/xfs_buf_mem.c                               |  270 ++++++++++++++++
 fs/xfs/xfs_buf_mem.h                               |   34 ++
 fs/xfs/xfs_health.c                                |    3 
 fs/xfs/xfs_mount.h                                 |    3 
 fs/xfs/xfs_trace.c                                 |    2 
 fs/xfs/xfs_trace.h                                 |  167 ++++++++++
 fs/xfs/xfs_trans.h                                 |    1 
 fs/xfs/xfs_trans_buf.c                             |   42 ++
 21 files changed, 1363 insertions(+), 138 deletions(-)
 create mode 100644 fs/xfs/libxfs/xfs_btree_mem.c
 create mode 100644 fs/xfs/libxfs/xfs_btree_mem.h
 create mode 100644 fs/xfs/xfs_buf_mem.c
 create mode 100644 fs/xfs/xfs_buf_mem.h


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-02-02  6:27 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-01 19:39 [PATCHSET v29.2 6/8] xfs: support in-memory btrees Darrick J. Wong
2024-02-01 19:57 ` [PATCH 1/5] xfs: teach buftargs to maintain their own buffer hashtable Darrick J. Wong
2024-02-02  6:26   ` Christoph Hellwig
2024-02-01 19:57 ` [PATCH 2/5] xfs: support in-memory buffer cache targets Darrick J. Wong
2024-02-02  6:27   ` Christoph Hellwig
2024-02-01 19:58 ` [PATCH 3/5] xfs: add a xfs_btree_ptrs_equal helper Darrick J. Wong
2024-02-01 19:58 ` [PATCH 4/5] xfs: support in-memory btrees Darrick J. Wong
2024-02-02  6:27   ` Christoph Hellwig
2024-02-01 19:58 ` [PATCH 5/5] xfs: launder in-memory btree buffers before transaction commit Darrick J. Wong
2024-02-02  6:27   ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox