Lines Matching +full:use +full:- +full:parity

1 // SPDX-License-Identifier: GPL-2.0-only
28 * We use the following conventions:
31 * p = # parity bits
39 * power-of-two bits for parity, the data bit number and the code bit
40 * number are offset by all the parity bits beforehand.
42 * Recall that bit numbers in hamming code are 1-based. This function
43 * takes the 0-based data bit from the caller.
46 * so it's a parity bit. 2 is a power of two (2^1), so it's a parity bit.
51 * number of parity bits added. This allows the function to start the
59 * Data bits are 0-based, but we're talking code bits, which in calc_code_bit()
60 * are 1-based. in calc_code_bit()
64 /* Use the cache if it is there */ in calc_code_bit()
73 * would be _if_ it were bumped up by the parity bit. Capice? in calc_code_bit()
92 * parity = ocfs2_hamming_encode(0, buf1, 512 * 8, 0);
93 * parity = ocfs2_hamming_encode(parity, buf2, 512 * 8, 512 * 8);
95 * If you just have one buffer, use ocfs2_hamming_encode_block().
97 u32 ocfs2_hamming_encode(u32 parity, void *data, unsigned int d, unsigned int nr) in ocfs2_hamming_encode() argument
105 * 1-based array, but C uses 0-based. So 'i' is for C, and 'b' is in ocfs2_hamming_encode()
122 * parity bits that are part of the bit number in ocfs2_hamming_encode()
126 * In other words, the parity bit at position 2^k in ocfs2_hamming_encode()
136 parity ^= b; in ocfs2_hamming_encode()
141 return parity; in ocfs2_hamming_encode()
154 * If you only have one hunk, use ocfs2_hamming_fix_block().
164 * If the bit to fix has an hweight of 1, it's a parity bit. One in ocfs2_hamming_fix()
165 * busted parity bit is its own error. Nothing to do here. in ocfs2_hamming_fix()
189 /* Skip past parity bits */ in ocfs2_hamming_fix()
235 debugfs_remove_recursive(stats->b_debug_dir); in ocfs2_blockcheck_debug_remove()
236 stats->b_debug_dir = NULL; in ocfs2_blockcheck_debug_remove()
246 stats->b_debug_dir = dir; in ocfs2_blockcheck_debug_install()
249 &stats->b_check_count, &blockcheck_fops); in ocfs2_blockcheck_debug_install()
252 &stats->b_failure_count, &blockcheck_fops); in ocfs2_blockcheck_debug_install()
255 &stats->b_recover_count, &blockcheck_fops); in ocfs2_blockcheck_debug_install()
269 /* Always-called wrappers for starting and stopping the debugfs files */
288 spin_lock(&stats->b_lock); in ocfs2_blockcheck_inc_check()
289 stats->b_check_count++; in ocfs2_blockcheck_inc_check()
290 new_count = stats->b_check_count; in ocfs2_blockcheck_inc_check()
291 spin_unlock(&stats->b_lock); in ocfs2_blockcheck_inc_check()
304 spin_lock(&stats->b_lock); in ocfs2_blockcheck_inc_failure()
305 stats->b_failure_count++; in ocfs2_blockcheck_inc_failure()
306 new_count = stats->b_failure_count; in ocfs2_blockcheck_inc_failure()
307 spin_unlock(&stats->b_lock); in ocfs2_blockcheck_inc_failure()
320 spin_lock(&stats->b_lock); in ocfs2_blockcheck_inc_recover()
321 stats->b_recover_count++; in ocfs2_blockcheck_inc_recover()
322 new_count = stats->b_recover_count; in ocfs2_blockcheck_inc_recover()
323 spin_unlock(&stats->b_lock); in ocfs2_blockcheck_inc_recover()
332 * These are the low-level APIs for using the ocfs2_block_check structure.
345 * The data buffer must be in on-disk endian (little endian for ocfs2).
346 * bc will be filled with little-endian values and will be ready to go to
366 bc->bc_crc32e = cpu_to_le32(crc); in ocfs2_block_check_compute()
367 bc->bc_ecc = cpu_to_le16((u16)ecc); in ocfs2_block_check_compute()
376 * Again, the data passed in should be the on-disk endian.
389 bc_crc32e = le32_to_cpu(bc->bc_crc32e); in ocfs2_block_check_validate()
390 bc_ecc = le16_to_cpu(bc->bc_ecc); in ocfs2_block_check_validate()
394 /* Fast path - if the crc32 validates, we're good to go */ in ocfs2_block_check_validate()
418 rc = -EIO; in ocfs2_block_check_validate()
421 bc->bc_crc32e = cpu_to_le32(bc_crc32e); in ocfs2_block_check_validate()
422 bc->bc_ecc = cpu_to_le16(bc_ecc); in ocfs2_block_check_validate()
437 * The data buffer must be in on-disk endian (little endian for ocfs2).
438 * bc will be filled with little-endian values and will be ready to go to
455 crc = crc32_le(crc, bhs[i]->b_data, bhs[i]->b_size); in ocfs2_block_check_compute_bhs()
461 ecc = (u16)ocfs2_hamming_encode(ecc, bhs[i]->b_data, in ocfs2_block_check_compute_bhs()
462 bhs[i]->b_size * 8, in ocfs2_block_check_compute_bhs()
463 bhs[i]->b_size * 8 * i); in ocfs2_block_check_compute_bhs()
472 bc->bc_crc32e = cpu_to_le32(crc); in ocfs2_block_check_compute_bhs()
473 bc->bc_ecc = cpu_to_le16((u16)ecc); in ocfs2_block_check_compute_bhs()
483 * Again, the data passed in should be the on-disk endian.
501 bc_crc32e = le32_to_cpu(bc->bc_crc32e); in ocfs2_block_check_validate_bhs()
502 bc_ecc = le16_to_cpu(bc->bc_ecc); in ocfs2_block_check_validate_bhs()
506 /* Fast path - if the crc32 validates, we're good to go */ in ocfs2_block_check_validate_bhs()
508 crc = crc32_le(crc, bhs[i]->b_data, bhs[i]->b_size); in ocfs2_block_check_validate_bhs()
524 ecc = (u16)ocfs2_hamming_encode(ecc, bhs[i]->b_data, in ocfs2_block_check_validate_bhs()
525 bhs[i]->b_size * 8, in ocfs2_block_check_validate_bhs()
526 bhs[i]->b_size * 8 * i); in ocfs2_block_check_validate_bhs()
534 ocfs2_hamming_fix(bhs[i]->b_data, bhs[i]->b_size * 8, in ocfs2_block_check_validate_bhs()
535 bhs[i]->b_size * 8 * i, fix); in ocfs2_block_check_validate_bhs()
540 crc = crc32_le(crc, bhs[i]->b_data, bhs[i]->b_size); in ocfs2_block_check_validate_bhs()
549 rc = -EIO; in ocfs2_block_check_validate_bhs()
552 bc->bc_crc32e = cpu_to_le32(bc_crc32e); in ocfs2_block_check_validate_bhs()
553 bc->bc_ecc = cpu_to_le16(bc_ecc); in ocfs2_block_check_validate_bhs()
568 ocfs2_block_check_compute(data, sb->s_blocksize, bc); in ocfs2_compute_meta_ecc()
578 rc = ocfs2_block_check_validate(data, sb->s_blocksize, bc, in ocfs2_validate_meta_ecc()
579 &osb->osb_ecc_stats); in ocfs2_validate_meta_ecc()
601 &osb->osb_ecc_stats); in ocfs2_validate_meta_ecc_bhs()