Skip to content

Commit d004d70

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
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: 4e4d520 ("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>
1 parent 9ce43ca commit d004d70

File tree

1 file changed

+2
-43
lines changed

1 file changed

+2
-43
lines changed

fs/xfs/xfs_zone_alloc.c

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -374,44 +374,6 @@ xfs_zone_free_blocks(
374374
return 0;
375375
}
376376

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-
415377
static struct xfs_group *
416378
xfs_find_free_zone(
417379
struct xfs_mount *mp,
@@ -918,12 +880,9 @@ xfs_zone_alloc_and_submit(
918880
goto out_error;
919881

920882
/*
921-
* If we don't have a cached zone in this write context, see if the
922-
* last extent before the one we are writing to points to an active
923-
* zone. If so, just continue writing to it.
883+
* If we don't have a locally cached zone in this write context, see if
884+
* the inode is still associated with a zone and use that if so.
924885
*/
925-
if (!*oz && ioend->io_offset)
926-
*oz = xfs_last_used_zone(ioend);
927886
if (!*oz)
928887
*oz = xfs_cached_zone(mp, ip);
929888

0 commit comments

Comments
 (0)