📄 fsckimap.c
字号:
* first extent of the other Aggregate Inode Table into the * regular fsck inode buffer. * * RETURNS: * success: FSCK_OK * failure: something else */int AIS_replication(){ int aisr_rc = FSCK_OK; int intermed_rc = FSCK_OK; struct dinode *source_inoptr, *target_inoptr; int64_t target_byte_offset = 0; xtpage_t *target_ait_root = 0; char *source_bufptr, *target_bufptr; int32_t inode_offset; int8_t source_is_primary, extents_in_memory; int8_t replication_failed = 0; uint32_t bytes_transferred; aisr_rc = temp_inode_buf_alloc(&source_bufptr); target_bufptr = agg_recptr->ino_buf_ptr; if (aisr_rc != FSCK_OK) goto aisr_exit; /* allocated the temp buffer */ /* * the filesystem inode could have different source-target than the * rest of the table, so deal with it first. */ extents_in_memory = 0; if (agg_recptr->primary_ait_4part2) { /* * primary for fileset inode source */ source_is_primary = -1; aisr_rc = ait_special_read_ext1(fsck_primary); if (aisr_rc != FSCK_OK) { /* read failed */ report_readait_error(aisr_rc, FSCK_FAILED_CANTREADAITEXT3, fsck_primary); aisr_rc = FSCK_FAILED_CANTREADAITEXT3; goto aisr_release; } } else { /* secondary for fileset inode source */ source_is_primary = 0; aisr_rc = ait_special_read_ext1(fsck_secondary); if (aisr_rc != FSCK_OK) { /* read failed */ report_readait_error(aisr_rc, FSCK_FAILED_CANTREADAITEXT4, fsck_secondary); aisr_rc = FSCK_FAILED_CANTREADAITEXT4; goto aisr_release; } } /* source is in the inode buffer */ memcpy((void *) source_bufptr, (void *) agg_recptr->ino_buf_ptr, INODE_IO_BUFSIZE); if (agg_recptr->primary_ait_4part2) { /* secondary for fileset inode target */ aisr_rc = ait_special_read_ext1(fsck_secondary); if (aisr_rc != FSCK_OK) { /* read failed */ report_readait_error(aisr_rc, FSCK_FAILED_CANTREADAITEXT5, fsck_secondary); aisr_rc = FSCK_FAILED_CANTREADAITEXT5; goto aisr_release; } target_byte_offset = addressPXD(&(sb_ptr->s_ait2)) * sb_ptr->s_bsize; } else { /* primary for fileset inode target */ aisr_rc = ait_special_read_ext1(fsck_primary); if (aisr_rc != FSCK_OK) { /* read failed */ report_readait_error(aisr_rc, FSCK_FAILED_CANTREADAITEXT6, fsck_primary); aisr_rc = FSCK_FAILED_CANTREADAITEXT6; goto aisr_release; } target_byte_offset = AITBL_OFF; } /* the 2 inode extents for the fileset inode are in memory */ extents_in_memory = -1; inode_offset = FILESYSTEM_I * sizeof (struct dinode); source_inoptr = (struct dinode *) (source_bufptr + inode_offset); target_inoptr = (struct dinode *) (target_bufptr + inode_offset); aisr_rc = AIS_inode_replication(source_is_primary, target_inoptr, source_inoptr); if (aisr_rc != FSCK_OK) goto aisr_release; aisr_rc = init_xtree_root(target_inoptr); if (aisr_rc != FSCK_OK) goto aisr_release; aisr_rc = FSIM_replication(source_is_primary, target_inoptr, source_inoptr, &replication_failed); if ((aisr_rc == FSCK_OK) && (replication_failed)) { if (!source_is_primary) { /* we're trying to repair the primary * table and can't -- that makes this a * dirty file system. */ agg_recptr->ag_dirty = 1; fsck_send_msg(fsck_CANTREPAIRAIS, "2"); } else { /* trying to repair the secondary table and can't * * We won't stop fsck and we won't the file system * dirty on this condition, but we'll issue a warning * and the superblock to prevent future attempts to * maintain the flawed table. */ fsck_send_msg(fsck_INCONSIST2NDRY1, "2"); } } if ((aisr_rc != FSCK_OK) || replication_failed) goto aisr_release; if (agg_recptr->primary_ait_4part1 != agg_recptr->primary_ait_4part2) { /* * we need to switch source and target */ /* swap if on big endian machine */ ujfs_swap_inoext((struct dinode *) target_bufptr, PUT, sb_ptr->s_flag); intermed_rc = readwrite_device(target_byte_offset, INODE_EXTENT_SIZE, &bytes_transferred, (void *) target_bufptr, fsck_WRITE); /* swap back */ ujfs_swap_inoext((struct dinode *) target_bufptr, GET, sb_ptr->s_flag); agg_recptr->ag_modified = 1; if ((intermed_rc != FSCK_OK) || (bytes_transferred != INODE_EXTENT_SIZE)) { /* * some or all didn't make it to the device. * */ agg_recptr->ait_aim_update_failed = 1; if (!source_is_primary) { /* we're trying to repair the primary * table and can't -- that makes this a * dirty file system. */ agg_recptr->ag_dirty = 1; fsck_send_msg(fsck_CANTREPAIRAIS, "3"); } else { /* trying to repair the secondary table and * can't * * We won't stop fsck and we won't the file * system dirty on this condition, but we'll * issue a warning and the superblock to * prevent future attempts to maintain the * flawed table. */ replication_failed = -1; fsck_send_msg(fsck_INCONSIST2NDRY1, "3"); } } extents_in_memory = 0; if (agg_recptr->primary_ait_4part1) { /* primary for remaining inodes source */ source_is_primary = -1; aisr_rc = ait_special_read_ext1(fsck_primary); if (aisr_rc != FSCK_OK) { /* read failed */ report_readait_error(aisr_rc, FSCK_FAILED_CANTREADAITEXT7, fsck_primary); aisr_rc = FSCK_FAILED_CANTREADAITEXT7; goto aisr_release; } } else { /* secondary for remaining inodes source */ source_is_primary = 0; aisr_rc = ait_special_read_ext1(fsck_secondary); if (aisr_rc != FSCK_OK) { /* read failed */ report_readait_error(aisr_rc, FSCK_FAILED_CANTREADAITEXT8, fsck_secondary); aisr_rc = FSCK_FAILED_CANTREADAITEXT8; goto aisr_release; } } /* source is in the inode buffer */ memcpy((void *) source_bufptr, (void *) agg_recptr->ino_buf_ptr, INODE_IO_BUFSIZE); if (agg_recptr->primary_ait_4part1) { /* secondary for remaining inodes target */ intermed_rc = ait_special_read_ext1(fsck_secondary); target_byte_offset = addressPXD(&(sb_ptr->s_ait2)) * sb_ptr->s_bsize; if (intermed_rc != FSCK_OK) { /* * message to debugger */ fsck_send_msg(fsck_ERRONAITRD, FSCK_CANTREADAITEXT3, intermed_rc, fsck_secondary); } } else { /* primary for remaining inodes target */ intermed_rc = ait_special_read_ext1(fsck_primary); target_byte_offset = AITBL_OFF; if (intermed_rc != FSCK_OK) { /* * message to debugger */ fsck_send_msg(fsck_ERRONAITRD, FSCK_CANTREADAITEXT4, intermed_rc, fsck_primary); } } if (intermed_rc == FSCK_OK) /* the 2 inode extents for the * remaining inodes are in memory */ extents_in_memory = -1; } if (replication_failed || !extents_in_memory) goto aisr_release; /* we have the extents for the remaining AIT inodes */ /* * the self inode */ inode_offset = AGGREGATE_I * sizeof (struct dinode); source_inoptr = (struct dinode *) (source_bufptr + inode_offset); target_inoptr = (struct dinode *) (target_bufptr + inode_offset); aisr_rc = AIS_inode_replication(source_is_primary, target_inoptr, source_inoptr); if (aisr_rc != FSCK_OK) goto aisr_release; /* aggregate inode replicated in buffer */ target_ait_root = (xtpage_t *) & (target_inoptr->di_btroot); /* * the bmap inode */ inode_offset = BMAP_I * sizeof (struct dinode); source_inoptr = (struct dinode *) (source_bufptr + inode_offset); target_inoptr = (struct dinode *) (target_bufptr + inode_offset); aisr_rc = AIS_inode_replication(source_is_primary, target_inoptr, source_inoptr); if (aisr_rc != FSCK_OK) goto aisr_release; /* * the journal log inode */ inode_offset = LOG_I * sizeof (struct dinode); source_inoptr = (struct dinode *) (source_bufptr + inode_offset); target_inoptr = (struct dinode *) (target_bufptr + inode_offset); aisr_rc = AIS_inode_replication(source_is_primary, target_inoptr, source_inoptr); if (aisr_rc != FSCK_OK) goto aisr_release; /* * the bad block inode */ inode_offset = BADBLOCK_I * sizeof (struct dinode); source_inoptr = (struct dinode *) (source_bufptr + inode_offset); target_inoptr = (struct dinode *) (target_bufptr + inode_offset); aisr_rc = AIS_inode_replication(source_is_primary, target_inoptr, source_inoptr); if (aisr_rc != FSCK_OK) goto aisr_release; /* the ait is replicated in the buffer * * now finish up the self inode by replicating the aggregate inode * map which it describes. */ aisr_rc = AIM_replication(source_is_primary, target_ait_root, source_bufptr, &replication_failed); if (aisr_rc != FSCK_OK) goto aisr_release; /* ait replication in buffer now complete */ /* swap if on big endian machine */ ujfs_swap_inoext((struct dinode *) target_bufptr, PUT, sb_ptr->s_flag); intermed_rc = readwrite_device(target_byte_offset, INODE_EXTENT_SIZE, &bytes_transferred, (void *) target_bufptr, fsck_WRITE); /* swap back */ ujfs_swap_inoext((struct dinode *) target_bufptr, GET, sb_ptr->s_flag); agg_recptr->ag_modified = 1; if ((intermed_rc != FSCK_OK) || (bytes_transferred != INODE_EXTENT_SIZE)) { /* * some or all didn't make it to the device. */ agg_recptr->ait_aim_update_failed = 1; if (!source_is_primary) { /* we're trying to repair the primary * table and can't -- that makes this a * dirty file system. */ agg_recptr->ag_dirty = 1; fsck_send_msg(fsck_CANTREPAIRAIS, "4"); } else { /* trying to repair the secondary table and can't * * We won't stop fsck and we won't the file system * dirty on this condition, but we'll issue a warning * and the superblock to prevent future attempts to * maintain the flawed table. */ replication_failed = -1; fsck_send_msg(fsck_INCONSIST2NDRY1, "4"); } } aisr_release: temp_inode_buf_release(source_bufptr); if (aisr_rc == FSCK_OK) { if (replication_failed) { sb_ptr->s_flag |= JFS_BAD_SAIT; } else { sb_ptr->s_flag &= (~JFS_BAD_SAIT); } } aisr_exit: return (aisr_rc);}/**************************************************************** * NAME: first_ref_check_inode_extents * * FUNCTION: Determine whether any inode extent in the aggregate (i.e., * in either the Aggregate Inode Table or in the Fileset Inode * Table) contains a reference to any multiply-allocated * aggregate block whose first reference has not yet been * resolved. * * PARAMETERS: none * * RETURNS: * success: FSCK_OK * failure: something else */int first_ref_check_inode_extents(){ int rdie_rc = FSCK_OK; int is_aggregate; int which_it; struct fsck_inode_record *inorecptr; struct fsck_ino_msg_info msg_info; struct fsck_ino_msg_info *msg_info_ptr; msg_info_ptr = &msg_info; msg_info_ptr->msg_inonum = AGGREGATE_I; msg_info_ptr->msg_inopfx = fsck_aggr_inode; msg_info_ptr->msg_inotyp = fsck_metaIAG; /* * check the inode extents in the Aggregate Inode Allocation Map * for first references to multiply allocated blocks. */ is_aggregate = -1; if (agg_recptr->primary_ait_4part1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -