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.

xfs: pass the write pointer to xfs_init_zone

Move the two methods to query the write pointer out of xfs_init_zone into
the callers, so that xfs_init_zone doesn't have to bother with the
blk_zone structure and instead operates purely at the XFS realtime group
level.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>

authored by

Christoph Hellwig and committed by
Carlos Maiolino
776b76f7 fc633b5c

+37 -29
+37 -29
fs/xfs/xfs_zone_alloc.c
··· 981 981 uint64_t reclaimable; 982 982 }; 983 983 984 + /* 985 + * For sequential write required zones, we restart writing at the hardware write 986 + * pointer returned by xfs_zone_validate(). 987 + * 988 + * For conventional zones or conventional devices we have to query the rmap to 989 + * find the highest recorded block and set the write pointer to the block after 990 + * that. In case of a power loss this misses blocks where the data I/O has 991 + * completed but not recorded in the rmap yet, and it also rewrites blocks if 992 + * the most recently written ones got deleted again before unmount, but this is 993 + * the best we can do without hardware support. 994 + */ 995 + static xfs_rgblock_t 996 + xfs_rmap_estimate_write_pointer( 997 + struct xfs_rtgroup *rtg) 998 + { 999 + xfs_rgblock_t highest_rgbno; 1000 + 1001 + xfs_rtgroup_lock(rtg, XFS_RTGLOCK_RMAP); 1002 + highest_rgbno = xfs_rtrmap_highest_rgbno(rtg); 1003 + xfs_rtgroup_unlock(rtg, XFS_RTGLOCK_RMAP); 1004 + 1005 + if (highest_rgbno == NULLRGBLOCK) 1006 + return 0; 1007 + return highest_rgbno + 1; 1008 + } 1009 + 984 1010 static int 985 1011 xfs_init_zone( 986 1012 struct xfs_init_zones *iz, 987 1013 struct xfs_rtgroup *rtg, 988 - struct blk_zone *zone) 1014 + xfs_rgblock_t write_pointer) 989 1015 { 990 1016 struct xfs_mount *mp = rtg_mount(rtg); 991 1017 struct xfs_zone_info *zi = mp->m_zone_info; 992 1018 uint32_t used = rtg_rmap(rtg)->i_used_blocks; 993 - xfs_rgblock_t write_pointer, highest_rgbno; 994 1019 int error; 995 - 996 - if (zone && !xfs_zone_validate(zone, rtg, &write_pointer)) 997 - return -EFSCORRUPTED; 998 - 999 - /* 1000 - * For sequential write required zones we retrieved the hardware write 1001 - * pointer above. 1002 - * 1003 - * For conventional zones or conventional devices we don't have that 1004 - * luxury. Instead query the rmap to find the highest recorded block 1005 - * and set the write pointer to the block after that. In case of a 1006 - * power loss this misses blocks where the data I/O has completed but 1007 - * not recorded in the rmap yet, and it also rewrites blocks if the most 1008 - * recently written ones got deleted again before unmount, but this is 1009 - * the best we can do without hardware support. 1010 - */ 1011 - if (!zone || zone->cond == BLK_ZONE_COND_NOT_WP) { 1012 - xfs_rtgroup_lock(rtg, XFS_RTGLOCK_RMAP); 1013 - highest_rgbno = xfs_rtrmap_highest_rgbno(rtg); 1014 - if (highest_rgbno == NULLRGBLOCK) 1015 - write_pointer = 0; 1016 - else 1017 - write_pointer = highest_rgbno + 1; 1018 - xfs_rtgroup_unlock(rtg, XFS_RTGLOCK_RMAP); 1019 - } 1020 1020 1021 1021 /* 1022 1022 * If there are no used blocks, but the zone is not in empty state yet ··· 1066 1066 struct xfs_mount *mp = iz->mp; 1067 1067 xfs_fsblock_t zsbno = xfs_daddr_to_rtb(mp, zone->start); 1068 1068 xfs_rgnumber_t rgno; 1069 + xfs_rgblock_t write_pointer; 1069 1070 struct xfs_rtgroup *rtg; 1070 1071 int error; 1071 1072 ··· 1081 1080 xfs_warn(mp, "realtime group not found for zone %u.", rgno); 1082 1081 return -EFSCORRUPTED; 1083 1082 } 1084 - error = xfs_init_zone(iz, rtg, zone); 1083 + if (!xfs_zone_validate(zone, rtg, &write_pointer)) { 1084 + xfs_rtgroup_rele(rtg); 1085 + return -EFSCORRUPTED; 1086 + } 1087 + if (zone->cond == BLK_ZONE_COND_NOT_WP) 1088 + write_pointer = xfs_rmap_estimate_write_pointer(rtg); 1089 + error = xfs_init_zone(iz, rtg, write_pointer); 1085 1090 xfs_rtgroup_rele(rtg); 1086 1091 return error; 1087 1092 } ··· 1297 1290 struct xfs_rtgroup *rtg = NULL; 1298 1291 1299 1292 while ((rtg = xfs_rtgroup_next(mp, rtg))) { 1300 - error = xfs_init_zone(&iz, rtg, NULL); 1293 + error = xfs_init_zone(&iz, rtg, 1294 + xfs_rmap_estimate_write_pointer(rtg)); 1301 1295 if (error) { 1302 1296 xfs_rtgroup_rele(rtg); 1303 1297 goto out_free_zone_info;