tree: https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux.git scrub-rtsummary head: 695cbba414eac11f6989dac8e3323882d67581f9 commit: f507d97a812d43da734618a53305f93ae560eca3 [15/27] xfs: teach scrub to check for adjacent bmaps when rmap larger than bmap config: i386-randconfig-r034-20201111 (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0 reproduce (this is a W=1 build): # https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux.git/commit/?id=f507d97a812d43da734618a53305f93ae560eca3 git remote add djwong-xfs https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux.git git fetch --no-tags djwong-xfs scrub-rtsummary git checkout f507d97a812d43da734618a53305f93ae560eca3 # save the attached .config to linux build tree make W=1 ARCH=i386 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All errors (new ones prefixed by >>): In file included from include/linux/string.h:6, from include/linux/uuid.h:12, from fs/xfs/xfs_linux.h:10, from fs/xfs/xfs.h:22, from fs/xfs/scrub/bmap.c:6: fs/xfs/scrub/bmap.c: In function 'xchk_bmap_xref_rmap': >> fs/xfs/scrub/bmap.c:283:62: error: 'bno' undeclared (first use in this function); did you mean 'bio'? 283 | if (info->whichfork != XFS_COW_FORK && rmap.rm_startblock < bno && | ^~~ include/linux/compiler.h:58:52: note: in definition of macro '__trace_if_var' 58 | #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond)) | ^~~~ fs/xfs/scrub/bmap.c:283:2: note: in expansion of macro 'if' 283 | if (info->whichfork != XFS_COW_FORK && rmap.rm_startblock < bno && | ^~ fs/xfs/scrub/bmap.c:283:62: note: each undeclared identifier is reported only once for each function it appears in 283 | if (info->whichfork != XFS_COW_FORK && rmap.rm_startblock < bno && | ^~~ include/linux/compiler.h:58:52: note: in definition of macro '__trace_if_var' 58 | #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond)) | ^~~~ fs/xfs/scrub/bmap.c:283:2: note: in expansion of macro 'if' 283 | if (info->whichfork != XFS_COW_FORK && rmap.rm_startblock < bno && | ^~ vim +283 fs/xfs/scrub/bmap.c 207 208 /* Make sure that we have rmapbt records for this extent. */ 209 STATIC void 210 xchk_bmap_xref_rmap( 211 struct xchk_bmap_info *info, 212 struct xfs_bmbt_irec *irec, 213 xfs_agblock_t agbno) 214 { 215 struct xfs_rmap_irec rmap; 216 unsigned long long rmap_end; 217 uint64_t owner; 218 219 if (!info->sc->sa.rmap_cur || xchk_skip_xref(info->sc->sm)) 220 return; 221 222 if (info->whichfork == XFS_COW_FORK) 223 owner = XFS_RMAP_OWN_COW; 224 else 225 owner = info->sc->ip->i_ino; 226 227 /* Find the rmap record for this irec. */ 228 if (!xchk_bmap_get_rmap(info, irec, agbno, owner, &rmap)) 229 return; 230 231 /* Check the rmap. */ 232 rmap_end = (unsigned long long)rmap.rm_startblock + rmap.rm_blockcount; 233 if (rmap.rm_startblock > agbno || 234 agbno + irec->br_blockcount > rmap_end) 235 xchk_fblock_xref_set_corrupt(info->sc, info->whichfork, 236 irec->br_startoff); 237 238 /* 239 * Check the logical offsets if applicable. CoW staging extents 240 * don't track logical offsets since the mappings only exist in 241 * memory. 242 */ 243 if (info->whichfork != XFS_COW_FORK) { 244 rmap_end = (unsigned long long)rmap.rm_offset + 245 rmap.rm_blockcount; 246 if (rmap.rm_offset > irec->br_startoff || 247 irec->br_startoff + irec->br_blockcount > rmap_end) 248 xchk_fblock_xref_set_corrupt(info->sc, 249 info->whichfork, irec->br_startoff); 250 } 251 252 if (rmap.rm_owner != owner) 253 xchk_fblock_xref_set_corrupt(info->sc, info->whichfork, 254 irec->br_startoff); 255 256 /* 257 * Check for discrepancies between the unwritten flag in the irec and 258 * the rmap. Note that the (in-memory) CoW fork distinguishes between 259 * unwritten and written extents, but we don't track that in the rmap 260 * records because the blocks are owned (on-disk) by the refcountbt, 261 * which doesn't track unwritten state. 262 */ 263 if (owner != XFS_RMAP_OWN_COW && 264 !!(irec->br_state == XFS_EXT_UNWRITTEN) != 265 !!(rmap.rm_flags & XFS_RMAP_UNWRITTEN)) 266 xchk_fblock_xref_set_corrupt(info->sc, info->whichfork, 267 irec->br_startoff); 268 269 if (!!(info->whichfork == XFS_ATTR_FORK) != 270 !!(rmap.rm_flags & XFS_RMAP_ATTR_FORK)) 271 xchk_fblock_xref_set_corrupt(info->sc, info->whichfork, 272 irec->br_startoff); 273 if (rmap.rm_flags & XFS_RMAP_BMBT_BLOCK) 274 xchk_fblock_xref_set_corrupt(info->sc, info->whichfork, 275 irec->br_startoff); 276 277 /* 278 * If the rmap starts before this bmbt record, make sure there's a bmbt 279 * record for the previous offset that is contiguous with this mapping. 280 * Skip this for CoW fork extents because the refcount btree (and not 281 * the inode) is the ondisk owner for those extents. 282 */ > 283 if (info->whichfork != XFS_COW_FORK && rmap.rm_startblock < bno && 284 !xchk_bmap_has_prev(info, irec)) { 285 xchk_fblock_xref_set_corrupt(info->sc, info->whichfork, 286 irec->br_startoff); 287 return; 288 } 289 290 /* 291 * If the rmap ends after this bmbt record, make sure there's a bmbt 292 * record for the next offset that is contiguous with this mapping. 293 * Skip this for CoW fork extents because the refcount btree (and not 294 * the inode) is the ondisk owner for those extents. 295 */ 296 rmap_end = (unsigned long long)rmap.rm_startblock + rmap.rm_blockcount; 297 if (info->whichfork != XFS_COW_FORK && 298 rmap_end > bno + irec->br_blockcount && 299 !xchk_bmap_has_next(info, irec)) { 300 xchk_fblock_xref_set_corrupt(info->sc, info->whichfork, 301 irec->br_startoff); 302 return; 303 } 304 } 305 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org