Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'xfs-fixes-6.19-rc2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux

Pull xfs fixes from Carlos Maiolino:
"This contains a few fixes for zoned devices support, an UAF and a
compiler warning, and some cleaning up"

* tag 'xfs-fixes-6.19-rc2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
xfs: fix the zoned RT growfs check for zone alignment
xfs: validate that zoned RT devices are zone aligned
xfs: fix XFS_ERRTAG_FORCE_ZERO_RANGE for zoned file system
xfs: fix a memory leak in xfs_buf_item_init()
xfs: fix stupid compiler warning
xfs: fix a UAF problem in xattr repair
xfs: ignore discard return value

+80 -41
+15
fs/xfs/libxfs/xfs_sb.c
··· 301 301 sbp->sb_rbmblocks != xfs_expected_rbmblocks(sbp)) 302 302 return false; 303 303 304 + if (xfs_sb_is_v5(sbp) && 305 + (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_ZONED)) { 306 + uint32_t mod; 307 + 308 + /* 309 + * Zoned RT devices must be aligned to the RT group size, 310 + * because garbage collection assumes that all zones have the 311 + * same size to avoid insane complexity if that weren't the 312 + * case. 313 + */ 314 + div_u64_rem(sbp->sb_rextents, sbp->sb_rgextents, &mod); 315 + if (mod) 316 + return false; 317 + } 318 + 304 319 return true; 305 320 } 306 321
+1 -1
fs/xfs/scrub/attr_repair.c
··· 333 333 .attr_filter = ent->flags & XFS_ATTR_NSP_ONDISK_MASK, 334 334 .namelen = rentry->namelen, 335 335 .name = rentry->name, 336 - .value = ab->value, 337 336 .valuelen = be32_to_cpu(rentry->valuelen), 338 337 }; 339 338 unsigned int namesize; ··· 362 363 error = -EDEADLOCK; 363 364 if (error) 364 365 return error; 366 + args.value = ab->value; 365 367 366 368 /* Look up the remote value and stash it for reconstruction. */ 367 369 error = xfs_attr3_leaf_getvalue(leaf_bp, &args);
+1 -1
fs/xfs/xfs_attr_item.c
··· 737 737 struct xfs_attri_log_item *attrip = ATTRI_ITEM(lip); 738 738 struct xfs_attr_intent *attr; 739 739 struct xfs_mount *mp = lip->li_log->l_mp; 740 - struct xfs_inode *ip; 740 + struct xfs_inode *ip = NULL; 741 741 struct xfs_da_args *args; 742 742 struct xfs_trans *tp; 743 743 struct xfs_trans_res resv;
+1
fs/xfs/xfs_buf_item.c
··· 896 896 map_size = DIV_ROUND_UP(chunks, NBWORD); 897 897 898 898 if (map_size > XFS_BLF_DATAMAP_SIZE) { 899 + xfs_buf_item_free_format(bip); 899 900 kmem_cache_free(xfs_buf_item_cache, bip); 900 901 xfs_err(mp, 901 902 "buffer item dirty bitmap (%u uints) too small to reflect %u bytes!",
+5 -22
fs/xfs/xfs_discard.c
··· 108 108 * list. We plug and chain the bios so that we only need a single completion 109 109 * call to clear all the busy extents once the discards are complete. 110 110 */ 111 - int 111 + void 112 112 xfs_discard_extents( 113 113 struct xfs_mount *mp, 114 114 struct xfs_busy_extents *extents) ··· 116 116 struct xfs_extent_busy *busyp; 117 117 struct bio *bio = NULL; 118 118 struct blk_plug plug; 119 - int error = 0; 120 119 121 120 blk_start_plug(&plug); 122 121 list_for_each_entry(busyp, &extents->extent_list, list) { ··· 125 126 126 127 trace_xfs_discard_extent(xg, busyp->bno, busyp->length); 127 128 128 - error = __blkdev_issue_discard(btp->bt_bdev, 129 + __blkdev_issue_discard(btp->bt_bdev, 129 130 xfs_gbno_to_daddr(xg, busyp->bno), 130 131 XFS_FSB_TO_BB(mp, busyp->length), 131 132 GFP_KERNEL, &bio); 132 - if (error && error != -EOPNOTSUPP) { 133 - xfs_info(mp, 134 - "discard failed for extent [0x%llx,%u], error %d", 135 - (unsigned long long)busyp->bno, 136 - busyp->length, 137 - error); 138 - break; 139 - } 140 133 } 141 134 142 135 if (bio) { ··· 139 148 xfs_discard_endio_work(&extents->endio_work); 140 149 } 141 150 blk_finish_plug(&plug); 142 - 143 - return error; 144 151 } 145 152 146 153 /* ··· 374 385 * list after this function call, as it may have been freed by 375 386 * the time control returns to us. 376 387 */ 377 - error = xfs_discard_extents(pag_mount(pag), extents); 378 - if (error) 379 - break; 388 + xfs_discard_extents(pag_mount(pag), extents); 380 389 381 390 if (xfs_trim_should_stop()) 382 391 break; ··· 483 496 484 497 trace_xfs_discard_rtextent(mp, busyp->bno, busyp->length); 485 498 486 - error = __blkdev_issue_discard(bdev, 499 + __blkdev_issue_discard(bdev, 487 500 xfs_rtb_to_daddr(mp, busyp->bno), 488 501 XFS_FSB_TO_BB(mp, busyp->length), 489 502 GFP_NOFS, &bio); 490 - if (error) 491 - break; 492 503 } 493 504 xfs_discard_free_rtdev_extents(tr); 494 505 ··· 726 741 * list after this function call, as it may have been freed by 727 742 * the time control returns to us. 728 743 */ 729 - error = xfs_discard_extents(rtg_mount(rtg), tr.extents); 730 - if (error) 731 - break; 744 + xfs_discard_extents(rtg_mount(rtg), tr.extents); 732 745 733 746 low = tr.restart_rtx; 734 747 } while (!xfs_trim_should_stop() && low <= high);
+1 -1
fs/xfs/xfs_discard.h
··· 6 6 struct xfs_mount; 7 7 struct xfs_busy_extents; 8 8 9 - int xfs_discard_extents(struct xfs_mount *mp, struct xfs_busy_extents *busy); 9 + void xfs_discard_extents(struct xfs_mount *mp, struct xfs_busy_extents *busy); 10 10 int xfs_ioc_trim(struct xfs_mount *mp, struct fstrim_range __user *fstrim); 11 11 12 12 #endif /* XFS_DISCARD_H */
+48 -10
fs/xfs/xfs_file.c
··· 1241 1241 } 1242 1242 1243 1243 /* 1244 + * For various operations we need to zero up to one block at each end of 1245 + * the affected range. For zoned file systems this will require a space 1246 + * allocation, for which we need a reservation ahead of time. 1247 + */ 1248 + #define XFS_ZONED_ZERO_EDGE_SPACE_RES 2 1249 + 1250 + /* 1251 + * Zero range implements a full zeroing mechanism but is only used in limited 1252 + * situations. It is more efficient to allocate unwritten extents than to 1253 + * perform zeroing here, so use an errortag to randomly force zeroing on DEBUG 1254 + * kernels for added test coverage. 1255 + * 1256 + * On zoned file systems, the error is already injected by 1257 + * xfs_file_zoned_fallocate, which then reserves the additional space needed. 1258 + * We only check for this extra space reservation here. 1259 + */ 1260 + static inline bool 1261 + xfs_falloc_force_zero( 1262 + struct xfs_inode *ip, 1263 + struct xfs_zone_alloc_ctx *ac) 1264 + { 1265 + if (xfs_is_zoned_inode(ip)) { 1266 + if (ac->reserved_blocks > XFS_ZONED_ZERO_EDGE_SPACE_RES) { 1267 + ASSERT(IS_ENABLED(CONFIG_XFS_DEBUG)); 1268 + return true; 1269 + } 1270 + return false; 1271 + } 1272 + return XFS_TEST_ERROR(ip->i_mount, XFS_ERRTAG_FORCE_ZERO_RANGE); 1273 + } 1274 + 1275 + /* 1244 1276 * Punch a hole and prealloc the range. We use a hole punch rather than 1245 1277 * unwritten extent conversion for two reasons: 1246 1278 * ··· 1300 1268 if (error) 1301 1269 return error; 1302 1270 1303 - /* 1304 - * Zero range implements a full zeroing mechanism but is only used in 1305 - * limited situations. It is more efficient to allocate unwritten 1306 - * extents than to perform zeroing here, so use an errortag to randomly 1307 - * force zeroing on DEBUG kernels for added test coverage. 1308 - */ 1309 - if (XFS_TEST_ERROR(ip->i_mount, 1310 - XFS_ERRTAG_FORCE_ZERO_RANGE)) { 1271 + if (xfs_falloc_force_zero(ip, ac)) { 1311 1272 error = xfs_zero_range(ip, offset, len, ac, NULL); 1312 1273 } else { 1313 1274 error = xfs_free_file_space(ip, offset, len, ac); ··· 1448 1423 { 1449 1424 struct xfs_zone_alloc_ctx ac = { }; 1450 1425 struct xfs_inode *ip = XFS_I(file_inode(file)); 1426 + struct xfs_mount *mp = ip->i_mount; 1427 + xfs_filblks_t count_fsb; 1451 1428 int error; 1452 1429 1453 - error = xfs_zoned_space_reserve(ip->i_mount, 2, XFS_ZR_RESERVED, &ac); 1430 + /* 1431 + * If full zeroing is forced by the error injection knob, we need a 1432 + * space reservation that covers the entire range. See the comment in 1433 + * xfs_zoned_write_space_reserve for the rationale for the calculation. 1434 + * Otherwise just reserve space for the two boundary blocks. 1435 + */ 1436 + count_fsb = XFS_ZONED_ZERO_EDGE_SPACE_RES; 1437 + if ((mode & FALLOC_FL_MODE_MASK) == FALLOC_FL_ZERO_RANGE && 1438 + XFS_TEST_ERROR(mp, XFS_ERRTAG_FORCE_ZERO_RANGE)) 1439 + count_fsb += XFS_B_TO_FSB(mp, len) + 1; 1440 + 1441 + error = xfs_zoned_space_reserve(mp, count_fsb, XFS_ZR_RESERVED, &ac); 1454 1442 if (error) 1455 1443 return error; 1456 1444 error = __xfs_file_fallocate(file, mode, offset, len, &ac); 1457 - xfs_zoned_space_unreserve(ip->i_mount, &ac); 1445 + xfs_zoned_space_unreserve(mp, &ac); 1458 1446 return error; 1459 1447 } 1460 1448
+8 -6
fs/xfs/xfs_rtalloc.c
··· 1255 1255 min_logfsbs = min_t(xfs_extlen_t, xfs_log_calc_minimum_size(nmp), 1256 1256 nmp->m_rsumblocks * 2); 1257 1257 1258 - kfree(nmp); 1259 - 1260 1258 trace_xfs_growfs_check_rtgeom(mp, min_logfsbs); 1261 1259 1262 1260 if (min_logfsbs > mp->m_sb.sb_logblocks) 1263 - return -EINVAL; 1261 + goto out_inval; 1264 1262 1265 1263 if (xfs_has_zoned(mp)) { 1266 1264 uint32_t gblocks = mp->m_groups[XG_TYPE_RTG].blocks; ··· 1266 1268 1267 1269 if (rextsize != 1) 1268 1270 return -EINVAL; 1269 - div_u64_rem(mp->m_sb.sb_rblocks, gblocks, &rem); 1271 + div_u64_rem(nmp->m_sb.sb_rblocks, gblocks, &rem); 1270 1272 if (rem) { 1271 1273 xfs_warn(mp, 1272 1274 "new RT volume size (%lld) not aligned to RT group size (%d)", 1273 - mp->m_sb.sb_rblocks, gblocks); 1274 - return -EINVAL; 1275 + nmp->m_sb.sb_rblocks, gblocks); 1276 + goto out_inval; 1275 1277 } 1276 1278 } 1277 1279 1280 + kfree(nmp); 1278 1281 return 0; 1282 + out_inval: 1283 + kfree(nmp); 1284 + return -EINVAL; 1279 1285 } 1280 1286 1281 1287 /*