]> Git Repo - linux.git/blob - fs/xfs/scrub/rtbitmap.h
Linux 6.14-rc3
[linux.git] / fs / xfs / scrub / rtbitmap.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (C) 2023 Oracle.  All Rights Reserved.
4  * Author: Darrick J. Wong <[email protected]>
5  */
6 #ifndef __XFS_SCRUB_RTBITMAP_H__
7 #define __XFS_SCRUB_RTBITMAP_H__
8
9 /*
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
14  * access.
15  */
16 typedef unsigned long long xrep_wordoff_t;
17 typedef unsigned int xrep_wordcnt_t;
18
19 /* Mask to round an rtx down to the nearest bitmap word. */
20 #define XREP_RTBMP_WORDMASK     ((1ULL << XFS_NBWORDLOG) - 1)
21
22
23 struct xchk_rtbitmap {
24         struct xfs_scrub        *sc;
25
26         uint64_t                rextents;
27         uint64_t                rbmblocks;
28         unsigned int            rextslog;
29         unsigned int            resblks;
30
31         /* The next free rt group block number that we expect to see. */
32         xfs_rgblock_t           next_free_rgbno;
33
34 #ifdef CONFIG_XFS_ONLINE_REPAIR
35         /* stuff for staging a new bitmap */
36         struct xfs_rtalloc_args args;
37         struct xrep_tempexch    tempexch;
38 #endif
39
40         /* The next rtgroup block we expect to see during our rtrmapbt walk. */
41         xfs_rgblock_t           next_rgbno;
42
43         /* rtgroup lock flags */
44         unsigned int            rtglock_flags;
45
46         /* rtword position of xfile as we write buffers to disk. */
47         xrep_wordoff_t          prep_wordoff;
48
49         /* In-Memory rtbitmap for repair. */
50         union xfs_rtword_raw    words[];
51 };
52
53 #ifdef CONFIG_XFS_ONLINE_REPAIR
54 int xrep_setup_rtbitmap(struct xfs_scrub *sc, struct xchk_rtbitmap *rtb);
55
56 /*
57  * How big should the words[] buffer be?
58  *
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.
63  */
64 static inline unsigned int
65 xchk_rtbitmap_wordcnt(
66         struct xfs_scrub        *sc)
67 {
68         if (xchk_could_repair(sc))
69                 return sc->mp->m_sb.sb_blocksize >> XFS_WORDLOG;
70         return 0;
71 }
72 #else
73 # define xrep_setup_rtbitmap(sc, rtb)   (0)
74 # define xchk_rtbitmap_wordcnt(sc)      (0)
75 #endif /* CONFIG_XFS_ONLINE_REPAIR */
76
77 #endif /* __XFS_SCRUB_RTBITMAP_H__ */
This page took 0.033779 seconds and 4 git commands to generate.