From: Brian Foster Date: Thu, 30 Jul 2015 23:18:22 +0000 (+1000) Subject: repair: do not prefetch holes in sparse inode chunks X-Git-Tag: v4.2.0-rc1~14 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=870b18fd05e6d246c6819c52fd88c4e641de6014;p=thirdparty%2Fxfsprogs-dev.git repair: do not prefetch holes in sparse inode chunks The repair prefetch mechanism reads all inode chunks in advance of repair processing to improve performance. Inode buffer verification and processing can occur within the prefetch mechanism such as when directories are being processed. Prefetch currently assumes fully populated inode chunks which leads to corruption errors attempting to verify inode buffers that do not contain inodes. Update prefetch to check the previously scanned sparse inode bits and skip inode buffer reads of clusters that are sparse. We check sparse state per-inode cluster because the cluster size is the min. allowable inode chunk hole granularity. Signed-off-by: Brian Foster Reviewed-by: Dave Chinner Signed-off-by: Dave Chinner --- diff --git a/repair/prefetch.c b/repair/prefetch.c index d6246ce3c..157797181 100644 --- a/repair/prefetch.c +++ b/repair/prefetch.c @@ -679,6 +679,7 @@ pf_queuing_worker( xfs_agblock_t bno; int i; int err; + uint64_t sparse; blks_per_cluster = mp->m_inode_cluster_size >> mp->m_sb.sb_blocklog; if (blks_per_cluster == 0) @@ -736,17 +737,27 @@ pf_queuing_worker( num_inos = 0; bno = XFS_AGINO_TO_AGBNO(mp, cur_irec->ino_startnum); + sparse = cur_irec->ir_sparse; do { struct xfs_buf_map map; map.bm_bn = XFS_AGB_TO_DADDR(mp, args->agno, bno); map.bm_len = XFS_FSB_TO_BB(mp, blks_per_cluster); - pf_queue_io(args, &map, 1, - (cur_irec->ino_isa_dir != 0) ? B_DIR_INODE - : B_INODE); + + /* + * Queue I/O for each non-sparse cluster. We can check + * sparse state in cluster sized chunks as cluster size + * is the min. granularity of sparse irec regions. + */ + if ((sparse & ((1 << inodes_per_cluster) - 1)) == 0) + pf_queue_io(args, &map, 1, + (cur_irec->ino_isa_dir != 0) ? + B_DIR_INODE : B_INODE); + bno += blks_per_cluster; num_inos += inodes_per_cluster; + sparse >>= inodes_per_cluster; } while (num_inos < mp->m_ialloc_inos); }