void o2fsck_print_resource_track(char *pass, o2fsck_state *ost, struct o2fsck_resource_track *rt, io_channel *channel) { struct ocfs2_io_stats *rtio = &rt->rt_io_stats; uint64_t total_io, cache_read; float rtime_s, utime_s, stime_s, walltime; uint32_t rtime_m, utime_m, stime_m; if (!ost->ost_show_stats) return ; if (pass && !ost->ost_show_extended_stats) return; #define split_time(_t, _m, _s) \ do { \ (_s) = timeval_in_secs(&_t); \ (_m) = (_s) / 60; \ (_s) -= ((_m) * 60); \ } while (0); split_time(rt->rt_real_time, rtime_m, rtime_s); split_time(rt->rt_user_time, utime_m, utime_s); split_time(rt->rt_sys_time, stime_m, stime_s); walltime = timeval_in_secs(&rt->rt_real_time) - timeval_in_secs(&rt->rt_user_time); /* TODO: Investigate why user time is sometimes > wall time*/ if (walltime < 0) walltime = 0; cache_read = (uint64_t)rtio->is_cache_hits * io_get_blksize(channel); total_io = rtio->is_bytes_read + rtio->is_bytes_written; if (!pass) printf(" Cache size: %luMB\n", mbytes(io_get_cache_size(channel))); printf(" I/O read disk/cache: %"PRIu64"MB / %"PRIu64"MB, " "write: %"PRIu64"MB, rate: %.2fMB/s\n", mbytes(rtio->is_bytes_read), mbytes(cache_read), mbytes(rtio->is_bytes_written), (double)(mbytes(total_io) / walltime)); printf(" Times real: %dm%.3fs, user: %dm%.3fs, sys: %dm%.3fs\n", rtime_m, rtime_s, utime_m, utime_s, stime_m, stime_s); }
errcode_t ocfs2_cache_chain_allocator_blocks(ocfs2_filesys *fs, struct ocfs2_dinode *di) { struct io_vec_unit *ivus = NULL; char *buf = NULL; errcode_t ret = 0; int i, j, count; struct ocfs2_chain_list *cl; struct ocfs2_chain_rec *cr; struct ocfs2_group_desc *gd; io_channel *channel = fs->fs_io; int blocksize = fs->fs_blocksize; int64_t group_size; if (!(di->i_flags & OCFS2_CHAIN_FL)) { ret = OCFS2_ET_INODE_NOT_VALID; goto out; } if (!channel) goto out; if (!di->i_clusters) goto out; group_size = (int64_t)di->i_clusters / di->id2.i_chain.cl_cpg; group_size *= blocksize; if (group_size > io_get_cache_size(channel)) goto out; cl = &(di->id2.i_chain); count = cl->cl_next_free_rec; ret = ocfs2_malloc_blocks(channel, count, &buf); if (ret) goto out; memset(buf, 0, count * blocksize); ret = ocfs2_malloc(sizeof(struct io_vec_unit) * count, &ivus); if (ret) goto out; for (i = 0; i < count; ++i) { cr = &(cl->cl_recs[i]); ivus[i].ivu_blkno = cr->c_blkno; ivus[i].ivu_buf = buf + (i * blocksize); ivus[i].ivu_buflen = blocksize; } while (count) { ret = io_vec_read_blocks(channel, ivus, count); if (ret) goto out; for (i = 0, j = 0; i < count; ++i) { gd = (struct ocfs2_group_desc *)ivus[i].ivu_buf; ret = ocfs2_validate_meta_ecc(fs, ivus[i].ivu_buf, &gd->bg_check); if (ret) goto out; if (memcmp(gd->bg_signature, OCFS2_GROUP_DESC_SIGNATURE, strlen(OCFS2_GROUP_DESC_SIGNATURE))) { ret = OCFS2_ET_BAD_GROUP_DESC_MAGIC; goto out; } ocfs2_swap_group_desc_to_cpu(fs, gd); if ((gd->bg_next_group > OCFS2_SUPER_BLOCK_BLKNO) && (gd->bg_next_group < fs->fs_blocks)) { ivus[j].ivu_blkno = gd->bg_next_group; memset(ivus[j].ivu_buf, 0, blocksize); ivus[j].ivu_buflen = blocksize; j++; } } count = j; } out: ocfs2_free(&ivus); ocfs2_free(&buf); return ret; }