~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/ocfs2/blockcheck.h

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0-only */
  2 /*
  3  * blockcheck.h
  4  *
  5  * Checksum and ECC codes for the OCFS2 userspace library.
  6  *
  7  * Copyright (C) 2004, 2008 Oracle.  All rights reserved.
  8  */
  9 
 10 #ifndef OCFS2_BLOCKCHECK_H
 11 #define OCFS2_BLOCKCHECK_H
 12 
 13 
 14 /* Count errors and error correction from blockcheck.c */
 15 struct ocfs2_blockcheck_stats {
 16         spinlock_t b_lock;
 17         u64 b_check_count;      /* Number of blocks we've checked */
 18         u64 b_failure_count;    /* Number of failed checksums */
 19         u64 b_recover_count;    /* Number of blocks fixed by ecc */
 20 
 21         /*
 22          * debugfs entries, used if this is passed to
 23          * ocfs2_blockcheck_stats_debugfs_install()
 24          */
 25         struct dentry *b_debug_dir;     /* Parent of the debugfs  files */
 26 };
 27 
 28 
 29 /* High level block API */
 30 void ocfs2_compute_meta_ecc(struct super_block *sb, void *data,
 31                             struct ocfs2_block_check *bc);
 32 int ocfs2_validate_meta_ecc(struct super_block *sb, void *data,
 33                             struct ocfs2_block_check *bc);
 34 void ocfs2_compute_meta_ecc_bhs(struct super_block *sb,
 35                                 struct buffer_head **bhs, int nr,
 36                                 struct ocfs2_block_check *bc);
 37 int ocfs2_validate_meta_ecc_bhs(struct super_block *sb,
 38                                 struct buffer_head **bhs, int nr,
 39                                 struct ocfs2_block_check *bc);
 40 
 41 /* Lower level API */
 42 void ocfs2_block_check_compute(void *data, size_t blocksize,
 43                                struct ocfs2_block_check *bc);
 44 int ocfs2_block_check_validate(void *data, size_t blocksize,
 45                                struct ocfs2_block_check *bc,
 46                                struct ocfs2_blockcheck_stats *stats);
 47 void ocfs2_block_check_compute_bhs(struct buffer_head **bhs, int nr,
 48                                    struct ocfs2_block_check *bc);
 49 int ocfs2_block_check_validate_bhs(struct buffer_head **bhs, int nr,
 50                                    struct ocfs2_block_check *bc,
 51                                    struct ocfs2_blockcheck_stats *stats);
 52 
 53 /* Debug Initialization */
 54 void ocfs2_blockcheck_stats_debugfs_install(struct ocfs2_blockcheck_stats *stats,
 55                                             struct dentry *parent);
 56 void ocfs2_blockcheck_stats_debugfs_remove(struct ocfs2_blockcheck_stats *stats);
 57 
 58 /*
 59  * Hamming code functions
 60  */
 61 
 62 /*
 63  * Encoding hamming code parity bits for a buffer.
 64  *
 65  * This is the low level encoder function.  It can be called across
 66  * multiple hunks just like the crc32 code.  'd' is the number of bits
 67  * _in_this_hunk_.  nr is the bit offset of this hunk.  So, if you had
 68  * two 512B buffers, you would do it like so:
 69  *
 70  * parity = ocfs2_hamming_encode(0, buf1, 512 * 8, 0);
 71  * parity = ocfs2_hamming_encode(parity, buf2, 512 * 8, 512 * 8);
 72  *
 73  * If you just have one buffer, use ocfs2_hamming_encode_block().
 74  */
 75 u32 ocfs2_hamming_encode(u32 parity, void *data, unsigned int d,
 76                          unsigned int nr);
 77 /*
 78  * Fix a buffer with a bit error.  The 'fix' is the original parity
 79  * xor'd with the parity calculated now.
 80  *
 81  * Like ocfs2_hamming_encode(), this can handle hunks.  nr is the bit
 82  * offset of the current hunk.  If bit to be fixed is not part of the
 83  * current hunk, this does nothing.
 84  *
 85  * If you only have one buffer, use ocfs2_hamming_fix_block().
 86  */
 87 void ocfs2_hamming_fix(void *data, unsigned int d, unsigned int nr,
 88                        unsigned int fix);
 89 
 90 /* Convenience wrappers for a single buffer of data */
 91 extern u32 ocfs2_hamming_encode_block(void *data, unsigned int blocksize);
 92 extern void ocfs2_hamming_fix_block(void *data, unsigned int blocksize,
 93                                     unsigned int fix);
 94 #endif
 95 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php