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-7.0-rc2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux

Pull xfs fixes from Carlos Maiolino:
"Nothing reeeally stands out here: a few bug fixes, some refactoring to
easily fit the bug fixes, and a couple cosmetic changes"

* tag 'xfs-fixes-7.0-rc2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
xfs: add static size checks for ioctl UABI
xfs: remove duplicate static size checks
xfs: Add comments for usages of some macros.
xfs: Update lazy counters in xfs_growfs_rt_bmblock()
xfs: Add a comment in xfs_log_sb()
xfs: Fix xfs_last_rt_bmblock()
xfs: don't report half-built inodes to fserror
xfs: don't report metadata inodes to fserror
xfs: fix potential pointer access race in xfs_healthmon_get
xfs: fix xfs_group release bug in xfs_dax_notify_dev_failure
xfs: fix xfs_group release bug in xfs_verify_report_losses
xfs: fix copy-paste error in previous fix
xfs: Fix error pointer dereference
xfs: remove metafile inodes from the active inode stat
xfs: cleanup inode counter stats
xfs: fix code alignment issues in xfs_ondisk.c
xfs: Replace &rtg->rtg_group with rtg_group()
xfs: Refactoring the nagcount and delta calculation
xfs: Replace ASSERT with XFS_IS_CORRUPT in xfs_rtcopy_summary()

