xfs: remove xfs_last_used_zone

This was my first attempt at caching the last used zone. But it turns out
for O_DIRECT or RWF_DONTCACHE that operate concurrently or in very short
sequence, the bmap btree does not record a written extent yet, so it fails.
Because it then still finds the last written zone it can lead to a weird
ping-pong around a few zones with writers seeing different values.

Remove it entirely as the later added xfs_cached_zone actually does a
much better job enforcing the locality as the zone is associated with the
inode in the MRU cache as soon as the zone is selected.

Fixes: 4e4d52075577 ("xfs: add the zoned space allocator")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Tested-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hans Holmberg <hans.holmberg@wdc.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>

authored by Christoph Hellwig and committed by Carlos Maiolino d004d70d 9ce43caa

+2 -43
+2 -43
fs/xfs/xfs_zone_alloc.c
··· 374 return 0; 375 } 376 377 - /* 378 - * Check if the zone containing the data just before the offset we are 379 - * writing to is still open and has space. 380 - */ 381 - static struct xfs_open_zone * 382 - xfs_last_used_zone( 383 - struct iomap_ioend *ioend) 384 - { 385 - struct xfs_inode *ip = XFS_I(ioend->io_inode); 386 - struct xfs_mount *mp = ip->i_mount; 387 - xfs_fileoff_t offset_fsb = XFS_B_TO_FSB(mp, ioend->io_offset); 388 - struct xfs_rtgroup *rtg = NULL; 389 - struct xfs_open_zone *oz = NULL; 390 - struct xfs_iext_cursor icur; 391 - struct xfs_bmbt_irec got; 392 - 393 - xfs_ilock(ip, XFS_ILOCK_SHARED); 394 - if (!xfs_iext_lookup_extent_before(ip, &ip->i_df, &offset_fsb, 395 - &icur, &got)) { 396 - xfs_iunlock(ip, XFS_ILOCK_SHARED); 397 - return NULL; 398 - } 399 - xfs_iunlock(ip, XFS_ILOCK_SHARED); 400 - 401 - rtg = xfs_rtgroup_grab(mp, xfs_rtb_to_rgno(mp, got.br_startblock)); 402 - if (!rtg) 403 - return NULL; 404 - 405 - xfs_ilock(rtg_rmap(rtg), XFS_ILOCK_SHARED); 406 - oz = READ_ONCE(rtg->rtg_open_zone); 407 - if (oz && (oz->oz_is_gc || !atomic_inc_not_zero(&oz->oz_ref))) 408 - oz = NULL; 409 - xfs_iunlock(rtg_rmap(rtg), XFS_ILOCK_SHARED); 410 - 411 - xfs_rtgroup_rele(rtg); 412 - return oz; 413 - } 414 - 415 static struct xfs_group * 416 xfs_find_free_zone( 417 struct xfs_mount *mp, ··· 880 goto out_error; 881 882 /* 883 - * If we don't have a cached zone in this write context, see if the 884 - * last extent before the one we are writing to points to an active 885 - * zone. If so, just continue writing to it. 886 */ 887 - if (!*oz && ioend->io_offset) 888 - *oz = xfs_last_used_zone(ioend); 889 if (!*oz) 890 *oz = xfs_cached_zone(mp, ip); 891
··· 374 return 0; 375 } 376 377 static struct xfs_group * 378 xfs_find_free_zone( 379 struct xfs_mount *mp, ··· 918 goto out_error; 919 920 /* 921 + * If we don't have a locally cached zone in this write context, see if 922 + * the inode is still associated with a zone and use that if so. 923 */ 924 if (!*oz) 925 *oz = xfs_cached_zone(mp, ip); 926