QString InstrList_Finger::prt_partern(const Instruction * phead) const { if (phead->type != i_CplxBegin) return ""; QString collector=""; Instruction * p = instr_next(m_list,phead); intptr_t buf[20]; memset(buf,0,20*sizeof(intptr_t)); int n = 0,label_num; int collected_entries=0; while (p != NULL && p != phead->begin.m_end) { collected_entries++; switch(p->type) { case i_Jump: label_num = search_and_add(buf,intptr_t(p->jmp.target_label),n); if (p->jmp.jmp_type == JMP_jmp) collector+=QString("jmp%1_").arg(label_num); else collector+=QString("jxx%1_").arg(label_num); break; case i_Label: label_num = search_and_add(buf,intptr_t(p),n); collector+=QString("from%1_").arg(label_num); break; case i_Begin: collector+="0_"; p = p->begin.m_end; // skipping to end of p's BB break; default: collected_entries--; // no entry was added in this case, also "why here ?" } p = instr_next(m_list,p); if (collected_entries > 12) // maximum collected pattern length { collector+="..."; break; } } qDebug()<<collector; return collector; }
/* * Walk aggregate inode table marking blocks: * - For inode map structures * - For inode extents belonging to this table * - For blocks belonging to inode's belonging to this table */ int32 walk_ait( int device, struct dinode *inode_buffer, boolean_t is_primary ) { int32 rc = 0; xtpage_t *btree_page; int32 index, lastindex; uint64 cur_block, last_block; dinomap_t control_page, disk_cp; struct list_item *top_freeiag = NULL; struct list_item *top_inofree[MAXAG]; struct list_item *top_extfree[MAXAG]; /* * Initialize control page and lists */ memset( &control_page, 0, sizeof(dinomap_t) ); memset( &top_inofree, 0, MAXAG * sizeof(struct list_item*) ); memset( &top_extfree, 0, MAXAG * sizeof(struct list_item*) ); btree_page = (xtpage_t *)&inode_buffer->di_btroot; /* * Mark blocks for the inode map structures (i.e. IAG's) */ lastindex = btree_page->header.nextindex; for( index = XTENTRYSTART; index < lastindex; index++ ) { if( btree_page->header.flag & BT_LEAF ) { /* * Read the extent as IAG's and mark its blocks */ walk_iag_extent( device, &(btree_page->xad[index]), is_primary, &control_page, &disk_cp, &top_freeiag, top_inofree, top_extfree, inode_buffer->di_inostamp ); } else { /* * This is an internal page of the b-tree. Mark these blocks and * then walk that page */ walk_internal_iag( device, &(btree_page->xad[index]), is_primary, &control_page, &disk_cp, &top_freeiag, top_inofree, top_extfree, inode_buffer->di_inostamp ); } } /* * Now compare the computed control page to the on-disk one. * Right now we are only checking inode number counts, so we can't do a * straight memory comparison */ if( is_primary ) { #if 0 rc = memcmp( &control_page, &disk_cp, sizeof(dinomap_t)); if( rc != 0 ) { error++; printf("Miscompare of control page.\n"); } #else if( control_page.in_numinos != disk_cp.in_numinos) { error++; printf("Miscompare on in_numinos; found: %d\tdisk: %d\n", control_page.in_numinos, disk_cp.in_numinos ); } if( control_page.in_numfree != disk_cp.in_numfree) { error++; printf("Miscompare on in_numfree; found: %d\tdisk: %d\n", control_page.in_numfree, disk_cp.in_numfree ); } for( index = 0; index < MAXAG; index++ ) { if( control_page.in_agctl[index].numinos != disk_cp.in_agctl[index].numinos) { error++; printf("Miscompare on AG (%d) numinos; found: %d\tdisk: %d\n", index, control_page.in_agctl[index].numinos, disk_cp.in_agctl[index].numinos ); } if( control_page.in_agctl[index].numfree != disk_cp.in_agctl[index].numfree) { error++; printf("Miscompare on AG (%d) numfree; found: %d\tdisk: %d\n", index, control_page.in_agctl[index].numfree, disk_cp.in_agctl[index].numfree ); } } if( control_page.in_nextiag != disk_cp.in_nextiag) { error++; printf("Miscompare on in_nextiag; found: %d\tdisk: %d\n", control_page.in_nextiag, disk_cp.in_nextiag ); } #endif /* * Add the on-disk start of the lists from the control page */ rc = search_and_add(&top_freeiag, disk_cp.in_freeiag, DISK_LIST); if( rc != 0 ) { error++; printf("Bad iagfree item on-disk: %d\n", disk_cp.in_freeiag); } for( index = 0; index < MAXAG; index++ ) { rc = search_and_add(&(top_extfree[index]), disk_cp.in_agctl[index].extfree, DISK_LIST); if( rc != 0 ) { error++; printf("Bad extfree[%d] item on-disk: %d\n", index, disk_cp.in_agctl[index].extfree); } rc = search_and_add(&(top_inofree[index]), disk_cp.in_agctl[index].inofree, DISK_LIST); if( rc != 0 ) { error++; printf("Bad inofree[%d] item on-disk: %d\n", index, disk_cp.in_agctl[index].inofree); } } /* * Verify the lists */ verify_list(top_freeiag, "IAG free"); for( index = 0; index < MAXAG; index++ ) { verify_list(top_extfree[index], "AG Extent free"); verify_list(top_inofree[index], "AG Inode free"); } } return 0; }
/* * Read the specified extent as an extent of IAG's * If its offset is 0 skip the first page since this is a control page. * For all other IAGs need to mark blocks: * - mark the blocks for any allocated extents for the IAG * - read the extent and mark blocks for any allocated inodes * Note: the blocks owned by the table itself will be marked when the inode for * the table is seen. */ void walk_iag_extent( int device, xad_t *extent, boolean_t is_primary, dinomap_t *control_page, dinomap_t *disk_cp, struct list_item **top_iagfree, struct list_item **top_inofree, struct list_item **top_extfree, int32 inostamp ) { uint64 offset, address, count, end; uint32 length, page_length; iag_t iag_buffer; int32 index, rc, extdx; pxd_t *inoext_ptr; uint32 map, found_map; uint32 agno; ino_t start_inum; uint32 mymap[EXTSPERIAG]; int16 seen_extent = 0, free_inodes = 0; offset = offsetXAD( extent ); address = addressXAD( extent ); length = lengthXAD( extent ); page_length = PSIZE >> sb.s_l2bsize; if( offset == 0 ) { /* * Read in the disk control page now. We will compare it after all the * other pages of the map have been processed. */ rc = ujfs_rw_diskblocks( device, address << sb.s_l2bsize, sizeof(dinomap_t), disk_cp, GET ); if( rc != 0 ) exit(rc); address += page_length; length -= page_length; } while( length > 0 ) { /* * Clear map to use for tracking inodes seen */ memset( mymap, 0, EXTSPERIAG * sizeof(uint32)); /* * Read next IAG */ rc = ujfs_rw_diskblocks( device, address << sb.s_l2bsize, PSIZE, &iag_buffer, GET ); if( rc != 0 ) exit(rc); length -= page_length; address += page_length; control_page->in_nextiag = iag_buffer.iagnum + 1; if( iag_buffer.iagfree != -1 ) { /* * We have an item on the iagfree list following this one. */ rc = search_and_add(top_iagfree, iag_buffer.iagfree, DISK_LIST); if( rc != 0 ) { printf("Bad iagfree item on-disk: %d\n", iag_buffer.iagfree); } } agno = iag_buffer.agstart / sb.s_agsize; if( iag_buffer.extfreefwd != -1 ) { /* * We have an item on the extfree list following this one. */ rc = search_and_add(&(top_extfree[agno]), iag_buffer.extfreefwd, DISK_LIST); if( rc != 0 ) { printf("Bad extfree[%d] item on-disk: %d\n", agno, iag_buffer.extfreefwd); } } if( iag_buffer.inofreefwd != -1 ) { /* * We have an item on the inofree list following this one. */ rc = search_and_add(&(top_inofree[agno]), iag_buffer.inofreefwd, DISK_LIST); if( rc != 0 ) { printf("Bad inofree[%d] item on-disk: %d\n", agno, iag_buffer.inofreefwd); } } /* * Mark blocks for any allocated inode extents */ for( index = 0; index < SMAPSZ; index++ ) { map = iag_buffer.extsmap[index]; inoext_ptr = iag_buffer.inoext + (index * EXTSPERSUM); for( extdx = 0; extdx < EXTSPERSUM, map != 0; extdx++, map <<= 1) { if( (map & HIGHORDER) != 0 ) { seen_extent++; /* * Count inodes for allocated inode extents */ control_page->in_numinos += NUM_INODE_PER_EXTENT; control_page->in_agctl[agno].numinos += NUM_INODE_PER_EXTENT; address = count = addressPXD(inoext_ptr + extdx); end = count + inoext_ptr[extdx].len; for( ; count < end; count++) { markit( count, 0 ); } if( is_primary == TRUE ) { /* * Now need to read inodes and mark blocks for them * Only do this for the primary inode table */ start_inum = (iag_buffer.iagnum << L2INOSPERIAG) + (index << (L2EXTSPERSUM + L2INOSPEREXT)) + (extdx << L2INOSPEREXT); walk_inoext( device, address, inoext_ptr[extdx].len, iag_buffer.wmap[(index * EXTSPERSUM) + extdx], control_page, agno, start_inum, &found_map, inostamp ); mymap[(index * EXTSPERSUM) + extdx] = found_map; if( ~found_map != 0 ) free_inodes = 1; } } } } if( seen_extent == 0 ) { /* * No extents for this IAG, add it to iagfree list */ rc = search_and_add(top_iagfree, iag_buffer.iagnum, FOUND_LIST); if( rc != 0 ) { printf("Bad iagfree item found: %d\n", iag_buffer.iagnum); } } else if( seen_extent != EXTSPERIAG ) { /* * Have free extents in this IAG, add to AG free extent list */ rc = search_and_add(&(top_extfree[agno]), iag_buffer.iagnum, FOUND_LIST); if( rc != 0 ) { printf("Bad extfree[%d] item found: %d\n", agno, iag_buffer.iagnum); } } if( free_inodes != 0 ) { /* * We have some free inodes in the extent */ rc = search_and_add(&(top_inofree[agno]), iag_buffer.iagnum, FOUND_LIST); if( rc != 0 ) { printf("Bad inofree[%d] item found: %d\n", agno, iag_buffer.iagnum); } } if( is_primary ) { /* * Compare map found by walking extents to the on-disk version */ rc = memcmp( mymap, iag_buffer.wmap, EXTSPERIAG * sizeof(uint32)); if( rc != 0 ) { error++; printf("Miscompare of inode wmap of IAG %d.\n", iag_buffer.iagnum); print_uint_array ("Found map:", mymap, EXTSPERIAG); print_uint_array ("Disk wmap:", iag_buffer.wmap, EXTSPERIAG); } rc = memcmp( mymap, iag_buffer.pmap, EXTSPERIAG * sizeof(uint32)); if( rc != 0 ) { error++; printf("Miscompare of inode pmap of IAG %d.\n", iag_buffer.iagnum); print_uint_array ("Found map:", mymap, EXTSPERIAG); print_uint_array ("Disk pmap:", iag_buffer.pmap, EXTSPERIAG); } } } }