• Home
  • Raw
  • Download

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

1 // SPDX-License-Identifier: GPL-2.0-only
2 /* -*- mode: c; c-basic-offset: 8; -*-
30 * We use the following conventions:
33 * p = # parity bits
41 * power-of-two bits for parity, the data bit number and the code bit
42 * number are offset by all the parity bits beforehand.
44 * Recall that bit numbers in hamming code are 1-based. This function
45 * takes the 0-based data bit from the caller.
48 * so it's a parity bit. 2 is a power of two (2^1), so it's a parity bit.
53 * number of parity bits added. This allows the function to start the
61 * Data bits are 0-based, but we're talking code bits, which in calc_code_bit()
62 * are 1-based. in calc_code_bit()
66 /* Use the cache if it is there */ in calc_code_bit()
75 * would be _if_ it were bumped up by the parity bit. Capice? in calc_code_bit()
94 * parity = ocfs2_hamming_encode(0, buf1, 512 * 8, 0);
95 * parity = ocfs2_hamming_encode(parity, buf2, 512 * 8, 512 * 8);
97 * If you just have one buffer, use ocfs2_hamming_encode_block().
99 u32 ocfs2_hamming_encode(u32 parity, void *data, unsigned int d, unsigned int nr) in ocfs2_hamming_encode() argument
107 * 1-based array, but C uses 0-based. So 'i' is for C, and 'b' is in ocfs2_hamming_encode()
124 * parity bits that are part of the bit number in ocfs2_hamming_encode()
128 * In other words, the parity bit at position 2^k in ocfs2_hamming_encode()
138 parity ^= b; in ocfs2_hamming_encode()
143 return parity; in ocfs2_hamming_encode()
156 * If you only have one hunk, use ocfs2_hamming_fix_block().
166 * If the bit to fix has an hweight of 1, it's a parity bit. One in ocfs2_hamming_fix()
167 * busted parity bit is its own error. Nothing to do here. in ocfs2_hamming_fix()
191 /* Skip past parity bits */ in ocfs2_hamming_fix()
237 debugfs_remove_recursive(stats->b_debug_dir); in ocfs2_blockcheck_debug_remove()
238 stats->b_debug_dir = NULL; in ocfs2_blockcheck_debug_remove()
248 stats->b_debug_dir = dir; in ocfs2_blockcheck_debug_install()
251 &stats->b_check_count, &blockcheck_fops); in ocfs2_blockcheck_debug_install()
254 &stats->b_failure_count, &blockcheck_fops); in ocfs2_blockcheck_debug_install()
257 &stats->b_recover_count, &blockcheck_fops); in ocfs2_blockcheck_debug_install()
271 /* Always-called wrappers for starting and stopping the debugfs files */
290 spin_lock(&stats->b_lock); in ocfs2_blockcheck_inc_check()
291 stats->b_check_count++; in ocfs2_blockcheck_inc_check()
292 new_count = stats->b_check_count; in ocfs2_blockcheck_inc_check()
293 spin_unlock(&stats->b_lock); in ocfs2_blockcheck_inc_check()
306 spin_lock(&stats->b_lock); in ocfs2_blockcheck_inc_failure()
307 stats->b_failure_count++; in ocfs2_blockcheck_inc_failure()
308 new_count = stats->b_failure_count; in ocfs2_blockcheck_inc_failure()
309 spin_unlock(&stats->b_lock); in ocfs2_blockcheck_inc_failure()
322 spin_lock(&stats->b_lock); in ocfs2_blockcheck_inc_recover()
323 stats->b_recover_count++; in ocfs2_blockcheck_inc_recover()
324 new_count = stats->b_recover_count; in ocfs2_blockcheck_inc_recover()
325 spin_unlock(&stats->b_lock); in ocfs2_blockcheck_inc_recover()
334 * These are the low-level APIs for using the ocfs2_block_check structure.
347 * The data buffer must be in on-disk endian (little endian for ocfs2).
348 * bc will be filled with little-endian values and will be ready to go to
368 bc->bc_crc32e = cpu_to_le32(crc); in ocfs2_block_check_compute()
369 bc->bc_ecc = cpu_to_le16((u16)ecc); in ocfs2_block_check_compute()
378 * Again, the data passed in should be the on-disk endian.
391 bc_crc32e = le32_to_cpu(bc->bc_crc32e); in ocfs2_block_check_validate()
392 bc_ecc = le16_to_cpu(bc->bc_ecc); in ocfs2_block_check_validate()
396 /* Fast path - if the crc32 validates, we're good to go */ in ocfs2_block_check_validate()
420 rc = -EIO; in ocfs2_block_check_validate()
423 bc->bc_crc32e = cpu_to_le32(bc_crc32e); in ocfs2_block_check_validate()
424 bc->bc_ecc = cpu_to_le16(bc_ecc); in ocfs2_block_check_validate()
439 * The data buffer must be in on-disk endian (little endian for ocfs2).
440 * bc will be filled with little-endian values and will be ready to go to
457 crc = crc32_le(crc, bhs[i]->b_data, bhs[i]->b_size); in ocfs2_block_check_compute_bhs()
463 ecc = (u16)ocfs2_hamming_encode(ecc, bhs[i]->b_data, in ocfs2_block_check_compute_bhs()
464 bhs[i]->b_size * 8, in ocfs2_block_check_compute_bhs()
465 bhs[i]->b_size * 8 * i); in ocfs2_block_check_compute_bhs()
474 bc->bc_crc32e = cpu_to_le32(crc); in ocfs2_block_check_compute_bhs()
475 bc->bc_ecc = cpu_to_le16((u16)ecc); in ocfs2_block_check_compute_bhs()
485 * Again, the data passed in should be the on-disk endian.
503 bc_crc32e = le32_to_cpu(bc->bc_crc32e); in ocfs2_block_check_validate_bhs()
504 bc_ecc = le16_to_cpu(bc->bc_ecc); in ocfs2_block_check_validate_bhs()
508 /* Fast path - if the crc32 validates, we're good to go */ in ocfs2_block_check_validate_bhs()
510 crc = crc32_le(crc, bhs[i]->b_data, bhs[i]->b_size); in ocfs2_block_check_validate_bhs()
526 ecc = (u16)ocfs2_hamming_encode(ecc, bhs[i]->b_data, in ocfs2_block_check_validate_bhs()
527 bhs[i]->b_size * 8, in ocfs2_block_check_validate_bhs()
528 bhs[i]->b_size * 8 * i); in ocfs2_block_check_validate_bhs()
536 ocfs2_hamming_fix(bhs[i]->b_data, bhs[i]->b_size * 8, in ocfs2_block_check_validate_bhs()
537 bhs[i]->b_size * 8 * i, fix); in ocfs2_block_check_validate_bhs()
542 crc = crc32_le(crc, bhs[i]->b_data, bhs[i]->b_size); in ocfs2_block_check_validate_bhs()
551 rc = -EIO; in ocfs2_block_check_validate_bhs()
554 bc->bc_crc32e = cpu_to_le32(bc_crc32e); in ocfs2_block_check_validate_bhs()
555 bc->bc_ecc = cpu_to_le16(bc_ecc); in ocfs2_block_check_validate_bhs()
570 ocfs2_block_check_compute(data, sb->s_blocksize, bc); in ocfs2_compute_meta_ecc()
580 rc = ocfs2_block_check_validate(data, sb->s_blocksize, bc, in ocfs2_validate_meta_ecc()
581 &osb->osb_ecc_stats); in ocfs2_validate_meta_ecc()
603 &osb->osb_ecc_stats); in ocfs2_validate_meta_ecc_bhs()