+209 -80
+28
fs/xfs/libxfs/xfs_ag.c
··· 872 872 return err2; 873 873 } 874 874 875 + void 876 + xfs_growfs_compute_deltas( 877 + struct xfs_mount *mp, 878 + xfs_rfsblock_t nb, 879 + int64_t *deltap, 880 + xfs_agnumber_t *nagcountp) 881 + { 882 + xfs_rfsblock_t nb_div, nb_mod; 883 + int64_t delta; 884 + xfs_agnumber_t nagcount; 885 + 886 + nb_div = nb; 887 + nb_mod = do_div(nb_div, mp->m_sb.sb_agblocks); 888 + if (nb_mod && nb_mod >= XFS_MIN_AG_BLOCKS) 889 + nb_div++; 890 + else if (nb_mod) 891 + nb = nb_div * mp->m_sb.sb_agblocks; 892 + 893 + if (nb_div > XFS_MAX_AGNUMBER + 1) { 894 + nb_div = XFS_MAX_AGNUMBER + 1; 895 + nb = nb_div * mp->m_sb.sb_agblocks; 896 + } 897 + nagcount = nb_div; 898 + delta = nb - mp->m_sb.sb_dblocks; 899 + *deltap = delta; 900 + *nagcountp = nagcount; 901 + } 902 + 875 903 /* 876 904 * Extent the AG indicated by the @id by the length passed in 877 905 */
+3
fs/xfs/libxfs/xfs_ag.h
··· 331 331 int xfs_ag_init_headers(struct xfs_mount *mp, struct aghdr_init_data *id); 332 332 int xfs_ag_shrink_space(struct xfs_perag *pag, struct xfs_trans **tpp, 333 333 xfs_extlen_t delta); 334 + void 335 + xfs_growfs_compute_deltas(struct xfs_mount *mp, xfs_rfsblock_t nb, 336 + int64_t *deltap, xfs_agnumber_t *nagcountp); 334 337 int xfs_ag_extend_space(struct xfs_perag *pag, struct xfs_trans *tp, 335 338 xfs_extlen_t len); 336 339 int xfs_ag_get_geometry(struct xfs_perag *pag, struct xfs_ag_geometry *ageo);
+4
fs/xfs/libxfs/xfs_inode_buf.c
··· 268 268 } 269 269 if (xfs_is_reflink_inode(ip)) 270 270 xfs_ifork_init_cow(ip); 271 + if (xfs_is_metadir_inode(ip)) { 272 + XFS_STATS_DEC(ip->i_mount, xs_inodes_active); 273 + XFS_STATS_INC(ip->i_mount, xs_inodes_meta); 274 + } 271 275 return 0; 272 276 273 277 out_destroy_data_fork:
+5
fs/xfs/libxfs/xfs_metafile.c
··· 61 61 ip->i_diflags2 |= XFS_DIFLAG2_METADATA; 62 62 ip->i_metatype = metafile_type; 63 63 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); 64 + 65 + XFS_STATS_DEC(ip->i_mount, xs_inodes_active); 66 + XFS_STATS_INC(ip->i_mount, xs_inodes_meta); 64 67 } 65 68 66 69 /* Clear the metadata directory inode flag. */ ··· 77 74 78 75 ip->i_diflags2 &= ~XFS_DIFLAG2_METADATA; 79 76 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); 77 + XFS_STATS_INC(ip->i_mount, xs_inodes_active); 78 + XFS_STATS_DEC(ip->i_mount, xs_inodes_meta); 80 79 } 81 80 82 81 /*
+36 -16
fs/xfs/libxfs/xfs_ondisk.h
··· 73 73 XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_free_hdr, 64); 74 74 XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_leaf, 64); 75 75 XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_leaf_hdr, 64); 76 - XFS_CHECK_STRUCT_SIZE(struct xfs_attr_leaf_entry, 8); 76 + XFS_CHECK_STRUCT_SIZE(struct xfs_attr_leaf_entry, 8); 77 77 XFS_CHECK_STRUCT_SIZE(struct xfs_attr_leaf_hdr, 32); 78 78 XFS_CHECK_STRUCT_SIZE(struct xfs_attr_leaf_map, 4); 79 79 XFS_CHECK_STRUCT_SIZE(struct xfs_attr_leaf_name_local, 4); ··· 116 116 XFS_CHECK_STRUCT_SIZE(struct xfs_da_intnode, 16); 117 117 XFS_CHECK_STRUCT_SIZE(struct xfs_da_node_entry, 8); 118 118 XFS_CHECK_STRUCT_SIZE(struct xfs_da_node_hdr, 16); 119 - XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_data_free, 4); 119 + XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_data_free, 4); 120 120 XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_data_hdr, 16); 121 121 XFS_CHECK_OFFSET(struct xfs_dir2_data_unused, freetag, 0); 122 122 XFS_CHECK_OFFSET(struct xfs_dir2_data_unused, length, 2); ··· 136 136 /* ondisk dir/attr structures from xfs/122 */ 137 137 XFS_CHECK_STRUCT_SIZE(struct xfs_attr_sf_entry, 3); 138 138 XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_data_free, 4); 139 - XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_data_hdr, 16); 140 139 XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_data_unused, 6); 141 - XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_free, 16); 142 - XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_free_hdr, 16); 143 - XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_leaf, 16); 144 - XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_leaf_entry, 8); 145 - XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_leaf_hdr, 16); 146 - XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_leaf_tail, 4); 147 - XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_sf_entry, 3); 148 - XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_sf_hdr, 10); 149 140 150 141 /* log structures */ 151 142 XFS_CHECK_STRUCT_SIZE(struct xfs_buf_log_format, 88); ··· 207 216 XFS_CHECK_OFFSET(struct xfs_dir3_data_hdr, hdr.magic, 0); 208 217 XFS_CHECK_OFFSET(struct xfs_dir3_free, hdr.hdr.magic, 0); 209 218 XFS_CHECK_OFFSET(struct xfs_attr3_leafblock, hdr.info.hdr, 0); 210 - 211 - XFS_CHECK_STRUCT_SIZE(struct xfs_bulkstat, 192); 212 - XFS_CHECK_STRUCT_SIZE(struct xfs_inumbers, 24); 213 - XFS_CHECK_STRUCT_SIZE(struct xfs_bulkstat_req, 64); 214 - XFS_CHECK_STRUCT_SIZE(struct xfs_inumbers_req, 64); 215 219 216 220 /* 217 221 * Make sure the incore inode timestamp range corresponds to hand ··· 287 301 XFS_CHECK_SB_OFFSET(sb_pad, 281); 288 302 XFS_CHECK_SB_OFFSET(sb_rtstart, 288); 289 303 XFS_CHECK_SB_OFFSET(sb_rtreserved, 296); 304 + 305 + /* 306 + * ioctl UABI 307 + * 308 + * Due to different padding/alignment requirements across 309 + * different architectures, some structures are ommited from 310 + * the size checks. In addition, structures with architecture 311 + * dependent size fields are also ommited (e.g. __kernel_long_t). 312 + */ 313 + XFS_CHECK_STRUCT_SIZE(struct xfs_bulkstat, 192); 314 + XFS_CHECK_STRUCT_SIZE(struct xfs_inumbers, 24); 315 + XFS_CHECK_STRUCT_SIZE(struct xfs_bulkstat_req, 64); 316 + XFS_CHECK_STRUCT_SIZE(struct xfs_inumbers_req, 64); 317 + XFS_CHECK_STRUCT_SIZE(struct dioattr, 12); 318 + XFS_CHECK_STRUCT_SIZE(struct getbmap, 32); 319 + XFS_CHECK_STRUCT_SIZE(struct getbmapx, 48); 320 + XFS_CHECK_STRUCT_SIZE(struct xfs_attrlist_cursor, 16); 321 + XFS_CHECK_STRUCT_SIZE(struct xfs_attrlist, 8); 322 + XFS_CHECK_STRUCT_SIZE(struct xfs_attrlist, 8); 323 + XFS_CHECK_STRUCT_SIZE(struct xfs_attrlist_ent, 4); 324 + XFS_CHECK_STRUCT_SIZE(struct xfs_ag_geometry, 128); 325 + XFS_CHECK_STRUCT_SIZE(struct xfs_rtgroup_geometry, 128); 326 + XFS_CHECK_STRUCT_SIZE(struct xfs_error_injection, 8); 327 + XFS_CHECK_STRUCT_SIZE(struct xfs_fsop_geom, 256); 328 + XFS_CHECK_STRUCT_SIZE(struct xfs_fsop_geom_v4, 112); 329 + XFS_CHECK_STRUCT_SIZE(struct xfs_fsop_counts, 32); 330 + XFS_CHECK_STRUCT_SIZE(struct xfs_fsop_resblks, 16); 331 + XFS_CHECK_STRUCT_SIZE(struct xfs_growfs_log, 8); 332 + XFS_CHECK_STRUCT_SIZE(struct xfs_bulk_ireq, 64); 333 + XFS_CHECK_STRUCT_SIZE(struct xfs_fs_eofblocks, 128); 334 + XFS_CHECK_STRUCT_SIZE(struct xfs_fsid, 8); 335 + XFS_CHECK_STRUCT_SIZE(struct xfs_scrub_metadata, 64); 336 + XFS_CHECK_STRUCT_SIZE(struct xfs_scrub_vec, 16); 337 + XFS_CHECK_STRUCT_SIZE(struct xfs_scrub_vec_head, 40); 290 338 } 291 339 292 340 #endif /* __XFS_ONDISK_H */
+3
fs/xfs/libxfs/xfs_sb.c
··· 1347 1347 * feature was introduced. This counter can go negative due to the way 1348 1348 * we handle nearly-lockless reservations, so we must use the _positive 1349 1349 * variant here to avoid writing out nonsense frextents. 1350 + * 1351 + * RT groups are only supported on v5 file systems, which always 1352 + * have lazy SB counters. 1350 1353 */ 1351 1354 if (xfs_has_rtgroups(mp) && !xfs_has_zoned(mp)) { 1352 1355 mp->m_sb.sb_frextents =
+1 -1
fs/xfs/scrub/dir_repair.c
··· 177 177 rd->dir_names = NULL; 178 178 if (rd->dir_entries) 179 179 xfarray_destroy(rd->dir_entries); 180 - rd->dir_names = NULL; 180 + rd->dir_entries = NULL; 181 181 } 182 182 183 183 /* Set up for a directory repair. */
+6 -1
fs/xfs/scrub/orphanage.c
··· 442 442 return 0; 443 443 444 444 d_child = try_lookup_noperm(&qname, d_orphanage); 445 + if (IS_ERR(d_child)) { 446 + dput(d_orphanage); 447 + return PTR_ERR(d_child); 448 + } 449 + 445 450 if (d_child) { 446 451 trace_xrep_adoption_check_child(sc->mp, d_child); 447 452 ··· 484 479 return; 485 480 486 481 d_child = try_lookup_noperm(&qname, d_orphanage); 487 - while (d_child != NULL) { 482 + while (!IS_ERR_OR_NULL(d_child)) { 488 483 trace_xrep_adoption_invalidate_child(sc->mp, d_child); 489 484 490 485 ASSERT(d_is_negative(d_child));
+2 -15
fs/xfs/xfs_fsops.c
··· 95 95 struct xfs_growfs_data *in) /* growfs data input struct */ 96 96 { 97 97 xfs_agnumber_t oagcount = mp->m_sb.sb_agcount; 98 + xfs_rfsblock_t nb = in->newblocks; 98 99 struct xfs_buf *bp; 99 100 int error; 100 101 xfs_agnumber_t nagcount; 101 102 xfs_agnumber_t nagimax = 0; 102 - xfs_rfsblock_t nb, nb_div, nb_mod; 103 103 int64_t delta; 104 104 bool lastag_extended = false; 105 105 struct xfs_trans *tp; 106 106 struct aghdr_init_data id = {}; 107 107 struct xfs_perag *last_pag; 108 108 109 - nb = in->newblocks; 110 109 error = xfs_sb_validate_fsb_count(&mp->m_sb, nb); 111 110 if (error) 112 111 return error; ··· 124 125 mp->m_sb.sb_rextsize); 125 126 if (error) 126 127 return error; 128 + xfs_growfs_compute_deltas(mp, nb, &delta, &nagcount); 127 129 128 - nb_div = nb; 129 - nb_mod = do_div(nb_div, mp->m_sb.sb_agblocks); 130 - if (nb_mod && nb_mod >= XFS_MIN_AG_BLOCKS) 131 - nb_div++; 132 - else if (nb_mod) 133 - nb = nb_div * mp->m_sb.sb_agblocks; 134 - 135 - if (nb_div > XFS_MAX_AGNUMBER + 1) { 136 - nb_div = XFS_MAX_AGNUMBER + 1; 137 - nb = nb_div * mp->m_sb.sb_agblocks; 138 - } 139 - nagcount = nb_div; 140 - delta = nb - mp->m_sb.sb_dblocks; 141 130 /* 142 131 * Reject filesystems with a single AG because they are not 143 132 * supported, and reject a shrink operation that would cause a
+18 -2
fs/xfs/xfs_health.c
··· 314 314 xfs_rtgroup_put(rtg); 315 315 } 316 316 317 + static inline void xfs_inode_report_fserror(struct xfs_inode *ip) 318 + { 319 + /* 320 + * Do not report inodes being constructed or freed, or metadata inodes, 321 + * to fsnotify. 322 + */ 323 + if (xfs_iflags_test(ip, XFS_INEW | XFS_IRECLAIM) || 324 + xfs_is_internal_inode(ip)) { 325 + fserror_report_metadata(ip->i_mount->m_super, -EFSCORRUPTED, 326 + GFP_NOFS); 327 + return; 328 + } 329 + 330 + fserror_report_file_metadata(VFS_I(ip), -EFSCORRUPTED, GFP_NOFS); 331 + } 332 + 317 333 /* Mark the unhealthy parts of an inode. */ 318 334 void 319 335 xfs_inode_mark_sick( ··· 355 339 inode_state_clear(VFS_I(ip), I_DONTCACHE); 356 340 spin_unlock(&VFS_I(ip)->i_lock); 357 341 358 - fserror_report_file_metadata(VFS_I(ip), -EFSCORRUPTED, GFP_NOFS); 342 + xfs_inode_report_fserror(ip); 359 343 if (mask) 360 344 xfs_healthmon_report_inode(ip, XFS_HEALTHMON_SICK, old_mask, 361 345 mask); ··· 387 371 inode_state_clear(VFS_I(ip), I_DONTCACHE); 388 372 spin_unlock(&VFS_I(ip)->i_lock); 389 373 390 - fserror_report_file_metadata(VFS_I(ip), -EFSCORRUPTED, GFP_NOFS); 374 + xfs_inode_report_fserror(ip); 391 375 if (mask) 392 376 xfs_healthmon_report_inode(ip, XFS_HEALTHMON_CORRUPT, old_mask, 393 377 mask);
+7 -4
fs/xfs/xfs_healthmon.c
··· 69 69 struct xfs_healthmon *hm; 70 70 71 71 rcu_read_lock(); 72 - hm = mp->m_healthmon; 72 + hm = rcu_dereference(mp->m_healthmon); 73 73 if (hm && !refcount_inc_not_zero(&hm->ref)) 74 74 hm = NULL; 75 75 rcu_read_unlock(); ··· 110 110 struct xfs_healthmon *hm) 111 111 { 112 112 spin_lock(&xfs_healthmon_lock); 113 - if (mp->m_healthmon != NULL) { 113 + if (rcu_access_pointer(mp->m_healthmon) != NULL) { 114 114 spin_unlock(&xfs_healthmon_lock); 115 115 return -EEXIST; 116 116 } 117 117 118 118 refcount_inc(&hm->ref); 119 - mp->m_healthmon = hm; 119 + rcu_assign_pointer(mp->m_healthmon, hm); 120 120 hm->mount_cookie = (uintptr_t)mp->m_super; 121 121 spin_unlock(&xfs_healthmon_lock); 122 122 ··· 128 128 xfs_healthmon_detach( 129 129 struct xfs_healthmon *hm) 130 130 { 131 + struct xfs_mount *mp; 132 + 131 133 spin_lock(&xfs_healthmon_lock); 132 134 if (hm->mount_cookie == DETACHED_MOUNT_COOKIE) { 133 135 spin_unlock(&xfs_healthmon_lock); 134 136 return; 135 137 } 136 138 137 - XFS_M((struct super_block *)hm->mount_cookie)->m_healthmon = NULL; 139 + mp = XFS_M((struct super_block *)hm->mount_cookie); 140 + rcu_assign_pointer(mp->m_healthmon, NULL); 138 141 hm->mount_cookie = DETACHED_MOUNT_COOKIE; 139 142 spin_unlock(&xfs_healthmon_lock); 140 143
+14 -4
fs/xfs/xfs_icache.c
··· 106 106 mapping_set_folio_min_order(VFS_I(ip)->i_mapping, 107 107 M_IGEO(mp)->min_folio_order); 108 108 109 - XFS_STATS_INC(mp, vn_active); 109 + XFS_STATS_INC(mp, xs_inodes_active); 110 110 ASSERT(atomic_read(&ip->i_pincount) == 0); 111 111 ASSERT(ip->i_ino == 0); 112 112 ··· 172 172 /* asserts to verify all state is correct here */ 173 173 ASSERT(atomic_read(&ip->i_pincount) == 0); 174 174 ASSERT(!ip->i_itemp || list_empty(&ip->i_itemp->ili_item.li_bio_list)); 175 - XFS_STATS_DEC(ip->i_mount, vn_active); 175 + if (xfs_is_metadir_inode(ip)) 176 + XFS_STATS_DEC(ip->i_mount, xs_inodes_meta); 177 + else 178 + XFS_STATS_DEC(ip->i_mount, xs_inodes_active); 176 179 177 180 call_rcu(&VFS_I(ip)->i_rcu, xfs_inode_free_callback); 178 181 } ··· 639 636 if (!ip) 640 637 return -ENOMEM; 641 638 639 + /* 640 + * Set XFS_INEW as early as possible so that the health code won't pass 641 + * the inode to the fserror code if the ondisk inode cannot be loaded. 642 + * We're going to free the xfs_inode immediately if that happens, which 643 + * would lead to UAF problems. 644 + */ 645 + xfs_iflags_set(ip, XFS_INEW); 646 + 642 647 error = xfs_imap(pag, tp, ip->i_ino, &ip->i_imap, flags); 643 648 if (error) 644 649 goto out_destroy; ··· 724 713 ip->i_udquot = NULL; 725 714 ip->i_gdquot = NULL; 726 715 ip->i_pdquot = NULL; 727 - xfs_iflags_set(ip, XFS_INEW); 728 716 729 717 /* insert the new inode */ 730 718 spin_lock(&pag->pag_ici_lock); ··· 2244 2234 struct xfs_mount *mp = ip->i_mount; 2245 2235 bool need_inactive; 2246 2236 2247 - XFS_STATS_INC(mp, vn_reclaim); 2237 + XFS_STATS_INC(mp, xs_inode_mark_reclaimable); 2248 2238 2249 2239 /* 2250 2240 * We should never get here with any of the reclaim flags already set.
+1 -1
fs/xfs/xfs_mount.h
··· 345 345 struct xfs_hooks m_dir_update_hooks; 346 346 347 347 /* Private data referring to a health monitor object. */ 348 - struct xfs_healthmon *m_healthmon; 348 + struct xfs_healthmon __rcu *m_healthmon; 349 349 } xfs_mount_t; 350 350 351 351 #define M_IGEO(mp) (&(mp)->m_ino_geo)
+2 -2
fs/xfs/xfs_notify_failure.c
··· 304 304 305 305 error = xfs_alloc_read_agf(pag, tp, 0, &agf_bp); 306 306 if (error) { 307 - xfs_perag_put(pag); 307 + xfs_perag_rele(pag); 308 308 break; 309 309 } 310 310 ··· 340 340 if (rtg) 341 341 xfs_rtgroup_unlock(rtg, XFS_RTGLOCK_RMAP); 342 342 if (error) { 343 - xfs_group_put(xg); 343 + xfs_group_rele(xg); 344 344 break; 345 345 } 346 346 }
+9
fs/xfs/xfs_platform.h
··· 235 235 236 236 #ifdef XFS_WARN 237 237 238 + /* 239 + * Please note that this ASSERT doesn't kill the kernel. It will if the kernel 240 + * has panic_on_warn set. 241 + */ 238 242 #define ASSERT(expr) \ 239 243 (likely(expr) ? (void)0 : asswarn(NULL, #expr, __FILE__, __LINE__)) 240 244 ··· 249 245 #endif /* XFS_WARN */ 250 246 #endif /* DEBUG */ 251 247 248 + /* 249 + * Use this to catch metadata corruptions that are not caught by block or 250 + * structure verifiers. The reason is that the verifiers check corruptions only 251 + * within the scope of the object being verified. 252 + */ 252 253 #define XFS_IS_CORRUPT(mp, expr) \ 253 254 (unlikely(expr) ? xfs_corruption_error(#expr, XFS_ERRLEVEL_LOW, (mp), \ 254 255 NULL, 0, __FILE__, __LINE__, \
+37 -7
fs/xfs/xfs_rtalloc.c
··· 112 112 error = xfs_rtget_summary(oargs, log, bbno, &sum); 113 113 if (error) 114 114 goto out; 115 + if (XFS_IS_CORRUPT(oargs->mp, sum < 0)) { 116 + error = -EFSCORRUPTED; 117 + goto out; 118 + } 115 119 if (sum == 0) 116 120 continue; 117 121 error = xfs_rtmodify_summary(oargs, log, bbno, -sum); ··· 124 120 error = xfs_rtmodify_summary(nargs, log, bbno, sum); 125 121 if (error) 126 122 goto out; 127 - ASSERT(sum > 0); 128 123 } 129 124 } 130 125 error = 0; ··· 1050 1047 */ 1051 1048 xfs_trans_resv_calc(mp, &mp->m_resv); 1052 1049 1050 + /* 1051 + * Sync sb counters now to reflect the updated values. Lazy counters are 1052 + * not always updated and in order to avoid inconsistencies between 1053 + * frextents and rtextents, it is better to sync the counters. 1054 + */ 1055 + 1056 + if (xfs_has_lazysbcount(mp)) 1057 + xfs_log_sb(args.tp); 1058 + 1053 1059 error = xfs_trans_commit(args.tp); 1054 1060 if (error) 1055 1061 goto out_free; ··· 1091 1079 } 1092 1080 1093 1081 /* 1094 - * Calculate the last rbmblock currently used. 1082 + * This will return the bitmap block number (indexed at 0) that will be 1083 + * extended/modified. There are 2 cases here: 1084 + * 1. The size of the rtg is such that it is a multiple of 1085 + * xfs_rtbitmap_rtx_per_rbmblock() i.e, an integral number of bitmap blocks 1086 + * are completely filled up. In this case, we should return 1087 + * 1 + (the last used bitmap block number). 1088 + * 2. The size of the rtg is not an multiple of xfs_rtbitmap_rtx_per_rbmblock(). 1089 + * Here we will return the block number of last used block number. In this 1090 + * case, we will modify the last used bitmap block to extend the size of the 1091 + * rtgroup. 1095 1092 * 1096 1093 * This also deals with the case where there were no rtextents before. 1097 1094 */ 1098 1095 static xfs_fileoff_t 1099 - xfs_last_rt_bmblock( 1096 + xfs_last_rt_bmblock_to_extend( 1100 1097 struct xfs_rtgroup *rtg) 1101 1098 { 1102 1099 struct xfs_mount *mp = rtg_mount(rtg); 1103 1100 xfs_rgnumber_t rgno = rtg_rgno(rtg); 1104 1101 xfs_fileoff_t bmbno = 0; 1102 + unsigned int mod = 0; 1105 1103 1106 1104 ASSERT(!mp->m_sb.sb_rgcount || rgno >= mp->m_sb.sb_rgcount - 1); 1107 1105 ··· 1119 1097 xfs_rtxnum_t nrext = xfs_last_rtgroup_extents(mp); 1120 1098 1121 1099 /* Also fill up the previous block if not entirely full. */ 1122 - bmbno = xfs_rtbitmap_blockcount_len(mp, nrext); 1123 - if (xfs_rtx_to_rbmword(mp, nrext) != 0) 1124 - bmbno--; 1100 + /* We are doing a -1 to convert it to a 0 based index */ 1101 + bmbno = xfs_rtbitmap_blockcount_len(mp, nrext) - 1; 1102 + div_u64_rem(nrext, xfs_rtbitmap_rtx_per_rbmblock(mp), &mod); 1103 + /* 1104 + * mod = 0 means that all the current blocks are full. So 1105 + * return the next block number to be used for the rtgroup 1106 + * growth. 1107 + */ 1108 + if (mod == 0) 1109 + bmbno++; 1125 1110 } 1126 1111 1127 1112 return bmbno; ··· 1233 1204 goto out_rele; 1234 1205 } 1235 1206 1236 - for (bmbno = xfs_last_rt_bmblock(rtg); bmbno < bmblocks; bmbno++) { 1207 + for (bmbno = xfs_last_rt_bmblock_to_extend(rtg); bmbno < bmblocks; 1208 + bmbno++) { 1237 1209 error = xfs_growfs_rt_bmblock(rtg, nrblocks, rextsize, bmbno); 1238 1210 if (error) 1239 1211 goto out_error;
+11 -6
fs/xfs/xfs_stats.c
··· 42 42 { "xstrat", xfsstats_offset(xs_write_calls) }, 43 43 { "rw", xfsstats_offset(xs_attr_get) }, 44 44 { "attr", xfsstats_offset(xs_iflush_count)}, 45 - { "icluster", xfsstats_offset(vn_active) }, 45 + { "icluster", xfsstats_offset(xs_inodes_active) }, 46 46 { "vnodes", xfsstats_offset(xb_get) }, 47 47 { "buf", xfsstats_offset(xs_abtb_2) }, 48 48 { "abtb2", xfsstats_offset(xs_abtc_2) }, ··· 59 59 { "rtrefcntbt", xfsstats_offset(xs_qm_dqreclaims)}, 60 60 /* we print both series of quota information together */ 61 61 { "qm", xfsstats_offset(xs_gc_read_calls)}, 62 - { "zoned", xfsstats_offset(__pad1)}, 62 + { "zoned", xfsstats_offset(xs_inodes_meta)}, 63 + { "metafile", xfsstats_offset(xs_xstrat_bytes)}, 63 64 }; 64 65 65 66 /* Loop over all stats groups */ ··· 100 99 101 100 void xfs_stats_clearall(struct xfsstats __percpu *stats) 102 101 { 102 + uint32_t xs_inodes_active, xs_inodes_meta; 103 103 int c; 104 - uint32_t vn_active; 105 104 106 105 xfs_notice(NULL, "Clearing xfsstats"); 107 106 for_each_possible_cpu(c) { 108 107 preempt_disable(); 109 - /* save vn_active, it's a universal truth! */ 110 - vn_active = per_cpu_ptr(stats, c)->s.vn_active; 108 + /* 109 + * Save the active / meta inode counters, as they are stateful. 110 + */ 111 + xs_inodes_active = per_cpu_ptr(stats, c)->s.xs_inodes_active; 112 + xs_inodes_meta = per_cpu_ptr(stats, c)->s.xs_inodes_meta; 111 113 memset(per_cpu_ptr(stats, c), 0, sizeof(*stats)); 112 - per_cpu_ptr(stats, c)->s.vn_active = vn_active; 114 + per_cpu_ptr(stats, c)->s.xs_inodes_active = xs_inodes_active; 115 + per_cpu_ptr(stats, c)->s.xs_inodes_meta = xs_inodes_meta; 113 116 preempt_enable(); 114 117 } 115 118 }
+10 -9
fs/xfs/xfs_stats.h
··· 100 100 uint32_t xs_iflush_count; 101 101 uint32_t xs_icluster_flushcnt; 102 102 uint32_t xs_icluster_flushinode; 103 - uint32_t vn_active; /* # vnodes not on free lists */ 104 - uint32_t vn_alloc; /* # times vn_alloc called */ 105 - uint32_t vn_get; /* # times vn_get called */ 106 - uint32_t vn_hold; /* # times vn_hold called */ 107 - uint32_t vn_rele; /* # times vn_rele called */ 108 - uint32_t vn_reclaim; /* # times vn_reclaim called */ 109 - uint32_t vn_remove; /* # times vn_remove called */ 110 - uint32_t vn_free; /* # times vn_free called */ 103 + uint32_t xs_inodes_active; 104 + uint32_t __unused_vn_alloc; 105 + uint32_t __unused_vn_get; 106 + uint32_t __unused_vn_hold; 107 + uint32_t xs_inode_destroy; 108 + uint32_t xs_inode_destroy2; /* same as xs_inode_destroy */ 109 + uint32_t xs_inode_mark_reclaimable; 110 + uint32_t __unused_vn_free; 111 111 uint32_t xb_get; 112 112 uint32_t xb_create; 113 113 uint32_t xb_get_locked; ··· 142 142 uint32_t xs_gc_read_calls; 143 143 uint32_t xs_gc_write_calls; 144 144 uint32_t xs_gc_zone_reset_calls; 145 - uint32_t __pad1; 145 + /* Metafile counters */ 146 + uint32_t xs_inodes_meta; 146 147 /* Extra precision counters */ 147 148 uint64_t xs_xstrat_bytes; 148 149 uint64_t xs_write_bytes;
+2 -2
fs/xfs/xfs_super.c
··· 712 712 trace_xfs_destroy_inode(ip); 713 713 714 714 ASSERT(!rwsem_is_locked(&inode->i_rwsem)); 715 - XFS_STATS_INC(ip->i_mount, vn_rele); 716 - XFS_STATS_INC(ip->i_mount, vn_remove); 715 + XFS_STATS_INC(ip->i_mount, xs_inode_destroy); 716 + XFS_STATS_INC(ip->i_mount, xs_inode_destroy2); 717 717 xfs_inode_mark_reclaimable(ip); 718 718 } 719 719
+2 -2
fs/xfs/xfs_verify_media.c
··· 122 122 123 123 error = xfs_alloc_read_agf(pag, tp, 0, &agf_bp); 124 124 if (error) { 125 - xfs_perag_put(pag); 125 + xfs_perag_rele(pag); 126 126 break; 127 127 } 128 128 ··· 158 158 if (rtg) 159 159 xfs_rtgroup_unlock(rtg, XFS_RTGLOCK_RMAP); 160 160 if (error) { 161 - xfs_group_put(xg); 161 + xfs_group_rele(xg); 162 162 break; 163 163 } 164 164 }
+3 -3
fs/xfs/xfs_zone_alloc.c
··· 78 78 struct xfs_rtgroup *rtg, 79 79 uint32_t freed) 80 80 { 81 - struct xfs_group *xg = &rtg->rtg_group; 81 + struct xfs_group *xg = rtg_group(rtg); 82 82 struct xfs_mount *mp = rtg_mount(rtg); 83 83 struct xfs_zone_info *zi = mp->m_zone_info; 84 84 uint32_t used = rtg_rmap(rtg)->i_used_blocks; ··· 759 759 760 760 trace_xfs_zone_alloc_blocks(oz, allocated, count_fsb); 761 761 762 - *sector = xfs_gbno_to_daddr(&rtg->rtg_group, 0); 762 + *sector = xfs_gbno_to_daddr(rtg_group(rtg), 0); 763 763 *is_seq = bdev_zone_is_seq(mp->m_rtdev_targp->bt_bdev, *sector); 764 764 if (!*is_seq) 765 765 *sector += XFS_FSB_TO_BB(mp, allocated); ··· 1080 1080 if (write_pointer == 0) { 1081 1081 /* zone is empty */ 1082 1082 atomic_inc(&zi->zi_nr_free_zones); 1083 - xfs_group_set_mark(&rtg->rtg_group, XFS_RTG_FREE); 1083 + xfs_group_set_mark(rtg_group(rtg), XFS_RTG_FREE); 1084 1084 iz->available += rtg_blocks(rtg); 1085 1085 } else if (write_pointer < rtg_blocks(rtg)) { 1086 1086 /* zone is open */
+5 -5
fs/xfs/xfs_zone_gc.c
··· 627 627 if (!*count_fsb) 628 628 return NULL; 629 629 630 - *daddr = xfs_gbno_to_daddr(&oz->oz_rtg->rtg_group, 0); 630 + *daddr = xfs_gbno_to_daddr(rtg_group(oz->oz_rtg), 0); 631 631 *is_seq = bdev_zone_is_seq(mp->m_rtdev_targp->bt_bdev, *daddr); 632 632 if (!*is_seq) 633 633 *daddr += XFS_FSB_TO_BB(mp, oz->oz_allocated); ··· 702 702 chunk->data = data; 703 703 chunk->oz = oz; 704 704 chunk->victim_rtg = iter->victim_rtg; 705 - atomic_inc(&chunk->victim_rtg->rtg_group.xg_active_ref); 705 + atomic_inc(&rtg_group(chunk->victim_rtg)->xg_active_ref); 706 706 atomic_inc(&chunk->victim_rtg->rtg_gccount); 707 707 708 708 bio->bi_iter.bi_sector = xfs_rtb_to_daddr(mp, chunk->old_startblock); ··· 788 788 atomic_inc(&chunk->oz->oz_ref); 789 789 790 790 split_chunk->victim_rtg = chunk->victim_rtg; 791 - atomic_inc(&chunk->victim_rtg->rtg_group.xg_active_ref); 791 + atomic_inc(&rtg_group(chunk->victim_rtg)->xg_active_ref); 792 792 atomic_inc(&chunk->victim_rtg->rtg_gccount); 793 793 794 794 chunk->offset += split_len; ··· 888 888 goto out; 889 889 } 890 890 891 - xfs_group_set_mark(&rtg->rtg_group, XFS_RTG_FREE); 891 + xfs_group_set_mark(rtg_group(rtg), XFS_RTG_FREE); 892 892 atomic_inc(&zi->zi_nr_free_zones); 893 893 894 894 xfs_zoned_add_available(mp, rtg_blocks(rtg)); ··· 917 917 918 918 XFS_STATS_INC(mp, xs_gc_zone_reset_calls); 919 919 920 - bio->bi_iter.bi_sector = xfs_gbno_to_daddr(&rtg->rtg_group, 0); 920 + bio->bi_iter.bi_sector = xfs_gbno_to_daddr(rtg_group(rtg), 0); 921 921 if (!bdev_zone_is_seq(bio->bi_bdev, bio->bi_iter.bi_sector)) { 922 922 /* 923 923 * Also use the bio to drive the state machine when neither