db_block_checksum 参数解析

本文详细介绍了Oracle数据库中的DB_BLOCK_CHECKSUM参数的作用及设置方法。此参数用于生成redo log file block的校验值,有助于检测block是否损坏。文章还讨论了不同设置对性能的影响,并建议使用typical(true)模式。
部署运行你感兴趣的模型镜像
db_block_checksum 参数解析
你可以使用DB_BLOCK_CHECKSUM参数产生来生成redo log file block 的校验值。数据库会为每一个
block 生成一个校验值,当block 写入磁盘中的时候,校验信息会存储在磁盘block中的头部。oracle
在检查redo log block 是否损坏的时候将用到block 的校验值。当实例恢复从归档日志中读取redo
data 的时候会对block 进行校验,同样的归档进程读取日志文件中的信息的时候也会对redo block
进行校验。当归档的时候发现有块损坏,系统会尝试从同组的其他日志文件成员中读取该块。如果
在该组中的所有的日志文件中的该块都已经损坏,则归档不能够继续。另外当启用db_block_checksum 
的时候会轻微的影响数据库系统的性能。此时你需要考虑是数据库的性能重要还是block的完整性重要。
该参数的值可以动态的通过alter system 语句更改。默认值是 typical(ture).
SQL> show parameter db_block_checksum;
NAME                                 TYPE        VALUE
------------------------------------ ----------- -------
db_block_checksum                    string      TYPICAL
另外如果启用了该特性DBWn 写data buffer 中的数据到磁盘块中的时候也会生成校验值。从磁盘中
读数据块的时候会进行校验。开启db_block_checksum 应该设置该参数的值为typical(ture)或者 full.
但是如果该参数的值是full。DBWn 在删除,更新语句执行以后会对有改动的数据库进行重新生成校验
值。LGWR 会对前台进程产生的校验值进行校验再进行写入。在full 模式下如果出现了损坏的数据库
将不会被写入磁盘。从oracle 11g 开始大部分的 redo block 校验值是由前台进程产生的。
如果该参数的值设置为off(flase),DBWn 只会为system 表空间的数据生成校验值。日志文件数据库将会不
生成校验值了。
在typical(ture) 模式下将会产生额外开销(1%~2%)。
在full 模式下将会产生的额外开销(4%~5%)。
oracle 推荐使用typical (ture)模式。
ture,false 是为了向后兼容而保留的参数。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26110315/viewspace-718304/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/26110315/viewspace-718304/

您可能感兴趣的与本文相关的镜像

Llama Factory

Llama Factory

模型微调
LLama-Factory

LLaMA Factory 是一个简单易用且高效的大型语言模型(Large Language Model)训练与微调平台。通过 LLaMA Factory,可以在无需编写任何代码的前提下,在本地完成上百种预训练模型的微调

