1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2023 Oracle. All Rights Reserved.
6 #ifndef __XFS_SCRUB_RTBITMAP_H__
7 #define __XFS_SCRUB_RTBITMAP_H__
10 * We use an xfile to construct new bitmap blocks for the portion of the
11 * rtbitmap file that we're replacing. Whereas the ondisk bitmap must be
12 * accessed through the buffer cache, the xfile bitmap supports direct
13 * word-level accesses. Therefore, we create a small abstraction for linear
16 typedef unsigned long long xrep_wordoff_t;
17 typedef unsigned int xrep_wordcnt_t;
19 /* Mask to round an rtx down to the nearest bitmap word. */
20 #define XREP_RTBMP_WORDMASK ((1ULL << XFS_NBWORDLOG) - 1)
23 struct xchk_rtbitmap {
28 unsigned int rextslog;
31 /* The next free rt group block number that we expect to see. */
32 xfs_rgblock_t next_free_rgbno;
34 #ifdef CONFIG_XFS_ONLINE_REPAIR
35 /* stuff for staging a new bitmap */
36 struct xfs_rtalloc_args args;
37 struct xrep_tempexch tempexch;
40 /* The next rtgroup block we expect to see during our rtrmapbt walk. */
41 xfs_rgblock_t next_rgbno;
43 /* rtgroup lock flags */
44 unsigned int rtglock_flags;
46 /* rtword position of xfile as we write buffers to disk. */
47 xrep_wordoff_t prep_wordoff;
49 /* In-Memory rtbitmap for repair. */
50 union xfs_rtword_raw words[];
53 #ifdef CONFIG_XFS_ONLINE_REPAIR
54 int xrep_setup_rtbitmap(struct xfs_scrub *sc, struct xchk_rtbitmap *rtb);
57 * How big should the words[] buffer be?
59 * For repairs, we want a full fsblock worth of space so that we can memcpy a
60 * buffer full of 1s into the xfile bitmap. The xfile bitmap doesn't have
61 * rtbitmap block headers, so we don't use blockwsize. Scrub doesn't use the
62 * words buffer at all.
64 static inline unsigned int
65 xchk_rtbitmap_wordcnt(
68 if (xchk_could_repair(sc))
69 return sc->mp->m_sb.sb_blocksize >> XFS_WORDLOG;
73 # define xrep_setup_rtbitmap(sc, rtb) (0)
74 # define xchk_rtbitmap_wordcnt(sc) (0)
75 #endif /* CONFIG_XFS_ONLINE_REPAIR */
77 #endif /* __XFS_SCRUB_RTBITMAP_H__ */