mirror of
https://github.com/torvalds/linux.git
synced 2024-12-03 17:41:22 +00:00
0dc63c8a1c
As we've noted in various places, all current users of in-memory btrees are online fsck. Online fsck only stages a btree long enough to rebuild an ondisk data structure, which means that the in-memory btree is ephemeral. Furthermore, if we encounter /any/ errors while updating an in-memory btree, all we do is tear down all the staged data and return an errno to userspace. In-memory btrees need not be transactional, so their buffers should not be committed to the ondisk log, nor should they be checkpointed by the AIL. That's just as well since the ephemeral nature of the btree means that the buftarg and the buffers may disappear quickly anyway. Therefore, we need a way to launder the btree buffers that get attached to the transaction by the generic btree code. Because the buffers are directly mapped to backing file pages, there's no need to bwrite them back to the tmpfs file. All we need to do is clean enough of the buffer log item state so that the bli can be detached from the buffer, remove the bli from the transaction's log item list, and reset the transaction dirty state as if the laundered items had never been there. For simplicity, create xfbtree transaction commit and cancel helpers that launder the in-memory btree buffers for callers. Once laundered, call the write verifier on non-stale buffers to avoid integrity issues, or punch a hole in the backing file for stale buffers. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
35 lines
1.0 KiB
C
35 lines
1.0 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
* Copyright (c) 2023-2024 Oracle. All Rights Reserved.
|
|
* Author: Darrick J. Wong <djwong@kernel.org>
|
|
*/
|
|
#ifndef __XFS_BUF_MEM_H__
|
|
#define __XFS_BUF_MEM_H__
|
|
|
|
#define XMBUF_BLOCKSIZE (PAGE_SIZE)
|
|
#define XMBUF_BLOCKSHIFT (PAGE_SHIFT)
|
|
|
|
#ifdef CONFIG_XFS_MEMORY_BUFS
|
|
static inline bool xfs_buftarg_is_mem(const struct xfs_buftarg *btp)
|
|
{
|
|
return btp->bt_bdev == NULL;
|
|
}
|
|
|
|
int xmbuf_alloc(struct xfs_mount *mp, const char *descr,
|
|
struct xfs_buftarg **btpp);
|
|
void xmbuf_free(struct xfs_buftarg *btp);
|
|
|
|
int xmbuf_map_page(struct xfs_buf *bp);
|
|
void xmbuf_unmap_page(struct xfs_buf *bp);
|
|
bool xmbuf_verify_daddr(struct xfs_buftarg *btp, xfs_daddr_t daddr);
|
|
void xmbuf_trans_bdetach(struct xfs_trans *tp, struct xfs_buf *bp);
|
|
int xmbuf_finalize(struct xfs_buf *bp);
|
|
#else
|
|
# define xfs_buftarg_is_mem(...) (false)
|
|
# define xmbuf_map_page(...) (-ENOMEM)
|
|
# define xmbuf_unmap_page(...) ((void)0)
|
|
# define xmbuf_verify_daddr(...) (false)
|
|
#endif /* CONFIG_XFS_MEMORY_BUFS */
|
|
|
|
#endif /* __XFS_BUF_MEM_H__ */
|