头信息示例如下vbf_version = 2.6; header { sw_part_number = "8895913857"; sw_version = "B"; sw_part_type = DATA; data_format_identifier = 0x00; ecu_address = 0x1012; erase = { { 0x00B60000, 0x00010000 }, { 0x40200300, 0x00000D00 } }; verification_block_start = 0x40200300; verification_block_length = 0x0000002C; verification_block_root_hash = 0x3AB70E8A9C521B370E37D6FF03263770426297167C495C80C8AF3EA0B9AC3C7C; file_checksum = 0xEDB03AFF; sw_signature_dev = 0x7B3E3A02DBBC87DCC7BB9BFD795C7D1355C82DCA947BA5225B5BC549F4FF1648C3DC78C7947DF7F751A856351FBF340CB9F9E5B0790F026DC080800EA8A7AE6383DF63A0C8447ADB921A29A6FD2B84BA83D4769301FDBD3B019442A8FC588864F299D546587019E7700C345899F4CBEA7E5F831132DDC563C589DDD64F5A842129B803BC4C324310918162BC01E6312374A370A39F201F425B4DB457F8BA829A459BD5ED9E1673D9BD923D5E1287AAB45AC3B8999FC96CA514CB5EFBEBD5B23FDBF8AC944C376F44153B2C7F3B415AB87D274A4BD2DD120B70DA67721062F03125FA9D162C10855CD4F59A43253D0421A8D7AE851188E9D0EB1BAB13DE308012; sw_signature = 0x422CB67A399E4C7E0AA3621C8B9DA49947E5E655E83D0181A76CFA8FEFD250E0615576E3907530A4263F3198B8080ACE74E5113987EFA419B88B409D794860FD4A65511B2C95B1716947C6B7BE335800D8231C327AB866B7CA4D4F9CCB06BEEBDBA5EB797E21FC419B7D608D68FDD9F8095603ED298991DB8AC836D023B2059BF3641D6BADC4F626F5DC201561726FE9FB58BB4AEA0A04B0D9FE3B05C072AAA0CFE711679635187062FDB1AED7309E3D4F3400D1A4254884832CDB20C2C7DA0E264EF7F622DC0042C94AB19D7C74C966999A2A6D0F4C43EE179FFB6743FD056113898DFD1FF3E5E0DDE3B7010381857F046CCAD27357F39403FA2776821C438F; }, 请用c写代码 把头信息都解析出来
06-09
static bool 113 verify_data_block(struct inode *inode, struct fsverity_info *vi, 114 const struct fsverity_pending_block *dblock, 115 unsigned long max_ra_pages) 116 { 117 const u64 data_pos = dblock->pos; 118 const struct merkle_tree_params *params = &vi->tree_params; 119 const unsigned int hsize = params->digest_size; 120 int level; 121 u8 _want_hash[FS_VERITY_MAX_DIGEST_SIZE]; 122 const u8 *want_hash; 123 u8 real_hash[FS_VERITY_MAX_DIGEST_SIZE]; 124 /* The hash blocks that are traversed, indexed by level */ 125 struct { 126 /* Page containing the hash block */ 127 struct page *page; 128 /* Mapped address of the hash block (will be within @page) */ 129 const void *addr; 130 /* Index of the hash block in the tree overall */ 131 unsigned long index; 132 /* Byte offset of the wanted hash relative to @addr */ 133 unsigned int hoffset; 134 } hblocks[FS_VERITY_MAX_LEVELS]; 135 /* 136 * The index of the previous level's block within that level; also the 137 * index of that block's hash within the current level. 138 */ 139 u64 hidx = data_pos >> params->log_blocksize; 140 141 /* 142 * Up to FS_VERITY_MAX_PENDING_DATA_BLOCKS + FS_VERITY_MAX_LEVELS pages 143 * may be mapped at once. 144 */ 145 BUILD_BUG_ON(FS_VERITY_MAX_PENDING_DATA_BLOCKS + 146 FS_VERITY_MAX_LEVELS > KM_MAX_IDX); 147 148 if (unlikely(data_pos >= inode->i_size)) { 149 /* 150 * This can happen in the data page spanning EOF when the Merkle 151 * tree block size is less than the page size. The Merkle tree 152 * doesn't cover data blocks fully past EOF. But the entire 153 * page spanning EOF can be visible to userspace via a mmap, and 154 * any part past EOF should be all zeroes. Therefore, we need 155 * to verify that any data blocks fully past EOF are all zeroes. 156 */ 157 if (memchr_inv(dblock->data, 0, params->block_size)) { 158 fsverity_err(inode, 159 "FILE CORRUPTED! Data past EOF is not zeroed"); 160 return false; 161 } 162 return true; 163 } 164 165 /* 166 * Starting at the leaf level, ascend the tree saving hash blocks along 167 * the way until we find a hash block that has already been verified, or 168 * until we reach the root. 169 */ 170 for (level = 0; level < params->num_levels; level++) { 171 unsigned long next_hidx; 172 unsigned long hblock_idx; 173 pgoff_t hpage_idx; 174 unsigned int hblock_offset_in_page; 175 unsigned int hoffset; 176 struct page *hpage; 177 const void *haddr; 178 179 /* 180 * The index of the block in the current level; also the index 181 * of that block's hash within the next level. 182 */ 183 next_hidx = hidx >> params->log_arity; 184 185 /* Index of the hash block in the tree overall */ 186 hblock_idx = params->level_start[level] + next_hidx; 187 188 /* Index of the hash page in the tree overall */ 189 hpage_idx = hblock_idx >> params->log_blocks_per_page; 190 191 /* Byte offset of the hash block within the page */ 192 hblock_offset_in_page = 193 (hblock_idx << params->log_blocksize) & ~PAGE_MASK; 194 195 /* Byte offset of the hash within the block */ 196 hoffset = (hidx << params->log_digestsize) & 197 (params->block_size - 1); 198 199 hpage = inode->i_sb->s_vop->read_merkle_tree_page(inode, 200 hpage_idx, level == 0 ? min(max_ra_pages, 201 params->tree_pages - hpage_idx) : 0); 202 if (IS_ERR(hpage)) { 203 fsverity_err(inode, 204 "Error %ld reading Merkle tree page %lu", 205 PTR_ERR(hpage), hpage_idx); 206 goto error; 207 } 208 haddr = kmap_local_page(hpage) + hblock_offset_in_page; 209 if (is_hash_block_verified(vi, hpage, hblock_idx)) { 210 memcpy(_want_hash, haddr + hoffset, hsize); 211 want_hash = _want_hash; 212 kunmap_local(haddr); 213 put_page(hpage); 214 goto descend; 215 } 216 hblocks[level].page = hpage; 217 hblocks[level].addr = haddr; 218 hblocks[level].index = hblock_idx; 219 hblocks[level].hoffset = hoffset; 220 hidx = next_hidx; 221 } 222 223 want_hash = vi->root_hash; 224 descend: 225 /* Descend the tree verifying hash blocks. */ 226 for (; level > 0; level--) { 227 struct page *hpage = hblocks[level - 1].page; 228 const void *haddr = hblocks[level - 1].addr; 229 unsigned long hblock_idx = hblocks[level - 1].index; 230 unsigned int hoffset = hblocks[level - 1].hoffset; 231 232 if (fsverity_hash_block(params, inode, haddr, real_hash) != 0) 233 goto error; 234 if (memcmp(want_hash, real_hash, hsize) != 0) 235 goto corrupted; 236 /* 237 * Mark the hash block as verified. This must be atomic and 238 * idempotent, as the same hash block might be verified by 239 * multiple threads concurrently. 240 */ 241 if (vi->hash_block_verified) 242 set_bit(hblock_idx, vi->hash_block_verified); 243 else 244 SetPageChecked(hpage); 245 memcpy(_want_hash, haddr + hoffset, hsize); 246 want_hash = _want_hash; 247 kunmap_local(haddr); 248 put_page(hpage); 249 } 250 251 /* Finally, verify the hash of the data block. */ 252 if (memcmp(want_hash, dblock->real_hash, hsize) != 0) 253 goto corrupted; 254 return true; 255 256 corrupted: 257 fsverity_err(inode, 258 "FILE CORRUPTED! pos=%llu, level=%d, want_hash=%s:%*phN, real_hash=%s:%*phN", 259 data_pos, level - 1, 260 params->hash_alg->name, hsize, want_hash, 261 params->hash_alg->name, hsize, 262 level == 0 ? dblock->real_hash : real_hash); 263 error: 264 for (; level > 0; level--) { 265 kunmap_local(hblocks[level - 1].addr); 266 put_page(hblocks[level - 1].page); 267 } 268 return false; 269 }
最新发布
06-16
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值