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

Pull yet more xfs bug fixes from Darrick Wong:
 "The first bugfix addresses a longstanding problem where we use the
  wrong file mapping cursors when trying to compute the speculative
  preallocation quantity. This has been causing sporadic crashes when
  alwayscow mode is engaged.

  The other two fixes correct minor problems in more recent changes.

   - Fix the new allocator tracepoints because git am mismerged the
     changes such that the trace_XXX got rebased to be in function YYY
     instead of XXX

   - Ensure that the perag AGFL_RESET state is consistent with whatever
     we've just read off the disk

   - Fix a bug where we used the wrong iext cursor during a write begin"

* tag 'xfs-6.3-fixes-7' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
  xfs: fix mismerged tracepoints
  xfs: clear incore AGFL_RESET state if it's not needed
  xfs: pass the correct cursor to xfs_iomap_prealloc_size
diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index 55ae08a..203f16c 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -3045,6 +3045,8 @@
 		pag->pagf_refcount_level = be32_to_cpu(agf->agf_refcount_level);
 		if (xfs_agfl_needs_reset(pag->pag_mount, agf))
 			set_bit(XFS_AGSTATE_AGFL_NEEDS_RESET, &pag->pag_opstate);
+		else
+			clear_bit(XFS_AGSTATE_AGFL_NEEDS_RESET, &pag->pag_opstate);
 
 		/*
 		 * Update the in-core allocbt counter. Filter out the rmapbt
@@ -3411,7 +3413,7 @@
 	args->agno = NULLAGNUMBER;
 	args->agbno = NULLAGBLOCK;
 
-	trace_xfs_alloc_vextent_first_ag(args);
+	trace_xfs_alloc_vextent_start_ag(args);
 
 	error = xfs_alloc_vextent_check_args(args, target, &minimum_agno);
 	if (error) {
@@ -3464,7 +3466,7 @@
 	args->agno = NULLAGNUMBER;
 	args->agbno = NULLAGBLOCK;
 
-	trace_xfs_alloc_vextent_start_ag(args);
+	trace_xfs_alloc_vextent_first_ag(args);
 
 	error = xfs_alloc_vextent_check_args(args, target, &minimum_agno);
 	if (error) {
@@ -3498,7 +3500,7 @@
 	args->agno = XFS_FSB_TO_AGNO(mp, target);
 	args->agbno = XFS_FSB_TO_AGBNO(mp, target);
 
-	trace_xfs_alloc_vextent_near_bno(args);
+	trace_xfs_alloc_vextent_exact_bno(args);
 
 	error = xfs_alloc_vextent_check_args(args, target, &minimum_agno);
 	if (error) {
@@ -3536,7 +3538,7 @@
 	args->agno = XFS_FSB_TO_AGNO(mp, target);
 	args->agbno = XFS_FSB_TO_AGBNO(mp, target);
 
-	trace_xfs_alloc_vextent_exact_bno(args);
+	trace_xfs_alloc_vextent_near_bno(args);
 
 	error = xfs_alloc_vextent_check_args(args, target, &minimum_agno);
 	if (error) {
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index 69dbe78..285885c 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -1090,9 +1090,12 @@
 		 */
 		if (xfs_has_allocsize(mp))
 			prealloc_blocks = mp->m_allocsize_blocks;
-		else
+		else if (allocfork == XFS_DATA_FORK)
 			prealloc_blocks = xfs_iomap_prealloc_size(ip, allocfork,
 						offset, count, &icur);
+		else
+			prealloc_blocks = xfs_iomap_prealloc_size(ip, allocfork,
+						offset, count, &ccur);
 		if (prealloc_blocks) {
 			xfs_extlen_t	align;
 			xfs_off_t	end_offset;