From: Darrick J. Wong Date: Wed, 18 May 2022 02:48:12 +0000 (-0400) Subject: xfs_repair: fix sizing of the incore rt space usage map calculation X-Git-Tag: v5.18.0-rc1~26 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3a7f7109a817e4084bd9eee1f311b579caaf2e77;p=thirdparty%2Fxfsprogs-dev.git xfs_repair: fix sizing of the incore rt space usage map calculation If someone creates a realtime volume exactly *one* extent in length, the sizing calculation for the incore rt space usage bitmap will be zero because the integer division here rounds down. Use howmany() to round up. Note that there can't be that many single-extent rt volumes since repair will corrupt them into zero-extent rt volumes, and we haven't gotten any reports. Found by running xfs/530 after fixing xfs_repair to check the rt bitmap. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Eric Sandeen --- diff --git a/repair/incore.c b/repair/incore.c index 4ffe18aba..10a8c2a8c 100644 --- a/repair/incore.c +++ b/repair/incore.c @@ -209,7 +209,7 @@ init_rt_bmap( if (mp->m_sb.sb_rextents == 0) return; - rt_bmap_size = roundup(mp->m_sb.sb_rextents / (NBBY / XR_BB), + rt_bmap_size = roundup(howmany(mp->m_sb.sb_rextents, (NBBY / XR_BB)), sizeof(uint64_t)); rt_bmap = memalign(sizeof(uint64_t), rt_bmap_size);