Lines Matching +full:counter +full:- +full:2

1 /* SPDX-License-Identifier: GPL-2.0 */
5 * additions: Copyright (C) 2003-2004, Paul Clements, SteelEye Technology, Inc.
11 /* version 4 insists the bitmap is in little-endian order
12 * with version 3, it is host-endian which is non-portable
20 * in-memory bitmap:
23 * The 2 high order bits are special-purpose, the first is a flag indicating
26 * This means that the counter is actually 14 bits:
28 * +--------+--------+------------------------------------------------+
29 * | resync | resync | counter |
31 * | (0-1) | (0-1) | (0-16383) |
32 * +--------+--------+------------------------------------------------+
38 * It is cleared (and resync-active set) when a resync starts across all drives
47 * The counter counts pending write requests, plus the on-disk bit.
48 * When the counter is '1' and the resync bits are clear, the on-disk
49 * bit can be cleared as well, thus setting the counter to 0.
50 * When we set a bit, or in the counter (to start a write), if the fields is
51 * 0, we first set the disk bit and set the counter to 1.
53 * If the counter is 0, the on-disk bit is clear and the stripe is clean
54 * Anything that dirties the stripe pushes the counter to 2 (at least)
55 * and sets the on-disk bit (lazily).
56 * If a periodic sweep find the counter at 2, it is decremented to 1.
57 * If the sweep find the counter at 1, the on-disk bit is cleared and the
58 * counter goes to zero.
65 * page pointer (32-bit)
67 * [ ] ------+
69 * +-------> [ ][ ]..[ ] (4096 byte page == 2048 counters)
74 * hijacked page pointer (32-bit)
77 * counter #1 (16-bit) counter #2 (16-bit)
89 #define COUNTER_BYTE_SHIFT (COUNTER_BIT_SHIFT - 3)
91 #define NEEDED_MASK ((bitmap_counter_t) (1 << (COUNTER_BITS - 1)))
92 #define RESYNC_MASK ((bitmap_counter_t) (1 << (COUNTER_BITS - 2)))
93 #define COUNTER_MAX ((bitmap_counter_t) RESYNC_MASK - 1)
96 #define COUNTER(x) (((bitmap_counter_t) x) & COUNTER_MAX) macro
101 #define PAGE_COUNTER_SHIFT (PAGE_BIT_SHIFT - COUNTER_BIT_SHIFT)
103 #define PAGE_COUNTER_MASK (PAGE_COUNTER_RATIO - 1)
115 /* use these for bitmap->flags and bitmap->sb->state bit-fields */
117 BITMAP_STALE = 1, /* the bitmap file is out of date or had -EIO */
118 BITMAP_WRITE_ERROR = 2, /* A write error has occurred */
122 /* the superblock at the front of the bitmap file -- little endian */
126 __u8 uuid[16]; /* 8 128 bit uuid - must match md device uuid */
127 __le64 events; /* 24 event counter for the bitmap (1)*/
128 __le64 events_cleared;/*32 event counter when last bit cleared (2) */
133 __le32 write_behind; /* 60 number of outstanding write-behind writes */
134 __le32 sectors_reserved; /* 64 number of 512-byte sectors that are
138 __u8 pad[256 - 136]; /* set to zero */
142 * (1) This event counter is updated before the eventcounter in the md superblock
143 * When a bitmap is loaded, it is only accepted if this event counter is equal
144 * to, or one greater than, the event counter in the superblock.
145 * (2) This event counter is updated when the other one is *if*and*only*if* the
157 /* the in-memory bitmap is represented by bitmap_pages */
169 * If any counter in this page is '1' or '2' - and so could be
179 /* the main bitmap structure - one per mddev */
189 unsigned long chunkshift; /* chunksize = 2^chunkshift
221 * the bitmap daemon - periodically wakes up and sweeps the bitmap
281 return bitmap && bitmap->storage.filemap && in md_bitmap_enabled()
282 !test_bit(BITMAP_STALE, &bitmap->flags); in md_bitmap_enabled()