Subject: linux-next: manual merge of the xfs tree with Linus' tree

From: Stephen Rothwell <[email-masked]>
Date: Tue, 31 Oct 2023 11:41:58 +1100

Hi all,

Today's linux-next merge of the xfs tree got conflicts in:

  fs/xfs/libxfs/xfs_rtbitmap.c
  fs/xfs/xfs_rtalloc.c

between commit:

  75d1e312bbbd ("xfs: convert to new timestamp accessors")

from Linus' tree and commit:

  41f33d82cfd3 ("xfs: consolidate realtime allocation arguments")
  a684c538bc14 ("xfs: convert xfs_extlen_t to xfs_rtxlen_t in the rt allocator")
  2d5f216b77e3 ("xfs: convert rt extent numbers to xfs_rtxnum_t")

from the xfs tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc fs/xfs/libxfs/xfs_rtbitmap.c
index 396648acb5be,b332ab490a48..000000000000
--- a/fs/xfs/libxfs/xfs_rtbitmap.c
+++ b/fs/xfs/libxfs/xfs_rtbitmap.c
@@@ -960,19 -931,18 +931,19 @@@ xfs_rtcheck_alloc_range
   * Free an extent in the realtime subvolume.  Length is expressed in
   * realtime extents, as is the block number.
   */
- int					/* error */
+ int
  xfs_rtfree_extent(
- 	xfs_trans_t	*tp,		/* transaction pointer */
- 	xfs_rtblock_t	bno,		/* starting block number to free */
- 	xfs_extlen_t	len)		/* length of extent freed */
+ 	struct xfs_trans	*tp,	/* transaction pointer */
+ 	xfs_rtxnum_t		start,	/* starting rtext number to free */
+ 	xfs_rtxlen_t		len)	/* length of extent freed */
  {
- 	int		error;		/* error value */
- 	xfs_mount_t	*mp;		/* file system mount structure */
- 	xfs_fsblock_t	sb;		/* summary file block number */
- 	struct xfs_buf	*sumbp = NULL;	/* summary file block buffer */
- 	struct timespec64 atime;
- 
- 	mp = tp->t_mountp;
+ 	struct xfs_mount	*mp = tp->t_mountp;
+ 	struct xfs_rtalloc_args	args = {
+ 		.mp		= mp,
+ 		.tp		= tp,
+ 	};
+ 	int			error;
++	struct timespec64	atime;
  
  	ASSERT(mp->m_rbmip->i_itemp != NULL);
  	ASSERT(xfs_isilocked(mp->m_rbmip, XFS_ILOCK_EXCL));
@@@ -1000,13 -970,46 +971,49 @@@
  	    mp->m_sb.sb_rextents) {
  		if (!(mp->m_rbmip->i_diflags & XFS_DIFLAG_NEWRTBM))
  			mp->m_rbmip->i_diflags |= XFS_DIFLAG_NEWRTBM;
 -		*(uint64_t *)&VFS_I(mp->m_rbmip)->i_atime = 0;
 +
 +		atime = inode_get_atime(VFS_I(mp->m_rbmip));
 +		*((uint64_t *)&atime) = 0;
 +		inode_set_atime_to_ts(VFS_I(mp->m_rbmip), atime);
  		xfs_trans_log_inode(tp, mp->m_rbmip, XFS_ILOG_CORE);
  	}
- 	return 0;
+ 	error = 0;
+ out:
+ 	xfs_rtbuf_cache_relse(&args);
+ 	return error;
+ }
+ 
+ /*
+  * Free some blocks in the realtime subvolume.  rtbno and rtlen are in units of
+  * rt blocks, not rt extents; must be aligned to the rt extent size; and rtlen
+  * cannot exceed XFS_MAX_BMBT_EXTLEN.
+  */
+ int
+ xfs_rtfree_blocks(
+ 	struct xfs_trans	*tp,
+ 	xfs_fsblock_t		rtbno,
+ 	xfs_filblks_t		rtlen)
+ {
+ 	struct xfs_mount	*mp = tp->t_mountp;
+ 	xfs_rtxnum_t		start;
+ 	xfs_filblks_t		len;
+ 	xfs_extlen_t		mod;
+ 
+ 	ASSERT(rtlen <= XFS_MAX_BMBT_EXTLEN);
+ 
+ 	len = xfs_rtb_to_rtxrem(mp, rtlen, &mod);
+ 	if (mod) {
+ 		ASSERT(mod == 0);
+ 		return -EIO;
+ 	}
+ 
+ 	start = xfs_rtb_to_rtxrem(mp, rtbno, &mod);
+ 	if (mod) {
+ 		ASSERT(mod == 0);
+ 		return -EIO;
+ 	}
+ 
+ 	return xfs_rtfree_extent(tp, start, len);
  }
  
  /* Find all the free records within a given range. */
diff --cc fs/xfs/xfs_rtalloc.c
index 2e1a4e5cd03d,ba66442910b1..000000000000
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@@ -1420,16 -1414,16 +1414,16 @@@ xfs_rtunmount_inodes
   */
  int					/* error */
  xfs_rtpick_extent(
 -	xfs_mount_t	*mp,		/* file system mount point */
 -	xfs_trans_t	*tp,		/* transaction pointer */
 -	xfs_rtxlen_t	len,		/* allocation length (rtextents) */
 -	xfs_rtxnum_t	*pick)		/* result rt extent */
 -{
 -	xfs_rtxnum_t	b;		/* result rtext */
 -	int		log2;		/* log of sequence number */
 -	uint64_t	resid;		/* residual after log removed */
 -	uint64_t	seq;		/* sequence number of file creation */
 -	uint64_t	*seqp;		/* pointer to seqno in inode */
 +	xfs_mount_t		*mp,		/* file system mount point */
 +	xfs_trans_t		*tp,		/* transaction pointer */
- 	xfs_extlen_t		len,		/* allocation length (rtextents) */
- 	xfs_rtblock_t		*pick)		/* result rt extent */
++	xfs_rtxlen_t		len,		/* allocation length (rtextents) */
++	xfs_rtxnum_t		*pick)		/* result rt extent */
 +	{
- 	xfs_rtblock_t		b;		/* result block */
++	xfs_rtxnum_t		b;		/* result rtext */
 +	int			log2;		/* log of sequence number */
 +	uint64_t		resid;		/* residual after log removed */
 +	uint64_t		seq;		/* sequence number of file creation */
 +	struct timespec64	ts;		/* temporary timespec64 storage */
  
  	ASSERT(xfs_isilocked(mp->m_rbmip, XFS_ILOCK_EXCL));