All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/25] xfs: embed firstblock in xfs_trans
@ 2018-07-03 17:22 Brian Foster
  2018-07-03 17:22 ` [PATCH 01/25] xfs: allow null firstblock in xfs_bmapi_write() when tp is null Brian Foster
                   ` (25 more replies)
  0 siblings, 26 replies; 58+ messages in thread
From: Brian Foster @ 2018-07-03 17:22 UTC (permalink / raw)
  To: linux-xfs

Hi all,

This is a quick refactor of firstblock usage thoughout XFS. A firstblock
variable is used to track the first allocation of a transaction to help
maintain AG lock order, but it has historically been passed all over the
place independent from the associated transaction (similar to dfops).
This makes sense in some cases where the transaction is rolled, but even
with that case, this can all be handled with a bit less code by pushing
firstblock directly into the transaction.

These are mostly simple, mechanical refactoring patches. The whole thing
could probably be squashed into half the patch count, but I opted to
keep smaller patches as it is easier to squash them later than take them
apart depending on preference. The series applies on top of the recent
->t_dfops refactoring series [1].

Patch 1 is a simple prepatory patch. Patch 2 adds the new ->t_firstblock
field to xfs_trans. Patches 3-24 are a sequence of replacing on-stack
firstblock usage with ->t_firstblock and removing unnecessary firstblock
function parameters and args passing struct fields. Once every
transaction that requires it is converted over to ->t_firstblock, patch
25 eliminates the unnecessary parameter and initialization from
xfs_defer_init().

This all survives a couple rounds of xfstests (with KASAN enabled)
without any explosions. Thoughts, reviews, flames appreciated.

Brian

[1] https://marc.info/?l=linux-xfs&m=153020380302037&w=2

Brian Foster (25):
  xfs: allow null firstblock in xfs_bmapi_write() when tp is null
  xfs: add firstblock field to xfs_trans
  xfs: use ->t_firstblock in dir ops
  xfs: remove firstblock param from xfs dir ops
  xfs: use ->t_firstblock in attrfork add
  xfs: use ->t_firstblock in xattr ops
  xfs: use ->t_firstblock for all xfs_bmapi_write() callers
  xfs: use ->t_firstblock for all xfs_bunmapi() callers
  xfs: use ->t_firstblock in xfs_bmapi_remap()
  xfs: use ->t_firstblock in insert/collapse range
  xfs: remove xfs_bmapi_write() firstblock param
  xfs: remove xfs_bunmapi() firstblock param
  xfs: remove bmap insert/collapse firstblock param
  xfs: use ->t_firstblock in bmap extent split
  xfs: remove xfs_bmalloca firstblock field
  xfs: remove bmap extent add helper firstblock params
  xfs: remove bmap format helpers firstblock params
  xfs: remove xfs_btree_cur private firstblock field
  xfs: remove xfs_alloc_arg firstblock field
  xfs: use ->t_firstblock in dq alloc
  xfs: replace no-op firstblock init with ->t_firstblock
  xfs: use ->t_firstblock in reflink cow block cancel
  xfs: use ->t_firstblock in extent swap
  xfs: use ->t_firstblock in inode inactivate
  xfs: remove xfs_defer_init() firstblock param

 fs/xfs/libxfs/xfs_alloc.c          |  20 ++--
 fs/xfs/libxfs/xfs_alloc.h          |   1 -
 fs/xfs/libxfs/xfs_attr.c           |  29 ++---
 fs/xfs/libxfs/xfs_attr_leaf.c      |   2 -
 fs/xfs/libxfs/xfs_attr_remote.c    |  13 +--
 fs/xfs/libxfs/xfs_bmap.c           | 181 +++++++++--------------------
 fs/xfs/libxfs/xfs_bmap.h           |  13 +--
 fs/xfs/libxfs/xfs_bmap_btree.c     |  11 +-
 fs/xfs/libxfs/xfs_btree.h          |   1 -
 fs/xfs/libxfs/xfs_da_btree.c       |   9 +-
 fs/xfs/libxfs/xfs_da_btree.h       |   1 -
 fs/xfs/libxfs/xfs_defer.c          |   5 +-
 fs/xfs/libxfs/xfs_defer.h          |   3 +-
 fs/xfs/libxfs/xfs_dir2.c           |  12 +-
 fs/xfs/libxfs/xfs_dir2.h           |   6 +-
 fs/xfs/libxfs/xfs_refcount.c       |   2 +-
 fs/xfs/libxfs/xfs_refcount_btree.c |   1 -
 fs/xfs/xfs_bmap_util.c             |  29 ++---
 fs/xfs/xfs_dquot.c                 |   9 +-
 fs/xfs/xfs_inode.c                 |  55 ++++-----
 fs/xfs/xfs_iomap.c                 |  20 ++--
 fs/xfs/xfs_log_recover.c           |   3 +-
 fs/xfs/xfs_reflink.c               |  28 ++---
 fs/xfs/xfs_rtalloc.c               |   7 +-
 fs/xfs/xfs_symlink.c               |  14 +--
 fs/xfs/xfs_trace.h                 |   2 +-
 fs/xfs/xfs_trans.c                 |   2 +
 fs/xfs/xfs_trans.h                 |   1 +
 28 files changed, 170 insertions(+), 310 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 01/25] xfs: allow null firstblock in xfs_bmapi_write() when tp is null
  2018-07-03 17:22 [PATCH 00/25] xfs: embed firstblock in xfs_trans Brian Foster
@ 2018-07-03 17:22 ` Brian Foster
  2018-07-04  0:24   ` Darrick J. Wong
  2018-07-08 15:26   ` Christoph Hellwig
  2018-07-03 17:22 ` [PATCH 02/25] xfs: add firstblock field to xfs_trans Brian Foster
                   ` (24 subsequent siblings)
  25 siblings, 2 replies; 58+ messages in thread
From: Brian Foster @ 2018-07-03 17:22 UTC (permalink / raw)
  To: linux-xfs

xfs_bmapi_write() always expects a valid firstblock pointer. It
immediately dereferences the pointer to help determine how to
initialize the bma.minleft field. The remaining accesses are
related to modifying btree format forks, which is only relevant for
!COW fork callers.

The reflink code passes a NULL transaction to xfs_bmapi_write() in a
couple places that do COW fork unwritten conversion. The purpose of
the firstblock field is to track the first block allocation in the
current transaction, so technically firstblock should not be
required for these callers either.

Tweak xfs_bmapi_write() to initialize the bma correctly without
accessing the firstblock pointer if no transaction is provided in
the first place. Update the reflink callers to pass NULL instead of
otherwise unused firstblock references.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/libxfs/xfs_bmap.c | 2 +-
 fs/xfs/xfs_reflink.c     | 9 +++------
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 2e2a9661600b..c6a5a957674d 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -4304,7 +4304,7 @@ xfs_bmapi_write(
 
 	XFS_STATS_INC(mp, xs_blk_mapw);
 
-	if (*firstblock == NULLFSBLOCK) {
+	if (!tp || *firstblock == NULLFSBLOCK) {
 		if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE)
 			bma.minleft = be16_to_cpu(ifp->if_broot->bb_level) + 1;
 		else
diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index 8496312dde6a..92b6e1b5d33c 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -314,7 +314,6 @@ xfs_reflink_convert_cow_extent(
 	xfs_fileoff_t			offset_fsb,
 	xfs_filblks_t			count_fsb)
 {
-	xfs_fsblock_t			first_block = NULLFSBLOCK;
 	int				nimaps = 1;
 
 	if (imap->br_state == XFS_EXT_NORM)
@@ -325,8 +324,8 @@ xfs_reflink_convert_cow_extent(
 	if (imap->br_blockcount == 0)
 		return 0;
 	return xfs_bmapi_write(NULL, ip, imap->br_startoff, imap->br_blockcount,
-			XFS_BMAPI_COWFORK | XFS_BMAPI_CONVERT, &first_block,
-			0, imap, &nimaps);
+			XFS_BMAPI_COWFORK | XFS_BMAPI_CONVERT, NULL, 0, imap,
+			&nimaps);
 }
 
 /* Convert all of the unwritten CoW extents in a file's range to real ones. */
@@ -341,7 +340,6 @@ xfs_reflink_convert_cow(
 	xfs_fileoff_t		end_fsb = XFS_B_TO_FSB(mp, offset + count);
 	xfs_filblks_t		count_fsb = end_fsb - offset_fsb;
 	struct xfs_bmbt_irec	imap;
-	xfs_fsblock_t		first_block = NULLFSBLOCK;
 	int			nimaps = 1, error = 0;
 
 	ASSERT(count != 0);
@@ -349,8 +347,7 @@ xfs_reflink_convert_cow(
 	xfs_ilock(ip, XFS_ILOCK_EXCL);
 	error = xfs_bmapi_write(NULL, ip, offset_fsb, count_fsb,
 			XFS_BMAPI_COWFORK | XFS_BMAPI_CONVERT |
-			XFS_BMAPI_CONVERT_ONLY, &first_block, 0, &imap,
-			&nimaps);
+			XFS_BMAPI_CONVERT_ONLY, NULL, 0, &imap, &nimaps);
 	xfs_iunlock(ip, XFS_ILOCK_EXCL);
 	return error;
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 02/25] xfs: add firstblock field to xfs_trans
  2018-07-03 17:22 [PATCH 00/25] xfs: embed firstblock in xfs_trans Brian Foster
  2018-07-03 17:22 ` [PATCH 01/25] xfs: allow null firstblock in xfs_bmapi_write() when tp is null Brian Foster
@ 2018-07-03 17:22 ` Brian Foster
  2018-07-04  0:41   ` Darrick J. Wong
  2018-07-08 15:26   ` Christoph Hellwig
  2018-07-03 17:22 ` [PATCH 03/25] xfs: use ->t_firstblock in dir ops Brian Foster
                   ` (23 subsequent siblings)
  25 siblings, 2 replies; 58+ messages in thread
From: Brian Foster @ 2018-07-03 17:22 UTC (permalink / raw)
  To: linux-xfs

A firstblock var is typically allocated and initialized along with
xfs_defer_ops structures and passed around independent from the
associated transaction. To facilitate combining the two, add an
optional ->t_firstblock field to xfs_trans that can be used in place
of an on-stack variable.

The firstblock value follows the lifetime of the transaction, so
initialize it on allocation and when a transaction rolls.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/xfs_trans.c | 2 ++
 fs/xfs/xfs_trans.h | 1 +
 2 files changed, 3 insertions(+)

diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index 630993387517..de00f79ff698 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -100,6 +100,7 @@ xfs_trans_dup(
 	ntp->t_mountp = tp->t_mountp;
 	INIT_LIST_HEAD(&ntp->t_items);
 	INIT_LIST_HEAD(&ntp->t_busy);
+	ntp->t_firstblock = NULLFSBLOCK;
 
 	ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES);
 	ASSERT(tp->t_ticket != NULL);
@@ -273,6 +274,7 @@ xfs_trans_alloc(
 	tp->t_mountp = mp;
 	INIT_LIST_HEAD(&tp->t_items);
 	INIT_LIST_HEAD(&tp->t_busy);
+	tp->t_firstblock = NULLFSBLOCK;
 
 	error = xfs_trans_reserve(tp, resp, blocks, rtextents);
 	if (error) {
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index d8a695c57103..37fdacc690c7 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -102,6 +102,7 @@ typedef struct xfs_trans {
 	unsigned int		t_blk_res_used;	/* # of resvd blocks used */
 	unsigned int		t_rtx_res;	/* # of rt extents resvd */
 	unsigned int		t_rtx_res_used;	/* # of resvd rt extents used */
+	xfs_fsblock_t		t_firstblock;	/* first block allocated */
 	struct xlog_ticket	*t_ticket;	/* log mgr ticket */
 	struct xfs_mount	*t_mountp;	/* ptr to fs mount struct */
 	struct xfs_dquot_acct   *t_dqinfo;	/* acctg info for dquots */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 03/25] xfs: use ->t_firstblock in dir ops
  2018-07-03 17:22 [PATCH 00/25] xfs: embed firstblock in xfs_trans Brian Foster
  2018-07-03 17:22 ` [PATCH 01/25] xfs: allow null firstblock in xfs_bmapi_write() when tp is null Brian Foster
  2018-07-03 17:22 ` [PATCH 02/25] xfs: add firstblock field to xfs_trans Brian Foster
@ 2018-07-03 17:22 ` Brian Foster
  2018-07-04  0:42   ` Darrick J. Wong
  2018-07-03 17:22 ` [PATCH 04/25] xfs: remove firstblock param from xfs " Brian Foster
                   ` (22 subsequent siblings)
  25 siblings, 1 reply; 58+ messages in thread
From: Brian Foster @ 2018-07-03 17:22 UTC (permalink / raw)
  To: linux-xfs

Callers of the xfs_dir_*() functions currently pass an on-stack
firstblock variable. While the dirops infrastructure carries a
pointer to this variable, it never rolls the transaction and so it
is safe to use ->t_firstblock instead.

Fix up the various xfs_dir_*() callers to use ->t_firstblock. Also
remove the unnecessary parameter for xfs_cross_rename().

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/xfs_inode.c   | 42 +++++++++++++++++++-----------------------
 fs/xfs/xfs_symlink.c |  9 ++++-----
 2 files changed, 23 insertions(+), 28 deletions(-)

diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 04e17234e5d7..6a3fe2d3df6c 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1143,7 +1143,6 @@ xfs_create(
 	struct xfs_trans	*tp = NULL;
 	int			error;
 	struct xfs_defer_ops	dfops;
-	xfs_fsblock_t		first_block;
 	bool                    unlock_dp_on_error = false;
 	prid_t			prid;
 	struct xfs_dquot	*udqp = NULL;
@@ -1195,7 +1194,7 @@ xfs_create(
 	xfs_ilock(dp, XFS_ILOCK_EXCL | XFS_ILOCK_PARENT);
 	unlock_dp_on_error = true;
 
-	xfs_defer_init(tp, &dfops, &first_block);
+	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
 
 	/*
 	 * Reserve disk quota and the inode.
@@ -1224,7 +1223,7 @@ xfs_create(
 	xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL);
 	unlock_dp_on_error = false;
 
-	error = xfs_dir_createname(tp, dp, name, ip->i_ino, &first_block,
+	error = xfs_dir_createname(tp, dp, name, ip->i_ino, &tp->t_firstblock,
 				   resblks ?
 					resblks - XFS_IALLOC_SPACE_RES(mp) : 0);
 	if (error) {
@@ -1401,7 +1400,6 @@ xfs_link(
 	xfs_trans_t		*tp;
 	int			error;
 	struct xfs_defer_ops	dfops;
-	xfs_fsblock_t           first_block;
 	int			resblks;
 
 	trace_xfs_link(tdp, target_name);
@@ -1450,7 +1448,7 @@ xfs_link(
 			goto error_return;
 	}
 
-	xfs_defer_init(tp, &dfops, &first_block);
+	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
 
 	/*
 	 * Handle initial link state of O_TMPFILE inode
@@ -1462,7 +1460,7 @@ xfs_link(
 	}
 
 	error = xfs_dir_createname(tp, tdp, target_name, sip->i_ino,
-				   &first_block, resblks);
+				   &tp->t_firstblock, resblks);
 	if (error)
 		goto error_return;
 	xfs_trans_ichgtime(tp, tdp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
@@ -2577,7 +2575,6 @@ xfs_remove(
 	int			is_dir = S_ISDIR(VFS_I(ip)->i_mode);
 	int                     error = 0;
 	struct xfs_defer_ops	dfops;
-	xfs_fsblock_t           first_block;
 	uint			resblks;
 
 	trace_xfs_remove(dp, name);
@@ -2657,8 +2654,8 @@ xfs_remove(
 	if (error)
 		goto out_trans_cancel;
 
-	xfs_defer_init(tp, &dfops, &first_block);
-	error = xfs_dir_removename(tp, dp, name, ip->i_ino, &first_block,
+	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
+	error = xfs_dir_removename(tp, dp, name, ip->i_ino, &tp->t_firstblock,
 				   resblks);
 	if (error) {
 		ASSERT(error != -ENOENT);
@@ -2783,7 +2780,6 @@ xfs_cross_rename(
 	struct xfs_inode	*dp2,
 	struct xfs_name		*name2,
 	struct xfs_inode	*ip2,
-	xfs_fsblock_t		*first_block,
 	int			spaceres)
 {
 	int		error = 0;
@@ -2792,13 +2788,13 @@ xfs_cross_rename(
 	int		dp2_flags = 0;
 
 	/* Swap inode number for dirent in first parent */
-	error = xfs_dir_replace(tp, dp1, name1, ip2->i_ino, first_block,
+	error = xfs_dir_replace(tp, dp1, name1, ip2->i_ino, &tp->t_firstblock,
 				spaceres);
 	if (error)
 		goto out_trans_abort;
 
 	/* Swap inode number for dirent in second parent */
-	error = xfs_dir_replace(tp, dp2, name2, ip1->i_ino, first_block,
+	error = xfs_dir_replace(tp, dp2, name2, ip1->i_ino, &tp->t_firstblock,
 				spaceres);
 	if (error)
 		goto out_trans_abort;
@@ -2813,7 +2809,7 @@ xfs_cross_rename(
 
 		if (S_ISDIR(VFS_I(ip2)->i_mode)) {
 			error = xfs_dir_replace(tp, ip2, &xfs_name_dotdot,
-						dp1->i_ino, first_block,
+						dp1->i_ino, &tp->t_firstblock,
 						spaceres);
 			if (error)
 				goto out_trans_abort;
@@ -2840,7 +2836,7 @@ xfs_cross_rename(
 
 		if (S_ISDIR(VFS_I(ip1)->i_mode)) {
 			error = xfs_dir_replace(tp, ip1, &xfs_name_dotdot,
-						dp2->i_ino, first_block,
+						dp2->i_ino, &tp->t_firstblock,
 						spaceres);
 			if (error)
 				goto out_trans_abort;
@@ -2939,7 +2935,6 @@ xfs_rename(
 	struct xfs_mount	*mp = src_dp->i_mount;
 	struct xfs_trans	*tp;
 	struct xfs_defer_ops	dfops;
-	xfs_fsblock_t		first_block;
 	struct xfs_inode	*wip = NULL;		/* whiteout inode */
 	struct xfs_inode	*inodes[__XFS_SORT_INODES];
 	int			num_inodes = __XFS_SORT_INODES;
@@ -3021,13 +3016,13 @@ xfs_rename(
 		goto out_trans_cancel;
 	}
 
-	xfs_defer_init(tp, &dfops, &first_block);
+	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
 
 	/* RENAME_EXCHANGE is unique from here on. */
 	if (flags & RENAME_EXCHANGE)
 		return xfs_cross_rename(tp, src_dp, src_name, src_ip,
 					target_dp, target_name, target_ip,
-					&first_block, spaceres);
+					spaceres);
 
 	/*
 	 * Set up the target.
@@ -3048,8 +3043,8 @@ xfs_rename(
 		 * to account for the ".." reference from the new entry.
 		 */
 		error = xfs_dir_createname(tp, target_dp, target_name,
-						src_ip->i_ino, &first_block,
-						spaceres);
+					   src_ip->i_ino, &tp->t_firstblock,
+					   spaceres);
 		if (error)
 			goto out_bmap_cancel;
 
@@ -3088,7 +3083,8 @@ xfs_rename(
 		 * name at the destination directory, remove it first.
 		 */
 		error = xfs_dir_replace(tp, target_dp, target_name,
-					src_ip->i_ino, &first_block, spaceres);
+					src_ip->i_ino, &tp->t_firstblock,
+					spaceres);
 		if (error)
 			goto out_bmap_cancel;
 
@@ -3122,7 +3118,7 @@ xfs_rename(
 		 * directory.
 		 */
 		error = xfs_dir_replace(tp, src_ip, &xfs_name_dotdot,
-					target_dp->i_ino, &first_block,
+					target_dp->i_ino, &tp->t_firstblock,
 					spaceres);
 		ASSERT(error != -EEXIST);
 		if (error)
@@ -3162,10 +3158,10 @@ xfs_rename(
 	 */
 	if (wip) {
 		error = xfs_dir_replace(tp, src_dp, src_name, wip->i_ino,
-					&first_block, spaceres);
+					&tp->t_firstblock, spaceres);
 	} else
 		error = xfs_dir_removename(tp, src_dp, src_name, src_ip->i_ino,
-					   &first_block, spaceres);
+					   &tp->t_firstblock, spaceres);
 	if (error)
 		goto out_bmap_cancel;
 
diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
index e50e97308f81..8ddc7f1147dc 100644
--- a/fs/xfs/xfs_symlink.c
+++ b/fs/xfs/xfs_symlink.c
@@ -164,7 +164,6 @@ xfs_symlink(
 	int			error = 0;
 	int			pathlen;
 	struct xfs_defer_ops	dfops;
-	xfs_fsblock_t		first_block;
 	bool                    unlock_dp_on_error = false;
 	xfs_fileoff_t		first_fsb;
 	xfs_filblks_t		fs_blocks;
@@ -246,7 +245,7 @@ xfs_symlink(
 	 * Initialize the bmap freelist prior to calling either
 	 * bmapi or the directory create code.
 	 */
-	xfs_defer_init(tp, &dfops, &first_block);
+	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
 
 	/*
 	 * Allocate an inode for the symlink.
@@ -289,8 +288,8 @@ xfs_symlink(
 		nmaps = XFS_SYMLINK_MAPS;
 
 		error = xfs_bmapi_write(tp, ip, first_fsb, fs_blocks,
-				  XFS_BMAPI_METADATA, &first_block, resblks,
-				  mval, &nmaps);
+				  XFS_BMAPI_METADATA, &tp->t_firstblock,
+				  resblks, mval, &nmaps);
 		if (error)
 			goto out_bmap_cancel;
 
@@ -338,7 +337,7 @@ xfs_symlink(
 	 * Create the directory entry for the symlink.
 	 */
 	error = xfs_dir_createname(tp, dp, link_name, ip->i_ino,
-				   &first_block, resblks);
+				   &tp->t_firstblock, resblks);
 	if (error)
 		goto out_bmap_cancel;
 	xfs_trans_ichgtime(tp, dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 04/25] xfs: remove firstblock param from xfs dir ops
  2018-07-03 17:22 [PATCH 00/25] xfs: embed firstblock in xfs_trans Brian Foster
                   ` (2 preceding siblings ...)
  2018-07-03 17:22 ` [PATCH 03/25] xfs: use ->t_firstblock in dir ops Brian Foster
@ 2018-07-03 17:22 ` Brian Foster
  2018-07-03 18:06   ` Darrick J. Wong
  2018-07-03 17:22 ` [PATCH 05/25] xfs: use ->t_firstblock in attrfork add Brian Foster
                   ` (21 subsequent siblings)
  25 siblings, 1 reply; 58+ messages in thread
From: Brian Foster @ 2018-07-03 17:22 UTC (permalink / raw)
  To: linux-xfs

All callers of the xfs_dir_*() functions pass ->t_firstblock as the
firstblock parameter. Drop the parameter and access ->t_firstblock
directly.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/libxfs/xfs_dir2.c | 12 ++++--------
 fs/xfs/libxfs/xfs_dir2.h |  6 +++---
 fs/xfs/xfs_inode.c       | 32 ++++++++++++--------------------
 fs/xfs/xfs_symlink.c     |  3 +--
 4 files changed, 20 insertions(+), 33 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
index 26918c5bd819..8a55990ca3a5 100644
--- a/fs/xfs/libxfs/xfs_dir2.c
+++ b/fs/xfs/libxfs/xfs_dir2.c
@@ -243,7 +243,6 @@ xfs_dir_createname(
 	struct xfs_inode	*dp,
 	struct xfs_name		*name,
 	xfs_ino_t		inum,		/* new entry inode number */
-	xfs_fsblock_t		*first,		/* bmap's firstblock */
 	xfs_extlen_t		total)		/* bmap's total block count */
 {
 	struct xfs_da_args	*args;
@@ -272,8 +271,7 @@ xfs_dir_createname(
 	args->total = total;
 	args->whichfork = XFS_DATA_FORK;
 	args->trans = tp;
-	ASSERT(tp->t_dfops || !first);
-	args->firstblock = first;
+	args->firstblock = &tp->t_firstblock;
 	args->op_flags = XFS_DA_OP_ADDNAME | XFS_DA_OP_OKNOENT;
 	if (!inum)
 		args->op_flags |= XFS_DA_OP_JUSTCHECK;
@@ -419,7 +417,6 @@ xfs_dir_removename(
 	struct xfs_inode	*dp,
 	struct xfs_name		*name,
 	xfs_ino_t		ino,
-	xfs_fsblock_t		*first,		/* bmap's firstblock */
 	xfs_extlen_t		total)		/* bmap's total block count */
 {
 	struct xfs_da_args	*args;
@@ -440,7 +437,7 @@ xfs_dir_removename(
 	args->hashval = dp->i_mount->m_dirnameops->hashname(name);
 	args->inumber = ino;
 	args->dp = dp;
-	args->firstblock = first;
+	args->firstblock = &tp->t_firstblock;
 	args->total = total;
 	args->whichfork = XFS_DATA_FORK;
 	args->trans = tp;
@@ -480,7 +477,6 @@ xfs_dir_replace(
 	struct xfs_inode	*dp,
 	struct xfs_name		*name,		/* name of entry to replace */
 	xfs_ino_t		inum,		/* new inode number */
-	xfs_fsblock_t		*first,		/* bmap's firstblock */
 	xfs_extlen_t		total)		/* bmap's total block count */
 {
 	struct xfs_da_args	*args;
@@ -504,7 +500,7 @@ xfs_dir_replace(
 	args->hashval = dp->i_mount->m_dirnameops->hashname(name);
 	args->inumber = inum;
 	args->dp = dp;
-	args->firstblock = first;
+	args->firstblock = &tp->t_firstblock;
 	args->total = total;
 	args->whichfork = XFS_DATA_FORK;
 	args->trans = tp;
@@ -544,7 +540,7 @@ xfs_dir_canenter(
 	xfs_inode_t	*dp,
 	struct xfs_name	*name)		/* name of entry to add */
 {
-	return xfs_dir_createname(tp, dp, name, 0, NULL, 0);
+	return xfs_dir_createname(tp, dp, name, 0, 0);
 }
 
 /*
diff --git a/fs/xfs/libxfs/xfs_dir2.h b/fs/xfs/libxfs/xfs_dir2.h
index f203aebc07ed..ba5acd03de94 100644
--- a/fs/xfs/libxfs/xfs_dir2.h
+++ b/fs/xfs/libxfs/xfs_dir2.h
@@ -118,16 +118,16 @@ extern int xfs_dir_init(struct xfs_trans *tp, struct xfs_inode *dp,
 				struct xfs_inode *pdp);
 extern int xfs_dir_createname(struct xfs_trans *tp, struct xfs_inode *dp,
 				struct xfs_name *name, xfs_ino_t inum,
-				xfs_fsblock_t *first, xfs_extlen_t tot);
+				xfs_extlen_t tot);
 extern int xfs_dir_lookup(struct xfs_trans *tp, struct xfs_inode *dp,
 				struct xfs_name *name, xfs_ino_t *inum,
 				struct xfs_name *ci_name);
 extern int xfs_dir_removename(struct xfs_trans *tp, struct xfs_inode *dp,
 				struct xfs_name *name, xfs_ino_t ino,
-				xfs_fsblock_t *first, xfs_extlen_t tot);
+				xfs_extlen_t tot);
 extern int xfs_dir_replace(struct xfs_trans *tp, struct xfs_inode *dp,
 				struct xfs_name *name, xfs_ino_t inum,
-				xfs_fsblock_t *first, xfs_extlen_t tot);
+				xfs_extlen_t tot);
 extern int xfs_dir_canenter(struct xfs_trans *tp, struct xfs_inode *dp,
 				struct xfs_name *name);
 
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 6a3fe2d3df6c..ab1fd696500c 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1223,7 +1223,7 @@ xfs_create(
 	xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL);
 	unlock_dp_on_error = false;
 
-	error = xfs_dir_createname(tp, dp, name, ip->i_ino, &tp->t_firstblock,
+	error = xfs_dir_createname(tp, dp, name, ip->i_ino,
 				   resblks ?
 					resblks - XFS_IALLOC_SPACE_RES(mp) : 0);
 	if (error) {
@@ -1460,7 +1460,7 @@ xfs_link(
 	}
 
 	error = xfs_dir_createname(tp, tdp, target_name, sip->i_ino,
-				   &tp->t_firstblock, resblks);
+				   resblks);
 	if (error)
 		goto error_return;
 	xfs_trans_ichgtime(tp, tdp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
@@ -2655,8 +2655,7 @@ xfs_remove(
 		goto out_trans_cancel;
 
 	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
-	error = xfs_dir_removename(tp, dp, name, ip->i_ino, &tp->t_firstblock,
-				   resblks);
+	error = xfs_dir_removename(tp, dp, name, ip->i_ino, resblks);
 	if (error) {
 		ASSERT(error != -ENOENT);
 		goto out_bmap_cancel;
@@ -2788,14 +2787,12 @@ xfs_cross_rename(
 	int		dp2_flags = 0;
 
 	/* Swap inode number for dirent in first parent */
-	error = xfs_dir_replace(tp, dp1, name1, ip2->i_ino, &tp->t_firstblock,
-				spaceres);
+	error = xfs_dir_replace(tp, dp1, name1, ip2->i_ino, spaceres);
 	if (error)
 		goto out_trans_abort;
 
 	/* Swap inode number for dirent in second parent */
-	error = xfs_dir_replace(tp, dp2, name2, ip1->i_ino, &tp->t_firstblock,
-				spaceres);
+	error = xfs_dir_replace(tp, dp2, name2, ip1->i_ino, spaceres);
 	if (error)
 		goto out_trans_abort;
 
@@ -2809,8 +2806,7 @@ xfs_cross_rename(
 
 		if (S_ISDIR(VFS_I(ip2)->i_mode)) {
 			error = xfs_dir_replace(tp, ip2, &xfs_name_dotdot,
-						dp1->i_ino, &tp->t_firstblock,
-						spaceres);
+						dp1->i_ino, spaceres);
 			if (error)
 				goto out_trans_abort;
 
@@ -2836,8 +2832,7 @@ xfs_cross_rename(
 
 		if (S_ISDIR(VFS_I(ip1)->i_mode)) {
 			error = xfs_dir_replace(tp, ip1, &xfs_name_dotdot,
-						dp2->i_ino, &tp->t_firstblock,
-						spaceres);
+						dp2->i_ino, spaceres);
 			if (error)
 				goto out_trans_abort;
 
@@ -3043,8 +3038,7 @@ xfs_rename(
 		 * to account for the ".." reference from the new entry.
 		 */
 		error = xfs_dir_createname(tp, target_dp, target_name,
-					   src_ip->i_ino, &tp->t_firstblock,
-					   spaceres);
+					   src_ip->i_ino, spaceres);
 		if (error)
 			goto out_bmap_cancel;
 
@@ -3083,8 +3077,7 @@ xfs_rename(
 		 * name at the destination directory, remove it first.
 		 */
 		error = xfs_dir_replace(tp, target_dp, target_name,
-					src_ip->i_ino, &tp->t_firstblock,
-					spaceres);
+					src_ip->i_ino, spaceres);
 		if (error)
 			goto out_bmap_cancel;
 
@@ -3118,8 +3111,7 @@ xfs_rename(
 		 * directory.
 		 */
 		error = xfs_dir_replace(tp, src_ip, &xfs_name_dotdot,
-					target_dp->i_ino, &tp->t_firstblock,
-					spaceres);
+					target_dp->i_ino, spaceres);
 		ASSERT(error != -EEXIST);
 		if (error)
 			goto out_bmap_cancel;
@@ -3158,10 +3150,10 @@ xfs_rename(
 	 */
 	if (wip) {
 		error = xfs_dir_replace(tp, src_dp, src_name, wip->i_ino,
-					&tp->t_firstblock, spaceres);
+					spaceres);
 	} else
 		error = xfs_dir_removename(tp, src_dp, src_name, src_ip->i_ino,
-					   &tp->t_firstblock, spaceres);
+					   spaceres);
 	if (error)
 		goto out_bmap_cancel;
 
diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
index 8ddc7f1147dc..583ca83353f7 100644
--- a/fs/xfs/xfs_symlink.c
+++ b/fs/xfs/xfs_symlink.c
@@ -336,8 +336,7 @@ xfs_symlink(
 	/*
 	 * Create the directory entry for the symlink.
 	 */
-	error = xfs_dir_createname(tp, dp, link_name, ip->i_ino,
-				   &tp->t_firstblock, resblks);
+	error = xfs_dir_createname(tp, dp, link_name, ip->i_ino, resblks);
 	if (error)
 		goto out_bmap_cancel;
 	xfs_trans_ichgtime(tp, dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 05/25] xfs: use ->t_firstblock in attrfork add
  2018-07-03 17:22 [PATCH 00/25] xfs: embed firstblock in xfs_trans Brian Foster
                   ` (3 preceding siblings ...)
  2018-07-03 17:22 ` [PATCH 04/25] xfs: remove firstblock param from xfs " Brian Foster
@ 2018-07-03 17:22 ` Brian Foster
  2018-07-04  0:43   ` Darrick J. Wong
  2018-07-03 17:23 ` [PATCH 06/25] xfs: use ->t_firstblock in xattr ops Brian Foster
                   ` (20 subsequent siblings)
  25 siblings, 1 reply; 58+ messages in thread
From: Brian Foster @ 2018-07-03 17:22 UTC (permalink / raw)
  To: linux-xfs

Note that this codepath is a user of struct xfs_da_args. Switch it
over to ->t_firstblock in preparation to remove
xfs_da_args.firstblock.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/libxfs/xfs_bmap.c | 33 +++++++++++++--------------------
 1 file changed, 13 insertions(+), 20 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index c6a5a957674d..fcd10b47044a 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -915,7 +915,6 @@ STATIC int					/* error */
 xfs_bmap_add_attrfork_btree(
 	xfs_trans_t		*tp,		/* transaction pointer */
 	xfs_inode_t		*ip,		/* incore inode pointer */
-	xfs_fsblock_t		*firstblock,	/* first block allocated */
 	int			*flags)		/* inode logging flags */
 {
 	xfs_btree_cur_t		*cur;		/* btree cursor */
@@ -928,7 +927,7 @@ xfs_bmap_add_attrfork_btree(
 		*flags |= XFS_ILOG_DBROOT;
 	else {
 		cur = xfs_bmbt_init_cursor(mp, tp, ip, XFS_DATA_FORK);
-		cur->bc_private.b.firstblock = *firstblock;
+		cur->bc_private.b.firstblock = tp->t_firstblock;
 		error = xfs_bmbt_lookup_first(cur, &stat);
 		if (error)
 			goto error0;
@@ -940,7 +939,7 @@ xfs_bmap_add_attrfork_btree(
 			xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);
 			return -ENOSPC;
 		}
-		*firstblock = cur->bc_private.b.firstblock;
+		tp->t_firstblock = cur->bc_private.b.firstblock;
 		cur->bc_private.b.allocated = 0;
 		xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);
 	}
@@ -957,7 +956,6 @@ STATIC int					/* error */
 xfs_bmap_add_attrfork_extents(
 	struct xfs_trans	*tp,		/* transaction pointer */
 	struct xfs_inode	*ip,		/* incore inode pointer */
-	xfs_fsblock_t		*firstblock,	/* first block allocated */
 	int			*flags)		/* inode logging flags */
 {
 	xfs_btree_cur_t		*cur;		/* bmap btree cursor */
@@ -966,8 +964,8 @@ xfs_bmap_add_attrfork_extents(
 	if (ip->i_d.di_nextents * sizeof(xfs_bmbt_rec_t) <= XFS_IFORK_DSIZE(ip))
 		return 0;
 	cur = NULL;
-	error = xfs_bmap_extents_to_btree(tp, ip, firstblock, &cur, 0, flags,
-					  XFS_DATA_FORK);
+	error = xfs_bmap_extents_to_btree(tp, ip, &tp->t_firstblock, &cur, 0,
+					  flags, XFS_DATA_FORK);
 	if (cur) {
 		cur->bc_private.b.allocated = 0;
 		xfs_btree_del_cursor(cur,
@@ -989,12 +987,11 @@ xfs_bmap_add_attrfork_extents(
  */
 STATIC int					/* error */
 xfs_bmap_add_attrfork_local(
-	xfs_trans_t		*tp,		/* transaction pointer */
-	xfs_inode_t		*ip,		/* incore inode pointer */
-	xfs_fsblock_t		*firstblock,	/* first block allocated */
+	struct xfs_trans	*tp,		/* transaction pointer */
+	struct xfs_inode	*ip,		/* incore inode pointer */
 	int			*flags)		/* inode logging flags */
 {
-	xfs_da_args_t		dargs;		/* args for dir/attr code */
+	struct xfs_da_args	dargs;		/* args for dir/attr code */
 
 	if (ip->i_df.if_bytes <= XFS_IFORK_DSIZE(ip))
 		return 0;
@@ -1003,7 +1000,7 @@ xfs_bmap_add_attrfork_local(
 		memset(&dargs, 0, sizeof(dargs));
 		dargs.geo = ip->i_mount->m_dir_geo;
 		dargs.dp = ip;
-		dargs.firstblock = firstblock;
+		dargs.firstblock = &tp->t_firstblock;
 		dargs.total = dargs.geo->fsbcount;
 		dargs.whichfork = XFS_DATA_FORK;
 		dargs.trans = tp;
@@ -1011,7 +1008,7 @@ xfs_bmap_add_attrfork_local(
 	}
 
 	if (S_ISLNK(VFS_I(ip)->i_mode))
-		return xfs_bmap_local_to_extents(tp, ip, firstblock, 1,
+		return xfs_bmap_local_to_extents(tp, ip, &tp->t_firstblock, 1,
 						 flags, XFS_DATA_FORK,
 						 xfs_symlink_local_to_remote);
 
@@ -1030,7 +1027,6 @@ xfs_bmap_add_attrfork(
 	int			size,		/* space new attribute needs */
 	int			rsvd)		/* xact may use reserved blks */
 {
-	xfs_fsblock_t		firstblock;	/* 1st block/ag allocated */
 	struct xfs_defer_ops	dfops;		/* freed extent records */
 	xfs_mount_t		*mp;		/* mount structure */
 	xfs_trans_t		*tp;		/* transaction pointer */
@@ -1050,7 +1046,7 @@ xfs_bmap_add_attrfork(
 			rsvd ? XFS_TRANS_RESERVE : 0, &tp);
 	if (error)
 		return error;
-	xfs_defer_init(tp, &dfops, &firstblock);
+	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
 
 	xfs_ilock(ip, XFS_ILOCK_EXCL);
 	error = xfs_trans_reserve_quota_nblks(tp, ip, blks, 0, rsvd ?
@@ -1100,16 +1096,13 @@ xfs_bmap_add_attrfork(
 	logflags = 0;
 	switch (ip->i_d.di_format) {
 	case XFS_DINODE_FMT_LOCAL:
-		error = xfs_bmap_add_attrfork_local(tp, ip, &firstblock,
-						    &logflags);
+		error = xfs_bmap_add_attrfork_local(tp, ip, &logflags);
 		break;
 	case XFS_DINODE_FMT_EXTENTS:
-		error = xfs_bmap_add_attrfork_extents(tp, ip, &firstblock,
-						      &logflags);
+		error = xfs_bmap_add_attrfork_extents(tp, ip, &logflags);
 		break;
 	case XFS_DINODE_FMT_BTREE:
-		error = xfs_bmap_add_attrfork_btree(tp, ip, &firstblock,
-						    &logflags);
+		error = xfs_bmap_add_attrfork_btree(tp, ip, &logflags);
 		break;
 	default:
 		error = 0;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 06/25] xfs: use ->t_firstblock in xattr ops
  2018-07-03 17:22 [PATCH 00/25] xfs: embed firstblock in xfs_trans Brian Foster
                   ` (4 preceding siblings ...)
  2018-07-03 17:22 ` [PATCH 05/25] xfs: use ->t_firstblock in attrfork add Brian Foster
@ 2018-07-03 17:23 ` Brian Foster
  2018-07-04  0:45   ` Darrick J. Wong
  2018-07-03 17:23 ` [PATCH 07/25] xfs: use ->t_firstblock for all xfs_bmapi_write() callers Brian Foster
                   ` (19 subsequent siblings)
  25 siblings, 1 reply; 58+ messages in thread
From: Brian Foster @ 2018-07-03 17:23 UTC (permalink / raw)
  To: linux-xfs

Similar to the dirops code, the xattr code uses an on-stack
firstblock variable for the various operations. This code rolls the
underlying transaction in various places, however, which means we
cannot simply replace the local firstblock vars with ->t_firstblock.
Doing so (without further changes) would invalidate the memory
pointed to by xfs_da_args.firstblock as soon as the first
transaction rolls.

To avoid this problem, remove xfs_da_args.firstblock and replace all
such accesses with ->t_firstblock at the same time. This ensures
that accesses to the current firstblock always occur through the
current transaction rather than a potentially invalid xfs_da_args
pointer.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/libxfs/xfs_attr.c        | 37 ++++++++++++++++-----------------
 fs/xfs/libxfs/xfs_attr_leaf.c   |  2 --
 fs/xfs/libxfs/xfs_attr_remote.c | 18 +++++++++-------
 fs/xfs/libxfs/xfs_bmap.c        |  1 -
 fs/xfs/libxfs/xfs_da_btree.c    |  7 +++----
 fs/xfs/libxfs/xfs_da_btree.h    |  1 -
 fs/xfs/libxfs/xfs_dir2.c        |  5 +----
 7 files changed, 33 insertions(+), 38 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
index 8a7e2c0308c4..153d2e29f872 100644
--- a/fs/xfs/libxfs/xfs_attr.c
+++ b/fs/xfs/libxfs/xfs_attr.c
@@ -204,7 +204,6 @@ xfs_attr_set(
 	struct xfs_da_args	args;
 	struct xfs_defer_ops	dfops;
 	struct xfs_trans_res	tres;
-	xfs_fsblock_t		firstblock;
 	int			rsvd = (flags & ATTR_ROOT) != 0;
 	int			error, err2, local;
 
@@ -219,7 +218,6 @@ xfs_attr_set(
 
 	args.value = value;
 	args.valuelen = valuelen;
-	args.firstblock = &firstblock;
 	args.op_flags = XFS_DA_OP_ADDNAME | XFS_DA_OP_OKNOENT;
 	args.total = xfs_attr_calc_size(&args, &local);
 
@@ -253,7 +251,7 @@ xfs_attr_set(
 			rsvd ? XFS_TRANS_RESERVE : 0, &args.trans);
 	if (error)
 		return error;
-	xfs_defer_init(args.trans, &dfops, &firstblock);
+	xfs_defer_init(args.trans, &dfops, &args.trans->t_firstblock);
 
 	xfs_ilock(dp, XFS_ILOCK_EXCL);
 	error = xfs_trans_reserve_quota_nblks(args.trans, dp, args.total, 0,
@@ -392,7 +390,6 @@ xfs_attr_remove(
 	struct xfs_mount	*mp = dp->i_mount;
 	struct xfs_da_args	args;
 	struct xfs_defer_ops	dfops;
-	xfs_fsblock_t		firstblock;
 	int			error;
 
 	XFS_STATS_INC(mp, xs_attr_remove);
@@ -404,8 +401,6 @@ xfs_attr_remove(
 	if (error)
 		return error;
 
-	args.firstblock = &firstblock;
-
 	/*
 	 * we have no control over the attribute names that userspace passes us
 	 * to remove, so we have to allow the name lookup prior to attribute
@@ -427,7 +422,7 @@ xfs_attr_remove(
 			&args.trans);
 	if (error)
 		return error;
-	xfs_defer_init(args.trans, &dfops, &firstblock);
+	xfs_defer_init(args.trans, &dfops, &args.trans->t_firstblock);
 
 	xfs_ilock(dp, XFS_ILOCK_EXCL);
 	/*
@@ -598,7 +593,8 @@ xfs_attr_leaf_addname(
 		 * Commit that transaction so that the node_addname() call
 		 * can manage its own transactions.
 		 */
-		xfs_defer_init(NULL, args->trans->t_dfops, args->firstblock);
+		xfs_defer_init(args->trans, args->trans->t_dfops,
+			       &args->trans->t_firstblock);
 		error = xfs_attr3_leaf_to_node(args);
 		if (error)
 			goto out_defer_cancel;
@@ -687,8 +683,8 @@ xfs_attr_leaf_addname(
 		 * If the result is small enough, shrink it all into the inode.
 		 */
 		if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
-			xfs_defer_init(NULL, args->trans->t_dfops,
-				       args->firstblock);
+			xfs_defer_init(args->trans, args->trans->t_dfops,
+				       &args->trans->t_firstblock);
 			error = xfs_attr3_leaf_to_shortform(bp, args, forkoff);
 			/* bp is gone due to xfs_da_shrink_inode */
 			if (error)
@@ -753,7 +749,8 @@ xfs_attr_leaf_removename(
 	 * If the result is small enough, shrink it all into the inode.
 	 */
 	if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
-		xfs_defer_init(NULL, args->trans->t_dfops, args->firstblock);
+		xfs_defer_init(args->trans, args->trans->t_dfops,
+			       &args->trans->t_firstblock);
 		error = xfs_attr3_leaf_to_shortform(bp, args, forkoff);
 		/* bp is gone due to xfs_da_shrink_inode */
 		if (error)
@@ -882,8 +879,8 @@ xfs_attr_node_addname(
 			 */
 			xfs_da_state_free(state);
 			state = NULL;
-			xfs_defer_init(NULL, args->trans->t_dfops,
-				       args->firstblock);
+			xfs_defer_init(args->trans, args->trans->t_dfops,
+				       &args->trans->t_firstblock);
 			error = xfs_attr3_leaf_to_node(args);
 			if (error)
 				goto out_defer_cancel;
@@ -910,7 +907,8 @@ xfs_attr_node_addname(
 		 * in the index/blkno/rmtblkno/rmtblkcnt fields and
 		 * in the index2/blkno2/rmtblkno2/rmtblkcnt2 fields.
 		 */
-		xfs_defer_init(NULL, args->trans->t_dfops, args->firstblock);
+		xfs_defer_init(args->trans, args->trans->t_dfops,
+			       &args->trans->t_firstblock);
 		error = xfs_da3_split(state);
 		if (error)
 			goto out_defer_cancel;
@@ -1008,8 +1006,8 @@ xfs_attr_node_addname(
 		 * Check to see if the tree needs to be collapsed.
 		 */
 		if (retval && (state->path.active > 1)) {
-			xfs_defer_init(NULL, args->trans->t_dfops,
-				       args->firstblock);
+			xfs_defer_init(args->trans, args->trans->t_dfops,
+				       &args->trans->t_firstblock);
 			error = xfs_da3_join(state);
 			if (error)
 				goto out_defer_cancel;
@@ -1134,7 +1132,8 @@ xfs_attr_node_removename(
 	 * Check to see if the tree needs to be collapsed.
 	 */
 	if (retval && (state->path.active > 1)) {
-		xfs_defer_init(NULL, args->trans->t_dfops, args->firstblock);
+		xfs_defer_init(args->trans, args->trans->t_dfops,
+			       &args->trans->t_firstblock);
 		error = xfs_da3_join(state);
 		if (error)
 			goto out_defer_cancel;
@@ -1166,8 +1165,8 @@ xfs_attr_node_removename(
 			goto out;
 
 		if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
-			xfs_defer_init(NULL, args->trans->t_dfops,
-				       args->firstblock);
+			xfs_defer_init(args->trans, args->trans->t_dfops,
+				       &args->trans->t_firstblock);
 			error = xfs_attr3_leaf_to_shortform(bp, args, forkoff);
 			/* bp is gone due to xfs_da_shrink_inode */
 			if (error)
diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
index c131469db0f1..251304f3bc5d 100644
--- a/fs/xfs/libxfs/xfs_attr_leaf.c
+++ b/fs/xfs/libxfs/xfs_attr_leaf.c
@@ -802,7 +802,6 @@ xfs_attr_shortform_to_leaf(
 	memset((char *)&nargs, 0, sizeof(nargs));
 	nargs.dp = dp;
 	nargs.geo = args->geo;
-	nargs.firstblock = args->firstblock;
 	nargs.total = args->total;
 	nargs.whichfork = XFS_ATTR_FORK;
 	nargs.trans = args->trans;
@@ -1005,7 +1004,6 @@ xfs_attr3_leaf_to_shortform(
 	memset((char *)&nargs, 0, sizeof(nargs));
 	nargs.geo = args->geo;
 	nargs.dp = dp;
-	nargs.firstblock = args->firstblock;
 	nargs.total = args->total;
 	nargs.whichfork = XFS_ATTR_FORK;
 	nargs.trans = args->trans;
diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c
index ab7c2755ad8c..205098aeb4bc 100644
--- a/fs/xfs/libxfs/xfs_attr_remote.c
+++ b/fs/xfs/libxfs/xfs_attr_remote.c
@@ -480,11 +480,13 @@ xfs_attr_rmtval_set(
 		 * extent and then crash then the block may not contain the
 		 * correct metadata after log recovery occurs.
 		 */
-		xfs_defer_init(NULL, args->trans->t_dfops, args->firstblock);
+		xfs_defer_init(args->trans, args->trans->t_dfops,
+			       &args->trans->t_firstblock);
 		nmap = 1;
 		error = xfs_bmapi_write(args->trans, dp, (xfs_fileoff_t)lblkno,
-				  blkcnt, XFS_BMAPI_ATTRFORK, args->firstblock,
-				  args->total, &map, &nmap);
+				  blkcnt, XFS_BMAPI_ATTRFORK,
+				  &args->trans->t_firstblock, args->total, &map,
+				  &nmap);
 		if (error)
 			goto out_defer_cancel;
 		xfs_defer_ijoin(args->trans->t_dfops, dp);
@@ -522,7 +524,8 @@ xfs_attr_rmtval_set(
 
 		ASSERT(blkcnt > 0);
 
-		xfs_defer_init(NULL, args->trans->t_dfops, args->firstblock);
+		xfs_defer_init(args->trans, args->trans->t_dfops,
+			       &args->trans->t_firstblock);
 		nmap = 1;
 		error = xfs_bmapi_read(dp, (xfs_fileoff_t)lblkno,
 				       blkcnt, &map, &nmap,
@@ -626,10 +629,11 @@ xfs_attr_rmtval_remove(
 	blkcnt = args->rmtblkcnt;
 	done = 0;
 	while (!done) {
-		xfs_defer_init(NULL, args->trans->t_dfops, args->firstblock);
+		xfs_defer_init(args->trans, args->trans->t_dfops,
+			       &args->trans->t_firstblock);
 		error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt,
-				    XFS_BMAPI_ATTRFORK, 1, args->firstblock,
-				    &done);
+				    XFS_BMAPI_ATTRFORK, 1,
+				    &args->trans->t_firstblock, &done);
 		if (error)
 			goto out_defer_cancel;
 		xfs_defer_ijoin(args->trans->t_dfops, args->dp);
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index fcd10b47044a..86097be47ae9 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -1000,7 +1000,6 @@ xfs_bmap_add_attrfork_local(
 		memset(&dargs, 0, sizeof(dargs));
 		dargs.geo = ip->i_mount->m_dir_geo;
 		dargs.dp = ip;
-		dargs.firstblock = &tp->t_firstblock;
 		dargs.total = dargs.geo->fsbcount;
 		dargs.whichfork = XFS_DATA_FORK;
 		dargs.trans = tp;
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index 68a72e3d9f53..2f2be86c10dc 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -2059,10 +2059,9 @@ xfs_da_grow_inode_int(
 	 * Try mapping it in one filesystem block.
 	 */
 	nmap = 1;
-	ASSERT(args->firstblock != NULL);
 	error = xfs_bmapi_write(tp, dp, *bno, count,
 			xfs_bmapi_aflag(w)|XFS_BMAPI_METADATA|XFS_BMAPI_CONTIG,
-			args->firstblock, args->total, &map, &nmap);
+			&tp->t_firstblock, args->total, &map, &nmap);
 	if (error)
 		return error;
 
@@ -2084,7 +2083,7 @@ xfs_da_grow_inode_int(
 			c = (int)(*bno + count - b);
 			error = xfs_bmapi_write(tp, dp, b, c,
 					xfs_bmapi_aflag(w)|XFS_BMAPI_METADATA,
-					args->firstblock, args->total,
+					&tp->t_firstblock, args->total,
 					&mapp[mapi], &nmap);
 			if (error)
 				goto out_free_map;
@@ -2394,7 +2393,7 @@ xfs_da_shrink_inode(
 		 * the last block to the place we want to kill.
 		 */
 		error = xfs_bunmapi(tp, dp, dead_blkno, count,
-				    xfs_bmapi_aflag(w), 0, args->firstblock,
+				    xfs_bmapi_aflag(w), 0, &tp->t_firstblock,
 				    &done);
 		if (error == -ENOSPC) {
 			if (w != XFS_DATA_FORK)
diff --git a/fs/xfs/libxfs/xfs_da_btree.h b/fs/xfs/libxfs/xfs_da_btree.h
index 6b8a04f3f162..59e290ef334f 100644
--- a/fs/xfs/libxfs/xfs_da_btree.h
+++ b/fs/xfs/libxfs/xfs_da_btree.h
@@ -57,7 +57,6 @@ typedef struct xfs_da_args {
 	xfs_dahash_t	hashval;	/* hash value of name */
 	xfs_ino_t	inumber;	/* input/output inode number */
 	struct xfs_inode *dp;		/* directory inode to manipulate */
-	xfs_fsblock_t	*firstblock;	/* ptr to firstblock for bmap calls */
 	struct xfs_trans *trans;	/* current trans (changes over time) */
 	xfs_extlen_t	total;		/* total blocks needed, for 1st bmap */
 	int		whichfork;	/* data or attribute fork */
diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
index 8a55990ca3a5..53e46fda8df4 100644
--- a/fs/xfs/libxfs/xfs_dir2.c
+++ b/fs/xfs/libxfs/xfs_dir2.c
@@ -271,7 +271,6 @@ xfs_dir_createname(
 	args->total = total;
 	args->whichfork = XFS_DATA_FORK;
 	args->trans = tp;
-	args->firstblock = &tp->t_firstblock;
 	args->op_flags = XFS_DA_OP_ADDNAME | XFS_DA_OP_OKNOENT;
 	if (!inum)
 		args->op_flags |= XFS_DA_OP_JUSTCHECK;
@@ -437,7 +436,6 @@ xfs_dir_removename(
 	args->hashval = dp->i_mount->m_dirnameops->hashname(name);
 	args->inumber = ino;
 	args->dp = dp;
-	args->firstblock = &tp->t_firstblock;
 	args->total = total;
 	args->whichfork = XFS_DATA_FORK;
 	args->trans = tp;
@@ -500,7 +498,6 @@ xfs_dir_replace(
 	args->hashval = dp->i_mount->m_dirnameops->hashname(name);
 	args->inumber = inum;
 	args->dp = dp;
-	args->firstblock = &tp->t_firstblock;
 	args->total = total;
 	args->whichfork = XFS_DATA_FORK;
 	args->trans = tp;
@@ -659,7 +656,7 @@ xfs_dir2_shrink_inode(
 
 	/* Unmap the fsblock(s). */
 	error = xfs_bunmapi(tp, dp, da, args->geo->fsbcount, 0, 0,
-			    args->firstblock, &done);
+			    &tp->t_firstblock, &done);
 	if (error) {
 		/*
 		 * ENOSPC actually can happen if we're in a removename with no
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 07/25] xfs: use ->t_firstblock for all xfs_bmapi_write() callers
  2018-07-03 17:22 [PATCH 00/25] xfs: embed firstblock in xfs_trans Brian Foster
                   ` (5 preceding siblings ...)
  2018-07-03 17:23 ` [PATCH 06/25] xfs: use ->t_firstblock in xattr ops Brian Foster
@ 2018-07-03 17:23 ` Brian Foster
  2018-07-04  0:47   ` Darrick J. Wong
  2018-07-03 17:23 ` [PATCH 08/25] xfs: use ->t_firstblock for all xfs_bunmapi() callers Brian Foster
                   ` (18 subsequent siblings)
  25 siblings, 1 reply; 58+ messages in thread
From: Brian Foster @ 2018-07-03 17:23 UTC (permalink / raw)
  To: linux-xfs

Convert all xfs_bmapi_write() users to ->t_firstblock.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/xfs_bmap_util.c |  8 ++++----
 fs/xfs/xfs_dquot.c     |  5 ++---
 fs/xfs/xfs_iomap.c     | 20 +++++++++-----------
 fs/xfs/xfs_reflink.c   |  7 +++----
 fs/xfs/xfs_rtalloc.c   |  5 ++---
 5 files changed, 20 insertions(+), 25 deletions(-)

diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index aea33d526db2..f9a0957343ea 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -872,7 +872,6 @@ xfs_alloc_file_space(
 	xfs_filblks_t		allocatesize_fsb;
 	xfs_extlen_t		extsz, temp;
 	xfs_fileoff_t		startoffset_fsb;
-	xfs_fsblock_t		firstfsb;
 	int			nimaps;
 	int			quota_flag;
 	int			rt;
@@ -971,10 +970,11 @@ xfs_alloc_file_space(
 
 		xfs_trans_ijoin(tp, ip, 0);
 
-		xfs_defer_init(tp, &dfops, &firstfsb);
+		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
 		error = xfs_bmapi_write(tp, ip, startoffset_fsb,
-					allocatesize_fsb, alloc_type, &firstfsb,
-					resblks, imapp, &nimaps);
+					allocatesize_fsb, alloc_type,
+					&tp->t_firstblock, resblks, imapp,
+					&nimaps);
 		if (error)
 			goto error0;
 
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index c698e7f6f744..2fc5e21373be 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -290,13 +290,12 @@ xfs_dquot_disk_alloc(
 	struct xfs_mount	*mp = tp->t_mountp;
 	struct xfs_buf		*bp;
 	struct xfs_inode	*quotip = xfs_quota_inode(mp, dqp->dq_flags);
-	xfs_fsblock_t		firstblock;
 	int			nmaps = 1;
 	int			error;
 
 	trace_xfs_dqalloc(dqp);
 
-	xfs_defer_init(tp, tp->t_dfops, &firstblock);
+	xfs_defer_init(tp, tp->t_dfops, &tp->t_firstblock);
 
 	xfs_ilock(quotip, XFS_ILOCK_EXCL);
 	if (!xfs_this_quota_on(dqp->q_mount, dqp->dq_flags)) {
@@ -312,7 +311,7 @@ xfs_dquot_disk_alloc(
 	xfs_trans_ijoin(tp, quotip, XFS_ILOCK_EXCL);
 	error = xfs_bmapi_write(tp, quotip, dqp->q_fileoffset,
 			XFS_DQUOT_CLUSTER_SIZE_FSB, XFS_BMAPI_METADATA,
-			&firstblock, XFS_QM_DQALLOC_SPACE_RES(mp),
+			&tp->t_firstblock, XFS_QM_DQALLOC_SPACE_RES(mp),
 			&map, &nmaps);
 	if (error)
 		goto error0;
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index c9b9c7984f95..4a8a85b0fad2 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -152,7 +152,6 @@ xfs_iomap_write_direct(
 	xfs_fileoff_t	offset_fsb;
 	xfs_fileoff_t	last_fsb;
 	xfs_filblks_t	count_fsb, resaligned;
-	xfs_fsblock_t	firstfsb;
 	xfs_extlen_t	extsz;
 	int		nimaps;
 	int		quota_flag;
@@ -254,10 +253,10 @@ xfs_iomap_write_direct(
 	 * From this point onwards we overwrite the imap pointer that the
 	 * caller gave to us.
 	 */
-	xfs_defer_init(tp, &dfops, &firstfsb);
+	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
 	nimaps = 1;
 	error = xfs_bmapi_write(tp, ip, offset_fsb, count_fsb,
-				bmapi_flags, &firstfsb, resblks, imap,
+				bmapi_flags, &tp->t_firstblock, resblks, imap,
 				&nimaps);
 	if (error)
 		goto out_bmap_cancel;
@@ -665,7 +664,6 @@ xfs_iomap_write_allocate(
 	xfs_mount_t	*mp = ip->i_mount;
 	xfs_fileoff_t	offset_fsb, last_block;
 	xfs_fileoff_t	end_fsb, map_start_fsb;
-	xfs_fsblock_t	first_block;
 	struct xfs_defer_ops	dfops;
 	xfs_filblks_t	count_fsb;
 	xfs_trans_t	*tp;
@@ -716,7 +714,7 @@ xfs_iomap_write_allocate(
 			xfs_ilock(ip, XFS_ILOCK_EXCL);
 			xfs_trans_ijoin(tp, ip, 0);
 
-			xfs_defer_init(tp, &dfops, &first_block);
+			xfs_defer_init(tp, &dfops, &tp->t_firstblock);
 
 			/*
 			 * it is possible that the extents have changed since
@@ -770,8 +768,9 @@ xfs_iomap_write_allocate(
 			 * pointer that the caller gave to us.
 			 */
 			error = xfs_bmapi_write(tp, ip, map_start_fsb,
-						count_fsb, flags, &first_block,
-						nres, imap, &nimaps);
+						count_fsb, flags,
+						&tp->t_firstblock, nres, imap,
+						&nimaps);
 			if (error)
 				goto trans_cancel;
 
@@ -827,7 +826,6 @@ xfs_iomap_write_unwritten(
 	xfs_fileoff_t	offset_fsb;
 	xfs_filblks_t	count_fsb;
 	xfs_filblks_t	numblks_fsb;
-	xfs_fsblock_t	firstfsb;
 	int		nimaps;
 	xfs_trans_t	*tp;
 	xfs_bmbt_irec_t imap;
@@ -876,11 +874,11 @@ xfs_iomap_write_unwritten(
 		/*
 		 * Modify the unwritten extent state of the buffer.
 		 */
-		xfs_defer_init(tp, &dfops, &firstfsb);
+		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
 		nimaps = 1;
 		error = xfs_bmapi_write(tp, ip, offset_fsb, count_fsb,
-					XFS_BMAPI_CONVERT, &firstfsb, resblks,
-					&imap, &nimaps);
+					XFS_BMAPI_CONVERT, &tp->t_firstblock,
+					resblks, &imap, &nimaps);
 		if (error)
 			goto error_on_bmapi_transaction;
 
diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index 92b6e1b5d33c..f0486b748376 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -366,7 +366,6 @@ xfs_reflink_allocate_cow(
 	struct xfs_bmbt_irec	got;
 	struct xfs_defer_ops	dfops;
 	struct xfs_trans	*tp = NULL;
-	xfs_fsblock_t		first_block;
 	int			nimaps, error = 0;
 	bool			trimmed;
 	xfs_filblks_t		resaligned;
@@ -425,13 +424,13 @@ xfs_reflink_allocate_cow(
 
 	xfs_trans_ijoin(tp, ip, 0);
 
-	xfs_defer_init(tp, &dfops, &first_block);
+	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
 	nimaps = 1;
 
 	/* Allocate the entire reservation as unwritten blocks. */
 	error = xfs_bmapi_write(tp, ip, imap->br_startoff, imap->br_blockcount,
-			XFS_BMAPI_COWFORK | XFS_BMAPI_PREALLOC, &first_block,
-			resblks, imap, &nimaps);
+			XFS_BMAPI_COWFORK | XFS_BMAPI_PREALLOC,
+			&tp->t_firstblock, resblks, imap, &nimaps);
 	if (error)
 		goto out_bmap_cancel;
 
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index c102b0d26bc1..1c894ea2abca 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -761,7 +761,6 @@ xfs_growfs_rt_alloc(
 	struct xfs_buf		*bp;	/* temporary buffer for zeroing */
 	xfs_daddr_t		d;		/* disk block address */
 	int			error;		/* error return value */
-	xfs_fsblock_t		firstblock;/* first block allocated in xaction */
 	struct xfs_defer_ops	dfops;		/* list of freed blocks */
 	xfs_fsblock_t		fsbno;		/* filesystem block for bno */
 	struct xfs_bmbt_irec	map;		/* block map output */
@@ -787,13 +786,13 @@ xfs_growfs_rt_alloc(
 		xfs_ilock(ip, XFS_ILOCK_EXCL);
 		xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
 
-		xfs_defer_init(tp, &dfops, &firstblock);
+		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
 		/*
 		 * Allocate blocks to the bitmap file.
 		 */
 		nmap = 1;
 		error = xfs_bmapi_write(tp, ip, oblocks, nblocks - oblocks,
-					XFS_BMAPI_METADATA, &firstblock,
+					XFS_BMAPI_METADATA, &tp->t_firstblock,
 					resblks, &map, &nmap);
 		if (!error && nmap < 1)
 			error = -ENOSPC;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 08/25] xfs: use ->t_firstblock for all xfs_bunmapi() callers
  2018-07-03 17:22 [PATCH 00/25] xfs: embed firstblock in xfs_trans Brian Foster
                   ` (6 preceding siblings ...)
  2018-07-03 17:23 ` [PATCH 07/25] xfs: use ->t_firstblock for all xfs_bmapi_write() callers Brian Foster
@ 2018-07-03 17:23 ` Brian Foster
  2018-07-04  0:47   ` Darrick J. Wong
  2018-07-03 17:23 ` [PATCH 09/25] xfs: use ->t_firstblock in xfs_bmapi_remap() Brian Foster
                   ` (17 subsequent siblings)
  25 siblings, 1 reply; 58+ messages in thread
From: Brian Foster @ 2018-07-03 17:23 UTC (permalink / raw)
  To: linux-xfs

Convert all xfs_bunmapi() callers to ->t_firstblock.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/libxfs/xfs_bmap.c | 12 ++----------
 fs/xfs/xfs_bmap_util.c   |  7 +++----
 fs/xfs/xfs_inode.c       |  5 ++---
 fs/xfs/xfs_reflink.c     | 11 +++++------
 fs/xfs/xfs_symlink.c     |  6 +++---
 5 files changed, 15 insertions(+), 26 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 86097be47ae9..4ace1267fc35 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -6134,17 +6134,9 @@ xfs_bmap_finish_one(
 	xfs_filblks_t			*blockcount,
 	xfs_exntst_t			state)
 {
-	xfs_fsblock_t			firstfsb;
 	int				error = 0;
 
-	/*
-	 * firstfsb is tied to the transaction lifetime and is used to
-	 * ensure correct AG locking order and schedule work item
-	 * continuations.  XFS_BUI_MAX_FAST_EXTENTS (== 1) restricts us
-	 * to only making one bmap call per transaction, so it should
-	 * be safe to have it as a local variable here.
-	 */
-	firstfsb = NULLFSBLOCK;
+	ASSERT(tp->t_firstblock == NULLFSBLOCK);
 
 	trace_xfs_bmap_deferred(tp->t_mountp,
 			XFS_FSB_TO_AGNO(tp->t_mountp, startblock), type,
@@ -6167,7 +6159,7 @@ xfs_bmap_finish_one(
 		break;
 	case XFS_BMAP_UNMAP:
 		error = __xfs_bunmapi(tp, ip, startoff, blockcount,
-				XFS_BMAPI_REMAP, 1, &firstfsb);
+				XFS_BMAPI_REMAP, 1, &tp->t_firstblock);
 		break;
 	default:
 		ASSERT(0);
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index f9a0957343ea..b49364779966 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -1023,7 +1023,6 @@ xfs_unmap_extent(
 	struct xfs_mount	*mp = ip->i_mount;
 	struct xfs_trans	*tp;
 	struct xfs_defer_ops	dfops;
-	xfs_fsblock_t		firstfsb;
 	uint			resblks = XFS_DIOSTRAT_SPACE_RES(mp, 0);
 	int			error;
 
@@ -1041,9 +1040,9 @@ xfs_unmap_extent(
 
 	xfs_trans_ijoin(tp, ip, 0);
 
-	xfs_defer_init(tp, &dfops, &firstfsb);
-	error = xfs_bunmapi(tp, ip, startoffset_fsb, len_fsb, 0, 2, &firstfsb,
-			    done);
+	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
+	error = xfs_bunmapi(tp, ip, startoffset_fsb, len_fsb, 0, 2,
+			    &tp->t_firstblock, done);
 	if (error)
 		goto out_bmap_cancel;
 
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index ab1fd696500c..3cdfd795a50c 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1543,7 +1543,6 @@ xfs_itruncate_extents_flags(
 	struct xfs_trans	*tp = *tpp;
 	struct xfs_defer_ops	*odfops = tp->t_dfops;
 	struct xfs_defer_ops	dfops;
-	xfs_fsblock_t		first_block;
 	xfs_fileoff_t		first_unmap_block;
 	xfs_fileoff_t		last_block;
 	xfs_filblks_t		unmap_len;
@@ -1580,9 +1579,9 @@ xfs_itruncate_extents_flags(
 	ASSERT(first_unmap_block < last_block);
 	unmap_len = last_block - first_unmap_block + 1;
 	while (!done) {
-		xfs_defer_init(tp, &dfops, &first_block);
+		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
 		error = xfs_bunmapi(tp, ip, first_unmap_block, unmap_len, flags,
-				    XFS_ITRUNC_MAX_EXTENTS, &first_block,
+				    XFS_ITRUNC_MAX_EXTENTS, &tp->t_firstblock,
 				    &done);
 		if (error)
 			goto out_bmap_cancel;
diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index f0486b748376..eed6b9df7944 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -690,7 +690,6 @@ xfs_reflink_end_cow(
 	struct xfs_trans		*tp;
 	xfs_fileoff_t			offset_fsb;
 	xfs_fileoff_t			end_fsb;
-	xfs_fsblock_t			firstfsb;
 	struct xfs_defer_ops		dfops;
 	int				error;
 	unsigned int			resblks;
@@ -758,10 +757,10 @@ xfs_reflink_end_cow(
 			goto prev_extent;
 
 		/* Unmap the old blocks in the data fork. */
-		xfs_defer_init(tp, &dfops, &firstfsb);
+		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
 		rlen = del.br_blockcount;
 		error = __xfs_bunmapi(tp, ip, del.br_startoff, &rlen, 0, 1,
-				&firstfsb);
+				&tp->t_firstblock);
 		if (error)
 			goto out_defer;
 
@@ -1065,7 +1064,6 @@ xfs_reflink_remap_extent(
 	struct xfs_mount	*mp = ip->i_mount;
 	bool			real_extent = xfs_bmap_is_real_extent(irec);
 	struct xfs_trans	*tp;
-	xfs_fsblock_t		firstfsb;
 	unsigned int		resblks;
 	struct xfs_defer_ops	dfops;
 	struct xfs_bmbt_irec	uirec;
@@ -1108,8 +1106,9 @@ xfs_reflink_remap_extent(
 	/* Unmap the old blocks in the data fork. */
 	rlen = unmap_len;
 	while (rlen) {
-		xfs_defer_init(tp, &dfops, &firstfsb);
-		error = __xfs_bunmapi(tp, ip, destoff, &rlen, 0, 1, &firstfsb);
+		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
+		error = __xfs_bunmapi(tp, ip, destoff, &rlen, 0, 1,
+				      &tp->t_firstblock);
 		if (error)
 			goto out_defer;
 
diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
index 583ca83353f7..18d9b4d301e5 100644
--- a/fs/xfs/xfs_symlink.c
+++ b/fs/xfs/xfs_symlink.c
@@ -400,7 +400,6 @@ xfs_inactive_symlink_rmt(
 	xfs_buf_t	*bp;
 	int		done;
 	int		error;
-	xfs_fsblock_t	first_block;
 	struct xfs_defer_ops	dfops;
 	int		i;
 	xfs_mount_t	*mp;
@@ -440,7 +439,7 @@ xfs_inactive_symlink_rmt(
 	 * Find the block(s) so we can inval and unmap them.
 	 */
 	done = 0;
-	xfs_defer_init(tp, &dfops, &first_block);
+	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
 	nmaps = ARRAY_SIZE(mval);
 	error = xfs_bmapi_read(ip, 0, xfs_symlink_blocks(mp, size),
 				mval, &nmaps, 0);
@@ -462,7 +461,8 @@ xfs_inactive_symlink_rmt(
 	/*
 	 * Unmap the dead block(s) to the dfops.
 	 */
-	error = xfs_bunmapi(tp, ip, 0, size, 0, nmaps, &first_block, &done);
+	error = xfs_bunmapi(tp, ip, 0, size, 0, nmaps, &tp->t_firstblock,
+			    &done);
 	if (error)
 		goto error_bmap_cancel;
 	ASSERT(done);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 09/25] xfs: use ->t_firstblock in xfs_bmapi_remap()
  2018-07-03 17:22 [PATCH 00/25] xfs: embed firstblock in xfs_trans Brian Foster
                   ` (7 preceding siblings ...)
  2018-07-03 17:23 ` [PATCH 08/25] xfs: use ->t_firstblock for all xfs_bunmapi() callers Brian Foster
@ 2018-07-03 17:23 ` Brian Foster
  2018-07-04  0:47   ` Darrick J. Wong
  2018-07-03 17:23 ` [PATCH 10/25] xfs: use ->t_firstblock in insert/collapse range Brian Foster
                   ` (16 subsequent siblings)
  25 siblings, 1 reply; 58+ messages in thread
From: Brian Foster @ 2018-07-03 17:23 UTC (permalink / raw)
  To: linux-xfs

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/libxfs/xfs_bmap.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 4ace1267fc35..05647d4b8f3e 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -4503,7 +4503,6 @@ xfs_bmapi_remap(
 	struct xfs_mount	*mp = ip->i_mount;
 	struct xfs_ifork	*ifp;
 	struct xfs_btree_cur	*cur = NULL;
-	xfs_fsblock_t		firstblock = NULLFSBLOCK;
 	struct xfs_bmbt_irec	got;
 	struct xfs_iext_cursor	icur;
 	int			whichfork = xfs_bmapi_whichfork(flags);
@@ -4546,7 +4545,7 @@ xfs_bmapi_remap(
 
 	if (ifp->if_flags & XFS_IFBROOT) {
 		cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
-		cur->bc_private.b.firstblock = firstblock;
+		cur->bc_private.b.firstblock = tp->t_firstblock;
 		cur->bc_private.b.flags = 0;
 	}
 
@@ -4559,7 +4558,7 @@ xfs_bmapi_remap(
 		got.br_state = XFS_EXT_NORM;
 
 	error = xfs_bmap_add_extent_hole_real(tp, ip, whichfork, &icur,
-			&cur, &got, &firstblock, &logflags, flags);
+			&cur, &got, &tp->t_firstblock, &logflags, flags);
 	if (error)
 		goto error0;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 10/25] xfs: use ->t_firstblock in insert/collapse range
  2018-07-03 17:22 [PATCH 00/25] xfs: embed firstblock in xfs_trans Brian Foster
                   ` (8 preceding siblings ...)
  2018-07-03 17:23 ` [PATCH 09/25] xfs: use ->t_firstblock in xfs_bmapi_remap() Brian Foster
@ 2018-07-03 17:23 ` Brian Foster
  2018-07-04  0:48   ` Darrick J. Wong
  2018-07-03 17:23 ` [PATCH 11/25] xfs: remove xfs_bmapi_write() firstblock param Brian Foster
                   ` (15 subsequent siblings)
  25 siblings, 1 reply; 58+ messages in thread
From: Brian Foster @ 2018-07-03 17:23 UTC (permalink / raw)
  To: linux-xfs

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/xfs_bmap_util.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index b49364779966..b690def4962b 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -1310,7 +1310,6 @@ xfs_collapse_file_space(
 	struct xfs_trans	*tp;
 	int			error;
 	struct xfs_defer_ops	dfops;
-	xfs_fsblock_t		first_block;
 	xfs_fileoff_t		next_fsb = XFS_B_TO_FSB(mp, offset + len);
 	xfs_fileoff_t		shift_fsb = XFS_B_TO_FSB(mp, len);
 	uint			resblks = XFS_DIOSTRAT_SPACE_RES(mp, 0);
@@ -1343,9 +1342,9 @@ xfs_collapse_file_space(
 			goto out_trans_cancel;
 		xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
 
-		xfs_defer_init(tp, &dfops, &first_block);
+		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
 		error = xfs_bmap_collapse_extents(tp, ip, &next_fsb, shift_fsb,
-				&done, &first_block);
+				&done, &tp->t_firstblock);
 		if (error)
 			goto out_bmap_cancel;
 
@@ -1386,7 +1385,6 @@ xfs_insert_file_space(
 	struct xfs_trans	*tp;
 	int			error;
 	struct xfs_defer_ops	dfops;
-	xfs_fsblock_t		first_block;
 	xfs_fileoff_t		stop_fsb = XFS_B_TO_FSB(mp, offset);
 	xfs_fileoff_t		next_fsb = NULLFSBLOCK;
 	xfs_fileoff_t		shift_fsb = XFS_B_TO_FSB(mp, len);
@@ -1422,9 +1420,9 @@ xfs_insert_file_space(
 
 		xfs_ilock(ip, XFS_ILOCK_EXCL);
 		xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
-		xfs_defer_init(tp, &dfops, &first_block);
+		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
 		error = xfs_bmap_insert_extents(tp, ip, &next_fsb, shift_fsb,
-				&done, stop_fsb, &first_block);
+				&done, stop_fsb, &tp->t_firstblock);
 		if (error)
 			goto out_bmap_cancel;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 11/25] xfs: remove xfs_bmapi_write() firstblock param
  2018-07-03 17:22 [PATCH 00/25] xfs: embed firstblock in xfs_trans Brian Foster
                   ` (9 preceding siblings ...)
  2018-07-03 17:23 ` [PATCH 10/25] xfs: use ->t_firstblock in insert/collapse range Brian Foster
@ 2018-07-03 17:23 ` Brian Foster
  2018-07-04  0:50   ` Darrick J. Wong
  2018-07-03 17:23 ` [PATCH 12/25] xfs: remove xfs_bunmapi() " Brian Foster
                   ` (14 subsequent siblings)
  25 siblings, 1 reply; 58+ messages in thread
From: Brian Foster @ 2018-07-03 17:23 UTC (permalink / raw)
  To: linux-xfs

All callers pass ->t_firstblock from the current transaction.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/libxfs/xfs_attr_remote.c |  3 +--
 fs/xfs/libxfs/xfs_bmap.c        | 18 +++++-------------
 fs/xfs/libxfs/xfs_bmap.h        |  3 +--
 fs/xfs/libxfs/xfs_da_btree.c    |  5 ++---
 fs/xfs/xfs_bmap_util.c          |  5 ++---
 fs/xfs/xfs_dquot.c              |  3 +--
 fs/xfs/xfs_iomap.c              | 10 ++++------
 fs/xfs/xfs_reflink.c            |  6 +++---
 fs/xfs/xfs_rtalloc.c            |  4 ++--
 fs/xfs/xfs_symlink.c            |  3 +--
 10 files changed, 22 insertions(+), 38 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c
index 205098aeb4bc..2db9ef186e05 100644
--- a/fs/xfs/libxfs/xfs_attr_remote.c
+++ b/fs/xfs/libxfs/xfs_attr_remote.c
@@ -484,8 +484,7 @@ xfs_attr_rmtval_set(
 			       &args->trans->t_firstblock);
 		nmap = 1;
 		error = xfs_bmapi_write(args->trans, dp, (xfs_fileoff_t)lblkno,
-				  blkcnt, XFS_BMAPI_ATTRFORK,
-				  &args->trans->t_firstblock, args->total, &map,
+				  blkcnt, XFS_BMAPI_ATTRFORK, args->total, &map,
 				  &nmap);
 		if (error)
 			goto out_defer_cancel;
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 05647d4b8f3e..fd4125e3b097 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -4213,12 +4213,6 @@ xfs_bmapi_convert_unwritten(
  * extent state if necessary.  Details behaviour is controlled by the flags
  * parameter.  Only allocates blocks from a single allocation group, to avoid
  * locking problems.
- *
- * The returned value in "firstblock" from the first call in a transaction
- * must be remembered and presented to subsequent calls in "firstblock".
- * An upper bound for the number of blocks to be allocated is supplied to
- * the first call in "total"; if no allocation group has that many free
- * blocks then the call will fail (return NULLFSBLOCK in "firstblock").
  */
 int
 xfs_bmapi_write(
@@ -4227,8 +4221,6 @@ xfs_bmapi_write(
 	xfs_fileoff_t		bno,		/* starting file offs. mapped */
 	xfs_filblks_t		len,		/* length to map in file */
 	int			flags,		/* XFS_BMAPI_... */
-	xfs_fsblock_t		*firstblock,	/* first allocated block
-						   controls a.g. for allocs */
 	xfs_extlen_t		total,		/* total blocks needed */
 	struct xfs_bmbt_irec	*mval,		/* output: map values */
 	int			*nmap)		/* i/o: mval size/count */
@@ -4296,7 +4288,7 @@ xfs_bmapi_write(
 
 	XFS_STATS_INC(mp, xs_blk_mapw);
 
-	if (!tp || *firstblock == NULLFSBLOCK) {
+	if (!tp || tp->t_firstblock == NULLFSBLOCK) {
 		if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE)
 			bma.minleft = be16_to_cpu(ifp->if_broot->bb_level) + 1;
 		else
@@ -4323,7 +4315,7 @@ xfs_bmapi_write(
 	bma.ip = ip;
 	bma.total = total;
 	bma.datatype = 0;
-	bma.firstblock = firstblock;
+	bma.firstblock = &tp->t_firstblock;
 	ASSERT(!tp || tp->t_dfops);
 
 	while (bno < end && n < *nmap) {
@@ -4476,11 +4468,11 @@ xfs_bmapi_write(
 
 	if (bma.cur) {
 		if (!error) {
-			ASSERT(*firstblock == NULLFSBLOCK ||
-			       XFS_FSB_TO_AGNO(mp, *firstblock) <=
+			ASSERT(tp->t_firstblock == NULLFSBLOCK ||
+			       XFS_FSB_TO_AGNO(mp, tp->t_firstblock) <=
 			       XFS_FSB_TO_AGNO(mp,
 				       bma.cur->bc_private.b.firstblock));
-			*firstblock = bma.cur->bc_private.b.firstblock;
+			tp->t_firstblock = bma.cur->bc_private.b.firstblock;
 		}
 		xfs_btree_del_cursor(bma.cur,
 			error ? XFS_BTREE_ERROR : XFS_BTREE_NOERROR);
diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h
index 2da6c6daada8..1f9e29f32f20 100644
--- a/fs/xfs/libxfs/xfs_bmap.h
+++ b/fs/xfs/libxfs/xfs_bmap.h
@@ -204,8 +204,7 @@ int	xfs_bmapi_read(struct xfs_inode *ip, xfs_fileoff_t bno,
 		int *nmap, int flags);
 int	xfs_bmapi_write(struct xfs_trans *tp, struct xfs_inode *ip,
 		xfs_fileoff_t bno, xfs_filblks_t len, int flags,
-		xfs_fsblock_t *firstblock, xfs_extlen_t total,
-		struct xfs_bmbt_irec *mval, int *nmap);
+		xfs_extlen_t total, struct xfs_bmbt_irec *mval, int *nmap);
 int	__xfs_bunmapi(struct xfs_trans *tp, struct xfs_inode *ip,
 		xfs_fileoff_t bno, xfs_filblks_t *rlen, int flags,
 		xfs_extnum_t nexts, xfs_fsblock_t *firstblock);
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index 2f2be86c10dc..fe4a192696ae 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -2061,7 +2061,7 @@ xfs_da_grow_inode_int(
 	nmap = 1;
 	error = xfs_bmapi_write(tp, dp, *bno, count,
 			xfs_bmapi_aflag(w)|XFS_BMAPI_METADATA|XFS_BMAPI_CONTIG,
-			&tp->t_firstblock, args->total, &map, &nmap);
+			args->total, &map, &nmap);
 	if (error)
 		return error;
 
@@ -2083,8 +2083,7 @@ xfs_da_grow_inode_int(
 			c = (int)(*bno + count - b);
 			error = xfs_bmapi_write(tp, dp, b, c,
 					xfs_bmapi_aflag(w)|XFS_BMAPI_METADATA,
-					&tp->t_firstblock, args->total,
-					&mapp[mapi], &nmap);
+					args->total, &mapp[mapi], &nmap);
 			if (error)
 				goto out_free_map;
 			if (nmap < 1)
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index b690def4962b..0c433dbc6eb2 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -972,9 +972,8 @@ xfs_alloc_file_space(
 
 		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
 		error = xfs_bmapi_write(tp, ip, startoffset_fsb,
-					allocatesize_fsb, alloc_type,
-					&tp->t_firstblock, resblks, imapp,
-					&nimaps);
+					allocatesize_fsb, alloc_type, resblks,
+					imapp, &nimaps);
 		if (error)
 			goto error0;
 
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index 2fc5e21373be..84359eeb20f4 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -311,8 +311,7 @@ xfs_dquot_disk_alloc(
 	xfs_trans_ijoin(tp, quotip, XFS_ILOCK_EXCL);
 	error = xfs_bmapi_write(tp, quotip, dqp->q_fileoffset,
 			XFS_DQUOT_CLUSTER_SIZE_FSB, XFS_BMAPI_METADATA,
-			&tp->t_firstblock, XFS_QM_DQALLOC_SPACE_RES(mp),
-			&map, &nmaps);
+			XFS_QM_DQALLOC_SPACE_RES(mp), &map, &nmaps);
 	if (error)
 		goto error0;
 	ASSERT(map.br_blockcount == XFS_DQUOT_CLUSTER_SIZE_FSB);
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index 4a8a85b0fad2..46ade3f7a5a3 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -256,8 +256,7 @@ xfs_iomap_write_direct(
 	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
 	nimaps = 1;
 	error = xfs_bmapi_write(tp, ip, offset_fsb, count_fsb,
-				bmapi_flags, &tp->t_firstblock, resblks, imap,
-				&nimaps);
+				bmapi_flags, resblks, imap, &nimaps);
 	if (error)
 		goto out_bmap_cancel;
 
@@ -768,8 +767,7 @@ xfs_iomap_write_allocate(
 			 * pointer that the caller gave to us.
 			 */
 			error = xfs_bmapi_write(tp, ip, map_start_fsb,
-						count_fsb, flags,
-						&tp->t_firstblock, nres, imap,
+						count_fsb, flags, nres, imap,
 						&nimaps);
 			if (error)
 				goto trans_cancel;
@@ -877,8 +875,8 @@ xfs_iomap_write_unwritten(
 		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
 		nimaps = 1;
 		error = xfs_bmapi_write(tp, ip, offset_fsb, count_fsb,
-					XFS_BMAPI_CONVERT, &tp->t_firstblock,
-					resblks, &imap, &nimaps);
+					XFS_BMAPI_CONVERT, resblks, &imap,
+					&nimaps);
 		if (error)
 			goto error_on_bmapi_transaction;
 
diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index eed6b9df7944..258183f28141 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -324,7 +324,7 @@ xfs_reflink_convert_cow_extent(
 	if (imap->br_blockcount == 0)
 		return 0;
 	return xfs_bmapi_write(NULL, ip, imap->br_startoff, imap->br_blockcount,
-			XFS_BMAPI_COWFORK | XFS_BMAPI_CONVERT, NULL, 0, imap,
+			XFS_BMAPI_COWFORK | XFS_BMAPI_CONVERT, 0, imap,
 			&nimaps);
 }
 
@@ -347,7 +347,7 @@ xfs_reflink_convert_cow(
 	xfs_ilock(ip, XFS_ILOCK_EXCL);
 	error = xfs_bmapi_write(NULL, ip, offset_fsb, count_fsb,
 			XFS_BMAPI_COWFORK | XFS_BMAPI_CONVERT |
-			XFS_BMAPI_CONVERT_ONLY, NULL, 0, &imap, &nimaps);
+			XFS_BMAPI_CONVERT_ONLY, 0, &imap, &nimaps);
 	xfs_iunlock(ip, XFS_ILOCK_EXCL);
 	return error;
 }
@@ -430,7 +430,7 @@ xfs_reflink_allocate_cow(
 	/* Allocate the entire reservation as unwritten blocks. */
 	error = xfs_bmapi_write(tp, ip, imap->br_startoff, imap->br_blockcount,
 			XFS_BMAPI_COWFORK | XFS_BMAPI_PREALLOC,
-			&tp->t_firstblock, resblks, imap, &nimaps);
+			resblks, imap, &nimaps);
 	if (error)
 		goto out_bmap_cancel;
 
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index 1c894ea2abca..edd949376a51 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -792,8 +792,8 @@ xfs_growfs_rt_alloc(
 		 */
 		nmap = 1;
 		error = xfs_bmapi_write(tp, ip, oblocks, nblocks - oblocks,
-					XFS_BMAPI_METADATA, &tp->t_firstblock,
-					resblks, &map, &nmap);
+					XFS_BMAPI_METADATA, resblks, &map,
+					&nmap);
 		if (!error && nmap < 1)
 			error = -ENOSPC;
 		if (error)
diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
index 18d9b4d301e5..94301b63525f 100644
--- a/fs/xfs/xfs_symlink.c
+++ b/fs/xfs/xfs_symlink.c
@@ -288,8 +288,7 @@ xfs_symlink(
 		nmaps = XFS_SYMLINK_MAPS;
 
 		error = xfs_bmapi_write(tp, ip, first_fsb, fs_blocks,
-				  XFS_BMAPI_METADATA, &tp->t_firstblock,
-				  resblks, mval, &nmaps);
+				  XFS_BMAPI_METADATA, resblks, mval, &nmaps);
 		if (error)
 			goto out_bmap_cancel;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 12/25] xfs: remove xfs_bunmapi() firstblock param
  2018-07-03 17:22 [PATCH 00/25] xfs: embed firstblock in xfs_trans Brian Foster
                   ` (10 preceding siblings ...)
  2018-07-03 17:23 ` [PATCH 11/25] xfs: remove xfs_bmapi_write() firstblock param Brian Foster
@ 2018-07-03 17:23 ` Brian Foster
  2018-07-04  0:51   ` Darrick J. Wong
  2018-07-03 17:23 ` [PATCH 13/25] xfs: remove bmap insert/collapse " Brian Foster
                   ` (13 subsequent siblings)
  25 siblings, 1 reply; 58+ messages in thread
From: Brian Foster @ 2018-07-03 17:23 UTC (permalink / raw)
  To: linux-xfs

All callers pass ->t_firstblock from the current transaction.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/libxfs/xfs_attr_remote.c |  3 +--
 fs/xfs/libxfs/xfs_bmap.c        | 25 ++++++++++++-------------
 fs/xfs/libxfs/xfs_bmap.h        |  5 ++---
 fs/xfs/libxfs/xfs_da_btree.c    |  3 +--
 fs/xfs/libxfs/xfs_dir2.c        |  3 +--
 fs/xfs/xfs_bmap_util.c          |  3 +--
 fs/xfs/xfs_inode.c              |  3 +--
 fs/xfs/xfs_reflink.c            |  6 ++----
 fs/xfs/xfs_symlink.c            |  3 +--
 9 files changed, 22 insertions(+), 32 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c
index 2db9ef186e05..f02c705965ff 100644
--- a/fs/xfs/libxfs/xfs_attr_remote.c
+++ b/fs/xfs/libxfs/xfs_attr_remote.c
@@ -631,8 +631,7 @@ xfs_attr_rmtval_remove(
 		xfs_defer_init(args->trans, args->trans->t_dfops,
 			       &args->trans->t_firstblock);
 		error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt,
-				    XFS_BMAPI_ATTRFORK, 1,
-				    &args->trans->t_firstblock, &done);
+				    XFS_BMAPI_ATTRFORK, 1, &done);
 		if (error)
 			goto out_defer_cancel;
 		xfs_defer_ijoin(args->trans->t_dfops, args->dp);
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index fd4125e3b097..967d12f9e415 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -5124,9 +5124,7 @@ __xfs_bunmapi(
 	xfs_fileoff_t		start,		/* first file offset deleted */
 	xfs_filblks_t		*rlen,		/* i/o: amount remaining */
 	int			flags,		/* misc flags */
-	xfs_extnum_t		nexts,		/* number of extents max */
-	xfs_fsblock_t		*firstblock)	/* first allocated block
-						   controls a.g. for allocs */
+	xfs_extnum_t		nexts)		/* number of extents max */
 {
 	struct xfs_btree_cur	*cur;		/* bmap btree cursor */
 	struct xfs_bmbt_irec	del;		/* extent being deleted */
@@ -5200,7 +5198,7 @@ __xfs_bunmapi(
 	if (ifp->if_flags & XFS_IFBROOT) {
 		ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE);
 		cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
-		cur->bc_private.b.firstblock = *firstblock;
+		cur->bc_private.b.firstblock = tp->t_firstblock;
 		cur->bc_private.b.flags = 0;
 	} else
 		cur = NULL;
@@ -5316,7 +5314,7 @@ __xfs_bunmapi(
 			del.br_state = XFS_EXT_UNWRITTEN;
 			error = xfs_bmap_add_extent_unwritten_real(tp, ip,
 					whichfork, &icur, &cur, &del,
-					firstblock, &logflags);
+					&tp->t_firstblock, &logflags);
 			if (error)
 				goto error0;
 			goto nodelete;
@@ -5373,7 +5371,8 @@ __xfs_bunmapi(
 				prev.br_state = XFS_EXT_UNWRITTEN;
 				error = xfs_bmap_add_extent_unwritten_real(tp,
 						ip, whichfork, &icur, &cur,
-						&prev, firstblock, &logflags);
+						&prev, &tp->t_firstblock,
+						&logflags);
 				if (error)
 					goto error0;
 				goto nodelete;
@@ -5382,7 +5381,8 @@ __xfs_bunmapi(
 				del.br_state = XFS_EXT_UNWRITTEN;
 				error = xfs_bmap_add_extent_unwritten_real(tp,
 						ip, whichfork, &icur, &cur,
-						&del, firstblock, &logflags);
+						&del, &tp->t_firstblock,
+						&logflags);
 				if (error)
 					goto error0;
 				goto nodelete;
@@ -5429,8 +5429,8 @@ __xfs_bunmapi(
 	 */
 	if (xfs_bmap_needs_btree(ip, whichfork)) {
 		ASSERT(cur == NULL);
-		error = xfs_bmap_extents_to_btree(tp, ip, firstblock, &cur, 0,
-				&tmp_logflags, whichfork);
+		error = xfs_bmap_extents_to_btree(tp, ip, &tp->t_firstblock,
+				&cur, 0, &tmp_logflags, whichfork);
 		logflags |= tmp_logflags;
 		if (error)
 			goto error0;
@@ -5469,7 +5469,7 @@ __xfs_bunmapi(
 		xfs_trans_log_inode(tp, ip, logflags);
 	if (cur) {
 		if (!error) {
-			*firstblock = cur->bc_private.b.firstblock;
+			tp->t_firstblock = cur->bc_private.b.firstblock;
 			cur->bc_private.b.allocated = 0;
 		}
 		xfs_btree_del_cursor(cur,
@@ -5487,12 +5487,11 @@ xfs_bunmapi(
 	xfs_filblks_t		len,
 	int			flags,
 	xfs_extnum_t		nexts,
-	xfs_fsblock_t		*firstblock,
 	int			*done)
 {
 	int			error;
 
-	error = __xfs_bunmapi(tp, ip, bno, &len, flags, nexts, firstblock);
+	error = __xfs_bunmapi(tp, ip, bno, &len, flags, nexts);
 	*done = (len == 0);
 	return error;
 }
@@ -6150,7 +6149,7 @@ xfs_bmap_finish_one(
 		break;
 	case XFS_BMAP_UNMAP:
 		error = __xfs_bunmapi(tp, ip, startoff, blockcount,
-				XFS_BMAPI_REMAP, 1, &tp->t_firstblock);
+				XFS_BMAPI_REMAP, 1);
 		break;
 	default:
 		ASSERT(0);
diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h
index 1f9e29f32f20..14e21dcc3044 100644
--- a/fs/xfs/libxfs/xfs_bmap.h
+++ b/fs/xfs/libxfs/xfs_bmap.h
@@ -207,11 +207,10 @@ int	xfs_bmapi_write(struct xfs_trans *tp, struct xfs_inode *ip,
 		xfs_extlen_t total, struct xfs_bmbt_irec *mval, int *nmap);
 int	__xfs_bunmapi(struct xfs_trans *tp, struct xfs_inode *ip,
 		xfs_fileoff_t bno, xfs_filblks_t *rlen, int flags,
-		xfs_extnum_t nexts, xfs_fsblock_t *firstblock);
+		xfs_extnum_t nexts);
 int	xfs_bunmapi(struct xfs_trans *tp, struct xfs_inode *ip,
 		xfs_fileoff_t bno, xfs_filblks_t len, int flags,
-		xfs_extnum_t nexts, xfs_fsblock_t *firstblock,
-		int *done);
+		xfs_extnum_t nexts, int *done);
 int	xfs_bmap_del_extent_delay(struct xfs_inode *ip, int whichfork,
 		struct xfs_iext_cursor *cur, struct xfs_bmbt_irec *got,
 		struct xfs_bmbt_irec *del);
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index fe4a192696ae..9efbd2038ffb 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -2392,8 +2392,7 @@ xfs_da_shrink_inode(
 		 * the last block to the place we want to kill.
 		 */
 		error = xfs_bunmapi(tp, dp, dead_blkno, count,
-				    xfs_bmapi_aflag(w), 0, &tp->t_firstblock,
-				    &done);
+				    xfs_bmapi_aflag(w), 0, &done);
 		if (error == -ENOSPC) {
 			if (w != XFS_DATA_FORK)
 				break;
diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
index 53e46fda8df4..eadfb3bc0c95 100644
--- a/fs/xfs/libxfs/xfs_dir2.c
+++ b/fs/xfs/libxfs/xfs_dir2.c
@@ -655,8 +655,7 @@ xfs_dir2_shrink_inode(
 	da = xfs_dir2_db_to_da(args->geo, db);
 
 	/* Unmap the fsblock(s). */
-	error = xfs_bunmapi(tp, dp, da, args->geo->fsbcount, 0, 0,
-			    &tp->t_firstblock, &done);
+	error = xfs_bunmapi(tp, dp, da, args->geo->fsbcount, 0, 0, &done);
 	if (error) {
 		/*
 		 * ENOSPC actually can happen if we're in a removename with no
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index 0c433dbc6eb2..3675babb5202 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -1040,8 +1040,7 @@ xfs_unmap_extent(
 	xfs_trans_ijoin(tp, ip, 0);
 
 	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
-	error = xfs_bunmapi(tp, ip, startoffset_fsb, len_fsb, 0, 2,
-			    &tp->t_firstblock, done);
+	error = xfs_bunmapi(tp, ip, startoffset_fsb, len_fsb, 0, 2, done);
 	if (error)
 		goto out_bmap_cancel;
 
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 3cdfd795a50c..5e1eaa26435c 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1581,8 +1581,7 @@ xfs_itruncate_extents_flags(
 	while (!done) {
 		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
 		error = xfs_bunmapi(tp, ip, first_unmap_block, unmap_len, flags,
-				    XFS_ITRUNC_MAX_EXTENTS, &tp->t_firstblock,
-				    &done);
+				    XFS_ITRUNC_MAX_EXTENTS, &done);
 		if (error)
 			goto out_bmap_cancel;
 
diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index 258183f28141..cf6080d42273 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -759,8 +759,7 @@ xfs_reflink_end_cow(
 		/* Unmap the old blocks in the data fork. */
 		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
 		rlen = del.br_blockcount;
-		error = __xfs_bunmapi(tp, ip, del.br_startoff, &rlen, 0, 1,
-				&tp->t_firstblock);
+		error = __xfs_bunmapi(tp, ip, del.br_startoff, &rlen, 0, 1);
 		if (error)
 			goto out_defer;
 
@@ -1107,8 +1106,7 @@ xfs_reflink_remap_extent(
 	rlen = unmap_len;
 	while (rlen) {
 		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
-		error = __xfs_bunmapi(tp, ip, destoff, &rlen, 0, 1,
-				      &tp->t_firstblock);
+		error = __xfs_bunmapi(tp, ip, destoff, &rlen, 0, 1);
 		if (error)
 			goto out_defer;
 
diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
index 94301b63525f..a3dc552a5b97 100644
--- a/fs/xfs/xfs_symlink.c
+++ b/fs/xfs/xfs_symlink.c
@@ -460,8 +460,7 @@ xfs_inactive_symlink_rmt(
 	/*
 	 * Unmap the dead block(s) to the dfops.
 	 */
-	error = xfs_bunmapi(tp, ip, 0, size, 0, nmaps, &tp->t_firstblock,
-			    &done);
+	error = xfs_bunmapi(tp, ip, 0, size, 0, nmaps, &done);
 	if (error)
 		goto error_bmap_cancel;
 	ASSERT(done);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 13/25] xfs: remove bmap insert/collapse firstblock param
  2018-07-03 17:22 [PATCH 00/25] xfs: embed firstblock in xfs_trans Brian Foster
                   ` (11 preceding siblings ...)
  2018-07-03 17:23 ` [PATCH 12/25] xfs: remove xfs_bunmapi() " Brian Foster
@ 2018-07-03 17:23 ` Brian Foster
  2018-07-04  0:51   ` Darrick J. Wong
  2018-07-03 17:23 ` [PATCH 14/25] xfs: use ->t_firstblock in bmap extent split Brian Foster
                   ` (12 subsequent siblings)
  25 siblings, 1 reply; 58+ messages in thread
From: Brian Foster @ 2018-07-03 17:23 UTC (permalink / raw)
  To: linux-xfs

The only callers pass ->t_firstblock.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/libxfs/xfs_bmap.c | 10 ++++------
 fs/xfs/libxfs/xfs_bmap.h |  4 ++--
 fs/xfs/xfs_bmap_util.c   |  4 ++--
 3 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 967d12f9e415..c9023c08a78d 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -5654,8 +5654,7 @@ xfs_bmap_collapse_extents(
 	struct xfs_inode	*ip,
 	xfs_fileoff_t		*next_fsb,
 	xfs_fileoff_t		offset_shift_fsb,
-	bool			*done,
-	xfs_fsblock_t		*firstblock)
+	bool			*done)
 {
 	int			whichfork = XFS_DATA_FORK;
 	struct xfs_mount	*mp = ip->i_mount;
@@ -5688,7 +5687,7 @@ xfs_bmap_collapse_extents(
 
 	if (ifp->if_flags & XFS_IFBROOT) {
 		cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
-		cur->bc_private.b.firstblock = *firstblock;
+		cur->bc_private.b.firstblock = tp->t_firstblock;
 		cur->bc_private.b.flags = 0;
 	}
 
@@ -5775,8 +5774,7 @@ xfs_bmap_insert_extents(
 	xfs_fileoff_t		*next_fsb,
 	xfs_fileoff_t		offset_shift_fsb,
 	bool			*done,
-	xfs_fileoff_t		stop_fsb,
-	xfs_fsblock_t		*firstblock)
+	xfs_fileoff_t		stop_fsb)
 {
 	int			whichfork = XFS_DATA_FORK;
 	struct xfs_mount	*mp = ip->i_mount;
@@ -5809,7 +5807,7 @@ xfs_bmap_insert_extents(
 
 	if (ifp->if_flags & XFS_IFBROOT) {
 		cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
-		cur->bc_private.b.firstblock = *firstblock;
+		cur->bc_private.b.firstblock = tp->t_firstblock;
 		cur->bc_private.b.flags = 0;
 	}
 
diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h
index 14e21dcc3044..fa839679ecb6 100644
--- a/fs/xfs/libxfs/xfs_bmap.h
+++ b/fs/xfs/libxfs/xfs_bmap.h
@@ -220,12 +220,12 @@ void	xfs_bmap_del_extent_cow(struct xfs_inode *ip,
 uint	xfs_default_attroffset(struct xfs_inode *ip);
 int	xfs_bmap_collapse_extents(struct xfs_trans *tp, struct xfs_inode *ip,
 		xfs_fileoff_t *next_fsb, xfs_fileoff_t offset_shift_fsb,
-		bool *done, xfs_fsblock_t *firstblock);
+		bool *done);
 int	xfs_bmap_can_insert_extents(struct xfs_inode *ip, xfs_fileoff_t off,
 		xfs_fileoff_t shift);
 int	xfs_bmap_insert_extents(struct xfs_trans *tp, struct xfs_inode *ip,
 		xfs_fileoff_t *next_fsb, xfs_fileoff_t offset_shift_fsb,
-		bool *done, xfs_fileoff_t stop_fsb, xfs_fsblock_t *firstblock);
+		bool *done, xfs_fileoff_t stop_fsb);
 int	xfs_bmap_split_extent(struct xfs_inode *ip, xfs_fileoff_t split_offset);
 int	xfs_bmapi_reserve_delalloc(struct xfs_inode *ip, int whichfork,
 		xfs_fileoff_t off, xfs_filblks_t len, xfs_filblks_t prealloc,
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index 3675babb5202..6d2baf51fec9 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -1342,7 +1342,7 @@ xfs_collapse_file_space(
 
 		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
 		error = xfs_bmap_collapse_extents(tp, ip, &next_fsb, shift_fsb,
-				&done, &tp->t_firstblock);
+				&done);
 		if (error)
 			goto out_bmap_cancel;
 
@@ -1420,7 +1420,7 @@ xfs_insert_file_space(
 		xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
 		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
 		error = xfs_bmap_insert_extents(tp, ip, &next_fsb, shift_fsb,
-				&done, stop_fsb, &tp->t_firstblock);
+				&done, stop_fsb);
 		if (error)
 			goto out_bmap_cancel;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 14/25] xfs: use ->t_firstblock in bmap extent split
  2018-07-03 17:22 [PATCH 00/25] xfs: embed firstblock in xfs_trans Brian Foster
                   ` (12 preceding siblings ...)
  2018-07-03 17:23 ` [PATCH 13/25] xfs: remove bmap insert/collapse " Brian Foster
@ 2018-07-03 17:23 ` Brian Foster
  2018-07-04  0:51   ` Darrick J. Wong
  2018-07-03 17:23 ` [PATCH 15/25] xfs: remove xfs_bmalloca firstblock field Brian Foster
                   ` (11 subsequent siblings)
  25 siblings, 1 reply; 58+ messages in thread
From: Brian Foster @ 2018-07-03 17:23 UTC (permalink / raw)
  To: linux-xfs

Also remove the unnecessary xfs_bmap_split_extent_at() parameter.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/libxfs/xfs_bmap.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index c9023c08a78d..43157e5ff46b 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -5880,8 +5880,7 @@ STATIC int
 xfs_bmap_split_extent_at(
 	struct xfs_trans	*tp,
 	struct xfs_inode	*ip,
-	xfs_fileoff_t		split_fsb,
-	xfs_fsblock_t		*firstfsb)
+	xfs_fileoff_t		split_fsb)
 {
 	int				whichfork = XFS_DATA_FORK;
 	struct xfs_btree_cur		*cur = NULL;
@@ -5930,7 +5929,7 @@ xfs_bmap_split_extent_at(
 
 	if (ifp->if_flags & XFS_IFBROOT) {
 		cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
-		cur->bc_private.b.firstblock = *firstfsb;
+		cur->bc_private.b.firstblock = tp->t_firstblock;
 		cur->bc_private.b.flags = 0;
 		error = xfs_bmbt_lookup_eq(cur, &got, &i);
 		if (error)
@@ -5974,8 +5973,8 @@ xfs_bmap_split_extent_at(
 		int tmp_logflags; /* partial log flag return val */
 
 		ASSERT(cur == NULL);
-		error = xfs_bmap_extents_to_btree(tp, ip, firstfsb, &cur, 0,
-				&tmp_logflags, whichfork);
+		error = xfs_bmap_extents_to_btree(tp, ip, &tp->t_firstblock,
+				&cur, 0, &tmp_logflags, whichfork);
 		logflags |= tmp_logflags;
 	}
 
@@ -5999,20 +5998,18 @@ xfs_bmap_split_extent(
 	struct xfs_mount        *mp = ip->i_mount;
 	struct xfs_trans        *tp;
 	struct xfs_defer_ops    dfops;
-	xfs_fsblock_t           firstfsb;
 	int                     error;
 
 	error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write,
 			XFS_DIOSTRAT_SPACE_RES(mp, 0), 0, 0, &tp);
 	if (error)
 		return error;
-	xfs_defer_init(tp, &dfops, &firstfsb);
+	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
 
 	xfs_ilock(ip, XFS_ILOCK_EXCL);
 	xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
 
-	error = xfs_bmap_split_extent_at(tp, ip, split_fsb,
-					 &firstfsb);
+	error = xfs_bmap_split_extent_at(tp, ip, split_fsb);
 	if (error)
 		goto out;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 15/25] xfs: remove xfs_bmalloca firstblock field
  2018-07-03 17:22 [PATCH 00/25] xfs: embed firstblock in xfs_trans Brian Foster
                   ` (13 preceding siblings ...)
  2018-07-03 17:23 ` [PATCH 14/25] xfs: use ->t_firstblock in bmap extent split Brian Foster
@ 2018-07-03 17:23 ` Brian Foster
  2018-07-04  0:52   ` Darrick J. Wong
  2018-07-03 17:23 ` [PATCH 16/25] xfs: remove bmap extent add helper firstblock params Brian Foster
                   ` (10 subsequent siblings)
  25 siblings, 1 reply; 58+ messages in thread
From: Brian Foster @ 2018-07-03 17:23 UTC (permalink / raw)
  To: linux-xfs

The xfs_bmalloca.firstblock field carries the firstblock value from
the transaction into the bmap infrastructure. It's initialized in
one place from ->t_firstblock, so drop the field and access
->t_firstblock directly throughout the bmap code.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/libxfs/xfs_bmap.c | 44 +++++++++++++++++++++-------------------
 fs/xfs/libxfs/xfs_bmap.h |  1 -
 2 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 43157e5ff46b..bd1273546b54 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -1794,7 +1794,7 @@ xfs_bmap_add_extent_delay_real(
 
 		if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
 			error = xfs_bmap_extents_to_btree(bma->tp, bma->ip,
-					bma->firstblock, &bma->cur, 1,
+					&bma->tp->t_firstblock, &bma->cur, 1,
 					&tmp_rval, whichfork);
 			rval |= tmp_rval;
 			if (error)
@@ -1872,7 +1872,7 @@ xfs_bmap_add_extent_delay_real(
 
 		if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
 			error = xfs_bmap_extents_to_btree(bma->tp, bma->ip,
-				bma->firstblock, &bma->cur, 1, &tmp_rval,
+				&bma->tp->t_firstblock, &bma->cur, 1, &tmp_rval,
 				whichfork);
 			rval |= tmp_rval;
 			if (error)
@@ -1953,7 +1953,7 @@ xfs_bmap_add_extent_delay_real(
 
 		if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
 			error = xfs_bmap_extents_to_btree(bma->tp, bma->ip,
-					bma->firstblock, &bma->cur, 1,
+					&bma->tp->t_firstblock, &bma->cur, 1,
 					&tmp_rval, whichfork);
 			rval |= tmp_rval;
 			if (error)
@@ -1991,7 +1991,7 @@ xfs_bmap_add_extent_delay_real(
 
 		ASSERT(bma->cur == NULL);
 		error = xfs_bmap_extents_to_btree(bma->tp, bma->ip,
-				bma->firstblock, &bma->cur, da_old > 0,
+				&bma->tp->t_firstblock, &bma->cur, da_old > 0,
 				&tmp_logflags, whichfork);
 		bma->logflags |= tmp_logflags;
 		if (error)
@@ -3056,10 +3056,11 @@ xfs_bmap_adjacent(
 		XFS_FSB_TO_AGBNO(mp, x) < mp->m_sb.sb_agblocks)
 
 	mp = ap->ip->i_mount;
-	nullfb = *ap->firstblock == NULLFSBLOCK;
+	nullfb = ap->tp->t_firstblock == NULLFSBLOCK;
 	rt = XFS_IS_REALTIME_INODE(ap->ip) &&
 		xfs_alloc_is_userdata(ap->datatype);
-	fb_agno = nullfb ? NULLAGNUMBER : XFS_FSB_TO_AGNO(mp, *ap->firstblock);
+	fb_agno = nullfb ? NULLAGNUMBER : XFS_FSB_TO_AGNO(mp,
+							ap->tp->t_firstblock);
 	/*
 	 * If allocating at eof, and there's a previous real block,
 	 * try to use its last block as our starting point.
@@ -3417,8 +3418,9 @@ xfs_bmap_btalloc(
 	}
 
 
-	nullfb = *ap->firstblock == NULLFSBLOCK;
-	fb_agno = nullfb ? NULLAGNUMBER : XFS_FSB_TO_AGNO(mp, *ap->firstblock);
+	nullfb = ap->tp->t_firstblock == NULLFSBLOCK;
+	fb_agno = nullfb ? NULLAGNUMBER : XFS_FSB_TO_AGNO(mp,
+							ap->tp->t_firstblock);
 	if (nullfb) {
 		if (xfs_alloc_is_userdata(ap->datatype) &&
 		    xfs_inode_is_filestream(ap->ip)) {
@@ -3429,7 +3431,7 @@ xfs_bmap_btalloc(
 			ap->blkno = XFS_INO_TO_FSB(mp, ap->ip->i_ino);
 		}
 	} else
-		ap->blkno = *ap->firstblock;
+		ap->blkno = ap->tp->t_firstblock;
 
 	xfs_bmap_adjacent(ap);
 
@@ -3440,7 +3442,7 @@ xfs_bmap_btalloc(
 	if (nullfb || XFS_FSB_TO_AGNO(mp, ap->blkno) == fb_agno)
 		;
 	else
-		ap->blkno = *ap->firstblock;
+		ap->blkno = ap->tp->t_firstblock;
 	/*
 	 * Normal allocation, done through xfs_alloc_vextent.
 	 */
@@ -3453,7 +3455,7 @@ xfs_bmap_btalloc(
 
 	/* Trim the allocation back to the maximum an AG can fit. */
 	args.maxlen = min(ap->length, mp->m_ag_max_usable);
-	args.firstblock = *ap->firstblock;
+	args.firstblock = ap->tp->t_firstblock;
 	blen = 0;
 	if (nullfb) {
 		/*
@@ -3602,13 +3604,13 @@ xfs_bmap_btalloc(
 		 * check the allocation happened at the same or higher AG than
 		 * the first block that was allocated.
 		 */
-		ASSERT(*ap->firstblock == NULLFSBLOCK ||
-		       XFS_FSB_TO_AGNO(mp, *ap->firstblock) <=
+		ASSERT(ap->tp->t_firstblock == NULLFSBLOCK ||
+		       XFS_FSB_TO_AGNO(mp, ap->tp->t_firstblock) <=
 		       XFS_FSB_TO_AGNO(mp, args.fsbno));
 
 		ap->blkno = args.fsbno;
-		if (*ap->firstblock == NULLFSBLOCK)
-			*ap->firstblock = args.fsbno;
+		if (ap->tp->t_firstblock == NULLFSBLOCK)
+			ap->tp->t_firstblock = args.fsbno;
 		ASSERT(nullfb || fb_agno <= args.agno);
 		ap->length = args.len;
 		/*
@@ -4065,12 +4067,12 @@ xfs_bmapi_allocate(
 		return error;
 
 	if (bma->cur)
-		bma->cur->bc_private.b.firstblock = *bma->firstblock;
+		bma->cur->bc_private.b.firstblock = bma->tp->t_firstblock;
 	if (bma->blkno == NULLFSBLOCK)
 		return 0;
 	if ((ifp->if_flags & XFS_IFBROOT) && !bma->cur) {
 		bma->cur = xfs_bmbt_init_cursor(mp, bma->tp, bma->ip, whichfork);
-		bma->cur->bc_private.b.firstblock = *bma->firstblock;
+		bma->cur->bc_private.b.firstblock = bma->tp->t_firstblock;
 	}
 	/*
 	 * Bump the number of extents we've allocated
@@ -4106,7 +4108,8 @@ xfs_bmapi_allocate(
 	else
 		error = xfs_bmap_add_extent_hole_real(bma->tp, bma->ip,
 				whichfork, &bma->icur, &bma->cur, &bma->got,
-				bma->firstblock, &bma->logflags, bma->flags);
+				&bma->tp->t_firstblock, &bma->logflags,
+				bma->flags);
 
 	bma->logflags |= tmp_logflags;
 	if (error)
@@ -4157,7 +4160,7 @@ xfs_bmapi_convert_unwritten(
 	if ((ifp->if_flags & XFS_IFBROOT) && !bma->cur) {
 		bma->cur = xfs_bmbt_init_cursor(bma->ip->i_mount, bma->tp,
 					bma->ip, whichfork);
-		bma->cur->bc_private.b.firstblock = *bma->firstblock;
+		bma->cur->bc_private.b.firstblock = bma->tp->t_firstblock;
 	}
 	mval->br_state = (mval->br_state == XFS_EXT_UNWRITTEN)
 				? XFS_EXT_NORM : XFS_EXT_UNWRITTEN;
@@ -4174,7 +4177,7 @@ xfs_bmapi_convert_unwritten(
 	}
 
 	error = xfs_bmap_add_extent_unwritten_real(bma->tp, bma->ip, whichfork,
-			&bma->icur, &bma->cur, mval, bma->firstblock,
+			&bma->icur, &bma->cur, mval, &bma->tp->t_firstblock,
 			&tmp_logflags);
 	/*
 	 * Log the inode core unconditionally in the unwritten extent conversion
@@ -4315,7 +4318,6 @@ xfs_bmapi_write(
 	bma.ip = ip;
 	bma.total = total;
 	bma.datatype = 0;
-	bma.firstblock = &tp->t_firstblock;
 	ASSERT(!tp || tp->t_dfops);
 
 	while (bno < end && n < *nmap) {
diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h
index fa839679ecb6..bbd641ae3261 100644
--- a/fs/xfs/libxfs/xfs_bmap.h
+++ b/fs/xfs/libxfs/xfs_bmap.h
@@ -19,7 +19,6 @@ extern kmem_zone_t	*xfs_bmap_free_item_zone;
  * Argument structure for xfs_bmap_alloc.
  */
 struct xfs_bmalloca {
-	xfs_fsblock_t		*firstblock; /* i/o first block allocated */
 	struct xfs_trans	*tp;	/* transaction pointer */
 	struct xfs_inode	*ip;	/* incore inode pointer */
 	struct xfs_bmbt_irec	prev;	/* extent before the new one */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 16/25] xfs: remove bmap extent add helper firstblock params
  2018-07-03 17:22 [PATCH 00/25] xfs: embed firstblock in xfs_trans Brian Foster
                   ` (14 preceding siblings ...)
  2018-07-03 17:23 ` [PATCH 15/25] xfs: remove xfs_bmalloca firstblock field Brian Foster
@ 2018-07-03 17:23 ` Brian Foster
  2018-07-04  0:52   ` Darrick J. Wong
  2018-07-03 17:23 ` [PATCH 17/25] xfs: remove bmap format helpers " Brian Foster
                   ` (9 subsequent siblings)
  25 siblings, 1 reply; 58+ messages in thread
From: Brian Foster @ 2018-07-03 17:23 UTC (permalink / raw)
  To: linux-xfs

The add extent helpers all receive firstblock via ->t_firstblock.
Drop the parameter and access it directly.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/libxfs/xfs_bmap.c | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index bd1273546b54..adc45a0941ff 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -2031,7 +2031,6 @@ xfs_bmap_add_extent_unwritten_real(
 	struct xfs_iext_cursor	*icur,
 	xfs_btree_cur_t		**curp,	/* if *curp is null, not a btree */
 	xfs_bmbt_irec_t		*new,	/* new data to add to file extents */
-	xfs_fsblock_t		*first,	/* pointer to firstblock variable */
 	int			*logflagsp) /* inode logging flags */
 {
 	xfs_btree_cur_t		*cur;	/* btree cursor */
@@ -2473,8 +2472,8 @@ xfs_bmap_add_extent_unwritten_real(
 		int	tmp_logflags;	/* partial log flag return val */
 
 		ASSERT(cur == NULL);
-		error = xfs_bmap_extents_to_btree(tp, ip, first, &cur, 0,
-				&tmp_logflags, whichfork);
+		error = xfs_bmap_extents_to_btree(tp, ip, &tp->t_firstblock,
+				&cur, 0, &tmp_logflags, whichfork);
 		*logflagsp |= tmp_logflags;
 		if (error)
 			goto done;
@@ -2645,7 +2644,6 @@ xfs_bmap_add_extent_hole_real(
 	struct xfs_iext_cursor	*icur,
 	struct xfs_btree_cur	**curp,
 	struct xfs_bmbt_irec	*new,
-	xfs_fsblock_t		*first,
 	int			*logflagsp,
 	int			flags)
 {
@@ -2837,8 +2835,8 @@ xfs_bmap_add_extent_hole_real(
 		int	tmp_logflags;	/* partial log flag return val */
 
 		ASSERT(cur == NULL);
-		error = xfs_bmap_extents_to_btree(tp, ip, first, curp, 0,
-				&tmp_logflags, whichfork);
+		error = xfs_bmap_extents_to_btree(tp, ip, &tp->t_firstblock,
+				curp, 0, &tmp_logflags, whichfork);
 		*logflagsp |= tmp_logflags;
 		cur = *curp;
 		if (error)
@@ -4108,8 +4106,7 @@ xfs_bmapi_allocate(
 	else
 		error = xfs_bmap_add_extent_hole_real(bma->tp, bma->ip,
 				whichfork, &bma->icur, &bma->cur, &bma->got,
-				&bma->tp->t_firstblock, &bma->logflags,
-				bma->flags);
+				&bma->logflags, bma->flags);
 
 	bma->logflags |= tmp_logflags;
 	if (error)
@@ -4177,8 +4174,7 @@ xfs_bmapi_convert_unwritten(
 	}
 
 	error = xfs_bmap_add_extent_unwritten_real(bma->tp, bma->ip, whichfork,
-			&bma->icur, &bma->cur, mval, &bma->tp->t_firstblock,
-			&tmp_logflags);
+			&bma->icur, &bma->cur, mval, &tmp_logflags);
 	/*
 	 * Log the inode core unconditionally in the unwritten extent conversion
 	 * path because the conversion might not have done so (e.g., if the
@@ -4552,7 +4548,7 @@ xfs_bmapi_remap(
 		got.br_state = XFS_EXT_NORM;
 
 	error = xfs_bmap_add_extent_hole_real(tp, ip, whichfork, &icur,
-			&cur, &got, &tp->t_firstblock, &logflags, flags);
+			&cur, &got, &logflags, flags);
 	if (error)
 		goto error0;
 
@@ -5316,7 +5312,7 @@ __xfs_bunmapi(
 			del.br_state = XFS_EXT_UNWRITTEN;
 			error = xfs_bmap_add_extent_unwritten_real(tp, ip,
 					whichfork, &icur, &cur, &del,
-					&tp->t_firstblock, &logflags);
+					&logflags);
 			if (error)
 				goto error0;
 			goto nodelete;
@@ -5373,8 +5369,7 @@ __xfs_bunmapi(
 				prev.br_state = XFS_EXT_UNWRITTEN;
 				error = xfs_bmap_add_extent_unwritten_real(tp,
 						ip, whichfork, &icur, &cur,
-						&prev, &tp->t_firstblock,
-						&logflags);
+						&prev, &logflags);
 				if (error)
 					goto error0;
 				goto nodelete;
@@ -5383,8 +5378,7 @@ __xfs_bunmapi(
 				del.br_state = XFS_EXT_UNWRITTEN;
 				error = xfs_bmap_add_extent_unwritten_real(tp,
 						ip, whichfork, &icur, &cur,
-						&del, &tp->t_firstblock,
-						&logflags);
+						&del, &logflags);
 				if (error)
 					goto error0;
 				goto nodelete;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 17/25] xfs: remove bmap format helpers firstblock params
  2018-07-03 17:22 [PATCH 00/25] xfs: embed firstblock in xfs_trans Brian Foster
                   ` (15 preceding siblings ...)
  2018-07-03 17:23 ` [PATCH 16/25] xfs: remove bmap extent add helper firstblock params Brian Foster
@ 2018-07-03 17:23 ` Brian Foster
  2018-07-04  0:53   ` Darrick J. Wong
  2018-07-03 17:23 ` [PATCH 18/25] xfs: remove xfs_btree_cur private firstblock field Brian Foster
                   ` (8 subsequent siblings)
  25 siblings, 1 reply; 58+ messages in thread
From: Brian Foster @ 2018-07-03 17:23 UTC (permalink / raw)
  To: linux-xfs

The bmap format helpers receive firstblock via ->t_firstblock. Drop
the param and access it directly.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/libxfs/xfs_bmap.c | 63 ++++++++++++++++++----------------------
 1 file changed, 29 insertions(+), 34 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index adc45a0941ff..016712434aa5 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -646,7 +646,6 @@ STATIC int					/* error */
 xfs_bmap_extents_to_btree(
 	struct xfs_trans	*tp,		/* transaction pointer */
 	struct xfs_inode	*ip,		/* incore inode pointer */
-	xfs_fsblock_t		*firstblock,	/* first-block-allocated */
 	struct xfs_btree_cur	**curp,		/* cursor returned to caller */
 	int			wasdel,		/* converting a delayed alloc */
 	int			*logflagsp,	/* inode logging flags */
@@ -689,7 +688,7 @@ xfs_bmap_extents_to_btree(
 	 * Need a cursor.  Can't allocate until bb_level is filled in.
 	 */
 	cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
-	cur->bc_private.b.firstblock = *firstblock;
+	cur->bc_private.b.firstblock = tp->t_firstblock;
 	cur->bc_private.b.flags = wasdel ? XFS_BTCUR_BPRV_WASDEL : 0;
 	/*
 	 * Convert to a btree with two levels, one record in root.
@@ -699,16 +698,16 @@ xfs_bmap_extents_to_btree(
 	args.tp = tp;
 	args.mp = mp;
 	xfs_rmap_ino_bmbt_owner(&args.oinfo, ip->i_ino, whichfork);
-	args.firstblock = *firstblock;
-	if (*firstblock == NULLFSBLOCK) {
+	args.firstblock = tp->t_firstblock;
+	if (tp->t_firstblock == NULLFSBLOCK) {
 		args.type = XFS_ALLOCTYPE_START_BNO;
 		args.fsbno = XFS_INO_TO_FSB(mp, ip->i_ino);
 	} else if (tp->t_dfops->dop_low) {
 		args.type = XFS_ALLOCTYPE_START_BNO;
-		args.fsbno = *firstblock;
+		args.fsbno = tp->t_firstblock;
 	} else {
 		args.type = XFS_ALLOCTYPE_NEAR_BNO;
-		args.fsbno = *firstblock;
+		args.fsbno = tp->t_firstblock;
 	}
 	args.minlen = args.maxlen = args.prod = 1;
 	args.wasdel = wasdel;
@@ -731,9 +730,9 @@ xfs_bmap_extents_to_btree(
 	/*
 	 * Allocation can't fail, the space was reserved.
 	 */
-	ASSERT(*firstblock == NULLFSBLOCK ||
-	       args.agno >= XFS_FSB_TO_AGNO(mp, *firstblock));
-	*firstblock = cur->bc_private.b.firstblock = args.fsbno;
+	ASSERT(tp->t_firstblock == NULLFSBLOCK ||
+	       args.agno >= XFS_FSB_TO_AGNO(mp, tp->t_firstblock));
+	tp->t_firstblock = cur->bc_private.b.firstblock = args.fsbno;
 	cur->bc_private.b.allocated++;
 	ip->i_d.di_nblocks++;
 	xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, 1L);
@@ -810,7 +809,6 @@ STATIC int				/* error */
 xfs_bmap_local_to_extents(
 	xfs_trans_t	*tp,		/* transaction pointer */
 	xfs_inode_t	*ip,		/* incore inode pointer */
-	xfs_fsblock_t	*firstblock,	/* first block allocated in xaction */
 	xfs_extlen_t	total,		/* total blocks needed by transaction */
 	int		*logflagsp,	/* inode logging flags */
 	int		whichfork,
@@ -848,16 +846,16 @@ xfs_bmap_local_to_extents(
 	args.tp = tp;
 	args.mp = ip->i_mount;
 	xfs_rmap_ino_owner(&args.oinfo, ip->i_ino, whichfork, 0);
-	args.firstblock = *firstblock;
+	args.firstblock = tp->t_firstblock;
 	/*
 	 * Allocate a block.  We know we need only one, since the
 	 * file currently fits in an inode.
 	 */
-	if (*firstblock == NULLFSBLOCK) {
+	if (tp->t_firstblock == NULLFSBLOCK) {
 		args.fsbno = XFS_INO_TO_FSB(args.mp, ip->i_ino);
 		args.type = XFS_ALLOCTYPE_START_BNO;
 	} else {
-		args.fsbno = *firstblock;
+		args.fsbno = tp->t_firstblock;
 		args.type = XFS_ALLOCTYPE_NEAR_BNO;
 	}
 	args.total = total;
@@ -869,7 +867,7 @@ xfs_bmap_local_to_extents(
 	/* Can't fail, the space was reserved. */
 	ASSERT(args.fsbno != NULLFSBLOCK);
 	ASSERT(args.len == 1);
-	*firstblock = args.fsbno;
+	tp->t_firstblock = args.fsbno;
 	bp = xfs_btree_get_bufl(args.mp, tp, args.fsbno, 0);
 
 	/*
@@ -964,8 +962,8 @@ xfs_bmap_add_attrfork_extents(
 	if (ip->i_d.di_nextents * sizeof(xfs_bmbt_rec_t) <= XFS_IFORK_DSIZE(ip))
 		return 0;
 	cur = NULL;
-	error = xfs_bmap_extents_to_btree(tp, ip, &tp->t_firstblock, &cur, 0,
-					  flags, XFS_DATA_FORK);
+	error = xfs_bmap_extents_to_btree(tp, ip, &cur, 0, flags,
+					  XFS_DATA_FORK);
 	if (cur) {
 		cur->bc_private.b.allocated = 0;
 		xfs_btree_del_cursor(cur,
@@ -1007,8 +1005,8 @@ xfs_bmap_add_attrfork_local(
 	}
 
 	if (S_ISLNK(VFS_I(ip)->i_mode))
-		return xfs_bmap_local_to_extents(tp, ip, &tp->t_firstblock, 1,
-						 flags, XFS_DATA_FORK,
+		return xfs_bmap_local_to_extents(tp, ip, 1, flags,
+						 XFS_DATA_FORK,
 						 xfs_symlink_local_to_remote);
 
 	/* should only be called for types that support local format data */
@@ -1794,8 +1792,7 @@ xfs_bmap_add_extent_delay_real(
 
 		if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
 			error = xfs_bmap_extents_to_btree(bma->tp, bma->ip,
-					&bma->tp->t_firstblock, &bma->cur, 1,
-					&tmp_rval, whichfork);
+					&bma->cur, 1, &tmp_rval, whichfork);
 			rval |= tmp_rval;
 			if (error)
 				goto done;
@@ -1872,8 +1869,7 @@ xfs_bmap_add_extent_delay_real(
 
 		if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
 			error = xfs_bmap_extents_to_btree(bma->tp, bma->ip,
-				&bma->tp->t_firstblock, &bma->cur, 1, &tmp_rval,
-				whichfork);
+				&bma->cur, 1, &tmp_rval, whichfork);
 			rval |= tmp_rval;
 			if (error)
 				goto done;
@@ -1953,8 +1949,7 @@ xfs_bmap_add_extent_delay_real(
 
 		if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
 			error = xfs_bmap_extents_to_btree(bma->tp, bma->ip,
-					&bma->tp->t_firstblock, &bma->cur, 1,
-					&tmp_rval, whichfork);
+					&bma->cur, 1, &tmp_rval, whichfork);
 			rval |= tmp_rval;
 			if (error)
 				goto done;
@@ -1991,8 +1986,8 @@ xfs_bmap_add_extent_delay_real(
 
 		ASSERT(bma->cur == NULL);
 		error = xfs_bmap_extents_to_btree(bma->tp, bma->ip,
-				&bma->tp->t_firstblock, &bma->cur, da_old > 0,
-				&tmp_logflags, whichfork);
+				&bma->cur, da_old > 0, &tmp_logflags,
+				whichfork);
 		bma->logflags |= tmp_logflags;
 		if (error)
 			goto done;
@@ -2472,8 +2467,8 @@ xfs_bmap_add_extent_unwritten_real(
 		int	tmp_logflags;	/* partial log flag return val */
 
 		ASSERT(cur == NULL);
-		error = xfs_bmap_extents_to_btree(tp, ip, &tp->t_firstblock,
-				&cur, 0, &tmp_logflags, whichfork);
+		error = xfs_bmap_extents_to_btree(tp, ip, &cur, 0,
+				&tmp_logflags, whichfork);
 		*logflagsp |= tmp_logflags;
 		if (error)
 			goto done;
@@ -2835,8 +2830,8 @@ xfs_bmap_add_extent_hole_real(
 		int	tmp_logflags;	/* partial log flag return val */
 
 		ASSERT(cur == NULL);
-		error = xfs_bmap_extents_to_btree(tp, ip, &tp->t_firstblock,
-				curp, 0, &tmp_logflags, whichfork);
+		error = xfs_bmap_extents_to_btree(tp, ip, curp, 0,
+				&tmp_logflags, whichfork);
 		*logflagsp |= tmp_logflags;
 		cur = *curp;
 		if (error)
@@ -5425,8 +5420,8 @@ __xfs_bunmapi(
 	 */
 	if (xfs_bmap_needs_btree(ip, whichfork)) {
 		ASSERT(cur == NULL);
-		error = xfs_bmap_extents_to_btree(tp, ip, &tp->t_firstblock,
-				&cur, 0, &tmp_logflags, whichfork);
+		error = xfs_bmap_extents_to_btree(tp, ip, &cur, 0,
+				&tmp_logflags, whichfork);
 		logflags |= tmp_logflags;
 		if (error)
 			goto error0;
@@ -5969,8 +5964,8 @@ xfs_bmap_split_extent_at(
 		int tmp_logflags; /* partial log flag return val */
 
 		ASSERT(cur == NULL);
-		error = xfs_bmap_extents_to_btree(tp, ip, &tp->t_firstblock,
-				&cur, 0, &tmp_logflags, whichfork);
+		error = xfs_bmap_extents_to_btree(tp, ip, &cur, 0,
+				&tmp_logflags, whichfork);
 		logflags |= tmp_logflags;
 	}
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 18/25] xfs: remove xfs_btree_cur private firstblock field
  2018-07-03 17:22 [PATCH 00/25] xfs: embed firstblock in xfs_trans Brian Foster
                   ` (16 preceding siblings ...)
  2018-07-03 17:23 ` [PATCH 17/25] xfs: remove bmap format helpers " Brian Foster
@ 2018-07-03 17:23 ` Brian Foster
  2018-07-04  0:54   ` Darrick J. Wong
  2018-07-03 17:23 ` [PATCH 19/25] xfs: remove xfs_alloc_arg " Brian Foster
                   ` (7 subsequent siblings)
  25 siblings, 1 reply; 58+ messages in thread
From: Brian Foster @ 2018-07-03 17:23 UTC (permalink / raw)
  To: linux-xfs

The bmbt cursor private structure has a firstblock field that is
used to maintain locking order on bmbt allocations. The field holds
an actual firstblock value (as opposed to a pointer), so it is
initialized on cursor creation, updated on allocation and then the
value is transferred back to the source before the cursor is
destroyed.

This value is always transferred from and back to the ->t_firstblock
field. Since xfs_btree_cur already carries a reference to the
transaction, we can remove this field from xfs_btree_cur and the
associated copying. The bmbt allocations will update the value in
the transaction directly.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/libxfs/xfs_bmap.c       | 28 +++-------------------------
 fs/xfs/libxfs/xfs_bmap_btree.c | 10 ++++------
 fs/xfs/libxfs/xfs_btree.h      |  1 -
 3 files changed, 7 insertions(+), 32 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 016712434aa5..c83add15233b 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -688,7 +688,6 @@ xfs_bmap_extents_to_btree(
 	 * Need a cursor.  Can't allocate until bb_level is filled in.
 	 */
 	cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
-	cur->bc_private.b.firstblock = tp->t_firstblock;
 	cur->bc_private.b.flags = wasdel ? XFS_BTCUR_BPRV_WASDEL : 0;
 	/*
 	 * Convert to a btree with two levels, one record in root.
@@ -732,7 +731,7 @@ xfs_bmap_extents_to_btree(
 	 */
 	ASSERT(tp->t_firstblock == NULLFSBLOCK ||
 	       args.agno >= XFS_FSB_TO_AGNO(mp, tp->t_firstblock));
-	tp->t_firstblock = cur->bc_private.b.firstblock = args.fsbno;
+	tp->t_firstblock = args.fsbno;
 	cur->bc_private.b.allocated++;
 	ip->i_d.di_nblocks++;
 	xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, 1L);
@@ -925,7 +924,6 @@ xfs_bmap_add_attrfork_btree(
 		*flags |= XFS_ILOG_DBROOT;
 	else {
 		cur = xfs_bmbt_init_cursor(mp, tp, ip, XFS_DATA_FORK);
-		cur->bc_private.b.firstblock = tp->t_firstblock;
 		error = xfs_bmbt_lookup_first(cur, &stat);
 		if (error)
 			goto error0;
@@ -937,7 +935,6 @@ xfs_bmap_add_attrfork_btree(
 			xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);
 			return -ENOSPC;
 		}
-		tp->t_firstblock = cur->bc_private.b.firstblock;
 		cur->bc_private.b.allocated = 0;
 		xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);
 	}
@@ -4059,14 +4056,10 @@ xfs_bmapi_allocate(
 	if (error)
 		return error;
 
-	if (bma->cur)
-		bma->cur->bc_private.b.firstblock = bma->tp->t_firstblock;
 	if (bma->blkno == NULLFSBLOCK)
 		return 0;
-	if ((ifp->if_flags & XFS_IFBROOT) && !bma->cur) {
+	if ((ifp->if_flags & XFS_IFBROOT) && !bma->cur)
 		bma->cur = xfs_bmbt_init_cursor(mp, bma->tp, bma->ip, whichfork);
-		bma->cur->bc_private.b.firstblock = bma->tp->t_firstblock;
-	}
 	/*
 	 * Bump the number of extents we've allocated
 	 * in this call.
@@ -4152,7 +4145,6 @@ xfs_bmapi_convert_unwritten(
 	if ((ifp->if_flags & XFS_IFBROOT) && !bma->cur) {
 		bma->cur = xfs_bmbt_init_cursor(bma->ip->i_mount, bma->tp,
 					bma->ip, whichfork);
-		bma->cur->bc_private.b.firstblock = bma->tp->t_firstblock;
 	}
 	mval->br_state = (mval->br_state == XFS_EXT_UNWRITTEN)
 				? XFS_EXT_NORM : XFS_EXT_UNWRITTEN;
@@ -4460,13 +4452,6 @@ xfs_bmapi_write(
 		xfs_trans_log_inode(tp, ip, bma.logflags);
 
 	if (bma.cur) {
-		if (!error) {
-			ASSERT(tp->t_firstblock == NULLFSBLOCK ||
-			       XFS_FSB_TO_AGNO(mp, tp->t_firstblock) <=
-			       XFS_FSB_TO_AGNO(mp,
-				       bma.cur->bc_private.b.firstblock));
-			tp->t_firstblock = bma.cur->bc_private.b.firstblock;
-		}
 		xfs_btree_del_cursor(bma.cur,
 			error ? XFS_BTREE_ERROR : XFS_BTREE_NOERROR);
 	}
@@ -4530,7 +4515,6 @@ xfs_bmapi_remap(
 
 	if (ifp->if_flags & XFS_IFBROOT) {
 		cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
-		cur->bc_private.b.firstblock = tp->t_firstblock;
 		cur->bc_private.b.flags = 0;
 	}
 
@@ -5191,7 +5175,6 @@ __xfs_bunmapi(
 	if (ifp->if_flags & XFS_IFBROOT) {
 		ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE);
 		cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
-		cur->bc_private.b.firstblock = tp->t_firstblock;
 		cur->bc_private.b.flags = 0;
 	} else
 		cur = NULL;
@@ -5459,10 +5442,8 @@ __xfs_bunmapi(
 	if (logflags)
 		xfs_trans_log_inode(tp, ip, logflags);
 	if (cur) {
-		if (!error) {
-			tp->t_firstblock = cur->bc_private.b.firstblock;
+		if (!error)
 			cur->bc_private.b.allocated = 0;
-		}
 		xfs_btree_del_cursor(cur,
 			error ? XFS_BTREE_ERROR : XFS_BTREE_NOERROR);
 	}
@@ -5678,7 +5659,6 @@ xfs_bmap_collapse_extents(
 
 	if (ifp->if_flags & XFS_IFBROOT) {
 		cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
-		cur->bc_private.b.firstblock = tp->t_firstblock;
 		cur->bc_private.b.flags = 0;
 	}
 
@@ -5798,7 +5778,6 @@ xfs_bmap_insert_extents(
 
 	if (ifp->if_flags & XFS_IFBROOT) {
 		cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
-		cur->bc_private.b.firstblock = tp->t_firstblock;
 		cur->bc_private.b.flags = 0;
 	}
 
@@ -5920,7 +5899,6 @@ xfs_bmap_split_extent_at(
 
 	if (ifp->if_flags & XFS_IFBROOT) {
 		cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
-		cur->bc_private.b.firstblock = tp->t_firstblock;
 		cur->bc_private.b.flags = 0;
 		error = xfs_bmbt_lookup_eq(cur, &got, &i);
 		if (error)
diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c
index e8b01af09db5..8a9b98b11e34 100644
--- a/fs/xfs/libxfs/xfs_bmap_btree.c
+++ b/fs/xfs/libxfs/xfs_bmap_btree.c
@@ -175,7 +175,6 @@ xfs_bmbt_dup_cursor(
 	 * Copy the firstblock, dfops, and flags values,
 	 * since init cursor doesn't get them.
 	 */
-	new->bc_private.b.firstblock = cur->bc_private.b.firstblock;
 	new->bc_private.b.flags = cur->bc_private.b.flags;
 
 	return new;
@@ -186,11 +185,11 @@ xfs_bmbt_update_cursor(
 	struct xfs_btree_cur	*src,
 	struct xfs_btree_cur	*dst)
 {
-	ASSERT((dst->bc_private.b.firstblock != NULLFSBLOCK) ||
+	ASSERT((dst->bc_tp->t_firstblock != NULLFSBLOCK) ||
 	       (dst->bc_private.b.ip->i_d.di_flags & XFS_DIFLAG_REALTIME));
 
 	dst->bc_private.b.allocated += src->bc_private.b.allocated;
-	dst->bc_private.b.firstblock = src->bc_private.b.firstblock;
+	dst->bc_tp->t_firstblock = src->bc_tp->t_firstblock;
 
 	src->bc_private.b.allocated = 0;
 }
@@ -208,7 +207,7 @@ xfs_bmbt_alloc_block(
 	memset(&args, 0, sizeof(args));
 	args.tp = cur->bc_tp;
 	args.mp = cur->bc_mp;
-	args.fsbno = cur->bc_private.b.firstblock;
+	args.fsbno = cur->bc_tp->t_firstblock;
 	args.firstblock = args.fsbno;
 	xfs_rmap_ino_bmbt_owner(&args.oinfo, cur->bc_private.b.ip->i_ino,
 			cur->bc_private.b.whichfork);
@@ -263,7 +262,7 @@ xfs_bmbt_alloc_block(
 	}
 
 	ASSERT(args.len == 1);
-	cur->bc_private.b.firstblock = args.fsbno;
+	cur->bc_tp->t_firstblock = args.fsbno;
 	cur->bc_private.b.allocated++;
 	cur->bc_private.b.ip->i_d.di_nblocks++;
 	xfs_trans_log_inode(args.tp, cur->bc_private.b.ip, XFS_ILOG_CORE);
@@ -562,7 +561,6 @@ xfs_bmbt_init_cursor(
 
 	cur->bc_private.b.forksize = XFS_IFORK_SIZE(ip, whichfork);
 	cur->bc_private.b.ip = ip;
-	cur->bc_private.b.firstblock = NULLFSBLOCK;
 	cur->bc_private.b.allocated = 0;
 	cur->bc_private.b.flags = 0;
 	cur->bc_private.b.whichfork = whichfork;
diff --git a/fs/xfs/libxfs/xfs_btree.h b/fs/xfs/libxfs/xfs_btree.h
index b986a8fc8d40..503615f4d729 100644
--- a/fs/xfs/libxfs/xfs_btree.h
+++ b/fs/xfs/libxfs/xfs_btree.h
@@ -214,7 +214,6 @@ typedef struct xfs_btree_cur
 		} a;
 		struct {			/* needed for BMAP */
 			struct xfs_inode *ip;	/* pointer to our inode */
-			xfs_fsblock_t	firstblock;	/* 1st blk allocated */
 			int		allocated;	/* count of alloced */
 			short		forksize;	/* fork's inode space */
 			char		whichfork;	/* data or attr fork */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 19/25] xfs: remove xfs_alloc_arg firstblock field
  2018-07-03 17:22 [PATCH 00/25] xfs: embed firstblock in xfs_trans Brian Foster
                   ` (17 preceding siblings ...)
  2018-07-03 17:23 ` [PATCH 18/25] xfs: remove xfs_btree_cur private firstblock field Brian Foster
@ 2018-07-03 17:23 ` Brian Foster
  2018-07-04  0:54   ` Darrick J. Wong
  2018-07-03 17:23 ` [PATCH 20/25] xfs: use ->t_firstblock in dq alloc Brian Foster
                   ` (6 subsequent siblings)
  25 siblings, 1 reply; 58+ messages in thread
From: Brian Foster @ 2018-07-03 17:23 UTC (permalink / raw)
  To: linux-xfs

The xfs_alloc_arg.firstblock field is used to control the starting
agno for an allocation. The structure already carries a pointer to
the transaction, which carries the current firstblock value.

Remove the field and access ->t_firstblock directly in the
allocation code.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/libxfs/xfs_alloc.c          | 20 ++++++++++----------
 fs/xfs/libxfs/xfs_alloc.h          |  1 -
 fs/xfs/libxfs/xfs_bmap.c           |  3 ---
 fs/xfs/libxfs/xfs_bmap_btree.c     |  1 -
 fs/xfs/libxfs/xfs_refcount_btree.c |  1 -
 fs/xfs/xfs_trace.h                 |  2 +-
 6 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index 5b1607d76fe9..bd6d8aeea825 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -2783,16 +2783,16 @@ xfs_alloc_read_agf(
  */
 int				/* error */
 xfs_alloc_vextent(
-	xfs_alloc_arg_t	*args)	/* allocation argument structure */
+	struct xfs_alloc_arg	*args)	/* allocation argument structure */
 {
-	xfs_agblock_t	agsize;	/* allocation group size */
-	int		error;
-	int		flags;	/* XFS_ALLOC_FLAG_... locking flags */
-	xfs_mount_t	*mp;	/* mount structure pointer */
-	xfs_agnumber_t	sagno;	/* starting allocation group number */
-	xfs_alloctype_t	type;	/* input allocation type */
-	int		bump_rotor = 0;
-	xfs_agnumber_t	rotorstep = xfs_rotorstep; /* inode32 agf stepper */
+	xfs_agblock_t		agsize;	/* allocation group size */
+	int			error;
+	int			flags;	/* XFS_ALLOC_FLAG_... locking flags */
+	struct xfs_mount	*mp;	/* mount structure pointer */
+	xfs_agnumber_t		sagno;	/* starting allocation group number */
+	xfs_alloctype_t		type;	/* input allocation type */
+	int			bump_rotor = 0;
+	xfs_agnumber_t		rotorstep = xfs_rotorstep; /* inode32 agf stepper */
 
 	mp = args->mp;
 	type = args->otype = args->type;
@@ -2913,7 +2913,7 @@ xfs_alloc_vextent(
 			* locking of AGF, which might cause deadlock.
 			*/
 			if (++(args->agno) == mp->m_sb.sb_agcount) {
-				if (args->firstblock != NULLFSBLOCK)
+				if (args->tp->t_firstblock != NULLFSBLOCK)
 					args->agno = sagno;
 				else
 					args->agno = 0;
diff --git a/fs/xfs/libxfs/xfs_alloc.h b/fs/xfs/libxfs/xfs_alloc.h
index e716c993ac4c..00cd5ec4cb6b 100644
--- a/fs/xfs/libxfs/xfs_alloc.h
+++ b/fs/xfs/libxfs/xfs_alloc.h
@@ -74,7 +74,6 @@ typedef struct xfs_alloc_arg {
 	int		datatype;	/* mask defining data type treatment */
 	char		wasdel;		/* set if allocation was prev delayed */
 	char		wasfromfl;	/* set if allocation is from freelist */
-	xfs_fsblock_t	firstblock;	/* io first block allocated */
 	struct xfs_owner_info	oinfo;	/* owner of blocks being allocated */
 	enum xfs_ag_resv_type	resv;	/* block reservation to use */
 } xfs_alloc_arg_t;
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index c83add15233b..1955b8410410 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -697,7 +697,6 @@ xfs_bmap_extents_to_btree(
 	args.tp = tp;
 	args.mp = mp;
 	xfs_rmap_ino_bmbt_owner(&args.oinfo, ip->i_ino, whichfork);
-	args.firstblock = tp->t_firstblock;
 	if (tp->t_firstblock == NULLFSBLOCK) {
 		args.type = XFS_ALLOCTYPE_START_BNO;
 		args.fsbno = XFS_INO_TO_FSB(mp, ip->i_ino);
@@ -845,7 +844,6 @@ xfs_bmap_local_to_extents(
 	args.tp = tp;
 	args.mp = ip->i_mount;
 	xfs_rmap_ino_owner(&args.oinfo, ip->i_ino, whichfork, 0);
-	args.firstblock = tp->t_firstblock;
 	/*
 	 * Allocate a block.  We know we need only one, since the
 	 * file currently fits in an inode.
@@ -3445,7 +3443,6 @@ xfs_bmap_btalloc(
 
 	/* Trim the allocation back to the maximum an AG can fit. */
 	args.maxlen = min(ap->length, mp->m_ag_max_usable);
-	args.firstblock = ap->tp->t_firstblock;
 	blen = 0;
 	if (nullfb) {
 		/*
diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c
index 8a9b98b11e34..628ed82ca286 100644
--- a/fs/xfs/libxfs/xfs_bmap_btree.c
+++ b/fs/xfs/libxfs/xfs_bmap_btree.c
@@ -208,7 +208,6 @@ xfs_bmbt_alloc_block(
 	args.tp = cur->bc_tp;
 	args.mp = cur->bc_mp;
 	args.fsbno = cur->bc_tp->t_firstblock;
-	args.firstblock = args.fsbno;
 	xfs_rmap_ino_bmbt_owner(&args.oinfo, cur->bc_private.b.ip->i_ino,
 			cur->bc_private.b.whichfork);
 
diff --git a/fs/xfs/libxfs/xfs_refcount_btree.c b/fs/xfs/libxfs/xfs_refcount_btree.c
index 393aa88f93db..26d2300ed865 100644
--- a/fs/xfs/libxfs/xfs_refcount_btree.c
+++ b/fs/xfs/libxfs/xfs_refcount_btree.c
@@ -70,7 +70,6 @@ xfs_refcountbt_alloc_block(
 	args.type = XFS_ALLOCTYPE_NEAR_BNO;
 	args.fsbno = XFS_AGB_TO_FSB(cur->bc_mp, cur->bc_private.a.agno,
 			xfs_refc_block(args.mp));
-	args.firstblock = args.fsbno;
 	xfs_rmap_ag_owner(&args.oinfo, XFS_RMAP_OWN_REFC);
 	args.minlen = args.maxlen = args.prod = 1;
 	args.resv = XFS_AG_RESV_METADATA;
diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
index 972d45d28097..392e026bea79 100644
--- a/fs/xfs/xfs_trace.h
+++ b/fs/xfs/xfs_trace.h
@@ -1604,7 +1604,7 @@ DECLARE_EVENT_CLASS(xfs_alloc_class,
 		__entry->wasfromfl = args->wasfromfl;
 		__entry->resv = args->resv;
 		__entry->datatype = args->datatype;
-		__entry->firstblock = args->firstblock;
+		__entry->firstblock = args->tp->t_firstblock;
 	),
 	TP_printk("dev %d:%d agno %u agbno %u minlen %u maxlen %u mod %u "
 		  "prod %u minleft %u total %u alignment %u minalignslop %u "
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 20/25] xfs: use ->t_firstblock in dq alloc
  2018-07-03 17:22 [PATCH 00/25] xfs: embed firstblock in xfs_trans Brian Foster
                   ` (18 preceding siblings ...)
  2018-07-03 17:23 ` [PATCH 19/25] xfs: remove xfs_alloc_arg " Brian Foster
@ 2018-07-03 17:23 ` Brian Foster
  2018-07-04  0:54   ` Darrick J. Wong
  2018-07-03 17:23 ` [PATCH 21/25] xfs: replace no-op firstblock init with ->t_firstblock Brian Foster
                   ` (5 subsequent siblings)
  25 siblings, 1 reply; 58+ messages in thread
From: Brian Foster @ 2018-07-03 17:23 UTC (permalink / raw)
  To: linux-xfs

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/xfs_dquot.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index 84359eeb20f4..3b61b4d266b4 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -540,14 +540,13 @@ xfs_qm_dqread_alloc(
 	struct xfs_trans	*tp;
 	struct xfs_defer_ops	dfops;
 	struct xfs_buf		*bp;
-	xfs_fsblock_t		firstblock;
 	int			error;
 
 	error = xfs_trans_alloc(mp, &M_RES(mp)->tr_qm_dqalloc,
 			XFS_QM_DQALLOC_SPACE_RES(mp), 0, 0, &tp);
 	if (error)
 		goto err;
-	xfs_defer_init(tp, &dfops, &firstblock);
+	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
 
 	error = xfs_dquot_disk_alloc(&tp, dqp, &bp);
 	if (error)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 21/25] xfs: replace no-op firstblock init with ->t_firstblock
  2018-07-03 17:22 [PATCH 00/25] xfs: embed firstblock in xfs_trans Brian Foster
                   ` (19 preceding siblings ...)
  2018-07-03 17:23 ` [PATCH 20/25] xfs: use ->t_firstblock in dq alloc Brian Foster
@ 2018-07-03 17:23 ` Brian Foster
  2018-07-04  0:54   ` Darrick J. Wong
  2018-07-03 17:23 ` [PATCH 22/25] xfs: use ->t_firstblock in reflink cow block cancel Brian Foster
                   ` (4 subsequent siblings)
  25 siblings, 1 reply; 58+ messages in thread
From: Brian Foster @ 2018-07-03 17:23 UTC (permalink / raw)
  To: linux-xfs

xfs_refcount_recover_cow_leftovers() has no need for a firstblock
variable and so passes an unrelated xfs_fsblock_t to
xfs_defer_init() to avoid declaring one. Replace this no-op
initialization with ->t_firstblock. This will be optimized away by
the removal of the xfs_defer_init() firstblock param.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/libxfs/xfs_refcount.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c
index 8dc380574cd8..d81c17aac710 100644
--- a/fs/xfs/libxfs/xfs_refcount.c
+++ b/fs/xfs/libxfs/xfs_refcount.c
@@ -1691,7 +1691,7 @@ xfs_refcount_recover_cow_leftovers(
 		trace_xfs_refcount_recover_extent(mp, agno, &rr->rr_rrec);
 
 		/* Free the orphan record */
-		xfs_defer_init(tp, &dfops, &fsb);
+		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
 		agbno = rr->rr_rrec.rc_startblock - XFS_REFC_COW_START;
 		fsb = XFS_AGB_TO_FSB(mp, agno, agbno);
 		error = xfs_refcount_free_cow_extent(mp, tp->t_dfops, fsb,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 22/25] xfs: use ->t_firstblock in reflink cow block cancel
  2018-07-03 17:22 [PATCH 00/25] xfs: embed firstblock in xfs_trans Brian Foster
                   ` (20 preceding siblings ...)
  2018-07-03 17:23 ` [PATCH 21/25] xfs: replace no-op firstblock init with ->t_firstblock Brian Foster
@ 2018-07-03 17:23 ` Brian Foster
  2018-07-04  0:55   ` Darrick J. Wong
  2018-07-03 17:23 ` [PATCH 23/25] xfs: use ->t_firstblock in extent swap Brian Foster
                   ` (3 subsequent siblings)
  25 siblings, 1 reply; 58+ messages in thread
From: Brian Foster @ 2018-07-03 17:23 UTC (permalink / raw)
  To: linux-xfs

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/xfs_reflink.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index cf6080d42273..d509bd7fa822 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -546,7 +546,6 @@ xfs_reflink_cancel_cow_blocks(
 	struct xfs_ifork		*ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK);
 	struct xfs_bmbt_irec		got, del;
 	struct xfs_iext_cursor		icur;
-	xfs_fsblock_t			firstfsb;
 	struct xfs_defer_ops		dfops;
 	struct xfs_defer_ops		*odfops = (*tpp)->t_dfops;
 	int				error = 0;
@@ -575,7 +574,7 @@ xfs_reflink_cancel_cow_blocks(
 			if (error)
 				break;
 		} else if (del.br_state == XFS_EXT_UNWRITTEN || cancel_real) {
-			xfs_defer_init(*tpp, &dfops, &firstfsb);
+			xfs_defer_init(*tpp, &dfops, &(*tpp)->t_firstblock);
 
 			/* Free the CoW orphan record. */
 			error = xfs_refcount_free_cow_extent(ip->i_mount,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 23/25] xfs: use ->t_firstblock in extent swap
  2018-07-03 17:22 [PATCH 00/25] xfs: embed firstblock in xfs_trans Brian Foster
                   ` (21 preceding siblings ...)
  2018-07-03 17:23 ` [PATCH 22/25] xfs: use ->t_firstblock in reflink cow block cancel Brian Foster
@ 2018-07-03 17:23 ` Brian Foster
  2018-07-04  0:55   ` Darrick J. Wong
  2018-07-03 17:23 ` [PATCH 24/25] xfs: use ->t_firstblock in inode inactivate Brian Foster
                   ` (2 subsequent siblings)
  25 siblings, 1 reply; 58+ messages in thread
From: Brian Foster @ 2018-07-03 17:23 UTC (permalink / raw)
  To: linux-xfs

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/xfs_bmap_util.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index 6d2baf51fec9..96810bea07fd 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -1569,7 +1569,6 @@ xfs_swap_extent_rmap(
 	xfs_fileoff_t			offset_fsb;
 	xfs_fileoff_t			end_fsb;
 	xfs_filblks_t			count_fsb;
-	xfs_fsblock_t			firstfsb;
 	int				error;
 	xfs_filblks_t			ilen;
 	xfs_filblks_t			rlen;
@@ -1605,7 +1604,7 @@ xfs_swap_extent_rmap(
 
 		/* Unmap the old blocks in the source file. */
 		while (tirec.br_blockcount) {
-			xfs_defer_init(tp, tp->t_dfops, &firstfsb);
+			xfs_defer_init(tp, tp->t_dfops, &tp->t_firstblock);
 			trace_xfs_swap_extent_rmap_remap_piece(tip, &tirec);
 
 			/* Read extent from the source file */
@@ -1847,7 +1846,6 @@ xfs_swap_extents(
 	struct xfs_ifork	*cowfp;
 	uint64_t		f;
 	int			resblks = 0;
-	xfs_fsblock_t		firstfsb;
 
 	/*
 	 * Lock the inodes against other IO, page faults and truncate to
@@ -1910,7 +1908,7 @@ xfs_swap_extents(
 	error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, resblks, 0, 0, &tp);
 	if (error)
 		goto out_unlock;
-	xfs_defer_init(tp, &dfops, &firstfsb);
+	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
 
 	/*
 	 * Lock and join the inodes to the tansaction so that transaction commit
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 24/25] xfs: use ->t_firstblock in inode inactivate
  2018-07-03 17:22 [PATCH 00/25] xfs: embed firstblock in xfs_trans Brian Foster
                   ` (22 preceding siblings ...)
  2018-07-03 17:23 ` [PATCH 23/25] xfs: use ->t_firstblock in extent swap Brian Foster
@ 2018-07-03 17:23 ` Brian Foster
  2018-07-04  0:55   ` Darrick J. Wong
  2018-07-03 17:23 ` [PATCH 25/25] xfs: remove xfs_defer_init() firstblock param Brian Foster
  2018-07-10  7:11 ` [PATCH 00/25] xfs: embed firstblock in xfs_trans Christoph Hellwig
  25 siblings, 1 reply; 58+ messages in thread
From: Brian Foster @ 2018-07-03 17:23 UTC (permalink / raw)
  To: linux-xfs

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/xfs_inode.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 5e1eaa26435c..48d22134b06f 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1772,7 +1772,6 @@ xfs_inactive_ifree(
 	struct xfs_inode *ip)
 {
 	struct xfs_defer_ops	dfops;
-	xfs_fsblock_t		first_block;
 	struct xfs_mount	*mp = ip->i_mount;
 	struct xfs_trans	*tp;
 	int			error;
@@ -1809,7 +1808,7 @@ xfs_inactive_ifree(
 	xfs_ilock(ip, XFS_ILOCK_EXCL);
 	xfs_trans_ijoin(tp, ip, 0);
 
-	xfs_defer_init(tp, &dfops, &first_block);
+	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
 	error = xfs_ifree(tp, ip);
 	if (error) {
 		/*
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 25/25] xfs: remove xfs_defer_init() firstblock param
  2018-07-03 17:22 [PATCH 00/25] xfs: embed firstblock in xfs_trans Brian Foster
                   ` (23 preceding siblings ...)
  2018-07-03 17:23 ` [PATCH 24/25] xfs: use ->t_firstblock in inode inactivate Brian Foster
@ 2018-07-03 17:23 ` Brian Foster
  2018-07-04  1:27   ` Darrick J. Wong
  2018-07-10  7:11 ` [PATCH 00/25] xfs: embed firstblock in xfs_trans Christoph Hellwig
  25 siblings, 1 reply; 58+ messages in thread
From: Brian Foster @ 2018-07-03 17:23 UTC (permalink / raw)
  To: linux-xfs

All but one caller of xfs_defer_init() passes in the ->t_firstblock
of the associated transaction. The one outlier is
xlog_recover_process_intents(), which simply passes a dummy value
because a valid pointer is required. This firstblock variable can
simply be removed.

At this point we could remove the xfs_defer_init() firstblock
parameter and initialize ->t_firstblock directly. Even that is not
necessary, however, because ->t_firstblock is automatically
reinitialized in the new transaction on a transaction roll. Since
xfs_defer_init() should never occur more than once on a particular
transaction (since the corresponding finish will roll it), replace
the reinit from xfs_defer_init() with an assert that verifies the
transaction has a NULLFSBLOCK firstblock.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/libxfs/xfs_attr.c        | 28 ++++++++++------------------
 fs/xfs/libxfs/xfs_attr_remote.c |  9 +++------
 fs/xfs/libxfs/xfs_bmap.c        |  4 ++--
 fs/xfs/libxfs/xfs_defer.c       |  5 ++---
 fs/xfs/libxfs/xfs_defer.h       |  3 +--
 fs/xfs/libxfs/xfs_refcount.c    |  2 +-
 fs/xfs/xfs_bmap_util.c          | 12 ++++++------
 fs/xfs/xfs_dquot.c              |  4 ++--
 fs/xfs/xfs_inode.c              | 12 ++++++------
 fs/xfs/xfs_iomap.c              |  6 +++---
 fs/xfs/xfs_log_recover.c        |  3 +--
 fs/xfs/xfs_reflink.c            |  8 ++++----
 fs/xfs/xfs_rtalloc.c            |  2 +-
 fs/xfs/xfs_symlink.c            |  4 ++--
 14 files changed, 44 insertions(+), 58 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
index 153d2e29f872..927d4c968f9a 100644
--- a/fs/xfs/libxfs/xfs_attr.c
+++ b/fs/xfs/libxfs/xfs_attr.c
@@ -251,7 +251,7 @@ xfs_attr_set(
 			rsvd ? XFS_TRANS_RESERVE : 0, &args.trans);
 	if (error)
 		return error;
-	xfs_defer_init(args.trans, &dfops, &args.trans->t_firstblock);
+	xfs_defer_init(args.trans, &dfops);
 
 	xfs_ilock(dp, XFS_ILOCK_EXCL);
 	error = xfs_trans_reserve_quota_nblks(args.trans, dp, args.total, 0,
@@ -422,7 +422,7 @@ xfs_attr_remove(
 			&args.trans);
 	if (error)
 		return error;
-	xfs_defer_init(args.trans, &dfops, &args.trans->t_firstblock);
+	xfs_defer_init(args.trans, &dfops);
 
 	xfs_ilock(dp, XFS_ILOCK_EXCL);
 	/*
@@ -593,8 +593,7 @@ xfs_attr_leaf_addname(
 		 * Commit that transaction so that the node_addname() call
 		 * can manage its own transactions.
 		 */
-		xfs_defer_init(args->trans, args->trans->t_dfops,
-			       &args->trans->t_firstblock);
+		xfs_defer_init(args->trans, args->trans->t_dfops);
 		error = xfs_attr3_leaf_to_node(args);
 		if (error)
 			goto out_defer_cancel;
@@ -683,8 +682,7 @@ xfs_attr_leaf_addname(
 		 * If the result is small enough, shrink it all into the inode.
 		 */
 		if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
-			xfs_defer_init(args->trans, args->trans->t_dfops,
-				       &args->trans->t_firstblock);
+			xfs_defer_init(args->trans, args->trans->t_dfops);
 			error = xfs_attr3_leaf_to_shortform(bp, args, forkoff);
 			/* bp is gone due to xfs_da_shrink_inode */
 			if (error)
@@ -749,8 +747,7 @@ xfs_attr_leaf_removename(
 	 * If the result is small enough, shrink it all into the inode.
 	 */
 	if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
-		xfs_defer_init(args->trans, args->trans->t_dfops,
-			       &args->trans->t_firstblock);
+		xfs_defer_init(args->trans, args->trans->t_dfops);
 		error = xfs_attr3_leaf_to_shortform(bp, args, forkoff);
 		/* bp is gone due to xfs_da_shrink_inode */
 		if (error)
@@ -879,8 +876,7 @@ xfs_attr_node_addname(
 			 */
 			xfs_da_state_free(state);
 			state = NULL;
-			xfs_defer_init(args->trans, args->trans->t_dfops,
-				       &args->trans->t_firstblock);
+			xfs_defer_init(args->trans, args->trans->t_dfops);
 			error = xfs_attr3_leaf_to_node(args);
 			if (error)
 				goto out_defer_cancel;
@@ -907,8 +903,7 @@ xfs_attr_node_addname(
 		 * in the index/blkno/rmtblkno/rmtblkcnt fields and
 		 * in the index2/blkno2/rmtblkno2/rmtblkcnt2 fields.
 		 */
-		xfs_defer_init(args->trans, args->trans->t_dfops,
-			       &args->trans->t_firstblock);
+		xfs_defer_init(args->trans, args->trans->t_dfops);
 		error = xfs_da3_split(state);
 		if (error)
 			goto out_defer_cancel;
@@ -1006,8 +1001,7 @@ xfs_attr_node_addname(
 		 * Check to see if the tree needs to be collapsed.
 		 */
 		if (retval && (state->path.active > 1)) {
-			xfs_defer_init(args->trans, args->trans->t_dfops,
-				       &args->trans->t_firstblock);
+			xfs_defer_init(args->trans, args->trans->t_dfops);
 			error = xfs_da3_join(state);
 			if (error)
 				goto out_defer_cancel;
@@ -1132,8 +1126,7 @@ xfs_attr_node_removename(
 	 * Check to see if the tree needs to be collapsed.
 	 */
 	if (retval && (state->path.active > 1)) {
-		xfs_defer_init(args->trans, args->trans->t_dfops,
-			       &args->trans->t_firstblock);
+		xfs_defer_init(args->trans, args->trans->t_dfops);
 		error = xfs_da3_join(state);
 		if (error)
 			goto out_defer_cancel;
@@ -1165,8 +1158,7 @@ xfs_attr_node_removename(
 			goto out;
 
 		if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
-			xfs_defer_init(args->trans, args->trans->t_dfops,
-				       &args->trans->t_firstblock);
+			xfs_defer_init(args->trans, args->trans->t_dfops);
 			error = xfs_attr3_leaf_to_shortform(bp, args, forkoff);
 			/* bp is gone due to xfs_da_shrink_inode */
 			if (error)
diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c
index f02c705965ff..7841e6255129 100644
--- a/fs/xfs/libxfs/xfs_attr_remote.c
+++ b/fs/xfs/libxfs/xfs_attr_remote.c
@@ -480,8 +480,7 @@ xfs_attr_rmtval_set(
 		 * extent and then crash then the block may not contain the
 		 * correct metadata after log recovery occurs.
 		 */
-		xfs_defer_init(args->trans, args->trans->t_dfops,
-			       &args->trans->t_firstblock);
+		xfs_defer_init(args->trans, args->trans->t_dfops);
 		nmap = 1;
 		error = xfs_bmapi_write(args->trans, dp, (xfs_fileoff_t)lblkno,
 				  blkcnt, XFS_BMAPI_ATTRFORK, args->total, &map,
@@ -523,8 +522,7 @@ xfs_attr_rmtval_set(
 
 		ASSERT(blkcnt > 0);
 
-		xfs_defer_init(args->trans, args->trans->t_dfops,
-			       &args->trans->t_firstblock);
+		xfs_defer_init(args->trans, args->trans->t_dfops);
 		nmap = 1;
 		error = xfs_bmapi_read(dp, (xfs_fileoff_t)lblkno,
 				       blkcnt, &map, &nmap,
@@ -628,8 +626,7 @@ xfs_attr_rmtval_remove(
 	blkcnt = args->rmtblkcnt;
 	done = 0;
 	while (!done) {
-		xfs_defer_init(args->trans, args->trans->t_dfops,
-			       &args->trans->t_firstblock);
+		xfs_defer_init(args->trans, args->trans->t_dfops);
 		error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt,
 				    XFS_BMAPI_ATTRFORK, 1, &done);
 		if (error)
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 1955b8410410..c7f7ef43d032 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -1038,7 +1038,7 @@ xfs_bmap_add_attrfork(
 			rsvd ? XFS_TRANS_RESERVE : 0, &tp);
 	if (error)
 		return error;
-	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
+	xfs_defer_init(tp, &dfops);
 
 	xfs_ilock(ip, XFS_ILOCK_EXCL);
 	error = xfs_trans_reserve_quota_nblks(tp, ip, blks, 0, rsvd ?
@@ -5970,7 +5970,7 @@ xfs_bmap_split_extent(
 			XFS_DIOSTRAT_SPACE_RES(mp, 0), 0, 0, &tp);
 	if (error)
 		return error;
-	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
+	xfs_defer_init(tp, &dfops);
 
 	xfs_ilock(ip, XFS_ILOCK_EXCL);
 	xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c
index 6b25a9436829..2713e2d808a7 100644
--- a/fs/xfs/libxfs/xfs_defer.c
+++ b/fs/xfs/libxfs/xfs_defer.c
@@ -524,16 +524,15 @@ xfs_defer_init_op_type(
 void
 xfs_defer_init(
 	struct xfs_trans		*tp,
-	struct xfs_defer_ops		*dop,
-	xfs_fsblock_t			*fbp)
+	struct xfs_defer_ops		*dop)
 {
 	struct xfs_mount		*mp = NULL;
 
 	memset(dop, 0, sizeof(struct xfs_defer_ops));
-	*fbp = NULLFSBLOCK;
 	INIT_LIST_HEAD(&dop->dop_intake);
 	INIT_LIST_HEAD(&dop->dop_pending);
 	if (tp) {
+		ASSERT(tp->t_firstblock == NULLFSBLOCK);
 		tp->t_dfops = dop;
 		mp = tp->t_mountp;
 	}
diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h
index 56eaaac31df5..c17c9deda995 100644
--- a/fs/xfs/libxfs/xfs_defer.h
+++ b/fs/xfs/libxfs/xfs_defer.h
@@ -63,8 +63,7 @@ void xfs_defer_add(struct xfs_defer_ops *dop, enum xfs_defer_ops_type type,
 		struct list_head *h);
 int xfs_defer_finish(struct xfs_trans **tp, struct xfs_defer_ops *dop);
 void xfs_defer_cancel(struct xfs_defer_ops *dop);
-void xfs_defer_init(struct xfs_trans *tp, struct xfs_defer_ops *dop,
-		    xfs_fsblock_t *fbp);
+void xfs_defer_init(struct xfs_trans *tp, struct xfs_defer_ops *dop);
 bool xfs_defer_has_unfinished_work(struct xfs_defer_ops *dop);
 int xfs_defer_ijoin(struct xfs_defer_ops *dop, struct xfs_inode *ip);
 int xfs_defer_bjoin(struct xfs_defer_ops *dop, struct xfs_buf *bp);
diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c
index d81c17aac710..2ecfb0518580 100644
--- a/fs/xfs/libxfs/xfs_refcount.c
+++ b/fs/xfs/libxfs/xfs_refcount.c
@@ -1691,7 +1691,7 @@ xfs_refcount_recover_cow_leftovers(
 		trace_xfs_refcount_recover_extent(mp, agno, &rr->rr_rrec);
 
 		/* Free the orphan record */
-		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
+		xfs_defer_init(tp, &dfops);
 		agbno = rr->rr_rrec.rc_startblock - XFS_REFC_COW_START;
 		fsb = XFS_AGB_TO_FSB(mp, agno, agbno);
 		error = xfs_refcount_free_cow_extent(mp, tp->t_dfops, fsb,
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index 96810bea07fd..7fb51534ebd3 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -970,7 +970,7 @@ xfs_alloc_file_space(
 
 		xfs_trans_ijoin(tp, ip, 0);
 
-		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
+		xfs_defer_init(tp, &dfops);
 		error = xfs_bmapi_write(tp, ip, startoffset_fsb,
 					allocatesize_fsb, alloc_type, resblks,
 					imapp, &nimaps);
@@ -1039,7 +1039,7 @@ xfs_unmap_extent(
 
 	xfs_trans_ijoin(tp, ip, 0);
 
-	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
+	xfs_defer_init(tp, &dfops);
 	error = xfs_bunmapi(tp, ip, startoffset_fsb, len_fsb, 0, 2, done);
 	if (error)
 		goto out_bmap_cancel;
@@ -1340,7 +1340,7 @@ xfs_collapse_file_space(
 			goto out_trans_cancel;
 		xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
 
-		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
+		xfs_defer_init(tp, &dfops);
 		error = xfs_bmap_collapse_extents(tp, ip, &next_fsb, shift_fsb,
 				&done);
 		if (error)
@@ -1418,7 +1418,7 @@ xfs_insert_file_space(
 
 		xfs_ilock(ip, XFS_ILOCK_EXCL);
 		xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
-		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
+		xfs_defer_init(tp, &dfops);
 		error = xfs_bmap_insert_extents(tp, ip, &next_fsb, shift_fsb,
 				&done, stop_fsb);
 		if (error)
@@ -1604,7 +1604,7 @@ xfs_swap_extent_rmap(
 
 		/* Unmap the old blocks in the source file. */
 		while (tirec.br_blockcount) {
-			xfs_defer_init(tp, tp->t_dfops, &tp->t_firstblock);
+			xfs_defer_init(tp, tp->t_dfops);
 			trace_xfs_swap_extent_rmap_remap_piece(tip, &tirec);
 
 			/* Read extent from the source file */
@@ -1908,7 +1908,7 @@ xfs_swap_extents(
 	error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, resblks, 0, 0, &tp);
 	if (error)
 		goto out_unlock;
-	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
+	xfs_defer_init(tp, &dfops);
 
 	/*
 	 * Lock and join the inodes to the tansaction so that transaction commit
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index 3b61b4d266b4..c53de34c9ae5 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -295,7 +295,7 @@ xfs_dquot_disk_alloc(
 
 	trace_xfs_dqalloc(dqp);
 
-	xfs_defer_init(tp, tp->t_dfops, &tp->t_firstblock);
+	xfs_defer_init(tp, tp->t_dfops);
 
 	xfs_ilock(quotip, XFS_ILOCK_EXCL);
 	if (!xfs_this_quota_on(dqp->q_mount, dqp->dq_flags)) {
@@ -546,7 +546,7 @@ xfs_qm_dqread_alloc(
 			XFS_QM_DQALLOC_SPACE_RES(mp), 0, 0, &tp);
 	if (error)
 		goto err;
-	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
+	xfs_defer_init(tp, &dfops);
 
 	error = xfs_dquot_disk_alloc(&tp, dqp, &bp);
 	if (error)
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 48d22134b06f..7b2694d3901a 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1194,7 +1194,7 @@ xfs_create(
 	xfs_ilock(dp, XFS_ILOCK_EXCL | XFS_ILOCK_PARENT);
 	unlock_dp_on_error = true;
 
-	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
+	xfs_defer_init(tp, &dfops);
 
 	/*
 	 * Reserve disk quota and the inode.
@@ -1448,7 +1448,7 @@ xfs_link(
 			goto error_return;
 	}
 
-	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
+	xfs_defer_init(tp, &dfops);
 
 	/*
 	 * Handle initial link state of O_TMPFILE inode
@@ -1579,7 +1579,7 @@ xfs_itruncate_extents_flags(
 	ASSERT(first_unmap_block < last_block);
 	unmap_len = last_block - first_unmap_block + 1;
 	while (!done) {
-		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
+		xfs_defer_init(tp, &dfops);
 		error = xfs_bunmapi(tp, ip, first_unmap_block, unmap_len, flags,
 				    XFS_ITRUNC_MAX_EXTENTS, &done);
 		if (error)
@@ -1808,7 +1808,7 @@ xfs_inactive_ifree(
 	xfs_ilock(ip, XFS_ILOCK_EXCL);
 	xfs_trans_ijoin(tp, ip, 0);
 
-	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
+	xfs_defer_init(tp, &dfops);
 	error = xfs_ifree(tp, ip);
 	if (error) {
 		/*
@@ -2651,7 +2651,7 @@ xfs_remove(
 	if (error)
 		goto out_trans_cancel;
 
-	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
+	xfs_defer_init(tp, &dfops);
 	error = xfs_dir_removename(tp, dp, name, ip->i_ino, resblks);
 	if (error) {
 		ASSERT(error != -ENOENT);
@@ -3008,7 +3008,7 @@ xfs_rename(
 		goto out_trans_cancel;
 	}
 
-	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
+	xfs_defer_init(tp, &dfops);
 
 	/* RENAME_EXCHANGE is unique from here on. */
 	if (flags & RENAME_EXCHANGE)
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index 46ade3f7a5a3..641861bf4b92 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -253,7 +253,7 @@ xfs_iomap_write_direct(
 	 * From this point onwards we overwrite the imap pointer that the
 	 * caller gave to us.
 	 */
-	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
+	xfs_defer_init(tp, &dfops);
 	nimaps = 1;
 	error = xfs_bmapi_write(tp, ip, offset_fsb, count_fsb,
 				bmapi_flags, resblks, imap, &nimaps);
@@ -713,7 +713,7 @@ xfs_iomap_write_allocate(
 			xfs_ilock(ip, XFS_ILOCK_EXCL);
 			xfs_trans_ijoin(tp, ip, 0);
 
-			xfs_defer_init(tp, &dfops, &tp->t_firstblock);
+			xfs_defer_init(tp, &dfops);
 
 			/*
 			 * it is possible that the extents have changed since
@@ -872,7 +872,7 @@ xfs_iomap_write_unwritten(
 		/*
 		 * Modify the unwritten extent state of the buffer.
 		 */
-		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
+		xfs_defer_init(tp, &dfops);
 		nimaps = 1;
 		error = xfs_bmapi_write(tp, ip, offset_fsb, count_fsb,
 					XFS_BMAPI_CONVERT, resblks, &imap,
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 940eb30e0271..8317023293a5 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -4890,7 +4890,6 @@ xlog_recover_process_intents(
 	struct xfs_ail_cursor	cur;
 	struct xfs_log_item	*lip;
 	struct xfs_ail		*ailp;
-	xfs_fsblock_t		firstfsb;
 	int			error = 0;
 #if defined(DEBUG) || defined(XFS_WARN)
 	xfs_lsn_t		last_lsn;
@@ -4902,7 +4901,7 @@ xlog_recover_process_intents(
 #if defined(DEBUG) || defined(XFS_WARN)
 	last_lsn = xlog_assign_lsn(log->l_curr_cycle, log->l_curr_block);
 #endif
-	xfs_defer_init(NULL, &dfops, &firstfsb);
+	xfs_defer_init(NULL, &dfops);
 	while (lip != NULL) {
 		/*
 		 * We're done when we see something other than an intent.
diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index d509bd7fa822..79b9ce855c72 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -424,7 +424,7 @@ xfs_reflink_allocate_cow(
 
 	xfs_trans_ijoin(tp, ip, 0);
 
-	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
+	xfs_defer_init(tp, &dfops);
 	nimaps = 1;
 
 	/* Allocate the entire reservation as unwritten blocks. */
@@ -574,7 +574,7 @@ xfs_reflink_cancel_cow_blocks(
 			if (error)
 				break;
 		} else if (del.br_state == XFS_EXT_UNWRITTEN || cancel_real) {
-			xfs_defer_init(*tpp, &dfops, &(*tpp)->t_firstblock);
+			xfs_defer_init(*tpp, &dfops);
 
 			/* Free the CoW orphan record. */
 			error = xfs_refcount_free_cow_extent(ip->i_mount,
@@ -756,7 +756,7 @@ xfs_reflink_end_cow(
 			goto prev_extent;
 
 		/* Unmap the old blocks in the data fork. */
-		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
+		xfs_defer_init(tp, &dfops);
 		rlen = del.br_blockcount;
 		error = __xfs_bunmapi(tp, ip, del.br_startoff, &rlen, 0, 1);
 		if (error)
@@ -1104,7 +1104,7 @@ xfs_reflink_remap_extent(
 	/* Unmap the old blocks in the data fork. */
 	rlen = unmap_len;
 	while (rlen) {
-		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
+		xfs_defer_init(tp, &dfops);
 		error = __xfs_bunmapi(tp, ip, destoff, &rlen, 0, 1);
 		if (error)
 			goto out_defer;
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index edd949376a51..bc471d42a968 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -786,7 +786,7 @@ xfs_growfs_rt_alloc(
 		xfs_ilock(ip, XFS_ILOCK_EXCL);
 		xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
 
-		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
+		xfs_defer_init(tp, &dfops);
 		/*
 		 * Allocate blocks to the bitmap file.
 		 */
diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
index a3dc552a5b97..d1ab0afa2723 100644
--- a/fs/xfs/xfs_symlink.c
+++ b/fs/xfs/xfs_symlink.c
@@ -245,7 +245,7 @@ xfs_symlink(
 	 * Initialize the bmap freelist prior to calling either
 	 * bmapi or the directory create code.
 	 */
-	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
+	xfs_defer_init(tp, &dfops);
 
 	/*
 	 * Allocate an inode for the symlink.
@@ -438,7 +438,7 @@ xfs_inactive_symlink_rmt(
 	 * Find the block(s) so we can inval and unmap them.
 	 */
 	done = 0;
-	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
+	xfs_defer_init(tp, &dfops);
 	nmaps = ARRAY_SIZE(mval);
 	error = xfs_bmapi_read(ip, 0, xfs_symlink_blocks(mp, size),
 				mval, &nmaps, 0);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* Re: [PATCH 04/25] xfs: remove firstblock param from xfs dir ops
  2018-07-03 17:22 ` [PATCH 04/25] xfs: remove firstblock param from xfs " Brian Foster
@ 2018-07-03 18:06   ` Darrick J. Wong
  2018-07-03 18:15     ` Brian Foster
  0 siblings, 1 reply; 58+ messages in thread
From: Darrick J. Wong @ 2018-07-03 18:06 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-xfs

On Tue, Jul 03, 2018 at 01:22:58PM -0400, Brian Foster wrote:
> All callers of the xfs_dir_*() functions pass ->t_firstblock as the
> firstblock parameter. Drop the parameter and access ->t_firstblock
> directly.
> 
> Signed-off-by: Brian Foster <bfoster@redhat.com>
> ---
>  fs/xfs/libxfs/xfs_dir2.c | 12 ++++--------
>  fs/xfs/libxfs/xfs_dir2.h |  6 +++---
>  fs/xfs/xfs_inode.c       | 32 ++++++++++++--------------------
>  fs/xfs/xfs_symlink.c     |  3 +--
>  4 files changed, 20 insertions(+), 33 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
> index 26918c5bd819..8a55990ca3a5 100644
> --- a/fs/xfs/libxfs/xfs_dir2.c
> +++ b/fs/xfs/libxfs/xfs_dir2.c
> @@ -243,7 +243,6 @@ xfs_dir_createname(
>  	struct xfs_inode	*dp,
>  	struct xfs_name		*name,
>  	xfs_ino_t		inum,		/* new entry inode number */
> -	xfs_fsblock_t		*first,		/* bmap's firstblock */
>  	xfs_extlen_t		total)		/* bmap's total block count */
>  {
>  	struct xfs_da_args	*args;
> @@ -272,8 +271,7 @@ xfs_dir_createname(
>  	args->total = total;
>  	args->whichfork = XFS_DATA_FORK;
>  	args->trans = tp;
> -	ASSERT(tp->t_dfops || !first);

Hmm, didn't this move elsewhere in this function in the v2 patches of
the t_dfops series?

--D

> -	args->firstblock = first;
> +	args->firstblock = &tp->t_firstblock;
>  	args->op_flags = XFS_DA_OP_ADDNAME | XFS_DA_OP_OKNOENT;
>  	if (!inum)
>  		args->op_flags |= XFS_DA_OP_JUSTCHECK;
> @@ -419,7 +417,6 @@ xfs_dir_removename(
>  	struct xfs_inode	*dp,
>  	struct xfs_name		*name,
>  	xfs_ino_t		ino,
> -	xfs_fsblock_t		*first,		/* bmap's firstblock */
>  	xfs_extlen_t		total)		/* bmap's total block count */
>  {
>  	struct xfs_da_args	*args;
> @@ -440,7 +437,7 @@ xfs_dir_removename(
>  	args->hashval = dp->i_mount->m_dirnameops->hashname(name);
>  	args->inumber = ino;
>  	args->dp = dp;
> -	args->firstblock = first;
> +	args->firstblock = &tp->t_firstblock;
>  	args->total = total;
>  	args->whichfork = XFS_DATA_FORK;
>  	args->trans = tp;
> @@ -480,7 +477,6 @@ xfs_dir_replace(
>  	struct xfs_inode	*dp,
>  	struct xfs_name		*name,		/* name of entry to replace */
>  	xfs_ino_t		inum,		/* new inode number */
> -	xfs_fsblock_t		*first,		/* bmap's firstblock */
>  	xfs_extlen_t		total)		/* bmap's total block count */
>  {
>  	struct xfs_da_args	*args;
> @@ -504,7 +500,7 @@ xfs_dir_replace(
>  	args->hashval = dp->i_mount->m_dirnameops->hashname(name);
>  	args->inumber = inum;
>  	args->dp = dp;
> -	args->firstblock = first;
> +	args->firstblock = &tp->t_firstblock;
>  	args->total = total;
>  	args->whichfork = XFS_DATA_FORK;
>  	args->trans = tp;
> @@ -544,7 +540,7 @@ xfs_dir_canenter(
>  	xfs_inode_t	*dp,
>  	struct xfs_name	*name)		/* name of entry to add */
>  {
> -	return xfs_dir_createname(tp, dp, name, 0, NULL, 0);
> +	return xfs_dir_createname(tp, dp, name, 0, 0);
>  }
>  
>  /*
> diff --git a/fs/xfs/libxfs/xfs_dir2.h b/fs/xfs/libxfs/xfs_dir2.h
> index f203aebc07ed..ba5acd03de94 100644
> --- a/fs/xfs/libxfs/xfs_dir2.h
> +++ b/fs/xfs/libxfs/xfs_dir2.h
> @@ -118,16 +118,16 @@ extern int xfs_dir_init(struct xfs_trans *tp, struct xfs_inode *dp,
>  				struct xfs_inode *pdp);
>  extern int xfs_dir_createname(struct xfs_trans *tp, struct xfs_inode *dp,
>  				struct xfs_name *name, xfs_ino_t inum,
> -				xfs_fsblock_t *first, xfs_extlen_t tot);
> +				xfs_extlen_t tot);
>  extern int xfs_dir_lookup(struct xfs_trans *tp, struct xfs_inode *dp,
>  				struct xfs_name *name, xfs_ino_t *inum,
>  				struct xfs_name *ci_name);
>  extern int xfs_dir_removename(struct xfs_trans *tp, struct xfs_inode *dp,
>  				struct xfs_name *name, xfs_ino_t ino,
> -				xfs_fsblock_t *first, xfs_extlen_t tot);
> +				xfs_extlen_t tot);
>  extern int xfs_dir_replace(struct xfs_trans *tp, struct xfs_inode *dp,
>  				struct xfs_name *name, xfs_ino_t inum,
> -				xfs_fsblock_t *first, xfs_extlen_t tot);
> +				xfs_extlen_t tot);
>  extern int xfs_dir_canenter(struct xfs_trans *tp, struct xfs_inode *dp,
>  				struct xfs_name *name);
>  
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 6a3fe2d3df6c..ab1fd696500c 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -1223,7 +1223,7 @@ xfs_create(
>  	xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL);
>  	unlock_dp_on_error = false;
>  
> -	error = xfs_dir_createname(tp, dp, name, ip->i_ino, &tp->t_firstblock,
> +	error = xfs_dir_createname(tp, dp, name, ip->i_ino,
>  				   resblks ?
>  					resblks - XFS_IALLOC_SPACE_RES(mp) : 0);
>  	if (error) {
> @@ -1460,7 +1460,7 @@ xfs_link(
>  	}
>  
>  	error = xfs_dir_createname(tp, tdp, target_name, sip->i_ino,
> -				   &tp->t_firstblock, resblks);
> +				   resblks);
>  	if (error)
>  		goto error_return;
>  	xfs_trans_ichgtime(tp, tdp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
> @@ -2655,8 +2655,7 @@ xfs_remove(
>  		goto out_trans_cancel;
>  
>  	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> -	error = xfs_dir_removename(tp, dp, name, ip->i_ino, &tp->t_firstblock,
> -				   resblks);
> +	error = xfs_dir_removename(tp, dp, name, ip->i_ino, resblks);
>  	if (error) {
>  		ASSERT(error != -ENOENT);
>  		goto out_bmap_cancel;
> @@ -2788,14 +2787,12 @@ xfs_cross_rename(
>  	int		dp2_flags = 0;
>  
>  	/* Swap inode number for dirent in first parent */
> -	error = xfs_dir_replace(tp, dp1, name1, ip2->i_ino, &tp->t_firstblock,
> -				spaceres);
> +	error = xfs_dir_replace(tp, dp1, name1, ip2->i_ino, spaceres);
>  	if (error)
>  		goto out_trans_abort;
>  
>  	/* Swap inode number for dirent in second parent */
> -	error = xfs_dir_replace(tp, dp2, name2, ip1->i_ino, &tp->t_firstblock,
> -				spaceres);
> +	error = xfs_dir_replace(tp, dp2, name2, ip1->i_ino, spaceres);
>  	if (error)
>  		goto out_trans_abort;
>  
> @@ -2809,8 +2806,7 @@ xfs_cross_rename(
>  
>  		if (S_ISDIR(VFS_I(ip2)->i_mode)) {
>  			error = xfs_dir_replace(tp, ip2, &xfs_name_dotdot,
> -						dp1->i_ino, &tp->t_firstblock,
> -						spaceres);
> +						dp1->i_ino, spaceres);
>  			if (error)
>  				goto out_trans_abort;
>  
> @@ -2836,8 +2832,7 @@ xfs_cross_rename(
>  
>  		if (S_ISDIR(VFS_I(ip1)->i_mode)) {
>  			error = xfs_dir_replace(tp, ip1, &xfs_name_dotdot,
> -						dp2->i_ino, &tp->t_firstblock,
> -						spaceres);
> +						dp2->i_ino, spaceres);
>  			if (error)
>  				goto out_trans_abort;
>  
> @@ -3043,8 +3038,7 @@ xfs_rename(
>  		 * to account for the ".." reference from the new entry.
>  		 */
>  		error = xfs_dir_createname(tp, target_dp, target_name,
> -					   src_ip->i_ino, &tp->t_firstblock,
> -					   spaceres);
> +					   src_ip->i_ino, spaceres);
>  		if (error)
>  			goto out_bmap_cancel;
>  
> @@ -3083,8 +3077,7 @@ xfs_rename(
>  		 * name at the destination directory, remove it first.
>  		 */
>  		error = xfs_dir_replace(tp, target_dp, target_name,
> -					src_ip->i_ino, &tp->t_firstblock,
> -					spaceres);
> +					src_ip->i_ino, spaceres);
>  		if (error)
>  			goto out_bmap_cancel;
>  
> @@ -3118,8 +3111,7 @@ xfs_rename(
>  		 * directory.
>  		 */
>  		error = xfs_dir_replace(tp, src_ip, &xfs_name_dotdot,
> -					target_dp->i_ino, &tp->t_firstblock,
> -					spaceres);
> +					target_dp->i_ino, spaceres);
>  		ASSERT(error != -EEXIST);
>  		if (error)
>  			goto out_bmap_cancel;
> @@ -3158,10 +3150,10 @@ xfs_rename(
>  	 */
>  	if (wip) {
>  		error = xfs_dir_replace(tp, src_dp, src_name, wip->i_ino,
> -					&tp->t_firstblock, spaceres);
> +					spaceres);
>  	} else
>  		error = xfs_dir_removename(tp, src_dp, src_name, src_ip->i_ino,
> -					   &tp->t_firstblock, spaceres);
> +					   spaceres);
>  	if (error)
>  		goto out_bmap_cancel;
>  
> diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
> index 8ddc7f1147dc..583ca83353f7 100644
> --- a/fs/xfs/xfs_symlink.c
> +++ b/fs/xfs/xfs_symlink.c
> @@ -336,8 +336,7 @@ xfs_symlink(
>  	/*
>  	 * Create the directory entry for the symlink.
>  	 */
> -	error = xfs_dir_createname(tp, dp, link_name, ip->i_ino,
> -				   &tp->t_firstblock, resblks);
> +	error = xfs_dir_createname(tp, dp, link_name, ip->i_ino, resblks);
>  	if (error)
>  		goto out_bmap_cancel;
>  	xfs_trans_ichgtime(tp, dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
> -- 
> 2.17.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 04/25] xfs: remove firstblock param from xfs dir ops
  2018-07-03 18:06   ` Darrick J. Wong
@ 2018-07-03 18:15     ` Brian Foster
  0 siblings, 0 replies; 58+ messages in thread
From: Brian Foster @ 2018-07-03 18:15 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs

On Tue, Jul 03, 2018 at 11:06:11AM -0700, Darrick J. Wong wrote:
> On Tue, Jul 03, 2018 at 01:22:58PM -0400, Brian Foster wrote:
> > All callers of the xfs_dir_*() functions pass ->t_firstblock as the
> > firstblock parameter. Drop the parameter and access ->t_firstblock
> > directly.
> > 
> > Signed-off-by: Brian Foster <bfoster@redhat.com>
> > ---
> >  fs/xfs/libxfs/xfs_dir2.c | 12 ++++--------
> >  fs/xfs/libxfs/xfs_dir2.h |  6 +++---
> >  fs/xfs/xfs_inode.c       | 32 ++++++++++++--------------------
> >  fs/xfs/xfs_symlink.c     |  3 +--
> >  4 files changed, 20 insertions(+), 33 deletions(-)
> > 
> > diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
> > index 26918c5bd819..8a55990ca3a5 100644
> > --- a/fs/xfs/libxfs/xfs_dir2.c
> > +++ b/fs/xfs/libxfs/xfs_dir2.c
> > @@ -243,7 +243,6 @@ xfs_dir_createname(
> >  	struct xfs_inode	*dp,
> >  	struct xfs_name		*name,
> >  	xfs_ino_t		inum,		/* new entry inode number */
> > -	xfs_fsblock_t		*first,		/* bmap's firstblock */
> >  	xfs_extlen_t		total)		/* bmap's total block count */
> >  {
> >  	struct xfs_da_args	*args;
> > @@ -272,8 +271,7 @@ xfs_dir_createname(
> >  	args->total = total;
> >  	args->whichfork = XFS_DATA_FORK;
> >  	args->trans = tp;
> > -	ASSERT(tp->t_dfops || !first);
> 
> Hmm, didn't this move elsewhere in this function in the v2 patches of
> the t_dfops series?
> 

Yeah, I realized I forgot to rebase onto v2 right after I sent this. :/
I think that was the only conflict, but either way I have it fixed up
locally. I'll post a v2 inline or as a full series depending on
feedback.

Brian

> --D
> 
> > -	args->firstblock = first;
> > +	args->firstblock = &tp->t_firstblock;
> >  	args->op_flags = XFS_DA_OP_ADDNAME | XFS_DA_OP_OKNOENT;
> >  	if (!inum)
> >  		args->op_flags |= XFS_DA_OP_JUSTCHECK;
> > @@ -419,7 +417,6 @@ xfs_dir_removename(
> >  	struct xfs_inode	*dp,
> >  	struct xfs_name		*name,
> >  	xfs_ino_t		ino,
> > -	xfs_fsblock_t		*first,		/* bmap's firstblock */
> >  	xfs_extlen_t		total)		/* bmap's total block count */
> >  {
> >  	struct xfs_da_args	*args;
> > @@ -440,7 +437,7 @@ xfs_dir_removename(
> >  	args->hashval = dp->i_mount->m_dirnameops->hashname(name);
> >  	args->inumber = ino;
> >  	args->dp = dp;
> > -	args->firstblock = first;
> > +	args->firstblock = &tp->t_firstblock;
> >  	args->total = total;
> >  	args->whichfork = XFS_DATA_FORK;
> >  	args->trans = tp;
> > @@ -480,7 +477,6 @@ xfs_dir_replace(
> >  	struct xfs_inode	*dp,
> >  	struct xfs_name		*name,		/* name of entry to replace */
> >  	xfs_ino_t		inum,		/* new inode number */
> > -	xfs_fsblock_t		*first,		/* bmap's firstblock */
> >  	xfs_extlen_t		total)		/* bmap's total block count */
> >  {
> >  	struct xfs_da_args	*args;
> > @@ -504,7 +500,7 @@ xfs_dir_replace(
> >  	args->hashval = dp->i_mount->m_dirnameops->hashname(name);
> >  	args->inumber = inum;
> >  	args->dp = dp;
> > -	args->firstblock = first;
> > +	args->firstblock = &tp->t_firstblock;
> >  	args->total = total;
> >  	args->whichfork = XFS_DATA_FORK;
> >  	args->trans = tp;
> > @@ -544,7 +540,7 @@ xfs_dir_canenter(
> >  	xfs_inode_t	*dp,
> >  	struct xfs_name	*name)		/* name of entry to add */
> >  {
> > -	return xfs_dir_createname(tp, dp, name, 0, NULL, 0);
> > +	return xfs_dir_createname(tp, dp, name, 0, 0);
> >  }
> >  
> >  /*
> > diff --git a/fs/xfs/libxfs/xfs_dir2.h b/fs/xfs/libxfs/xfs_dir2.h
> > index f203aebc07ed..ba5acd03de94 100644
> > --- a/fs/xfs/libxfs/xfs_dir2.h
> > +++ b/fs/xfs/libxfs/xfs_dir2.h
> > @@ -118,16 +118,16 @@ extern int xfs_dir_init(struct xfs_trans *tp, struct xfs_inode *dp,
> >  				struct xfs_inode *pdp);
> >  extern int xfs_dir_createname(struct xfs_trans *tp, struct xfs_inode *dp,
> >  				struct xfs_name *name, xfs_ino_t inum,
> > -				xfs_fsblock_t *first, xfs_extlen_t tot);
> > +				xfs_extlen_t tot);
> >  extern int xfs_dir_lookup(struct xfs_trans *tp, struct xfs_inode *dp,
> >  				struct xfs_name *name, xfs_ino_t *inum,
> >  				struct xfs_name *ci_name);
> >  extern int xfs_dir_removename(struct xfs_trans *tp, struct xfs_inode *dp,
> >  				struct xfs_name *name, xfs_ino_t ino,
> > -				xfs_fsblock_t *first, xfs_extlen_t tot);
> > +				xfs_extlen_t tot);
> >  extern int xfs_dir_replace(struct xfs_trans *tp, struct xfs_inode *dp,
> >  				struct xfs_name *name, xfs_ino_t inum,
> > -				xfs_fsblock_t *first, xfs_extlen_t tot);
> > +				xfs_extlen_t tot);
> >  extern int xfs_dir_canenter(struct xfs_trans *tp, struct xfs_inode *dp,
> >  				struct xfs_name *name);
> >  
> > diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> > index 6a3fe2d3df6c..ab1fd696500c 100644
> > --- a/fs/xfs/xfs_inode.c
> > +++ b/fs/xfs/xfs_inode.c
> > @@ -1223,7 +1223,7 @@ xfs_create(
> >  	xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL);
> >  	unlock_dp_on_error = false;
> >  
> > -	error = xfs_dir_createname(tp, dp, name, ip->i_ino, &tp->t_firstblock,
> > +	error = xfs_dir_createname(tp, dp, name, ip->i_ino,
> >  				   resblks ?
> >  					resblks - XFS_IALLOC_SPACE_RES(mp) : 0);
> >  	if (error) {
> > @@ -1460,7 +1460,7 @@ xfs_link(
> >  	}
> >  
> >  	error = xfs_dir_createname(tp, tdp, target_name, sip->i_ino,
> > -				   &tp->t_firstblock, resblks);
> > +				   resblks);
> >  	if (error)
> >  		goto error_return;
> >  	xfs_trans_ichgtime(tp, tdp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
> > @@ -2655,8 +2655,7 @@ xfs_remove(
> >  		goto out_trans_cancel;
> >  
> >  	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> > -	error = xfs_dir_removename(tp, dp, name, ip->i_ino, &tp->t_firstblock,
> > -				   resblks);
> > +	error = xfs_dir_removename(tp, dp, name, ip->i_ino, resblks);
> >  	if (error) {
> >  		ASSERT(error != -ENOENT);
> >  		goto out_bmap_cancel;
> > @@ -2788,14 +2787,12 @@ xfs_cross_rename(
> >  	int		dp2_flags = 0;
> >  
> >  	/* Swap inode number for dirent in first parent */
> > -	error = xfs_dir_replace(tp, dp1, name1, ip2->i_ino, &tp->t_firstblock,
> > -				spaceres);
> > +	error = xfs_dir_replace(tp, dp1, name1, ip2->i_ino, spaceres);
> >  	if (error)
> >  		goto out_trans_abort;
> >  
> >  	/* Swap inode number for dirent in second parent */
> > -	error = xfs_dir_replace(tp, dp2, name2, ip1->i_ino, &tp->t_firstblock,
> > -				spaceres);
> > +	error = xfs_dir_replace(tp, dp2, name2, ip1->i_ino, spaceres);
> >  	if (error)
> >  		goto out_trans_abort;
> >  
> > @@ -2809,8 +2806,7 @@ xfs_cross_rename(
> >  
> >  		if (S_ISDIR(VFS_I(ip2)->i_mode)) {
> >  			error = xfs_dir_replace(tp, ip2, &xfs_name_dotdot,
> > -						dp1->i_ino, &tp->t_firstblock,
> > -						spaceres);
> > +						dp1->i_ino, spaceres);
> >  			if (error)
> >  				goto out_trans_abort;
> >  
> > @@ -2836,8 +2832,7 @@ xfs_cross_rename(
> >  
> >  		if (S_ISDIR(VFS_I(ip1)->i_mode)) {
> >  			error = xfs_dir_replace(tp, ip1, &xfs_name_dotdot,
> > -						dp2->i_ino, &tp->t_firstblock,
> > -						spaceres);
> > +						dp2->i_ino, spaceres);
> >  			if (error)
> >  				goto out_trans_abort;
> >  
> > @@ -3043,8 +3038,7 @@ xfs_rename(
> >  		 * to account for the ".." reference from the new entry.
> >  		 */
> >  		error = xfs_dir_createname(tp, target_dp, target_name,
> > -					   src_ip->i_ino, &tp->t_firstblock,
> > -					   spaceres);
> > +					   src_ip->i_ino, spaceres);
> >  		if (error)
> >  			goto out_bmap_cancel;
> >  
> > @@ -3083,8 +3077,7 @@ xfs_rename(
> >  		 * name at the destination directory, remove it first.
> >  		 */
> >  		error = xfs_dir_replace(tp, target_dp, target_name,
> > -					src_ip->i_ino, &tp->t_firstblock,
> > -					spaceres);
> > +					src_ip->i_ino, spaceres);
> >  		if (error)
> >  			goto out_bmap_cancel;
> >  
> > @@ -3118,8 +3111,7 @@ xfs_rename(
> >  		 * directory.
> >  		 */
> >  		error = xfs_dir_replace(tp, src_ip, &xfs_name_dotdot,
> > -					target_dp->i_ino, &tp->t_firstblock,
> > -					spaceres);
> > +					target_dp->i_ino, spaceres);
> >  		ASSERT(error != -EEXIST);
> >  		if (error)
> >  			goto out_bmap_cancel;
> > @@ -3158,10 +3150,10 @@ xfs_rename(
> >  	 */
> >  	if (wip) {
> >  		error = xfs_dir_replace(tp, src_dp, src_name, wip->i_ino,
> > -					&tp->t_firstblock, spaceres);
> > +					spaceres);
> >  	} else
> >  		error = xfs_dir_removename(tp, src_dp, src_name, src_ip->i_ino,
> > -					   &tp->t_firstblock, spaceres);
> > +					   spaceres);
> >  	if (error)
> >  		goto out_bmap_cancel;
> >  
> > diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
> > index 8ddc7f1147dc..583ca83353f7 100644
> > --- a/fs/xfs/xfs_symlink.c
> > +++ b/fs/xfs/xfs_symlink.c
> > @@ -336,8 +336,7 @@ xfs_symlink(
> >  	/*
> >  	 * Create the directory entry for the symlink.
> >  	 */
> > -	error = xfs_dir_createname(tp, dp, link_name, ip->i_ino,
> > -				   &tp->t_firstblock, resblks);
> > +	error = xfs_dir_createname(tp, dp, link_name, ip->i_ino, resblks);
> >  	if (error)
> >  		goto out_bmap_cancel;
> >  	xfs_trans_ichgtime(tp, dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
> > -- 
> > 2.17.1
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 01/25] xfs: allow null firstblock in xfs_bmapi_write() when tp is null
  2018-07-03 17:22 ` [PATCH 01/25] xfs: allow null firstblock in xfs_bmapi_write() when tp is null Brian Foster
@ 2018-07-04  0:24   ` Darrick J. Wong
  2018-07-08 15:26   ` Christoph Hellwig
  1 sibling, 0 replies; 58+ messages in thread
From: Darrick J. Wong @ 2018-07-04  0:24 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-xfs

On Tue, Jul 03, 2018 at 01:22:55PM -0400, Brian Foster wrote:
> xfs_bmapi_write() always expects a valid firstblock pointer. It
> immediately dereferences the pointer to help determine how to
> initialize the bma.minleft field. The remaining accesses are
> related to modifying btree format forks, which is only relevant for
> !COW fork callers.
> 
> The reflink code passes a NULL transaction to xfs_bmapi_write() in a
> couple places that do COW fork unwritten conversion. The purpose of
> the firstblock field is to track the first block allocation in the
> current transaction, so technically firstblock should not be
> required for these callers either.
> 
> Tweak xfs_bmapi_write() to initialize the bma correctly without
> accessing the firstblock pointer if no transaction is provided in
> the first place. Update the reflink callers to pass NULL instead of
> otherwise unused firstblock references.
> 
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_bmap.c | 2 +-
>  fs/xfs/xfs_reflink.c     | 9 +++------
>  2 files changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 2e2a9661600b..c6a5a957674d 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -4304,7 +4304,7 @@ xfs_bmapi_write(
>  
>  	XFS_STATS_INC(mp, xs_blk_mapw);
>  
> -	if (*firstblock == NULLFSBLOCK) {
> +	if (!tp || *firstblock == NULLFSBLOCK) {
>  		if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE)
>  			bma.minleft = be16_to_cpu(ifp->if_broot->bb_level) + 1;
>  		else
> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> index 8496312dde6a..92b6e1b5d33c 100644
> --- a/fs/xfs/xfs_reflink.c
> +++ b/fs/xfs/xfs_reflink.c
> @@ -314,7 +314,6 @@ xfs_reflink_convert_cow_extent(
>  	xfs_fileoff_t			offset_fsb,
>  	xfs_filblks_t			count_fsb)
>  {
> -	xfs_fsblock_t			first_block = NULLFSBLOCK;
>  	int				nimaps = 1;
>  
>  	if (imap->br_state == XFS_EXT_NORM)
> @@ -325,8 +324,8 @@ xfs_reflink_convert_cow_extent(
>  	if (imap->br_blockcount == 0)
>  		return 0;
>  	return xfs_bmapi_write(NULL, ip, imap->br_startoff, imap->br_blockcount,
> -			XFS_BMAPI_COWFORK | XFS_BMAPI_CONVERT, &first_block,
> -			0, imap, &nimaps);
> +			XFS_BMAPI_COWFORK | XFS_BMAPI_CONVERT, NULL, 0, imap,
> +			&nimaps);
>  }
>  
>  /* Convert all of the unwritten CoW extents in a file's range to real ones. */
> @@ -341,7 +340,6 @@ xfs_reflink_convert_cow(
>  	xfs_fileoff_t		end_fsb = XFS_B_TO_FSB(mp, offset + count);
>  	xfs_filblks_t		count_fsb = end_fsb - offset_fsb;
>  	struct xfs_bmbt_irec	imap;
> -	xfs_fsblock_t		first_block = NULLFSBLOCK;
>  	int			nimaps = 1, error = 0;
>  
>  	ASSERT(count != 0);
> @@ -349,8 +347,7 @@ xfs_reflink_convert_cow(
>  	xfs_ilock(ip, XFS_ILOCK_EXCL);
>  	error = xfs_bmapi_write(NULL, ip, offset_fsb, count_fsb,
>  			XFS_BMAPI_COWFORK | XFS_BMAPI_CONVERT |
> -			XFS_BMAPI_CONVERT_ONLY, &first_block, 0, &imap,
> -			&nimaps);
> +			XFS_BMAPI_CONVERT_ONLY, NULL, 0, &imap, &nimaps);
>  	xfs_iunlock(ip, XFS_ILOCK_EXCL);
>  	return error;
>  }
> -- 
> 2.17.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 02/25] xfs: add firstblock field to xfs_trans
  2018-07-03 17:22 ` [PATCH 02/25] xfs: add firstblock field to xfs_trans Brian Foster
@ 2018-07-04  0:41   ` Darrick J. Wong
  2018-07-08 15:26   ` Christoph Hellwig
  1 sibling, 0 replies; 58+ messages in thread
From: Darrick J. Wong @ 2018-07-04  0:41 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-xfs

On Tue, Jul 03, 2018 at 01:22:56PM -0400, Brian Foster wrote:
> A firstblock var is typically allocated and initialized along with
> xfs_defer_ops structures and passed around independent from the
> associated transaction. To facilitate combining the two, add an
> optional ->t_firstblock field to xfs_trans that can be used in place
> of an on-stack variable.
> 
> The firstblock value follows the lifetime of the transaction, so
> initialize it on allocation and when a transaction rolls.
> 
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Seems ok so far,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/xfs_trans.c | 2 ++
>  fs/xfs/xfs_trans.h | 1 +
>  2 files changed, 3 insertions(+)
> 
> diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
> index 630993387517..de00f79ff698 100644
> --- a/fs/xfs/xfs_trans.c
> +++ b/fs/xfs/xfs_trans.c
> @@ -100,6 +100,7 @@ xfs_trans_dup(
>  	ntp->t_mountp = tp->t_mountp;
>  	INIT_LIST_HEAD(&ntp->t_items);
>  	INIT_LIST_HEAD(&ntp->t_busy);
> +	ntp->t_firstblock = NULLFSBLOCK;
>  
>  	ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES);
>  	ASSERT(tp->t_ticket != NULL);
> @@ -273,6 +274,7 @@ xfs_trans_alloc(
>  	tp->t_mountp = mp;
>  	INIT_LIST_HEAD(&tp->t_items);
>  	INIT_LIST_HEAD(&tp->t_busy);
> +	tp->t_firstblock = NULLFSBLOCK;
>  
>  	error = xfs_trans_reserve(tp, resp, blocks, rtextents);
>  	if (error) {
> diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
> index d8a695c57103..37fdacc690c7 100644
> --- a/fs/xfs/xfs_trans.h
> +++ b/fs/xfs/xfs_trans.h
> @@ -102,6 +102,7 @@ typedef struct xfs_trans {
>  	unsigned int		t_blk_res_used;	/* # of resvd blocks used */
>  	unsigned int		t_rtx_res;	/* # of rt extents resvd */
>  	unsigned int		t_rtx_res_used;	/* # of resvd rt extents used */
> +	xfs_fsblock_t		t_firstblock;	/* first block allocated */
>  	struct xlog_ticket	*t_ticket;	/* log mgr ticket */
>  	struct xfs_mount	*t_mountp;	/* ptr to fs mount struct */
>  	struct xfs_dquot_acct   *t_dqinfo;	/* acctg info for dquots */
> -- 
> 2.17.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 03/25] xfs: use ->t_firstblock in dir ops
  2018-07-03 17:22 ` [PATCH 03/25] xfs: use ->t_firstblock in dir ops Brian Foster
@ 2018-07-04  0:42   ` Darrick J. Wong
  0 siblings, 0 replies; 58+ messages in thread
From: Darrick J. Wong @ 2018-07-04  0:42 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-xfs

On Tue, Jul 03, 2018 at 01:22:57PM -0400, Brian Foster wrote:
> Callers of the xfs_dir_*() functions currently pass an on-stack
> firstblock variable. While the dirops infrastructure carries a
> pointer to this variable, it never rolls the transaction and so it
> is safe to use ->t_firstblock instead.
> 
> Fix up the various xfs_dir_*() callers to use ->t_firstblock. Also
> remove the unnecessary parameter for xfs_cross_rename().
> 
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/xfs_inode.c   | 42 +++++++++++++++++++-----------------------
>  fs/xfs/xfs_symlink.c |  9 ++++-----
>  2 files changed, 23 insertions(+), 28 deletions(-)
> 
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 04e17234e5d7..6a3fe2d3df6c 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -1143,7 +1143,6 @@ xfs_create(
>  	struct xfs_trans	*tp = NULL;
>  	int			error;
>  	struct xfs_defer_ops	dfops;
> -	xfs_fsblock_t		first_block;
>  	bool                    unlock_dp_on_error = false;
>  	prid_t			prid;
>  	struct xfs_dquot	*udqp = NULL;
> @@ -1195,7 +1194,7 @@ xfs_create(
>  	xfs_ilock(dp, XFS_ILOCK_EXCL | XFS_ILOCK_PARENT);
>  	unlock_dp_on_error = true;
>  
> -	xfs_defer_init(tp, &dfops, &first_block);
> +	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
>  
>  	/*
>  	 * Reserve disk quota and the inode.
> @@ -1224,7 +1223,7 @@ xfs_create(
>  	xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL);
>  	unlock_dp_on_error = false;
>  
> -	error = xfs_dir_createname(tp, dp, name, ip->i_ino, &first_block,
> +	error = xfs_dir_createname(tp, dp, name, ip->i_ino, &tp->t_firstblock,
>  				   resblks ?
>  					resblks - XFS_IALLOC_SPACE_RES(mp) : 0);
>  	if (error) {
> @@ -1401,7 +1400,6 @@ xfs_link(
>  	xfs_trans_t		*tp;
>  	int			error;
>  	struct xfs_defer_ops	dfops;
> -	xfs_fsblock_t           first_block;
>  	int			resblks;
>  
>  	trace_xfs_link(tdp, target_name);
> @@ -1450,7 +1448,7 @@ xfs_link(
>  			goto error_return;
>  	}
>  
> -	xfs_defer_init(tp, &dfops, &first_block);
> +	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
>  
>  	/*
>  	 * Handle initial link state of O_TMPFILE inode
> @@ -1462,7 +1460,7 @@ xfs_link(
>  	}
>  
>  	error = xfs_dir_createname(tp, tdp, target_name, sip->i_ino,
> -				   &first_block, resblks);
> +				   &tp->t_firstblock, resblks);
>  	if (error)
>  		goto error_return;
>  	xfs_trans_ichgtime(tp, tdp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
> @@ -2577,7 +2575,6 @@ xfs_remove(
>  	int			is_dir = S_ISDIR(VFS_I(ip)->i_mode);
>  	int                     error = 0;
>  	struct xfs_defer_ops	dfops;
> -	xfs_fsblock_t           first_block;
>  	uint			resblks;
>  
>  	trace_xfs_remove(dp, name);
> @@ -2657,8 +2654,8 @@ xfs_remove(
>  	if (error)
>  		goto out_trans_cancel;
>  
> -	xfs_defer_init(tp, &dfops, &first_block);
> -	error = xfs_dir_removename(tp, dp, name, ip->i_ino, &first_block,
> +	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> +	error = xfs_dir_removename(tp, dp, name, ip->i_ino, &tp->t_firstblock,
>  				   resblks);
>  	if (error) {
>  		ASSERT(error != -ENOENT);
> @@ -2783,7 +2780,6 @@ xfs_cross_rename(
>  	struct xfs_inode	*dp2,
>  	struct xfs_name		*name2,
>  	struct xfs_inode	*ip2,
> -	xfs_fsblock_t		*first_block,
>  	int			spaceres)
>  {
>  	int		error = 0;
> @@ -2792,13 +2788,13 @@ xfs_cross_rename(
>  	int		dp2_flags = 0;
>  
>  	/* Swap inode number for dirent in first parent */
> -	error = xfs_dir_replace(tp, dp1, name1, ip2->i_ino, first_block,
> +	error = xfs_dir_replace(tp, dp1, name1, ip2->i_ino, &tp->t_firstblock,
>  				spaceres);
>  	if (error)
>  		goto out_trans_abort;
>  
>  	/* Swap inode number for dirent in second parent */
> -	error = xfs_dir_replace(tp, dp2, name2, ip1->i_ino, first_block,
> +	error = xfs_dir_replace(tp, dp2, name2, ip1->i_ino, &tp->t_firstblock,
>  				spaceres);
>  	if (error)
>  		goto out_trans_abort;
> @@ -2813,7 +2809,7 @@ xfs_cross_rename(
>  
>  		if (S_ISDIR(VFS_I(ip2)->i_mode)) {
>  			error = xfs_dir_replace(tp, ip2, &xfs_name_dotdot,
> -						dp1->i_ino, first_block,
> +						dp1->i_ino, &tp->t_firstblock,
>  						spaceres);
>  			if (error)
>  				goto out_trans_abort;
> @@ -2840,7 +2836,7 @@ xfs_cross_rename(
>  
>  		if (S_ISDIR(VFS_I(ip1)->i_mode)) {
>  			error = xfs_dir_replace(tp, ip1, &xfs_name_dotdot,
> -						dp2->i_ino, first_block,
> +						dp2->i_ino, &tp->t_firstblock,
>  						spaceres);
>  			if (error)
>  				goto out_trans_abort;
> @@ -2939,7 +2935,6 @@ xfs_rename(
>  	struct xfs_mount	*mp = src_dp->i_mount;
>  	struct xfs_trans	*tp;
>  	struct xfs_defer_ops	dfops;
> -	xfs_fsblock_t		first_block;
>  	struct xfs_inode	*wip = NULL;		/* whiteout inode */
>  	struct xfs_inode	*inodes[__XFS_SORT_INODES];
>  	int			num_inodes = __XFS_SORT_INODES;
> @@ -3021,13 +3016,13 @@ xfs_rename(
>  		goto out_trans_cancel;
>  	}
>  
> -	xfs_defer_init(tp, &dfops, &first_block);
> +	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
>  
>  	/* RENAME_EXCHANGE is unique from here on. */
>  	if (flags & RENAME_EXCHANGE)
>  		return xfs_cross_rename(tp, src_dp, src_name, src_ip,
>  					target_dp, target_name, target_ip,
> -					&first_block, spaceres);
> +					spaceres);
>  
>  	/*
>  	 * Set up the target.
> @@ -3048,8 +3043,8 @@ xfs_rename(
>  		 * to account for the ".." reference from the new entry.
>  		 */
>  		error = xfs_dir_createname(tp, target_dp, target_name,
> -						src_ip->i_ino, &first_block,
> -						spaceres);
> +					   src_ip->i_ino, &tp->t_firstblock,
> +					   spaceres);
>  		if (error)
>  			goto out_bmap_cancel;
>  
> @@ -3088,7 +3083,8 @@ xfs_rename(
>  		 * name at the destination directory, remove it first.
>  		 */
>  		error = xfs_dir_replace(tp, target_dp, target_name,
> -					src_ip->i_ino, &first_block, spaceres);
> +					src_ip->i_ino, &tp->t_firstblock,
> +					spaceres);
>  		if (error)
>  			goto out_bmap_cancel;
>  
> @@ -3122,7 +3118,7 @@ xfs_rename(
>  		 * directory.
>  		 */
>  		error = xfs_dir_replace(tp, src_ip, &xfs_name_dotdot,
> -					target_dp->i_ino, &first_block,
> +					target_dp->i_ino, &tp->t_firstblock,
>  					spaceres);
>  		ASSERT(error != -EEXIST);
>  		if (error)
> @@ -3162,10 +3158,10 @@ xfs_rename(
>  	 */
>  	if (wip) {
>  		error = xfs_dir_replace(tp, src_dp, src_name, wip->i_ino,
> -					&first_block, spaceres);
> +					&tp->t_firstblock, spaceres);
>  	} else
>  		error = xfs_dir_removename(tp, src_dp, src_name, src_ip->i_ino,
> -					   &first_block, spaceres);
> +					   &tp->t_firstblock, spaceres);
>  	if (error)
>  		goto out_bmap_cancel;
>  
> diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
> index e50e97308f81..8ddc7f1147dc 100644
> --- a/fs/xfs/xfs_symlink.c
> +++ b/fs/xfs/xfs_symlink.c
> @@ -164,7 +164,6 @@ xfs_symlink(
>  	int			error = 0;
>  	int			pathlen;
>  	struct xfs_defer_ops	dfops;
> -	xfs_fsblock_t		first_block;
>  	bool                    unlock_dp_on_error = false;
>  	xfs_fileoff_t		first_fsb;
>  	xfs_filblks_t		fs_blocks;
> @@ -246,7 +245,7 @@ xfs_symlink(
>  	 * Initialize the bmap freelist prior to calling either
>  	 * bmapi or the directory create code.
>  	 */
> -	xfs_defer_init(tp, &dfops, &first_block);
> +	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
>  
>  	/*
>  	 * Allocate an inode for the symlink.
> @@ -289,8 +288,8 @@ xfs_symlink(
>  		nmaps = XFS_SYMLINK_MAPS;
>  
>  		error = xfs_bmapi_write(tp, ip, first_fsb, fs_blocks,
> -				  XFS_BMAPI_METADATA, &first_block, resblks,
> -				  mval, &nmaps);
> +				  XFS_BMAPI_METADATA, &tp->t_firstblock,
> +				  resblks, mval, &nmaps);
>  		if (error)
>  			goto out_bmap_cancel;
>  
> @@ -338,7 +337,7 @@ xfs_symlink(
>  	 * Create the directory entry for the symlink.
>  	 */
>  	error = xfs_dir_createname(tp, dp, link_name, ip->i_ino,
> -				   &first_block, resblks);
> +				   &tp->t_firstblock, resblks);
>  	if (error)
>  		goto out_bmap_cancel;
>  	xfs_trans_ichgtime(tp, dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
> -- 
> 2.17.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 05/25] xfs: use ->t_firstblock in attrfork add
  2018-07-03 17:22 ` [PATCH 05/25] xfs: use ->t_firstblock in attrfork add Brian Foster
@ 2018-07-04  0:43   ` Darrick J. Wong
  0 siblings, 0 replies; 58+ messages in thread
From: Darrick J. Wong @ 2018-07-04  0:43 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-xfs

On Tue, Jul 03, 2018 at 01:22:59PM -0400, Brian Foster wrote:
> Note that this codepath is a user of struct xfs_da_args. Switch it
> over to ->t_firstblock in preparation to remove
> xfs_da_args.firstblock.
> 
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_bmap.c | 33 +++++++++++++--------------------
>  1 file changed, 13 insertions(+), 20 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index c6a5a957674d..fcd10b47044a 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -915,7 +915,6 @@ STATIC int					/* error */
>  xfs_bmap_add_attrfork_btree(
>  	xfs_trans_t		*tp,		/* transaction pointer */
>  	xfs_inode_t		*ip,		/* incore inode pointer */
> -	xfs_fsblock_t		*firstblock,	/* first block allocated */
>  	int			*flags)		/* inode logging flags */
>  {
>  	xfs_btree_cur_t		*cur;		/* btree cursor */
> @@ -928,7 +927,7 @@ xfs_bmap_add_attrfork_btree(
>  		*flags |= XFS_ILOG_DBROOT;
>  	else {
>  		cur = xfs_bmbt_init_cursor(mp, tp, ip, XFS_DATA_FORK);
> -		cur->bc_private.b.firstblock = *firstblock;
> +		cur->bc_private.b.firstblock = tp->t_firstblock;
>  		error = xfs_bmbt_lookup_first(cur, &stat);
>  		if (error)
>  			goto error0;
> @@ -940,7 +939,7 @@ xfs_bmap_add_attrfork_btree(
>  			xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);
>  			return -ENOSPC;
>  		}
> -		*firstblock = cur->bc_private.b.firstblock;
> +		tp->t_firstblock = cur->bc_private.b.firstblock;
>  		cur->bc_private.b.allocated = 0;
>  		xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);
>  	}
> @@ -957,7 +956,6 @@ STATIC int					/* error */
>  xfs_bmap_add_attrfork_extents(
>  	struct xfs_trans	*tp,		/* transaction pointer */
>  	struct xfs_inode	*ip,		/* incore inode pointer */
> -	xfs_fsblock_t		*firstblock,	/* first block allocated */
>  	int			*flags)		/* inode logging flags */
>  {
>  	xfs_btree_cur_t		*cur;		/* bmap btree cursor */
> @@ -966,8 +964,8 @@ xfs_bmap_add_attrfork_extents(
>  	if (ip->i_d.di_nextents * sizeof(xfs_bmbt_rec_t) <= XFS_IFORK_DSIZE(ip))
>  		return 0;
>  	cur = NULL;
> -	error = xfs_bmap_extents_to_btree(tp, ip, firstblock, &cur, 0, flags,
> -					  XFS_DATA_FORK);
> +	error = xfs_bmap_extents_to_btree(tp, ip, &tp->t_firstblock, &cur, 0,
> +					  flags, XFS_DATA_FORK);
>  	if (cur) {
>  		cur->bc_private.b.allocated = 0;
>  		xfs_btree_del_cursor(cur,
> @@ -989,12 +987,11 @@ xfs_bmap_add_attrfork_extents(
>   */
>  STATIC int					/* error */
>  xfs_bmap_add_attrfork_local(
> -	xfs_trans_t		*tp,		/* transaction pointer */
> -	xfs_inode_t		*ip,		/* incore inode pointer */
> -	xfs_fsblock_t		*firstblock,	/* first block allocated */
> +	struct xfs_trans	*tp,		/* transaction pointer */
> +	struct xfs_inode	*ip,		/* incore inode pointer */
>  	int			*flags)		/* inode logging flags */
>  {
> -	xfs_da_args_t		dargs;		/* args for dir/attr code */
> +	struct xfs_da_args	dargs;		/* args for dir/attr code */
>  
>  	if (ip->i_df.if_bytes <= XFS_IFORK_DSIZE(ip))
>  		return 0;
> @@ -1003,7 +1000,7 @@ xfs_bmap_add_attrfork_local(
>  		memset(&dargs, 0, sizeof(dargs));
>  		dargs.geo = ip->i_mount->m_dir_geo;
>  		dargs.dp = ip;
> -		dargs.firstblock = firstblock;
> +		dargs.firstblock = &tp->t_firstblock;
>  		dargs.total = dargs.geo->fsbcount;
>  		dargs.whichfork = XFS_DATA_FORK;
>  		dargs.trans = tp;
> @@ -1011,7 +1008,7 @@ xfs_bmap_add_attrfork_local(
>  	}
>  
>  	if (S_ISLNK(VFS_I(ip)->i_mode))
> -		return xfs_bmap_local_to_extents(tp, ip, firstblock, 1,
> +		return xfs_bmap_local_to_extents(tp, ip, &tp->t_firstblock, 1,
>  						 flags, XFS_DATA_FORK,
>  						 xfs_symlink_local_to_remote);
>  
> @@ -1030,7 +1027,6 @@ xfs_bmap_add_attrfork(
>  	int			size,		/* space new attribute needs */
>  	int			rsvd)		/* xact may use reserved blks */
>  {
> -	xfs_fsblock_t		firstblock;	/* 1st block/ag allocated */
>  	struct xfs_defer_ops	dfops;		/* freed extent records */
>  	xfs_mount_t		*mp;		/* mount structure */
>  	xfs_trans_t		*tp;		/* transaction pointer */
> @@ -1050,7 +1046,7 @@ xfs_bmap_add_attrfork(
>  			rsvd ? XFS_TRANS_RESERVE : 0, &tp);
>  	if (error)
>  		return error;
> -	xfs_defer_init(tp, &dfops, &firstblock);
> +	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
>  
>  	xfs_ilock(ip, XFS_ILOCK_EXCL);
>  	error = xfs_trans_reserve_quota_nblks(tp, ip, blks, 0, rsvd ?
> @@ -1100,16 +1096,13 @@ xfs_bmap_add_attrfork(
>  	logflags = 0;
>  	switch (ip->i_d.di_format) {
>  	case XFS_DINODE_FMT_LOCAL:
> -		error = xfs_bmap_add_attrfork_local(tp, ip, &firstblock,
> -						    &logflags);
> +		error = xfs_bmap_add_attrfork_local(tp, ip, &logflags);
>  		break;
>  	case XFS_DINODE_FMT_EXTENTS:
> -		error = xfs_bmap_add_attrfork_extents(tp, ip, &firstblock,
> -						      &logflags);
> +		error = xfs_bmap_add_attrfork_extents(tp, ip, &logflags);
>  		break;
>  	case XFS_DINODE_FMT_BTREE:
> -		error = xfs_bmap_add_attrfork_btree(tp, ip, &firstblock,
> -						    &logflags);
> +		error = xfs_bmap_add_attrfork_btree(tp, ip, &logflags);
>  		break;
>  	default:
>  		error = 0;
> -- 
> 2.17.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 06/25] xfs: use ->t_firstblock in xattr ops
  2018-07-03 17:23 ` [PATCH 06/25] xfs: use ->t_firstblock in xattr ops Brian Foster
@ 2018-07-04  0:45   ` Darrick J. Wong
  0 siblings, 0 replies; 58+ messages in thread
From: Darrick J. Wong @ 2018-07-04  0:45 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-xfs

On Tue, Jul 03, 2018 at 01:23:00PM -0400, Brian Foster wrote:
> Similar to the dirops code, the xattr code uses an on-stack
> firstblock variable for the various operations. This code rolls the
> underlying transaction in various places, however, which means we
> cannot simply replace the local firstblock vars with ->t_firstblock.
> Doing so (without further changes) would invalidate the memory
> pointed to by xfs_da_args.firstblock as soon as the first
> transaction rolls.
> 
> To avoid this problem, remove xfs_da_args.firstblock and replace all
> such accesses with ->t_firstblock at the same time. This ensures
> that accesses to the current firstblock always occur through the
> current transaction rather than a potentially invalid xfs_da_args
> pointer.
> 
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_attr.c        | 37 ++++++++++++++++-----------------
>  fs/xfs/libxfs/xfs_attr_leaf.c   |  2 --
>  fs/xfs/libxfs/xfs_attr_remote.c | 18 +++++++++-------
>  fs/xfs/libxfs/xfs_bmap.c        |  1 -
>  fs/xfs/libxfs/xfs_da_btree.c    |  7 +++----
>  fs/xfs/libxfs/xfs_da_btree.h    |  1 -
>  fs/xfs/libxfs/xfs_dir2.c        |  5 +----
>  7 files changed, 33 insertions(+), 38 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
> index 8a7e2c0308c4..153d2e29f872 100644
> --- a/fs/xfs/libxfs/xfs_attr.c
> +++ b/fs/xfs/libxfs/xfs_attr.c
> @@ -204,7 +204,6 @@ xfs_attr_set(
>  	struct xfs_da_args	args;
>  	struct xfs_defer_ops	dfops;
>  	struct xfs_trans_res	tres;
> -	xfs_fsblock_t		firstblock;
>  	int			rsvd = (flags & ATTR_ROOT) != 0;
>  	int			error, err2, local;
>  
> @@ -219,7 +218,6 @@ xfs_attr_set(
>  
>  	args.value = value;
>  	args.valuelen = valuelen;
> -	args.firstblock = &firstblock;
>  	args.op_flags = XFS_DA_OP_ADDNAME | XFS_DA_OP_OKNOENT;
>  	args.total = xfs_attr_calc_size(&args, &local);
>  
> @@ -253,7 +251,7 @@ xfs_attr_set(
>  			rsvd ? XFS_TRANS_RESERVE : 0, &args.trans);
>  	if (error)
>  		return error;
> -	xfs_defer_init(args.trans, &dfops, &firstblock);
> +	xfs_defer_init(args.trans, &dfops, &args.trans->t_firstblock);
>  
>  	xfs_ilock(dp, XFS_ILOCK_EXCL);
>  	error = xfs_trans_reserve_quota_nblks(args.trans, dp, args.total, 0,
> @@ -392,7 +390,6 @@ xfs_attr_remove(
>  	struct xfs_mount	*mp = dp->i_mount;
>  	struct xfs_da_args	args;
>  	struct xfs_defer_ops	dfops;
> -	xfs_fsblock_t		firstblock;
>  	int			error;
>  
>  	XFS_STATS_INC(mp, xs_attr_remove);
> @@ -404,8 +401,6 @@ xfs_attr_remove(
>  	if (error)
>  		return error;
>  
> -	args.firstblock = &firstblock;
> -
>  	/*
>  	 * we have no control over the attribute names that userspace passes us
>  	 * to remove, so we have to allow the name lookup prior to attribute
> @@ -427,7 +422,7 @@ xfs_attr_remove(
>  			&args.trans);
>  	if (error)
>  		return error;
> -	xfs_defer_init(args.trans, &dfops, &firstblock);
> +	xfs_defer_init(args.trans, &dfops, &args.trans->t_firstblock);
>  
>  	xfs_ilock(dp, XFS_ILOCK_EXCL);
>  	/*
> @@ -598,7 +593,8 @@ xfs_attr_leaf_addname(
>  		 * Commit that transaction so that the node_addname() call
>  		 * can manage its own transactions.
>  		 */
> -		xfs_defer_init(NULL, args->trans->t_dfops, args->firstblock);
> +		xfs_defer_init(args->trans, args->trans->t_dfops,
> +			       &args->trans->t_firstblock);
>  		error = xfs_attr3_leaf_to_node(args);
>  		if (error)
>  			goto out_defer_cancel;
> @@ -687,8 +683,8 @@ xfs_attr_leaf_addname(
>  		 * If the result is small enough, shrink it all into the inode.
>  		 */
>  		if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
> -			xfs_defer_init(NULL, args->trans->t_dfops,
> -				       args->firstblock);
> +			xfs_defer_init(args->trans, args->trans->t_dfops,
> +				       &args->trans->t_firstblock);
>  			error = xfs_attr3_leaf_to_shortform(bp, args, forkoff);
>  			/* bp is gone due to xfs_da_shrink_inode */
>  			if (error)
> @@ -753,7 +749,8 @@ xfs_attr_leaf_removename(
>  	 * If the result is small enough, shrink it all into the inode.
>  	 */
>  	if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
> -		xfs_defer_init(NULL, args->trans->t_dfops, args->firstblock);
> +		xfs_defer_init(args->trans, args->trans->t_dfops,
> +			       &args->trans->t_firstblock);
>  		error = xfs_attr3_leaf_to_shortform(bp, args, forkoff);
>  		/* bp is gone due to xfs_da_shrink_inode */
>  		if (error)
> @@ -882,8 +879,8 @@ xfs_attr_node_addname(
>  			 */
>  			xfs_da_state_free(state);
>  			state = NULL;
> -			xfs_defer_init(NULL, args->trans->t_dfops,
> -				       args->firstblock);
> +			xfs_defer_init(args->trans, args->trans->t_dfops,
> +				       &args->trans->t_firstblock);
>  			error = xfs_attr3_leaf_to_node(args);
>  			if (error)
>  				goto out_defer_cancel;
> @@ -910,7 +907,8 @@ xfs_attr_node_addname(
>  		 * in the index/blkno/rmtblkno/rmtblkcnt fields and
>  		 * in the index2/blkno2/rmtblkno2/rmtblkcnt2 fields.
>  		 */
> -		xfs_defer_init(NULL, args->trans->t_dfops, args->firstblock);
> +		xfs_defer_init(args->trans, args->trans->t_dfops,
> +			       &args->trans->t_firstblock);
>  		error = xfs_da3_split(state);
>  		if (error)
>  			goto out_defer_cancel;
> @@ -1008,8 +1006,8 @@ xfs_attr_node_addname(
>  		 * Check to see if the tree needs to be collapsed.
>  		 */
>  		if (retval && (state->path.active > 1)) {
> -			xfs_defer_init(NULL, args->trans->t_dfops,
> -				       args->firstblock);
> +			xfs_defer_init(args->trans, args->trans->t_dfops,
> +				       &args->trans->t_firstblock);
>  			error = xfs_da3_join(state);
>  			if (error)
>  				goto out_defer_cancel;
> @@ -1134,7 +1132,8 @@ xfs_attr_node_removename(
>  	 * Check to see if the tree needs to be collapsed.
>  	 */
>  	if (retval && (state->path.active > 1)) {
> -		xfs_defer_init(NULL, args->trans->t_dfops, args->firstblock);
> +		xfs_defer_init(args->trans, args->trans->t_dfops,
> +			       &args->trans->t_firstblock);
>  		error = xfs_da3_join(state);
>  		if (error)
>  			goto out_defer_cancel;
> @@ -1166,8 +1165,8 @@ xfs_attr_node_removename(
>  			goto out;
>  
>  		if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
> -			xfs_defer_init(NULL, args->trans->t_dfops,
> -				       args->firstblock);
> +			xfs_defer_init(args->trans, args->trans->t_dfops,
> +				       &args->trans->t_firstblock);
>  			error = xfs_attr3_leaf_to_shortform(bp, args, forkoff);
>  			/* bp is gone due to xfs_da_shrink_inode */
>  			if (error)
> diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
> index c131469db0f1..251304f3bc5d 100644
> --- a/fs/xfs/libxfs/xfs_attr_leaf.c
> +++ b/fs/xfs/libxfs/xfs_attr_leaf.c
> @@ -802,7 +802,6 @@ xfs_attr_shortform_to_leaf(
>  	memset((char *)&nargs, 0, sizeof(nargs));
>  	nargs.dp = dp;
>  	nargs.geo = args->geo;
> -	nargs.firstblock = args->firstblock;
>  	nargs.total = args->total;
>  	nargs.whichfork = XFS_ATTR_FORK;
>  	nargs.trans = args->trans;
> @@ -1005,7 +1004,6 @@ xfs_attr3_leaf_to_shortform(
>  	memset((char *)&nargs, 0, sizeof(nargs));
>  	nargs.geo = args->geo;
>  	nargs.dp = dp;
> -	nargs.firstblock = args->firstblock;
>  	nargs.total = args->total;
>  	nargs.whichfork = XFS_ATTR_FORK;
>  	nargs.trans = args->trans;
> diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c
> index ab7c2755ad8c..205098aeb4bc 100644
> --- a/fs/xfs/libxfs/xfs_attr_remote.c
> +++ b/fs/xfs/libxfs/xfs_attr_remote.c
> @@ -480,11 +480,13 @@ xfs_attr_rmtval_set(
>  		 * extent and then crash then the block may not contain the
>  		 * correct metadata after log recovery occurs.
>  		 */
> -		xfs_defer_init(NULL, args->trans->t_dfops, args->firstblock);
> +		xfs_defer_init(args->trans, args->trans->t_dfops,
> +			       &args->trans->t_firstblock);
>  		nmap = 1;
>  		error = xfs_bmapi_write(args->trans, dp, (xfs_fileoff_t)lblkno,
> -				  blkcnt, XFS_BMAPI_ATTRFORK, args->firstblock,
> -				  args->total, &map, &nmap);
> +				  blkcnt, XFS_BMAPI_ATTRFORK,
> +				  &args->trans->t_firstblock, args->total, &map,
> +				  &nmap);
>  		if (error)
>  			goto out_defer_cancel;
>  		xfs_defer_ijoin(args->trans->t_dfops, dp);
> @@ -522,7 +524,8 @@ xfs_attr_rmtval_set(
>  
>  		ASSERT(blkcnt > 0);
>  
> -		xfs_defer_init(NULL, args->trans->t_dfops, args->firstblock);
> +		xfs_defer_init(args->trans, args->trans->t_dfops,
> +			       &args->trans->t_firstblock);
>  		nmap = 1;
>  		error = xfs_bmapi_read(dp, (xfs_fileoff_t)lblkno,
>  				       blkcnt, &map, &nmap,
> @@ -626,10 +629,11 @@ xfs_attr_rmtval_remove(
>  	blkcnt = args->rmtblkcnt;
>  	done = 0;
>  	while (!done) {
> -		xfs_defer_init(NULL, args->trans->t_dfops, args->firstblock);
> +		xfs_defer_init(args->trans, args->trans->t_dfops,
> +			       &args->trans->t_firstblock);
>  		error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt,
> -				    XFS_BMAPI_ATTRFORK, 1, args->firstblock,
> -				    &done);
> +				    XFS_BMAPI_ATTRFORK, 1,
> +				    &args->trans->t_firstblock, &done);
>  		if (error)
>  			goto out_defer_cancel;
>  		xfs_defer_ijoin(args->trans->t_dfops, args->dp);
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index fcd10b47044a..86097be47ae9 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -1000,7 +1000,6 @@ xfs_bmap_add_attrfork_local(
>  		memset(&dargs, 0, sizeof(dargs));
>  		dargs.geo = ip->i_mount->m_dir_geo;
>  		dargs.dp = ip;
> -		dargs.firstblock = &tp->t_firstblock;
>  		dargs.total = dargs.geo->fsbcount;
>  		dargs.whichfork = XFS_DATA_FORK;
>  		dargs.trans = tp;
> diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
> index 68a72e3d9f53..2f2be86c10dc 100644
> --- a/fs/xfs/libxfs/xfs_da_btree.c
> +++ b/fs/xfs/libxfs/xfs_da_btree.c
> @@ -2059,10 +2059,9 @@ xfs_da_grow_inode_int(
>  	 * Try mapping it in one filesystem block.
>  	 */
>  	nmap = 1;
> -	ASSERT(args->firstblock != NULL);
>  	error = xfs_bmapi_write(tp, dp, *bno, count,
>  			xfs_bmapi_aflag(w)|XFS_BMAPI_METADATA|XFS_BMAPI_CONTIG,
> -			args->firstblock, args->total, &map, &nmap);
> +			&tp->t_firstblock, args->total, &map, &nmap);
>  	if (error)
>  		return error;
>  
> @@ -2084,7 +2083,7 @@ xfs_da_grow_inode_int(
>  			c = (int)(*bno + count - b);
>  			error = xfs_bmapi_write(tp, dp, b, c,
>  					xfs_bmapi_aflag(w)|XFS_BMAPI_METADATA,
> -					args->firstblock, args->total,
> +					&tp->t_firstblock, args->total,
>  					&mapp[mapi], &nmap);
>  			if (error)
>  				goto out_free_map;
> @@ -2394,7 +2393,7 @@ xfs_da_shrink_inode(
>  		 * the last block to the place we want to kill.
>  		 */
>  		error = xfs_bunmapi(tp, dp, dead_blkno, count,
> -				    xfs_bmapi_aflag(w), 0, args->firstblock,
> +				    xfs_bmapi_aflag(w), 0, &tp->t_firstblock,
>  				    &done);
>  		if (error == -ENOSPC) {
>  			if (w != XFS_DATA_FORK)
> diff --git a/fs/xfs/libxfs/xfs_da_btree.h b/fs/xfs/libxfs/xfs_da_btree.h
> index 6b8a04f3f162..59e290ef334f 100644
> --- a/fs/xfs/libxfs/xfs_da_btree.h
> +++ b/fs/xfs/libxfs/xfs_da_btree.h
> @@ -57,7 +57,6 @@ typedef struct xfs_da_args {
>  	xfs_dahash_t	hashval;	/* hash value of name */
>  	xfs_ino_t	inumber;	/* input/output inode number */
>  	struct xfs_inode *dp;		/* directory inode to manipulate */
> -	xfs_fsblock_t	*firstblock;	/* ptr to firstblock for bmap calls */
>  	struct xfs_trans *trans;	/* current trans (changes over time) */
>  	xfs_extlen_t	total;		/* total blocks needed, for 1st bmap */
>  	int		whichfork;	/* data or attribute fork */
> diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
> index 8a55990ca3a5..53e46fda8df4 100644
> --- a/fs/xfs/libxfs/xfs_dir2.c
> +++ b/fs/xfs/libxfs/xfs_dir2.c
> @@ -271,7 +271,6 @@ xfs_dir_createname(
>  	args->total = total;
>  	args->whichfork = XFS_DATA_FORK;
>  	args->trans = tp;
> -	args->firstblock = &tp->t_firstblock;
>  	args->op_flags = XFS_DA_OP_ADDNAME | XFS_DA_OP_OKNOENT;
>  	if (!inum)
>  		args->op_flags |= XFS_DA_OP_JUSTCHECK;
> @@ -437,7 +436,6 @@ xfs_dir_removename(
>  	args->hashval = dp->i_mount->m_dirnameops->hashname(name);
>  	args->inumber = ino;
>  	args->dp = dp;
> -	args->firstblock = &tp->t_firstblock;
>  	args->total = total;
>  	args->whichfork = XFS_DATA_FORK;
>  	args->trans = tp;
> @@ -500,7 +498,6 @@ xfs_dir_replace(
>  	args->hashval = dp->i_mount->m_dirnameops->hashname(name);
>  	args->inumber = inum;
>  	args->dp = dp;
> -	args->firstblock = &tp->t_firstblock;
>  	args->total = total;
>  	args->whichfork = XFS_DATA_FORK;
>  	args->trans = tp;
> @@ -659,7 +656,7 @@ xfs_dir2_shrink_inode(
>  
>  	/* Unmap the fsblock(s). */
>  	error = xfs_bunmapi(tp, dp, da, args->geo->fsbcount, 0, 0,
> -			    args->firstblock, &done);
> +			    &tp->t_firstblock, &done);
>  	if (error) {
>  		/*
>  		 * ENOSPC actually can happen if we're in a removename with no
> -- 
> 2.17.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 07/25] xfs: use ->t_firstblock for all xfs_bmapi_write() callers
  2018-07-03 17:23 ` [PATCH 07/25] xfs: use ->t_firstblock for all xfs_bmapi_write() callers Brian Foster
@ 2018-07-04  0:47   ` Darrick J. Wong
  0 siblings, 0 replies; 58+ messages in thread
From: Darrick J. Wong @ 2018-07-04  0:47 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-xfs

On Tue, Jul 03, 2018 at 01:23:01PM -0400, Brian Foster wrote:
> Convert all xfs_bmapi_write() users to ->t_firstblock.
> 
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/xfs_bmap_util.c |  8 ++++----
>  fs/xfs/xfs_dquot.c     |  5 ++---
>  fs/xfs/xfs_iomap.c     | 20 +++++++++-----------
>  fs/xfs/xfs_reflink.c   |  7 +++----
>  fs/xfs/xfs_rtalloc.c   |  5 ++---
>  5 files changed, 20 insertions(+), 25 deletions(-)
> 
> diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
> index aea33d526db2..f9a0957343ea 100644
> --- a/fs/xfs/xfs_bmap_util.c
> +++ b/fs/xfs/xfs_bmap_util.c
> @@ -872,7 +872,6 @@ xfs_alloc_file_space(
>  	xfs_filblks_t		allocatesize_fsb;
>  	xfs_extlen_t		extsz, temp;
>  	xfs_fileoff_t		startoffset_fsb;
> -	xfs_fsblock_t		firstfsb;
>  	int			nimaps;
>  	int			quota_flag;
>  	int			rt;
> @@ -971,10 +970,11 @@ xfs_alloc_file_space(
>  
>  		xfs_trans_ijoin(tp, ip, 0);
>  
> -		xfs_defer_init(tp, &dfops, &firstfsb);
> +		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
>  		error = xfs_bmapi_write(tp, ip, startoffset_fsb,
> -					allocatesize_fsb, alloc_type, &firstfsb,
> -					resblks, imapp, &nimaps);
> +					allocatesize_fsb, alloc_type,
> +					&tp->t_firstblock, resblks, imapp,
> +					&nimaps);
>  		if (error)
>  			goto error0;
>  
> diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
> index c698e7f6f744..2fc5e21373be 100644
> --- a/fs/xfs/xfs_dquot.c
> +++ b/fs/xfs/xfs_dquot.c
> @@ -290,13 +290,12 @@ xfs_dquot_disk_alloc(
>  	struct xfs_mount	*mp = tp->t_mountp;
>  	struct xfs_buf		*bp;
>  	struct xfs_inode	*quotip = xfs_quota_inode(mp, dqp->dq_flags);
> -	xfs_fsblock_t		firstblock;
>  	int			nmaps = 1;
>  	int			error;
>  
>  	trace_xfs_dqalloc(dqp);
>  
> -	xfs_defer_init(tp, tp->t_dfops, &firstblock);
> +	xfs_defer_init(tp, tp->t_dfops, &tp->t_firstblock);
>  
>  	xfs_ilock(quotip, XFS_ILOCK_EXCL);
>  	if (!xfs_this_quota_on(dqp->q_mount, dqp->dq_flags)) {
> @@ -312,7 +311,7 @@ xfs_dquot_disk_alloc(
>  	xfs_trans_ijoin(tp, quotip, XFS_ILOCK_EXCL);
>  	error = xfs_bmapi_write(tp, quotip, dqp->q_fileoffset,
>  			XFS_DQUOT_CLUSTER_SIZE_FSB, XFS_BMAPI_METADATA,
> -			&firstblock, XFS_QM_DQALLOC_SPACE_RES(mp),
> +			&tp->t_firstblock, XFS_QM_DQALLOC_SPACE_RES(mp),
>  			&map, &nmaps);
>  	if (error)
>  		goto error0;
> diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
> index c9b9c7984f95..4a8a85b0fad2 100644
> --- a/fs/xfs/xfs_iomap.c
> +++ b/fs/xfs/xfs_iomap.c
> @@ -152,7 +152,6 @@ xfs_iomap_write_direct(
>  	xfs_fileoff_t	offset_fsb;
>  	xfs_fileoff_t	last_fsb;
>  	xfs_filblks_t	count_fsb, resaligned;
> -	xfs_fsblock_t	firstfsb;
>  	xfs_extlen_t	extsz;
>  	int		nimaps;
>  	int		quota_flag;
> @@ -254,10 +253,10 @@ xfs_iomap_write_direct(
>  	 * From this point onwards we overwrite the imap pointer that the
>  	 * caller gave to us.
>  	 */
> -	xfs_defer_init(tp, &dfops, &firstfsb);
> +	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
>  	nimaps = 1;
>  	error = xfs_bmapi_write(tp, ip, offset_fsb, count_fsb,
> -				bmapi_flags, &firstfsb, resblks, imap,
> +				bmapi_flags, &tp->t_firstblock, resblks, imap,
>  				&nimaps);
>  	if (error)
>  		goto out_bmap_cancel;
> @@ -665,7 +664,6 @@ xfs_iomap_write_allocate(
>  	xfs_mount_t	*mp = ip->i_mount;
>  	xfs_fileoff_t	offset_fsb, last_block;
>  	xfs_fileoff_t	end_fsb, map_start_fsb;
> -	xfs_fsblock_t	first_block;
>  	struct xfs_defer_ops	dfops;
>  	xfs_filblks_t	count_fsb;
>  	xfs_trans_t	*tp;
> @@ -716,7 +714,7 @@ xfs_iomap_write_allocate(
>  			xfs_ilock(ip, XFS_ILOCK_EXCL);
>  			xfs_trans_ijoin(tp, ip, 0);
>  
> -			xfs_defer_init(tp, &dfops, &first_block);
> +			xfs_defer_init(tp, &dfops, &tp->t_firstblock);
>  
>  			/*
>  			 * it is possible that the extents have changed since
> @@ -770,8 +768,9 @@ xfs_iomap_write_allocate(
>  			 * pointer that the caller gave to us.
>  			 */
>  			error = xfs_bmapi_write(tp, ip, map_start_fsb,
> -						count_fsb, flags, &first_block,
> -						nres, imap, &nimaps);
> +						count_fsb, flags,
> +						&tp->t_firstblock, nres, imap,
> +						&nimaps);
>  			if (error)
>  				goto trans_cancel;
>  
> @@ -827,7 +826,6 @@ xfs_iomap_write_unwritten(
>  	xfs_fileoff_t	offset_fsb;
>  	xfs_filblks_t	count_fsb;
>  	xfs_filblks_t	numblks_fsb;
> -	xfs_fsblock_t	firstfsb;
>  	int		nimaps;
>  	xfs_trans_t	*tp;
>  	xfs_bmbt_irec_t imap;
> @@ -876,11 +874,11 @@ xfs_iomap_write_unwritten(
>  		/*
>  		 * Modify the unwritten extent state of the buffer.
>  		 */
> -		xfs_defer_init(tp, &dfops, &firstfsb);
> +		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
>  		nimaps = 1;
>  		error = xfs_bmapi_write(tp, ip, offset_fsb, count_fsb,
> -					XFS_BMAPI_CONVERT, &firstfsb, resblks,
> -					&imap, &nimaps);
> +					XFS_BMAPI_CONVERT, &tp->t_firstblock,
> +					resblks, &imap, &nimaps);
>  		if (error)
>  			goto error_on_bmapi_transaction;
>  
> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> index 92b6e1b5d33c..f0486b748376 100644
> --- a/fs/xfs/xfs_reflink.c
> +++ b/fs/xfs/xfs_reflink.c
> @@ -366,7 +366,6 @@ xfs_reflink_allocate_cow(
>  	struct xfs_bmbt_irec	got;
>  	struct xfs_defer_ops	dfops;
>  	struct xfs_trans	*tp = NULL;
> -	xfs_fsblock_t		first_block;
>  	int			nimaps, error = 0;
>  	bool			trimmed;
>  	xfs_filblks_t		resaligned;
> @@ -425,13 +424,13 @@ xfs_reflink_allocate_cow(
>  
>  	xfs_trans_ijoin(tp, ip, 0);
>  
> -	xfs_defer_init(tp, &dfops, &first_block);
> +	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
>  	nimaps = 1;
>  
>  	/* Allocate the entire reservation as unwritten blocks. */
>  	error = xfs_bmapi_write(tp, ip, imap->br_startoff, imap->br_blockcount,
> -			XFS_BMAPI_COWFORK | XFS_BMAPI_PREALLOC, &first_block,
> -			resblks, imap, &nimaps);
> +			XFS_BMAPI_COWFORK | XFS_BMAPI_PREALLOC,
> +			&tp->t_firstblock, resblks, imap, &nimaps);
>  	if (error)
>  		goto out_bmap_cancel;
>  
> diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
> index c102b0d26bc1..1c894ea2abca 100644
> --- a/fs/xfs/xfs_rtalloc.c
> +++ b/fs/xfs/xfs_rtalloc.c
> @@ -761,7 +761,6 @@ xfs_growfs_rt_alloc(
>  	struct xfs_buf		*bp;	/* temporary buffer for zeroing */
>  	xfs_daddr_t		d;		/* disk block address */
>  	int			error;		/* error return value */
> -	xfs_fsblock_t		firstblock;/* first block allocated in xaction */
>  	struct xfs_defer_ops	dfops;		/* list of freed blocks */
>  	xfs_fsblock_t		fsbno;		/* filesystem block for bno */
>  	struct xfs_bmbt_irec	map;		/* block map output */
> @@ -787,13 +786,13 @@ xfs_growfs_rt_alloc(
>  		xfs_ilock(ip, XFS_ILOCK_EXCL);
>  		xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
>  
> -		xfs_defer_init(tp, &dfops, &firstblock);
> +		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
>  		/*
>  		 * Allocate blocks to the bitmap file.
>  		 */
>  		nmap = 1;
>  		error = xfs_bmapi_write(tp, ip, oblocks, nblocks - oblocks,
> -					XFS_BMAPI_METADATA, &firstblock,
> +					XFS_BMAPI_METADATA, &tp->t_firstblock,
>  					resblks, &map, &nmap);
>  		if (!error && nmap < 1)
>  			error = -ENOSPC;
> -- 
> 2.17.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 08/25] xfs: use ->t_firstblock for all xfs_bunmapi() callers
  2018-07-03 17:23 ` [PATCH 08/25] xfs: use ->t_firstblock for all xfs_bunmapi() callers Brian Foster
@ 2018-07-04  0:47   ` Darrick J. Wong
  0 siblings, 0 replies; 58+ messages in thread
From: Darrick J. Wong @ 2018-07-04  0:47 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-xfs

On Tue, Jul 03, 2018 at 01:23:02PM -0400, Brian Foster wrote:
> Convert all xfs_bunmapi() callers to ->t_firstblock.
> 
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_bmap.c | 12 ++----------
>  fs/xfs/xfs_bmap_util.c   |  7 +++----
>  fs/xfs/xfs_inode.c       |  5 ++---
>  fs/xfs/xfs_reflink.c     | 11 +++++------
>  fs/xfs/xfs_symlink.c     |  6 +++---
>  5 files changed, 15 insertions(+), 26 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 86097be47ae9..4ace1267fc35 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -6134,17 +6134,9 @@ xfs_bmap_finish_one(
>  	xfs_filblks_t			*blockcount,
>  	xfs_exntst_t			state)
>  {
> -	xfs_fsblock_t			firstfsb;
>  	int				error = 0;
>  
> -	/*
> -	 * firstfsb is tied to the transaction lifetime and is used to
> -	 * ensure correct AG locking order and schedule work item
> -	 * continuations.  XFS_BUI_MAX_FAST_EXTENTS (== 1) restricts us
> -	 * to only making one bmap call per transaction, so it should
> -	 * be safe to have it as a local variable here.
> -	 */
> -	firstfsb = NULLFSBLOCK;
> +	ASSERT(tp->t_firstblock == NULLFSBLOCK);
>  
>  	trace_xfs_bmap_deferred(tp->t_mountp,
>  			XFS_FSB_TO_AGNO(tp->t_mountp, startblock), type,
> @@ -6167,7 +6159,7 @@ xfs_bmap_finish_one(
>  		break;
>  	case XFS_BMAP_UNMAP:
>  		error = __xfs_bunmapi(tp, ip, startoff, blockcount,
> -				XFS_BMAPI_REMAP, 1, &firstfsb);
> +				XFS_BMAPI_REMAP, 1, &tp->t_firstblock);
>  		break;
>  	default:
>  		ASSERT(0);
> diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
> index f9a0957343ea..b49364779966 100644
> --- a/fs/xfs/xfs_bmap_util.c
> +++ b/fs/xfs/xfs_bmap_util.c
> @@ -1023,7 +1023,6 @@ xfs_unmap_extent(
>  	struct xfs_mount	*mp = ip->i_mount;
>  	struct xfs_trans	*tp;
>  	struct xfs_defer_ops	dfops;
> -	xfs_fsblock_t		firstfsb;
>  	uint			resblks = XFS_DIOSTRAT_SPACE_RES(mp, 0);
>  	int			error;
>  
> @@ -1041,9 +1040,9 @@ xfs_unmap_extent(
>  
>  	xfs_trans_ijoin(tp, ip, 0);
>  
> -	xfs_defer_init(tp, &dfops, &firstfsb);
> -	error = xfs_bunmapi(tp, ip, startoffset_fsb, len_fsb, 0, 2, &firstfsb,
> -			    done);
> +	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> +	error = xfs_bunmapi(tp, ip, startoffset_fsb, len_fsb, 0, 2,
> +			    &tp->t_firstblock, done);
>  	if (error)
>  		goto out_bmap_cancel;
>  
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index ab1fd696500c..3cdfd795a50c 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -1543,7 +1543,6 @@ xfs_itruncate_extents_flags(
>  	struct xfs_trans	*tp = *tpp;
>  	struct xfs_defer_ops	*odfops = tp->t_dfops;
>  	struct xfs_defer_ops	dfops;
> -	xfs_fsblock_t		first_block;
>  	xfs_fileoff_t		first_unmap_block;
>  	xfs_fileoff_t		last_block;
>  	xfs_filblks_t		unmap_len;
> @@ -1580,9 +1579,9 @@ xfs_itruncate_extents_flags(
>  	ASSERT(first_unmap_block < last_block);
>  	unmap_len = last_block - first_unmap_block + 1;
>  	while (!done) {
> -		xfs_defer_init(tp, &dfops, &first_block);
> +		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
>  		error = xfs_bunmapi(tp, ip, first_unmap_block, unmap_len, flags,
> -				    XFS_ITRUNC_MAX_EXTENTS, &first_block,
> +				    XFS_ITRUNC_MAX_EXTENTS, &tp->t_firstblock,
>  				    &done);
>  		if (error)
>  			goto out_bmap_cancel;
> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> index f0486b748376..eed6b9df7944 100644
> --- a/fs/xfs/xfs_reflink.c
> +++ b/fs/xfs/xfs_reflink.c
> @@ -690,7 +690,6 @@ xfs_reflink_end_cow(
>  	struct xfs_trans		*tp;
>  	xfs_fileoff_t			offset_fsb;
>  	xfs_fileoff_t			end_fsb;
> -	xfs_fsblock_t			firstfsb;
>  	struct xfs_defer_ops		dfops;
>  	int				error;
>  	unsigned int			resblks;
> @@ -758,10 +757,10 @@ xfs_reflink_end_cow(
>  			goto prev_extent;
>  
>  		/* Unmap the old blocks in the data fork. */
> -		xfs_defer_init(tp, &dfops, &firstfsb);
> +		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
>  		rlen = del.br_blockcount;
>  		error = __xfs_bunmapi(tp, ip, del.br_startoff, &rlen, 0, 1,
> -				&firstfsb);
> +				&tp->t_firstblock);
>  		if (error)
>  			goto out_defer;
>  
> @@ -1065,7 +1064,6 @@ xfs_reflink_remap_extent(
>  	struct xfs_mount	*mp = ip->i_mount;
>  	bool			real_extent = xfs_bmap_is_real_extent(irec);
>  	struct xfs_trans	*tp;
> -	xfs_fsblock_t		firstfsb;
>  	unsigned int		resblks;
>  	struct xfs_defer_ops	dfops;
>  	struct xfs_bmbt_irec	uirec;
> @@ -1108,8 +1106,9 @@ xfs_reflink_remap_extent(
>  	/* Unmap the old blocks in the data fork. */
>  	rlen = unmap_len;
>  	while (rlen) {
> -		xfs_defer_init(tp, &dfops, &firstfsb);
> -		error = __xfs_bunmapi(tp, ip, destoff, &rlen, 0, 1, &firstfsb);
> +		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> +		error = __xfs_bunmapi(tp, ip, destoff, &rlen, 0, 1,
> +				      &tp->t_firstblock);
>  		if (error)
>  			goto out_defer;
>  
> diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
> index 583ca83353f7..18d9b4d301e5 100644
> --- a/fs/xfs/xfs_symlink.c
> +++ b/fs/xfs/xfs_symlink.c
> @@ -400,7 +400,6 @@ xfs_inactive_symlink_rmt(
>  	xfs_buf_t	*bp;
>  	int		done;
>  	int		error;
> -	xfs_fsblock_t	first_block;
>  	struct xfs_defer_ops	dfops;
>  	int		i;
>  	xfs_mount_t	*mp;
> @@ -440,7 +439,7 @@ xfs_inactive_symlink_rmt(
>  	 * Find the block(s) so we can inval and unmap them.
>  	 */
>  	done = 0;
> -	xfs_defer_init(tp, &dfops, &first_block);
> +	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
>  	nmaps = ARRAY_SIZE(mval);
>  	error = xfs_bmapi_read(ip, 0, xfs_symlink_blocks(mp, size),
>  				mval, &nmaps, 0);
> @@ -462,7 +461,8 @@ xfs_inactive_symlink_rmt(
>  	/*
>  	 * Unmap the dead block(s) to the dfops.
>  	 */
> -	error = xfs_bunmapi(tp, ip, 0, size, 0, nmaps, &first_block, &done);
> +	error = xfs_bunmapi(tp, ip, 0, size, 0, nmaps, &tp->t_firstblock,
> +			    &done);
>  	if (error)
>  		goto error_bmap_cancel;
>  	ASSERT(done);
> -- 
> 2.17.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 09/25] xfs: use ->t_firstblock in xfs_bmapi_remap()
  2018-07-03 17:23 ` [PATCH 09/25] xfs: use ->t_firstblock in xfs_bmapi_remap() Brian Foster
@ 2018-07-04  0:47   ` Darrick J. Wong
  0 siblings, 0 replies; 58+ messages in thread
From: Darrick J. Wong @ 2018-07-04  0:47 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-xfs

On Tue, Jul 03, 2018 at 01:23:03PM -0400, Brian Foster wrote:
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_bmap.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 4ace1267fc35..05647d4b8f3e 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -4503,7 +4503,6 @@ xfs_bmapi_remap(
>  	struct xfs_mount	*mp = ip->i_mount;
>  	struct xfs_ifork	*ifp;
>  	struct xfs_btree_cur	*cur = NULL;
> -	xfs_fsblock_t		firstblock = NULLFSBLOCK;
>  	struct xfs_bmbt_irec	got;
>  	struct xfs_iext_cursor	icur;
>  	int			whichfork = xfs_bmapi_whichfork(flags);
> @@ -4546,7 +4545,7 @@ xfs_bmapi_remap(
>  
>  	if (ifp->if_flags & XFS_IFBROOT) {
>  		cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
> -		cur->bc_private.b.firstblock = firstblock;
> +		cur->bc_private.b.firstblock = tp->t_firstblock;
>  		cur->bc_private.b.flags = 0;
>  	}
>  
> @@ -4559,7 +4558,7 @@ xfs_bmapi_remap(
>  		got.br_state = XFS_EXT_NORM;
>  
>  	error = xfs_bmap_add_extent_hole_real(tp, ip, whichfork, &icur,
> -			&cur, &got, &firstblock, &logflags, flags);
> +			&cur, &got, &tp->t_firstblock, &logflags, flags);
>  	if (error)
>  		goto error0;
>  
> -- 
> 2.17.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 10/25] xfs: use ->t_firstblock in insert/collapse range
  2018-07-03 17:23 ` [PATCH 10/25] xfs: use ->t_firstblock in insert/collapse range Brian Foster
@ 2018-07-04  0:48   ` Darrick J. Wong
  0 siblings, 0 replies; 58+ messages in thread
From: Darrick J. Wong @ 2018-07-04  0:48 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-xfs

On Tue, Jul 03, 2018 at 01:23:04PM -0400, Brian Foster wrote:
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/xfs_bmap_util.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
> index b49364779966..b690def4962b 100644
> --- a/fs/xfs/xfs_bmap_util.c
> +++ b/fs/xfs/xfs_bmap_util.c
> @@ -1310,7 +1310,6 @@ xfs_collapse_file_space(
>  	struct xfs_trans	*tp;
>  	int			error;
>  	struct xfs_defer_ops	dfops;
> -	xfs_fsblock_t		first_block;
>  	xfs_fileoff_t		next_fsb = XFS_B_TO_FSB(mp, offset + len);
>  	xfs_fileoff_t		shift_fsb = XFS_B_TO_FSB(mp, len);
>  	uint			resblks = XFS_DIOSTRAT_SPACE_RES(mp, 0);
> @@ -1343,9 +1342,9 @@ xfs_collapse_file_space(
>  			goto out_trans_cancel;
>  		xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
>  
> -		xfs_defer_init(tp, &dfops, &first_block);
> +		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
>  		error = xfs_bmap_collapse_extents(tp, ip, &next_fsb, shift_fsb,
> -				&done, &first_block);
> +				&done, &tp->t_firstblock);
>  		if (error)
>  			goto out_bmap_cancel;
>  
> @@ -1386,7 +1385,6 @@ xfs_insert_file_space(
>  	struct xfs_trans	*tp;
>  	int			error;
>  	struct xfs_defer_ops	dfops;
> -	xfs_fsblock_t		first_block;
>  	xfs_fileoff_t		stop_fsb = XFS_B_TO_FSB(mp, offset);
>  	xfs_fileoff_t		next_fsb = NULLFSBLOCK;
>  	xfs_fileoff_t		shift_fsb = XFS_B_TO_FSB(mp, len);
> @@ -1422,9 +1420,9 @@ xfs_insert_file_space(
>  
>  		xfs_ilock(ip, XFS_ILOCK_EXCL);
>  		xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
> -		xfs_defer_init(tp, &dfops, &first_block);
> +		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
>  		error = xfs_bmap_insert_extents(tp, ip, &next_fsb, shift_fsb,
> -				&done, stop_fsb, &first_block);
> +				&done, stop_fsb, &tp->t_firstblock);
>  		if (error)
>  			goto out_bmap_cancel;
>  
> -- 
> 2.17.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 11/25] xfs: remove xfs_bmapi_write() firstblock param
  2018-07-03 17:23 ` [PATCH 11/25] xfs: remove xfs_bmapi_write() firstblock param Brian Foster
@ 2018-07-04  0:50   ` Darrick J. Wong
  0 siblings, 0 replies; 58+ messages in thread
From: Darrick J. Wong @ 2018-07-04  0:50 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-xfs

On Tue, Jul 03, 2018 at 01:23:05PM -0400, Brian Foster wrote:
> All callers pass ->t_firstblock from the current transaction.
> 
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_attr_remote.c |  3 +--
>  fs/xfs/libxfs/xfs_bmap.c        | 18 +++++-------------
>  fs/xfs/libxfs/xfs_bmap.h        |  3 +--
>  fs/xfs/libxfs/xfs_da_btree.c    |  5 ++---
>  fs/xfs/xfs_bmap_util.c          |  5 ++---
>  fs/xfs/xfs_dquot.c              |  3 +--
>  fs/xfs/xfs_iomap.c              | 10 ++++------
>  fs/xfs/xfs_reflink.c            |  6 +++---
>  fs/xfs/xfs_rtalloc.c            |  4 ++--
>  fs/xfs/xfs_symlink.c            |  3 +--
>  10 files changed, 22 insertions(+), 38 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c
> index 205098aeb4bc..2db9ef186e05 100644
> --- a/fs/xfs/libxfs/xfs_attr_remote.c
> +++ b/fs/xfs/libxfs/xfs_attr_remote.c
> @@ -484,8 +484,7 @@ xfs_attr_rmtval_set(
>  			       &args->trans->t_firstblock);
>  		nmap = 1;
>  		error = xfs_bmapi_write(args->trans, dp, (xfs_fileoff_t)lblkno,
> -				  blkcnt, XFS_BMAPI_ATTRFORK,
> -				  &args->trans->t_firstblock, args->total, &map,
> +				  blkcnt, XFS_BMAPI_ATTRFORK, args->total, &map,
>  				  &nmap);
>  		if (error)
>  			goto out_defer_cancel;
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 05647d4b8f3e..fd4125e3b097 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -4213,12 +4213,6 @@ xfs_bmapi_convert_unwritten(
>   * extent state if necessary.  Details behaviour is controlled by the flags
>   * parameter.  Only allocates blocks from a single allocation group, to avoid
>   * locking problems.
> - *
> - * The returned value in "firstblock" from the first call in a transaction
> - * must be remembered and presented to subsequent calls in "firstblock".
> - * An upper bound for the number of blocks to be allocated is supplied to
> - * the first call in "total"; if no allocation group has that many free
> - * blocks then the call will fail (return NULLFSBLOCK in "firstblock").
>   */
>  int
>  xfs_bmapi_write(
> @@ -4227,8 +4221,6 @@ xfs_bmapi_write(
>  	xfs_fileoff_t		bno,		/* starting file offs. mapped */
>  	xfs_filblks_t		len,		/* length to map in file */
>  	int			flags,		/* XFS_BMAPI_... */
> -	xfs_fsblock_t		*firstblock,	/* first allocated block
> -						   controls a.g. for allocs */
>  	xfs_extlen_t		total,		/* total blocks needed */
>  	struct xfs_bmbt_irec	*mval,		/* output: map values */
>  	int			*nmap)		/* i/o: mval size/count */
> @@ -4296,7 +4288,7 @@ xfs_bmapi_write(
>  
>  	XFS_STATS_INC(mp, xs_blk_mapw);
>  
> -	if (!tp || *firstblock == NULLFSBLOCK) {
> +	if (!tp || tp->t_firstblock == NULLFSBLOCK) {
>  		if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE)
>  			bma.minleft = be16_to_cpu(ifp->if_broot->bb_level) + 1;
>  		else
> @@ -4323,7 +4315,7 @@ xfs_bmapi_write(
>  	bma.ip = ip;
>  	bma.total = total;
>  	bma.datatype = 0;
> -	bma.firstblock = firstblock;
> +	bma.firstblock = &tp->t_firstblock;
>  	ASSERT(!tp || tp->t_dfops);
>  
>  	while (bno < end && n < *nmap) {
> @@ -4476,11 +4468,11 @@ xfs_bmapi_write(
>  
>  	if (bma.cur) {
>  		if (!error) {
> -			ASSERT(*firstblock == NULLFSBLOCK ||
> -			       XFS_FSB_TO_AGNO(mp, *firstblock) <=
> +			ASSERT(tp->t_firstblock == NULLFSBLOCK ||
> +			       XFS_FSB_TO_AGNO(mp, tp->t_firstblock) <=
>  			       XFS_FSB_TO_AGNO(mp,
>  				       bma.cur->bc_private.b.firstblock));
> -			*firstblock = bma.cur->bc_private.b.firstblock;
> +			tp->t_firstblock = bma.cur->bc_private.b.firstblock;
>  		}
>  		xfs_btree_del_cursor(bma.cur,
>  			error ? XFS_BTREE_ERROR : XFS_BTREE_NOERROR);
> diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h
> index 2da6c6daada8..1f9e29f32f20 100644
> --- a/fs/xfs/libxfs/xfs_bmap.h
> +++ b/fs/xfs/libxfs/xfs_bmap.h
> @@ -204,8 +204,7 @@ int	xfs_bmapi_read(struct xfs_inode *ip, xfs_fileoff_t bno,
>  		int *nmap, int flags);
>  int	xfs_bmapi_write(struct xfs_trans *tp, struct xfs_inode *ip,
>  		xfs_fileoff_t bno, xfs_filblks_t len, int flags,
> -		xfs_fsblock_t *firstblock, xfs_extlen_t total,
> -		struct xfs_bmbt_irec *mval, int *nmap);
> +		xfs_extlen_t total, struct xfs_bmbt_irec *mval, int *nmap);
>  int	__xfs_bunmapi(struct xfs_trans *tp, struct xfs_inode *ip,
>  		xfs_fileoff_t bno, xfs_filblks_t *rlen, int flags,
>  		xfs_extnum_t nexts, xfs_fsblock_t *firstblock);
> diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
> index 2f2be86c10dc..fe4a192696ae 100644
> --- a/fs/xfs/libxfs/xfs_da_btree.c
> +++ b/fs/xfs/libxfs/xfs_da_btree.c
> @@ -2061,7 +2061,7 @@ xfs_da_grow_inode_int(
>  	nmap = 1;
>  	error = xfs_bmapi_write(tp, dp, *bno, count,
>  			xfs_bmapi_aflag(w)|XFS_BMAPI_METADATA|XFS_BMAPI_CONTIG,
> -			&tp->t_firstblock, args->total, &map, &nmap);
> +			args->total, &map, &nmap);
>  	if (error)
>  		return error;
>  
> @@ -2083,8 +2083,7 @@ xfs_da_grow_inode_int(
>  			c = (int)(*bno + count - b);
>  			error = xfs_bmapi_write(tp, dp, b, c,
>  					xfs_bmapi_aflag(w)|XFS_BMAPI_METADATA,
> -					&tp->t_firstblock, args->total,
> -					&mapp[mapi], &nmap);
> +					args->total, &mapp[mapi], &nmap);
>  			if (error)
>  				goto out_free_map;
>  			if (nmap < 1)
> diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
> index b690def4962b..0c433dbc6eb2 100644
> --- a/fs/xfs/xfs_bmap_util.c
> +++ b/fs/xfs/xfs_bmap_util.c
> @@ -972,9 +972,8 @@ xfs_alloc_file_space(
>  
>  		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
>  		error = xfs_bmapi_write(tp, ip, startoffset_fsb,
> -					allocatesize_fsb, alloc_type,
> -					&tp->t_firstblock, resblks, imapp,
> -					&nimaps);
> +					allocatesize_fsb, alloc_type, resblks,
> +					imapp, &nimaps);
>  		if (error)
>  			goto error0;
>  
> diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
> index 2fc5e21373be..84359eeb20f4 100644
> --- a/fs/xfs/xfs_dquot.c
> +++ b/fs/xfs/xfs_dquot.c
> @@ -311,8 +311,7 @@ xfs_dquot_disk_alloc(
>  	xfs_trans_ijoin(tp, quotip, XFS_ILOCK_EXCL);
>  	error = xfs_bmapi_write(tp, quotip, dqp->q_fileoffset,
>  			XFS_DQUOT_CLUSTER_SIZE_FSB, XFS_BMAPI_METADATA,
> -			&tp->t_firstblock, XFS_QM_DQALLOC_SPACE_RES(mp),
> -			&map, &nmaps);
> +			XFS_QM_DQALLOC_SPACE_RES(mp), &map, &nmaps);
>  	if (error)
>  		goto error0;
>  	ASSERT(map.br_blockcount == XFS_DQUOT_CLUSTER_SIZE_FSB);
> diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
> index 4a8a85b0fad2..46ade3f7a5a3 100644
> --- a/fs/xfs/xfs_iomap.c
> +++ b/fs/xfs/xfs_iomap.c
> @@ -256,8 +256,7 @@ xfs_iomap_write_direct(
>  	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
>  	nimaps = 1;
>  	error = xfs_bmapi_write(tp, ip, offset_fsb, count_fsb,
> -				bmapi_flags, &tp->t_firstblock, resblks, imap,
> -				&nimaps);
> +				bmapi_flags, resblks, imap, &nimaps);
>  	if (error)
>  		goto out_bmap_cancel;
>  
> @@ -768,8 +767,7 @@ xfs_iomap_write_allocate(
>  			 * pointer that the caller gave to us.
>  			 */
>  			error = xfs_bmapi_write(tp, ip, map_start_fsb,
> -						count_fsb, flags,
> -						&tp->t_firstblock, nres, imap,
> +						count_fsb, flags, nres, imap,
>  						&nimaps);
>  			if (error)
>  				goto trans_cancel;
> @@ -877,8 +875,8 @@ xfs_iomap_write_unwritten(
>  		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
>  		nimaps = 1;
>  		error = xfs_bmapi_write(tp, ip, offset_fsb, count_fsb,
> -					XFS_BMAPI_CONVERT, &tp->t_firstblock,
> -					resblks, &imap, &nimaps);
> +					XFS_BMAPI_CONVERT, resblks, &imap,
> +					&nimaps);
>  		if (error)
>  			goto error_on_bmapi_transaction;
>  
> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> index eed6b9df7944..258183f28141 100644
> --- a/fs/xfs/xfs_reflink.c
> +++ b/fs/xfs/xfs_reflink.c
> @@ -324,7 +324,7 @@ xfs_reflink_convert_cow_extent(
>  	if (imap->br_blockcount == 0)
>  		return 0;
>  	return xfs_bmapi_write(NULL, ip, imap->br_startoff, imap->br_blockcount,
> -			XFS_BMAPI_COWFORK | XFS_BMAPI_CONVERT, NULL, 0, imap,
> +			XFS_BMAPI_COWFORK | XFS_BMAPI_CONVERT, 0, imap,
>  			&nimaps);
>  }
>  
> @@ -347,7 +347,7 @@ xfs_reflink_convert_cow(
>  	xfs_ilock(ip, XFS_ILOCK_EXCL);
>  	error = xfs_bmapi_write(NULL, ip, offset_fsb, count_fsb,
>  			XFS_BMAPI_COWFORK | XFS_BMAPI_CONVERT |
> -			XFS_BMAPI_CONVERT_ONLY, NULL, 0, &imap, &nimaps);
> +			XFS_BMAPI_CONVERT_ONLY, 0, &imap, &nimaps);
>  	xfs_iunlock(ip, XFS_ILOCK_EXCL);
>  	return error;
>  }
> @@ -430,7 +430,7 @@ xfs_reflink_allocate_cow(
>  	/* Allocate the entire reservation as unwritten blocks. */
>  	error = xfs_bmapi_write(tp, ip, imap->br_startoff, imap->br_blockcount,
>  			XFS_BMAPI_COWFORK | XFS_BMAPI_PREALLOC,
> -			&tp->t_firstblock, resblks, imap, &nimaps);
> +			resblks, imap, &nimaps);
>  	if (error)
>  		goto out_bmap_cancel;
>  
> diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
> index 1c894ea2abca..edd949376a51 100644
> --- a/fs/xfs/xfs_rtalloc.c
> +++ b/fs/xfs/xfs_rtalloc.c
> @@ -792,8 +792,8 @@ xfs_growfs_rt_alloc(
>  		 */
>  		nmap = 1;
>  		error = xfs_bmapi_write(tp, ip, oblocks, nblocks - oblocks,
> -					XFS_BMAPI_METADATA, &tp->t_firstblock,
> -					resblks, &map, &nmap);
> +					XFS_BMAPI_METADATA, resblks, &map,
> +					&nmap);
>  		if (!error && nmap < 1)
>  			error = -ENOSPC;
>  		if (error)
> diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
> index 18d9b4d301e5..94301b63525f 100644
> --- a/fs/xfs/xfs_symlink.c
> +++ b/fs/xfs/xfs_symlink.c
> @@ -288,8 +288,7 @@ xfs_symlink(
>  		nmaps = XFS_SYMLINK_MAPS;
>  
>  		error = xfs_bmapi_write(tp, ip, first_fsb, fs_blocks,
> -				  XFS_BMAPI_METADATA, &tp->t_firstblock,
> -				  resblks, mval, &nmaps);
> +				  XFS_BMAPI_METADATA, resblks, mval, &nmaps);
>  		if (error)
>  			goto out_bmap_cancel;
>  
> -- 
> 2.17.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 12/25] xfs: remove xfs_bunmapi() firstblock param
  2018-07-03 17:23 ` [PATCH 12/25] xfs: remove xfs_bunmapi() " Brian Foster
@ 2018-07-04  0:51   ` Darrick J. Wong
  0 siblings, 0 replies; 58+ messages in thread
From: Darrick J. Wong @ 2018-07-04  0:51 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-xfs

On Tue, Jul 03, 2018 at 01:23:06PM -0400, Brian Foster wrote:
> All callers pass ->t_firstblock from the current transaction.
> 
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_attr_remote.c |  3 +--
>  fs/xfs/libxfs/xfs_bmap.c        | 25 ++++++++++++-------------
>  fs/xfs/libxfs/xfs_bmap.h        |  5 ++---
>  fs/xfs/libxfs/xfs_da_btree.c    |  3 +--
>  fs/xfs/libxfs/xfs_dir2.c        |  3 +--
>  fs/xfs/xfs_bmap_util.c          |  3 +--
>  fs/xfs/xfs_inode.c              |  3 +--
>  fs/xfs/xfs_reflink.c            |  6 ++----
>  fs/xfs/xfs_symlink.c            |  3 +--
>  9 files changed, 22 insertions(+), 32 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c
> index 2db9ef186e05..f02c705965ff 100644
> --- a/fs/xfs/libxfs/xfs_attr_remote.c
> +++ b/fs/xfs/libxfs/xfs_attr_remote.c
> @@ -631,8 +631,7 @@ xfs_attr_rmtval_remove(
>  		xfs_defer_init(args->trans, args->trans->t_dfops,
>  			       &args->trans->t_firstblock);
>  		error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt,
> -				    XFS_BMAPI_ATTRFORK, 1,
> -				    &args->trans->t_firstblock, &done);
> +				    XFS_BMAPI_ATTRFORK, 1, &done);
>  		if (error)
>  			goto out_defer_cancel;
>  		xfs_defer_ijoin(args->trans->t_dfops, args->dp);
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index fd4125e3b097..967d12f9e415 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -5124,9 +5124,7 @@ __xfs_bunmapi(
>  	xfs_fileoff_t		start,		/* first file offset deleted */
>  	xfs_filblks_t		*rlen,		/* i/o: amount remaining */
>  	int			flags,		/* misc flags */
> -	xfs_extnum_t		nexts,		/* number of extents max */
> -	xfs_fsblock_t		*firstblock)	/* first allocated block
> -						   controls a.g. for allocs */
> +	xfs_extnum_t		nexts)		/* number of extents max */
>  {
>  	struct xfs_btree_cur	*cur;		/* bmap btree cursor */
>  	struct xfs_bmbt_irec	del;		/* extent being deleted */
> @@ -5200,7 +5198,7 @@ __xfs_bunmapi(
>  	if (ifp->if_flags & XFS_IFBROOT) {
>  		ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE);
>  		cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
> -		cur->bc_private.b.firstblock = *firstblock;
> +		cur->bc_private.b.firstblock = tp->t_firstblock;
>  		cur->bc_private.b.flags = 0;
>  	} else
>  		cur = NULL;
> @@ -5316,7 +5314,7 @@ __xfs_bunmapi(
>  			del.br_state = XFS_EXT_UNWRITTEN;
>  			error = xfs_bmap_add_extent_unwritten_real(tp, ip,
>  					whichfork, &icur, &cur, &del,
> -					firstblock, &logflags);
> +					&tp->t_firstblock, &logflags);
>  			if (error)
>  				goto error0;
>  			goto nodelete;
> @@ -5373,7 +5371,8 @@ __xfs_bunmapi(
>  				prev.br_state = XFS_EXT_UNWRITTEN;
>  				error = xfs_bmap_add_extent_unwritten_real(tp,
>  						ip, whichfork, &icur, &cur,
> -						&prev, firstblock, &logflags);
> +						&prev, &tp->t_firstblock,
> +						&logflags);
>  				if (error)
>  					goto error0;
>  				goto nodelete;
> @@ -5382,7 +5381,8 @@ __xfs_bunmapi(
>  				del.br_state = XFS_EXT_UNWRITTEN;
>  				error = xfs_bmap_add_extent_unwritten_real(tp,
>  						ip, whichfork, &icur, &cur,
> -						&del, firstblock, &logflags);
> +						&del, &tp->t_firstblock,
> +						&logflags);
>  				if (error)
>  					goto error0;
>  				goto nodelete;
> @@ -5429,8 +5429,8 @@ __xfs_bunmapi(
>  	 */
>  	if (xfs_bmap_needs_btree(ip, whichfork)) {
>  		ASSERT(cur == NULL);
> -		error = xfs_bmap_extents_to_btree(tp, ip, firstblock, &cur, 0,
> -				&tmp_logflags, whichfork);
> +		error = xfs_bmap_extents_to_btree(tp, ip, &tp->t_firstblock,
> +				&cur, 0, &tmp_logflags, whichfork);
>  		logflags |= tmp_logflags;
>  		if (error)
>  			goto error0;
> @@ -5469,7 +5469,7 @@ __xfs_bunmapi(
>  		xfs_trans_log_inode(tp, ip, logflags);
>  	if (cur) {
>  		if (!error) {
> -			*firstblock = cur->bc_private.b.firstblock;
> +			tp->t_firstblock = cur->bc_private.b.firstblock;
>  			cur->bc_private.b.allocated = 0;
>  		}
>  		xfs_btree_del_cursor(cur,
> @@ -5487,12 +5487,11 @@ xfs_bunmapi(
>  	xfs_filblks_t		len,
>  	int			flags,
>  	xfs_extnum_t		nexts,
> -	xfs_fsblock_t		*firstblock,
>  	int			*done)
>  {
>  	int			error;
>  
> -	error = __xfs_bunmapi(tp, ip, bno, &len, flags, nexts, firstblock);
> +	error = __xfs_bunmapi(tp, ip, bno, &len, flags, nexts);
>  	*done = (len == 0);
>  	return error;
>  }
> @@ -6150,7 +6149,7 @@ xfs_bmap_finish_one(
>  		break;
>  	case XFS_BMAP_UNMAP:
>  		error = __xfs_bunmapi(tp, ip, startoff, blockcount,
> -				XFS_BMAPI_REMAP, 1, &tp->t_firstblock);
> +				XFS_BMAPI_REMAP, 1);
>  		break;
>  	default:
>  		ASSERT(0);
> diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h
> index 1f9e29f32f20..14e21dcc3044 100644
> --- a/fs/xfs/libxfs/xfs_bmap.h
> +++ b/fs/xfs/libxfs/xfs_bmap.h
> @@ -207,11 +207,10 @@ int	xfs_bmapi_write(struct xfs_trans *tp, struct xfs_inode *ip,
>  		xfs_extlen_t total, struct xfs_bmbt_irec *mval, int *nmap);
>  int	__xfs_bunmapi(struct xfs_trans *tp, struct xfs_inode *ip,
>  		xfs_fileoff_t bno, xfs_filblks_t *rlen, int flags,
> -		xfs_extnum_t nexts, xfs_fsblock_t *firstblock);
> +		xfs_extnum_t nexts);
>  int	xfs_bunmapi(struct xfs_trans *tp, struct xfs_inode *ip,
>  		xfs_fileoff_t bno, xfs_filblks_t len, int flags,
> -		xfs_extnum_t nexts, xfs_fsblock_t *firstblock,
> -		int *done);
> +		xfs_extnum_t nexts, int *done);
>  int	xfs_bmap_del_extent_delay(struct xfs_inode *ip, int whichfork,
>  		struct xfs_iext_cursor *cur, struct xfs_bmbt_irec *got,
>  		struct xfs_bmbt_irec *del);
> diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
> index fe4a192696ae..9efbd2038ffb 100644
> --- a/fs/xfs/libxfs/xfs_da_btree.c
> +++ b/fs/xfs/libxfs/xfs_da_btree.c
> @@ -2392,8 +2392,7 @@ xfs_da_shrink_inode(
>  		 * the last block to the place we want to kill.
>  		 */
>  		error = xfs_bunmapi(tp, dp, dead_blkno, count,
> -				    xfs_bmapi_aflag(w), 0, &tp->t_firstblock,
> -				    &done);
> +				    xfs_bmapi_aflag(w), 0, &done);
>  		if (error == -ENOSPC) {
>  			if (w != XFS_DATA_FORK)
>  				break;
> diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
> index 53e46fda8df4..eadfb3bc0c95 100644
> --- a/fs/xfs/libxfs/xfs_dir2.c
> +++ b/fs/xfs/libxfs/xfs_dir2.c
> @@ -655,8 +655,7 @@ xfs_dir2_shrink_inode(
>  	da = xfs_dir2_db_to_da(args->geo, db);
>  
>  	/* Unmap the fsblock(s). */
> -	error = xfs_bunmapi(tp, dp, da, args->geo->fsbcount, 0, 0,
> -			    &tp->t_firstblock, &done);
> +	error = xfs_bunmapi(tp, dp, da, args->geo->fsbcount, 0, 0, &done);
>  	if (error) {
>  		/*
>  		 * ENOSPC actually can happen if we're in a removename with no
> diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
> index 0c433dbc6eb2..3675babb5202 100644
> --- a/fs/xfs/xfs_bmap_util.c
> +++ b/fs/xfs/xfs_bmap_util.c
> @@ -1040,8 +1040,7 @@ xfs_unmap_extent(
>  	xfs_trans_ijoin(tp, ip, 0);
>  
>  	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> -	error = xfs_bunmapi(tp, ip, startoffset_fsb, len_fsb, 0, 2,
> -			    &tp->t_firstblock, done);
> +	error = xfs_bunmapi(tp, ip, startoffset_fsb, len_fsb, 0, 2, done);
>  	if (error)
>  		goto out_bmap_cancel;
>  
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 3cdfd795a50c..5e1eaa26435c 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -1581,8 +1581,7 @@ xfs_itruncate_extents_flags(
>  	while (!done) {
>  		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
>  		error = xfs_bunmapi(tp, ip, first_unmap_block, unmap_len, flags,
> -				    XFS_ITRUNC_MAX_EXTENTS, &tp->t_firstblock,
> -				    &done);
> +				    XFS_ITRUNC_MAX_EXTENTS, &done);
>  		if (error)
>  			goto out_bmap_cancel;
>  
> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> index 258183f28141..cf6080d42273 100644
> --- a/fs/xfs/xfs_reflink.c
> +++ b/fs/xfs/xfs_reflink.c
> @@ -759,8 +759,7 @@ xfs_reflink_end_cow(
>  		/* Unmap the old blocks in the data fork. */
>  		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
>  		rlen = del.br_blockcount;
> -		error = __xfs_bunmapi(tp, ip, del.br_startoff, &rlen, 0, 1,
> -				&tp->t_firstblock);
> +		error = __xfs_bunmapi(tp, ip, del.br_startoff, &rlen, 0, 1);
>  		if (error)
>  			goto out_defer;
>  
> @@ -1107,8 +1106,7 @@ xfs_reflink_remap_extent(
>  	rlen = unmap_len;
>  	while (rlen) {
>  		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> -		error = __xfs_bunmapi(tp, ip, destoff, &rlen, 0, 1,
> -				      &tp->t_firstblock);
> +		error = __xfs_bunmapi(tp, ip, destoff, &rlen, 0, 1);
>  		if (error)
>  			goto out_defer;
>  
> diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
> index 94301b63525f..a3dc552a5b97 100644
> --- a/fs/xfs/xfs_symlink.c
> +++ b/fs/xfs/xfs_symlink.c
> @@ -460,8 +460,7 @@ xfs_inactive_symlink_rmt(
>  	/*
>  	 * Unmap the dead block(s) to the dfops.
>  	 */
> -	error = xfs_bunmapi(tp, ip, 0, size, 0, nmaps, &tp->t_firstblock,
> -			    &done);
> +	error = xfs_bunmapi(tp, ip, 0, size, 0, nmaps, &done);
>  	if (error)
>  		goto error_bmap_cancel;
>  	ASSERT(done);
> -- 
> 2.17.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 13/25] xfs: remove bmap insert/collapse firstblock param
  2018-07-03 17:23 ` [PATCH 13/25] xfs: remove bmap insert/collapse " Brian Foster
@ 2018-07-04  0:51   ` Darrick J. Wong
  0 siblings, 0 replies; 58+ messages in thread
From: Darrick J. Wong @ 2018-07-04  0:51 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-xfs

On Tue, Jul 03, 2018 at 01:23:07PM -0400, Brian Foster wrote:
> The only callers pass ->t_firstblock.
> 
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_bmap.c | 10 ++++------
>  fs/xfs/libxfs/xfs_bmap.h |  4 ++--
>  fs/xfs/xfs_bmap_util.c   |  4 ++--
>  3 files changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 967d12f9e415..c9023c08a78d 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -5654,8 +5654,7 @@ xfs_bmap_collapse_extents(
>  	struct xfs_inode	*ip,
>  	xfs_fileoff_t		*next_fsb,
>  	xfs_fileoff_t		offset_shift_fsb,
> -	bool			*done,
> -	xfs_fsblock_t		*firstblock)
> +	bool			*done)
>  {
>  	int			whichfork = XFS_DATA_FORK;
>  	struct xfs_mount	*mp = ip->i_mount;
> @@ -5688,7 +5687,7 @@ xfs_bmap_collapse_extents(
>  
>  	if (ifp->if_flags & XFS_IFBROOT) {
>  		cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
> -		cur->bc_private.b.firstblock = *firstblock;
> +		cur->bc_private.b.firstblock = tp->t_firstblock;
>  		cur->bc_private.b.flags = 0;
>  	}
>  
> @@ -5775,8 +5774,7 @@ xfs_bmap_insert_extents(
>  	xfs_fileoff_t		*next_fsb,
>  	xfs_fileoff_t		offset_shift_fsb,
>  	bool			*done,
> -	xfs_fileoff_t		stop_fsb,
> -	xfs_fsblock_t		*firstblock)
> +	xfs_fileoff_t		stop_fsb)
>  {
>  	int			whichfork = XFS_DATA_FORK;
>  	struct xfs_mount	*mp = ip->i_mount;
> @@ -5809,7 +5807,7 @@ xfs_bmap_insert_extents(
>  
>  	if (ifp->if_flags & XFS_IFBROOT) {
>  		cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
> -		cur->bc_private.b.firstblock = *firstblock;
> +		cur->bc_private.b.firstblock = tp->t_firstblock;
>  		cur->bc_private.b.flags = 0;
>  	}
>  
> diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h
> index 14e21dcc3044..fa839679ecb6 100644
> --- a/fs/xfs/libxfs/xfs_bmap.h
> +++ b/fs/xfs/libxfs/xfs_bmap.h
> @@ -220,12 +220,12 @@ void	xfs_bmap_del_extent_cow(struct xfs_inode *ip,
>  uint	xfs_default_attroffset(struct xfs_inode *ip);
>  int	xfs_bmap_collapse_extents(struct xfs_trans *tp, struct xfs_inode *ip,
>  		xfs_fileoff_t *next_fsb, xfs_fileoff_t offset_shift_fsb,
> -		bool *done, xfs_fsblock_t *firstblock);
> +		bool *done);
>  int	xfs_bmap_can_insert_extents(struct xfs_inode *ip, xfs_fileoff_t off,
>  		xfs_fileoff_t shift);
>  int	xfs_bmap_insert_extents(struct xfs_trans *tp, struct xfs_inode *ip,
>  		xfs_fileoff_t *next_fsb, xfs_fileoff_t offset_shift_fsb,
> -		bool *done, xfs_fileoff_t stop_fsb, xfs_fsblock_t *firstblock);
> +		bool *done, xfs_fileoff_t stop_fsb);
>  int	xfs_bmap_split_extent(struct xfs_inode *ip, xfs_fileoff_t split_offset);
>  int	xfs_bmapi_reserve_delalloc(struct xfs_inode *ip, int whichfork,
>  		xfs_fileoff_t off, xfs_filblks_t len, xfs_filblks_t prealloc,
> diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
> index 3675babb5202..6d2baf51fec9 100644
> --- a/fs/xfs/xfs_bmap_util.c
> +++ b/fs/xfs/xfs_bmap_util.c
> @@ -1342,7 +1342,7 @@ xfs_collapse_file_space(
>  
>  		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
>  		error = xfs_bmap_collapse_extents(tp, ip, &next_fsb, shift_fsb,
> -				&done, &tp->t_firstblock);
> +				&done);
>  		if (error)
>  			goto out_bmap_cancel;
>  
> @@ -1420,7 +1420,7 @@ xfs_insert_file_space(
>  		xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
>  		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
>  		error = xfs_bmap_insert_extents(tp, ip, &next_fsb, shift_fsb,
> -				&done, stop_fsb, &tp->t_firstblock);
> +				&done, stop_fsb);
>  		if (error)
>  			goto out_bmap_cancel;
>  
> -- 
> 2.17.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 14/25] xfs: use ->t_firstblock in bmap extent split
  2018-07-03 17:23 ` [PATCH 14/25] xfs: use ->t_firstblock in bmap extent split Brian Foster
@ 2018-07-04  0:51   ` Darrick J. Wong
  0 siblings, 0 replies; 58+ messages in thread
From: Darrick J. Wong @ 2018-07-04  0:51 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-xfs

On Tue, Jul 03, 2018 at 01:23:08PM -0400, Brian Foster wrote:
> Also remove the unnecessary xfs_bmap_split_extent_at() parameter.
> 
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_bmap.c | 15 ++++++---------
>  1 file changed, 6 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index c9023c08a78d..43157e5ff46b 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -5880,8 +5880,7 @@ STATIC int
>  xfs_bmap_split_extent_at(
>  	struct xfs_trans	*tp,
>  	struct xfs_inode	*ip,
> -	xfs_fileoff_t		split_fsb,
> -	xfs_fsblock_t		*firstfsb)
> +	xfs_fileoff_t		split_fsb)
>  {
>  	int				whichfork = XFS_DATA_FORK;
>  	struct xfs_btree_cur		*cur = NULL;
> @@ -5930,7 +5929,7 @@ xfs_bmap_split_extent_at(
>  
>  	if (ifp->if_flags & XFS_IFBROOT) {
>  		cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
> -		cur->bc_private.b.firstblock = *firstfsb;
> +		cur->bc_private.b.firstblock = tp->t_firstblock;
>  		cur->bc_private.b.flags = 0;
>  		error = xfs_bmbt_lookup_eq(cur, &got, &i);
>  		if (error)
> @@ -5974,8 +5973,8 @@ xfs_bmap_split_extent_at(
>  		int tmp_logflags; /* partial log flag return val */
>  
>  		ASSERT(cur == NULL);
> -		error = xfs_bmap_extents_to_btree(tp, ip, firstfsb, &cur, 0,
> -				&tmp_logflags, whichfork);
> +		error = xfs_bmap_extents_to_btree(tp, ip, &tp->t_firstblock,
> +				&cur, 0, &tmp_logflags, whichfork);
>  		logflags |= tmp_logflags;
>  	}
>  
> @@ -5999,20 +5998,18 @@ xfs_bmap_split_extent(
>  	struct xfs_mount        *mp = ip->i_mount;
>  	struct xfs_trans        *tp;
>  	struct xfs_defer_ops    dfops;
> -	xfs_fsblock_t           firstfsb;
>  	int                     error;
>  
>  	error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write,
>  			XFS_DIOSTRAT_SPACE_RES(mp, 0), 0, 0, &tp);
>  	if (error)
>  		return error;
> -	xfs_defer_init(tp, &dfops, &firstfsb);
> +	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
>  
>  	xfs_ilock(ip, XFS_ILOCK_EXCL);
>  	xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
>  
> -	error = xfs_bmap_split_extent_at(tp, ip, split_fsb,
> -					 &firstfsb);
> +	error = xfs_bmap_split_extent_at(tp, ip, split_fsb);
>  	if (error)
>  		goto out;
>  
> -- 
> 2.17.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 15/25] xfs: remove xfs_bmalloca firstblock field
  2018-07-03 17:23 ` [PATCH 15/25] xfs: remove xfs_bmalloca firstblock field Brian Foster
@ 2018-07-04  0:52   ` Darrick J. Wong
  0 siblings, 0 replies; 58+ messages in thread
From: Darrick J. Wong @ 2018-07-04  0:52 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-xfs

On Tue, Jul 03, 2018 at 01:23:09PM -0400, Brian Foster wrote:
> The xfs_bmalloca.firstblock field carries the firstblock value from
> the transaction into the bmap infrastructure. It's initialized in
> one place from ->t_firstblock, so drop the field and access
> ->t_firstblock directly throughout the bmap code.
> 
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_bmap.c | 44 +++++++++++++++++++++-------------------
>  fs/xfs/libxfs/xfs_bmap.h |  1 -
>  2 files changed, 23 insertions(+), 22 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 43157e5ff46b..bd1273546b54 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -1794,7 +1794,7 @@ xfs_bmap_add_extent_delay_real(
>  
>  		if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
>  			error = xfs_bmap_extents_to_btree(bma->tp, bma->ip,
> -					bma->firstblock, &bma->cur, 1,
> +					&bma->tp->t_firstblock, &bma->cur, 1,
>  					&tmp_rval, whichfork);
>  			rval |= tmp_rval;
>  			if (error)
> @@ -1872,7 +1872,7 @@ xfs_bmap_add_extent_delay_real(
>  
>  		if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
>  			error = xfs_bmap_extents_to_btree(bma->tp, bma->ip,
> -				bma->firstblock, &bma->cur, 1, &tmp_rval,
> +				&bma->tp->t_firstblock, &bma->cur, 1, &tmp_rval,
>  				whichfork);
>  			rval |= tmp_rval;
>  			if (error)
> @@ -1953,7 +1953,7 @@ xfs_bmap_add_extent_delay_real(
>  
>  		if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
>  			error = xfs_bmap_extents_to_btree(bma->tp, bma->ip,
> -					bma->firstblock, &bma->cur, 1,
> +					&bma->tp->t_firstblock, &bma->cur, 1,
>  					&tmp_rval, whichfork);
>  			rval |= tmp_rval;
>  			if (error)
> @@ -1991,7 +1991,7 @@ xfs_bmap_add_extent_delay_real(
>  
>  		ASSERT(bma->cur == NULL);
>  		error = xfs_bmap_extents_to_btree(bma->tp, bma->ip,
> -				bma->firstblock, &bma->cur, da_old > 0,
> +				&bma->tp->t_firstblock, &bma->cur, da_old > 0,
>  				&tmp_logflags, whichfork);
>  		bma->logflags |= tmp_logflags;
>  		if (error)
> @@ -3056,10 +3056,11 @@ xfs_bmap_adjacent(
>  		XFS_FSB_TO_AGBNO(mp, x) < mp->m_sb.sb_agblocks)
>  
>  	mp = ap->ip->i_mount;
> -	nullfb = *ap->firstblock == NULLFSBLOCK;
> +	nullfb = ap->tp->t_firstblock == NULLFSBLOCK;
>  	rt = XFS_IS_REALTIME_INODE(ap->ip) &&
>  		xfs_alloc_is_userdata(ap->datatype);
> -	fb_agno = nullfb ? NULLAGNUMBER : XFS_FSB_TO_AGNO(mp, *ap->firstblock);
> +	fb_agno = nullfb ? NULLAGNUMBER : XFS_FSB_TO_AGNO(mp,
> +							ap->tp->t_firstblock);
>  	/*
>  	 * If allocating at eof, and there's a previous real block,
>  	 * try to use its last block as our starting point.
> @@ -3417,8 +3418,9 @@ xfs_bmap_btalloc(
>  	}
>  
>  
> -	nullfb = *ap->firstblock == NULLFSBLOCK;
> -	fb_agno = nullfb ? NULLAGNUMBER : XFS_FSB_TO_AGNO(mp, *ap->firstblock);
> +	nullfb = ap->tp->t_firstblock == NULLFSBLOCK;
> +	fb_agno = nullfb ? NULLAGNUMBER : XFS_FSB_TO_AGNO(mp,
> +							ap->tp->t_firstblock);
>  	if (nullfb) {
>  		if (xfs_alloc_is_userdata(ap->datatype) &&
>  		    xfs_inode_is_filestream(ap->ip)) {
> @@ -3429,7 +3431,7 @@ xfs_bmap_btalloc(
>  			ap->blkno = XFS_INO_TO_FSB(mp, ap->ip->i_ino);
>  		}
>  	} else
> -		ap->blkno = *ap->firstblock;
> +		ap->blkno = ap->tp->t_firstblock;
>  
>  	xfs_bmap_adjacent(ap);
>  
> @@ -3440,7 +3442,7 @@ xfs_bmap_btalloc(
>  	if (nullfb || XFS_FSB_TO_AGNO(mp, ap->blkno) == fb_agno)
>  		;
>  	else
> -		ap->blkno = *ap->firstblock;
> +		ap->blkno = ap->tp->t_firstblock;
>  	/*
>  	 * Normal allocation, done through xfs_alloc_vextent.
>  	 */
> @@ -3453,7 +3455,7 @@ xfs_bmap_btalloc(
>  
>  	/* Trim the allocation back to the maximum an AG can fit. */
>  	args.maxlen = min(ap->length, mp->m_ag_max_usable);
> -	args.firstblock = *ap->firstblock;
> +	args.firstblock = ap->tp->t_firstblock;
>  	blen = 0;
>  	if (nullfb) {
>  		/*
> @@ -3602,13 +3604,13 @@ xfs_bmap_btalloc(
>  		 * check the allocation happened at the same or higher AG than
>  		 * the first block that was allocated.
>  		 */
> -		ASSERT(*ap->firstblock == NULLFSBLOCK ||
> -		       XFS_FSB_TO_AGNO(mp, *ap->firstblock) <=
> +		ASSERT(ap->tp->t_firstblock == NULLFSBLOCK ||
> +		       XFS_FSB_TO_AGNO(mp, ap->tp->t_firstblock) <=
>  		       XFS_FSB_TO_AGNO(mp, args.fsbno));
>  
>  		ap->blkno = args.fsbno;
> -		if (*ap->firstblock == NULLFSBLOCK)
> -			*ap->firstblock = args.fsbno;
> +		if (ap->tp->t_firstblock == NULLFSBLOCK)
> +			ap->tp->t_firstblock = args.fsbno;
>  		ASSERT(nullfb || fb_agno <= args.agno);
>  		ap->length = args.len;
>  		/*
> @@ -4065,12 +4067,12 @@ xfs_bmapi_allocate(
>  		return error;
>  
>  	if (bma->cur)
> -		bma->cur->bc_private.b.firstblock = *bma->firstblock;
> +		bma->cur->bc_private.b.firstblock = bma->tp->t_firstblock;
>  	if (bma->blkno == NULLFSBLOCK)
>  		return 0;
>  	if ((ifp->if_flags & XFS_IFBROOT) && !bma->cur) {
>  		bma->cur = xfs_bmbt_init_cursor(mp, bma->tp, bma->ip, whichfork);
> -		bma->cur->bc_private.b.firstblock = *bma->firstblock;
> +		bma->cur->bc_private.b.firstblock = bma->tp->t_firstblock;
>  	}
>  	/*
>  	 * Bump the number of extents we've allocated
> @@ -4106,7 +4108,8 @@ xfs_bmapi_allocate(
>  	else
>  		error = xfs_bmap_add_extent_hole_real(bma->tp, bma->ip,
>  				whichfork, &bma->icur, &bma->cur, &bma->got,
> -				bma->firstblock, &bma->logflags, bma->flags);
> +				&bma->tp->t_firstblock, &bma->logflags,
> +				bma->flags);
>  
>  	bma->logflags |= tmp_logflags;
>  	if (error)
> @@ -4157,7 +4160,7 @@ xfs_bmapi_convert_unwritten(
>  	if ((ifp->if_flags & XFS_IFBROOT) && !bma->cur) {
>  		bma->cur = xfs_bmbt_init_cursor(bma->ip->i_mount, bma->tp,
>  					bma->ip, whichfork);
> -		bma->cur->bc_private.b.firstblock = *bma->firstblock;
> +		bma->cur->bc_private.b.firstblock = bma->tp->t_firstblock;
>  	}
>  	mval->br_state = (mval->br_state == XFS_EXT_UNWRITTEN)
>  				? XFS_EXT_NORM : XFS_EXT_UNWRITTEN;
> @@ -4174,7 +4177,7 @@ xfs_bmapi_convert_unwritten(
>  	}
>  
>  	error = xfs_bmap_add_extent_unwritten_real(bma->tp, bma->ip, whichfork,
> -			&bma->icur, &bma->cur, mval, bma->firstblock,
> +			&bma->icur, &bma->cur, mval, &bma->tp->t_firstblock,
>  			&tmp_logflags);
>  	/*
>  	 * Log the inode core unconditionally in the unwritten extent conversion
> @@ -4315,7 +4318,6 @@ xfs_bmapi_write(
>  	bma.ip = ip;
>  	bma.total = total;
>  	bma.datatype = 0;
> -	bma.firstblock = &tp->t_firstblock;
>  	ASSERT(!tp || tp->t_dfops);
>  
>  	while (bno < end && n < *nmap) {
> diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h
> index fa839679ecb6..bbd641ae3261 100644
> --- a/fs/xfs/libxfs/xfs_bmap.h
> +++ b/fs/xfs/libxfs/xfs_bmap.h
> @@ -19,7 +19,6 @@ extern kmem_zone_t	*xfs_bmap_free_item_zone;
>   * Argument structure for xfs_bmap_alloc.
>   */
>  struct xfs_bmalloca {
> -	xfs_fsblock_t		*firstblock; /* i/o first block allocated */
>  	struct xfs_trans	*tp;	/* transaction pointer */
>  	struct xfs_inode	*ip;	/* incore inode pointer */
>  	struct xfs_bmbt_irec	prev;	/* extent before the new one */
> -- 
> 2.17.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 16/25] xfs: remove bmap extent add helper firstblock params
  2018-07-03 17:23 ` [PATCH 16/25] xfs: remove bmap extent add helper firstblock params Brian Foster
@ 2018-07-04  0:52   ` Darrick J. Wong
  0 siblings, 0 replies; 58+ messages in thread
From: Darrick J. Wong @ 2018-07-04  0:52 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-xfs

On Tue, Jul 03, 2018 at 01:23:10PM -0400, Brian Foster wrote:
> The add extent helpers all receive firstblock via ->t_firstblock.
> Drop the parameter and access it directly.
> 
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_bmap.c | 26 ++++++++++----------------
>  1 file changed, 10 insertions(+), 16 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index bd1273546b54..adc45a0941ff 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -2031,7 +2031,6 @@ xfs_bmap_add_extent_unwritten_real(
>  	struct xfs_iext_cursor	*icur,
>  	xfs_btree_cur_t		**curp,	/* if *curp is null, not a btree */
>  	xfs_bmbt_irec_t		*new,	/* new data to add to file extents */
> -	xfs_fsblock_t		*first,	/* pointer to firstblock variable */
>  	int			*logflagsp) /* inode logging flags */
>  {
>  	xfs_btree_cur_t		*cur;	/* btree cursor */
> @@ -2473,8 +2472,8 @@ xfs_bmap_add_extent_unwritten_real(
>  		int	tmp_logflags;	/* partial log flag return val */
>  
>  		ASSERT(cur == NULL);
> -		error = xfs_bmap_extents_to_btree(tp, ip, first, &cur, 0,
> -				&tmp_logflags, whichfork);
> +		error = xfs_bmap_extents_to_btree(tp, ip, &tp->t_firstblock,
> +				&cur, 0, &tmp_logflags, whichfork);
>  		*logflagsp |= tmp_logflags;
>  		if (error)
>  			goto done;
> @@ -2645,7 +2644,6 @@ xfs_bmap_add_extent_hole_real(
>  	struct xfs_iext_cursor	*icur,
>  	struct xfs_btree_cur	**curp,
>  	struct xfs_bmbt_irec	*new,
> -	xfs_fsblock_t		*first,
>  	int			*logflagsp,
>  	int			flags)
>  {
> @@ -2837,8 +2835,8 @@ xfs_bmap_add_extent_hole_real(
>  		int	tmp_logflags;	/* partial log flag return val */
>  
>  		ASSERT(cur == NULL);
> -		error = xfs_bmap_extents_to_btree(tp, ip, first, curp, 0,
> -				&tmp_logflags, whichfork);
> +		error = xfs_bmap_extents_to_btree(tp, ip, &tp->t_firstblock,
> +				curp, 0, &tmp_logflags, whichfork);
>  		*logflagsp |= tmp_logflags;
>  		cur = *curp;
>  		if (error)
> @@ -4108,8 +4106,7 @@ xfs_bmapi_allocate(
>  	else
>  		error = xfs_bmap_add_extent_hole_real(bma->tp, bma->ip,
>  				whichfork, &bma->icur, &bma->cur, &bma->got,
> -				&bma->tp->t_firstblock, &bma->logflags,
> -				bma->flags);
> +				&bma->logflags, bma->flags);
>  
>  	bma->logflags |= tmp_logflags;
>  	if (error)
> @@ -4177,8 +4174,7 @@ xfs_bmapi_convert_unwritten(
>  	}
>  
>  	error = xfs_bmap_add_extent_unwritten_real(bma->tp, bma->ip, whichfork,
> -			&bma->icur, &bma->cur, mval, &bma->tp->t_firstblock,
> -			&tmp_logflags);
> +			&bma->icur, &bma->cur, mval, &tmp_logflags);
>  	/*
>  	 * Log the inode core unconditionally in the unwritten extent conversion
>  	 * path because the conversion might not have done so (e.g., if the
> @@ -4552,7 +4548,7 @@ xfs_bmapi_remap(
>  		got.br_state = XFS_EXT_NORM;
>  
>  	error = xfs_bmap_add_extent_hole_real(tp, ip, whichfork, &icur,
> -			&cur, &got, &tp->t_firstblock, &logflags, flags);
> +			&cur, &got, &logflags, flags);
>  	if (error)
>  		goto error0;
>  
> @@ -5316,7 +5312,7 @@ __xfs_bunmapi(
>  			del.br_state = XFS_EXT_UNWRITTEN;
>  			error = xfs_bmap_add_extent_unwritten_real(tp, ip,
>  					whichfork, &icur, &cur, &del,
> -					&tp->t_firstblock, &logflags);
> +					&logflags);
>  			if (error)
>  				goto error0;
>  			goto nodelete;
> @@ -5373,8 +5369,7 @@ __xfs_bunmapi(
>  				prev.br_state = XFS_EXT_UNWRITTEN;
>  				error = xfs_bmap_add_extent_unwritten_real(tp,
>  						ip, whichfork, &icur, &cur,
> -						&prev, &tp->t_firstblock,
> -						&logflags);
> +						&prev, &logflags);
>  				if (error)
>  					goto error0;
>  				goto nodelete;
> @@ -5383,8 +5378,7 @@ __xfs_bunmapi(
>  				del.br_state = XFS_EXT_UNWRITTEN;
>  				error = xfs_bmap_add_extent_unwritten_real(tp,
>  						ip, whichfork, &icur, &cur,
> -						&del, &tp->t_firstblock,
> -						&logflags);
> +						&del, &logflags);
>  				if (error)
>  					goto error0;
>  				goto nodelete;
> -- 
> 2.17.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 17/25] xfs: remove bmap format helpers firstblock params
  2018-07-03 17:23 ` [PATCH 17/25] xfs: remove bmap format helpers " Brian Foster
@ 2018-07-04  0:53   ` Darrick J. Wong
  0 siblings, 0 replies; 58+ messages in thread
From: Darrick J. Wong @ 2018-07-04  0:53 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-xfs

On Tue, Jul 03, 2018 at 01:23:11PM -0400, Brian Foster wrote:
> The bmap format helpers receive firstblock via ->t_firstblock. Drop
> the param and access it directly.
> 
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_bmap.c | 63 ++++++++++++++++++----------------------
>  1 file changed, 29 insertions(+), 34 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index adc45a0941ff..016712434aa5 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -646,7 +646,6 @@ STATIC int					/* error */
>  xfs_bmap_extents_to_btree(
>  	struct xfs_trans	*tp,		/* transaction pointer */
>  	struct xfs_inode	*ip,		/* incore inode pointer */
> -	xfs_fsblock_t		*firstblock,	/* first-block-allocated */
>  	struct xfs_btree_cur	**curp,		/* cursor returned to caller */
>  	int			wasdel,		/* converting a delayed alloc */
>  	int			*logflagsp,	/* inode logging flags */
> @@ -689,7 +688,7 @@ xfs_bmap_extents_to_btree(
>  	 * Need a cursor.  Can't allocate until bb_level is filled in.
>  	 */
>  	cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
> -	cur->bc_private.b.firstblock = *firstblock;
> +	cur->bc_private.b.firstblock = tp->t_firstblock;
>  	cur->bc_private.b.flags = wasdel ? XFS_BTCUR_BPRV_WASDEL : 0;
>  	/*
>  	 * Convert to a btree with two levels, one record in root.
> @@ -699,16 +698,16 @@ xfs_bmap_extents_to_btree(
>  	args.tp = tp;
>  	args.mp = mp;
>  	xfs_rmap_ino_bmbt_owner(&args.oinfo, ip->i_ino, whichfork);
> -	args.firstblock = *firstblock;
> -	if (*firstblock == NULLFSBLOCK) {
> +	args.firstblock = tp->t_firstblock;
> +	if (tp->t_firstblock == NULLFSBLOCK) {
>  		args.type = XFS_ALLOCTYPE_START_BNO;
>  		args.fsbno = XFS_INO_TO_FSB(mp, ip->i_ino);
>  	} else if (tp->t_dfops->dop_low) {
>  		args.type = XFS_ALLOCTYPE_START_BNO;
> -		args.fsbno = *firstblock;
> +		args.fsbno = tp->t_firstblock;
>  	} else {
>  		args.type = XFS_ALLOCTYPE_NEAR_BNO;
> -		args.fsbno = *firstblock;
> +		args.fsbno = tp->t_firstblock;
>  	}
>  	args.minlen = args.maxlen = args.prod = 1;
>  	args.wasdel = wasdel;
> @@ -731,9 +730,9 @@ xfs_bmap_extents_to_btree(
>  	/*
>  	 * Allocation can't fail, the space was reserved.
>  	 */
> -	ASSERT(*firstblock == NULLFSBLOCK ||
> -	       args.agno >= XFS_FSB_TO_AGNO(mp, *firstblock));
> -	*firstblock = cur->bc_private.b.firstblock = args.fsbno;
> +	ASSERT(tp->t_firstblock == NULLFSBLOCK ||
> +	       args.agno >= XFS_FSB_TO_AGNO(mp, tp->t_firstblock));
> +	tp->t_firstblock = cur->bc_private.b.firstblock = args.fsbno;
>  	cur->bc_private.b.allocated++;
>  	ip->i_d.di_nblocks++;
>  	xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, 1L);
> @@ -810,7 +809,6 @@ STATIC int				/* error */
>  xfs_bmap_local_to_extents(
>  	xfs_trans_t	*tp,		/* transaction pointer */
>  	xfs_inode_t	*ip,		/* incore inode pointer */
> -	xfs_fsblock_t	*firstblock,	/* first block allocated in xaction */
>  	xfs_extlen_t	total,		/* total blocks needed by transaction */
>  	int		*logflagsp,	/* inode logging flags */
>  	int		whichfork,
> @@ -848,16 +846,16 @@ xfs_bmap_local_to_extents(
>  	args.tp = tp;
>  	args.mp = ip->i_mount;
>  	xfs_rmap_ino_owner(&args.oinfo, ip->i_ino, whichfork, 0);
> -	args.firstblock = *firstblock;
> +	args.firstblock = tp->t_firstblock;
>  	/*
>  	 * Allocate a block.  We know we need only one, since the
>  	 * file currently fits in an inode.
>  	 */
> -	if (*firstblock == NULLFSBLOCK) {
> +	if (tp->t_firstblock == NULLFSBLOCK) {
>  		args.fsbno = XFS_INO_TO_FSB(args.mp, ip->i_ino);
>  		args.type = XFS_ALLOCTYPE_START_BNO;
>  	} else {
> -		args.fsbno = *firstblock;
> +		args.fsbno = tp->t_firstblock;
>  		args.type = XFS_ALLOCTYPE_NEAR_BNO;
>  	}
>  	args.total = total;
> @@ -869,7 +867,7 @@ xfs_bmap_local_to_extents(
>  	/* Can't fail, the space was reserved. */
>  	ASSERT(args.fsbno != NULLFSBLOCK);
>  	ASSERT(args.len == 1);
> -	*firstblock = args.fsbno;
> +	tp->t_firstblock = args.fsbno;
>  	bp = xfs_btree_get_bufl(args.mp, tp, args.fsbno, 0);
>  
>  	/*
> @@ -964,8 +962,8 @@ xfs_bmap_add_attrfork_extents(
>  	if (ip->i_d.di_nextents * sizeof(xfs_bmbt_rec_t) <= XFS_IFORK_DSIZE(ip))
>  		return 0;
>  	cur = NULL;
> -	error = xfs_bmap_extents_to_btree(tp, ip, &tp->t_firstblock, &cur, 0,
> -					  flags, XFS_DATA_FORK);
> +	error = xfs_bmap_extents_to_btree(tp, ip, &cur, 0, flags,
> +					  XFS_DATA_FORK);
>  	if (cur) {
>  		cur->bc_private.b.allocated = 0;
>  		xfs_btree_del_cursor(cur,
> @@ -1007,8 +1005,8 @@ xfs_bmap_add_attrfork_local(
>  	}
>  
>  	if (S_ISLNK(VFS_I(ip)->i_mode))
> -		return xfs_bmap_local_to_extents(tp, ip, &tp->t_firstblock, 1,
> -						 flags, XFS_DATA_FORK,
> +		return xfs_bmap_local_to_extents(tp, ip, 1, flags,
> +						 XFS_DATA_FORK,
>  						 xfs_symlink_local_to_remote);
>  
>  	/* should only be called for types that support local format data */
> @@ -1794,8 +1792,7 @@ xfs_bmap_add_extent_delay_real(
>  
>  		if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
>  			error = xfs_bmap_extents_to_btree(bma->tp, bma->ip,
> -					&bma->tp->t_firstblock, &bma->cur, 1,
> -					&tmp_rval, whichfork);
> +					&bma->cur, 1, &tmp_rval, whichfork);
>  			rval |= tmp_rval;
>  			if (error)
>  				goto done;
> @@ -1872,8 +1869,7 @@ xfs_bmap_add_extent_delay_real(
>  
>  		if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
>  			error = xfs_bmap_extents_to_btree(bma->tp, bma->ip,
> -				&bma->tp->t_firstblock, &bma->cur, 1, &tmp_rval,
> -				whichfork);
> +				&bma->cur, 1, &tmp_rval, whichfork);
>  			rval |= tmp_rval;
>  			if (error)
>  				goto done;
> @@ -1953,8 +1949,7 @@ xfs_bmap_add_extent_delay_real(
>  
>  		if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
>  			error = xfs_bmap_extents_to_btree(bma->tp, bma->ip,
> -					&bma->tp->t_firstblock, &bma->cur, 1,
> -					&tmp_rval, whichfork);
> +					&bma->cur, 1, &tmp_rval, whichfork);
>  			rval |= tmp_rval;
>  			if (error)
>  				goto done;
> @@ -1991,8 +1986,8 @@ xfs_bmap_add_extent_delay_real(
>  
>  		ASSERT(bma->cur == NULL);
>  		error = xfs_bmap_extents_to_btree(bma->tp, bma->ip,
> -				&bma->tp->t_firstblock, &bma->cur, da_old > 0,
> -				&tmp_logflags, whichfork);
> +				&bma->cur, da_old > 0, &tmp_logflags,
> +				whichfork);
>  		bma->logflags |= tmp_logflags;
>  		if (error)
>  			goto done;
> @@ -2472,8 +2467,8 @@ xfs_bmap_add_extent_unwritten_real(
>  		int	tmp_logflags;	/* partial log flag return val */
>  
>  		ASSERT(cur == NULL);
> -		error = xfs_bmap_extents_to_btree(tp, ip, &tp->t_firstblock,
> -				&cur, 0, &tmp_logflags, whichfork);
> +		error = xfs_bmap_extents_to_btree(tp, ip, &cur, 0,
> +				&tmp_logflags, whichfork);
>  		*logflagsp |= tmp_logflags;
>  		if (error)
>  			goto done;
> @@ -2835,8 +2830,8 @@ xfs_bmap_add_extent_hole_real(
>  		int	tmp_logflags;	/* partial log flag return val */
>  
>  		ASSERT(cur == NULL);
> -		error = xfs_bmap_extents_to_btree(tp, ip, &tp->t_firstblock,
> -				curp, 0, &tmp_logflags, whichfork);
> +		error = xfs_bmap_extents_to_btree(tp, ip, curp, 0,
> +				&tmp_logflags, whichfork);
>  		*logflagsp |= tmp_logflags;
>  		cur = *curp;
>  		if (error)
> @@ -5425,8 +5420,8 @@ __xfs_bunmapi(
>  	 */
>  	if (xfs_bmap_needs_btree(ip, whichfork)) {
>  		ASSERT(cur == NULL);
> -		error = xfs_bmap_extents_to_btree(tp, ip, &tp->t_firstblock,
> -				&cur, 0, &tmp_logflags, whichfork);
> +		error = xfs_bmap_extents_to_btree(tp, ip, &cur, 0,
> +				&tmp_logflags, whichfork);
>  		logflags |= tmp_logflags;
>  		if (error)
>  			goto error0;
> @@ -5969,8 +5964,8 @@ xfs_bmap_split_extent_at(
>  		int tmp_logflags; /* partial log flag return val */
>  
>  		ASSERT(cur == NULL);
> -		error = xfs_bmap_extents_to_btree(tp, ip, &tp->t_firstblock,
> -				&cur, 0, &tmp_logflags, whichfork);
> +		error = xfs_bmap_extents_to_btree(tp, ip, &cur, 0,
> +				&tmp_logflags, whichfork);
>  		logflags |= tmp_logflags;
>  	}
>  
> -- 
> 2.17.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 18/25] xfs: remove xfs_btree_cur private firstblock field
  2018-07-03 17:23 ` [PATCH 18/25] xfs: remove xfs_btree_cur private firstblock field Brian Foster
@ 2018-07-04  0:54   ` Darrick J. Wong
  0 siblings, 0 replies; 58+ messages in thread
From: Darrick J. Wong @ 2018-07-04  0:54 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-xfs

On Tue, Jul 03, 2018 at 01:23:12PM -0400, Brian Foster wrote:
> The bmbt cursor private structure has a firstblock field that is
> used to maintain locking order on bmbt allocations. The field holds
> an actual firstblock value (as opposed to a pointer), so it is
> initialized on cursor creation, updated on allocation and then the
> value is transferred back to the source before the cursor is
> destroyed.
> 
> This value is always transferred from and back to the ->t_firstblock
> field. Since xfs_btree_cur already carries a reference to the
> transaction, we can remove this field from xfs_btree_cur and the
> associated copying. The bmbt allocations will update the value in
> the transaction directly.
> 
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_bmap.c       | 28 +++-------------------------
>  fs/xfs/libxfs/xfs_bmap_btree.c | 10 ++++------
>  fs/xfs/libxfs/xfs_btree.h      |  1 -
>  3 files changed, 7 insertions(+), 32 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 016712434aa5..c83add15233b 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -688,7 +688,6 @@ xfs_bmap_extents_to_btree(
>  	 * Need a cursor.  Can't allocate until bb_level is filled in.
>  	 */
>  	cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
> -	cur->bc_private.b.firstblock = tp->t_firstblock;
>  	cur->bc_private.b.flags = wasdel ? XFS_BTCUR_BPRV_WASDEL : 0;
>  	/*
>  	 * Convert to a btree with two levels, one record in root.
> @@ -732,7 +731,7 @@ xfs_bmap_extents_to_btree(
>  	 */
>  	ASSERT(tp->t_firstblock == NULLFSBLOCK ||
>  	       args.agno >= XFS_FSB_TO_AGNO(mp, tp->t_firstblock));
> -	tp->t_firstblock = cur->bc_private.b.firstblock = args.fsbno;
> +	tp->t_firstblock = args.fsbno;
>  	cur->bc_private.b.allocated++;
>  	ip->i_d.di_nblocks++;
>  	xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, 1L);
> @@ -925,7 +924,6 @@ xfs_bmap_add_attrfork_btree(
>  		*flags |= XFS_ILOG_DBROOT;
>  	else {
>  		cur = xfs_bmbt_init_cursor(mp, tp, ip, XFS_DATA_FORK);
> -		cur->bc_private.b.firstblock = tp->t_firstblock;
>  		error = xfs_bmbt_lookup_first(cur, &stat);
>  		if (error)
>  			goto error0;
> @@ -937,7 +935,6 @@ xfs_bmap_add_attrfork_btree(
>  			xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);
>  			return -ENOSPC;
>  		}
> -		tp->t_firstblock = cur->bc_private.b.firstblock;
>  		cur->bc_private.b.allocated = 0;
>  		xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);
>  	}
> @@ -4059,14 +4056,10 @@ xfs_bmapi_allocate(
>  	if (error)
>  		return error;
>  
> -	if (bma->cur)
> -		bma->cur->bc_private.b.firstblock = bma->tp->t_firstblock;
>  	if (bma->blkno == NULLFSBLOCK)
>  		return 0;
> -	if ((ifp->if_flags & XFS_IFBROOT) && !bma->cur) {
> +	if ((ifp->if_flags & XFS_IFBROOT) && !bma->cur)
>  		bma->cur = xfs_bmbt_init_cursor(mp, bma->tp, bma->ip, whichfork);
> -		bma->cur->bc_private.b.firstblock = bma->tp->t_firstblock;
> -	}
>  	/*
>  	 * Bump the number of extents we've allocated
>  	 * in this call.
> @@ -4152,7 +4145,6 @@ xfs_bmapi_convert_unwritten(
>  	if ((ifp->if_flags & XFS_IFBROOT) && !bma->cur) {
>  		bma->cur = xfs_bmbt_init_cursor(bma->ip->i_mount, bma->tp,
>  					bma->ip, whichfork);
> -		bma->cur->bc_private.b.firstblock = bma->tp->t_firstblock;
>  	}
>  	mval->br_state = (mval->br_state == XFS_EXT_UNWRITTEN)
>  				? XFS_EXT_NORM : XFS_EXT_UNWRITTEN;
> @@ -4460,13 +4452,6 @@ xfs_bmapi_write(
>  		xfs_trans_log_inode(tp, ip, bma.logflags);
>  
>  	if (bma.cur) {
> -		if (!error) {
> -			ASSERT(tp->t_firstblock == NULLFSBLOCK ||
> -			       XFS_FSB_TO_AGNO(mp, tp->t_firstblock) <=
> -			       XFS_FSB_TO_AGNO(mp,
> -				       bma.cur->bc_private.b.firstblock));
> -			tp->t_firstblock = bma.cur->bc_private.b.firstblock;
> -		}
>  		xfs_btree_del_cursor(bma.cur,
>  			error ? XFS_BTREE_ERROR : XFS_BTREE_NOERROR);
>  	}
> @@ -4530,7 +4515,6 @@ xfs_bmapi_remap(
>  
>  	if (ifp->if_flags & XFS_IFBROOT) {
>  		cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
> -		cur->bc_private.b.firstblock = tp->t_firstblock;
>  		cur->bc_private.b.flags = 0;
>  	}
>  
> @@ -5191,7 +5175,6 @@ __xfs_bunmapi(
>  	if (ifp->if_flags & XFS_IFBROOT) {
>  		ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE);
>  		cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
> -		cur->bc_private.b.firstblock = tp->t_firstblock;
>  		cur->bc_private.b.flags = 0;
>  	} else
>  		cur = NULL;
> @@ -5459,10 +5442,8 @@ __xfs_bunmapi(
>  	if (logflags)
>  		xfs_trans_log_inode(tp, ip, logflags);
>  	if (cur) {
> -		if (!error) {
> -			tp->t_firstblock = cur->bc_private.b.firstblock;
> +		if (!error)
>  			cur->bc_private.b.allocated = 0;
> -		}
>  		xfs_btree_del_cursor(cur,
>  			error ? XFS_BTREE_ERROR : XFS_BTREE_NOERROR);
>  	}
> @@ -5678,7 +5659,6 @@ xfs_bmap_collapse_extents(
>  
>  	if (ifp->if_flags & XFS_IFBROOT) {
>  		cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
> -		cur->bc_private.b.firstblock = tp->t_firstblock;
>  		cur->bc_private.b.flags = 0;
>  	}
>  
> @@ -5798,7 +5778,6 @@ xfs_bmap_insert_extents(
>  
>  	if (ifp->if_flags & XFS_IFBROOT) {
>  		cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
> -		cur->bc_private.b.firstblock = tp->t_firstblock;
>  		cur->bc_private.b.flags = 0;
>  	}
>  
> @@ -5920,7 +5899,6 @@ xfs_bmap_split_extent_at(
>  
>  	if (ifp->if_flags & XFS_IFBROOT) {
>  		cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
> -		cur->bc_private.b.firstblock = tp->t_firstblock;
>  		cur->bc_private.b.flags = 0;
>  		error = xfs_bmbt_lookup_eq(cur, &got, &i);
>  		if (error)
> diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c
> index e8b01af09db5..8a9b98b11e34 100644
> --- a/fs/xfs/libxfs/xfs_bmap_btree.c
> +++ b/fs/xfs/libxfs/xfs_bmap_btree.c
> @@ -175,7 +175,6 @@ xfs_bmbt_dup_cursor(
>  	 * Copy the firstblock, dfops, and flags values,
>  	 * since init cursor doesn't get them.
>  	 */
> -	new->bc_private.b.firstblock = cur->bc_private.b.firstblock;
>  	new->bc_private.b.flags = cur->bc_private.b.flags;
>  
>  	return new;
> @@ -186,11 +185,11 @@ xfs_bmbt_update_cursor(
>  	struct xfs_btree_cur	*src,
>  	struct xfs_btree_cur	*dst)
>  {
> -	ASSERT((dst->bc_private.b.firstblock != NULLFSBLOCK) ||
> +	ASSERT((dst->bc_tp->t_firstblock != NULLFSBLOCK) ||
>  	       (dst->bc_private.b.ip->i_d.di_flags & XFS_DIFLAG_REALTIME));
>  
>  	dst->bc_private.b.allocated += src->bc_private.b.allocated;
> -	dst->bc_private.b.firstblock = src->bc_private.b.firstblock;
> +	dst->bc_tp->t_firstblock = src->bc_tp->t_firstblock;
>  
>  	src->bc_private.b.allocated = 0;
>  }
> @@ -208,7 +207,7 @@ xfs_bmbt_alloc_block(
>  	memset(&args, 0, sizeof(args));
>  	args.tp = cur->bc_tp;
>  	args.mp = cur->bc_mp;
> -	args.fsbno = cur->bc_private.b.firstblock;
> +	args.fsbno = cur->bc_tp->t_firstblock;
>  	args.firstblock = args.fsbno;
>  	xfs_rmap_ino_bmbt_owner(&args.oinfo, cur->bc_private.b.ip->i_ino,
>  			cur->bc_private.b.whichfork);
> @@ -263,7 +262,7 @@ xfs_bmbt_alloc_block(
>  	}
>  
>  	ASSERT(args.len == 1);
> -	cur->bc_private.b.firstblock = args.fsbno;
> +	cur->bc_tp->t_firstblock = args.fsbno;
>  	cur->bc_private.b.allocated++;
>  	cur->bc_private.b.ip->i_d.di_nblocks++;
>  	xfs_trans_log_inode(args.tp, cur->bc_private.b.ip, XFS_ILOG_CORE);
> @@ -562,7 +561,6 @@ xfs_bmbt_init_cursor(
>  
>  	cur->bc_private.b.forksize = XFS_IFORK_SIZE(ip, whichfork);
>  	cur->bc_private.b.ip = ip;
> -	cur->bc_private.b.firstblock = NULLFSBLOCK;
>  	cur->bc_private.b.allocated = 0;
>  	cur->bc_private.b.flags = 0;
>  	cur->bc_private.b.whichfork = whichfork;
> diff --git a/fs/xfs/libxfs/xfs_btree.h b/fs/xfs/libxfs/xfs_btree.h
> index b986a8fc8d40..503615f4d729 100644
> --- a/fs/xfs/libxfs/xfs_btree.h
> +++ b/fs/xfs/libxfs/xfs_btree.h
> @@ -214,7 +214,6 @@ typedef struct xfs_btree_cur
>  		} a;
>  		struct {			/* needed for BMAP */
>  			struct xfs_inode *ip;	/* pointer to our inode */
> -			xfs_fsblock_t	firstblock;	/* 1st blk allocated */
>  			int		allocated;	/* count of alloced */
>  			short		forksize;	/* fork's inode space */
>  			char		whichfork;	/* data or attr fork */
> -- 
> 2.17.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 19/25] xfs: remove xfs_alloc_arg firstblock field
  2018-07-03 17:23 ` [PATCH 19/25] xfs: remove xfs_alloc_arg " Brian Foster
@ 2018-07-04  0:54   ` Darrick J. Wong
  0 siblings, 0 replies; 58+ messages in thread
From: Darrick J. Wong @ 2018-07-04  0:54 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-xfs

On Tue, Jul 03, 2018 at 01:23:13PM -0400, Brian Foster wrote:
> The xfs_alloc_arg.firstblock field is used to control the starting
> agno for an allocation. The structure already carries a pointer to
> the transaction, which carries the current firstblock value.
> 
> Remove the field and access ->t_firstblock directly in the
> allocation code.
> 
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_alloc.c          | 20 ++++++++++----------
>  fs/xfs/libxfs/xfs_alloc.h          |  1 -
>  fs/xfs/libxfs/xfs_bmap.c           |  3 ---
>  fs/xfs/libxfs/xfs_bmap_btree.c     |  1 -
>  fs/xfs/libxfs/xfs_refcount_btree.c |  1 -
>  fs/xfs/xfs_trace.h                 |  2 +-
>  6 files changed, 11 insertions(+), 17 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
> index 5b1607d76fe9..bd6d8aeea825 100644
> --- a/fs/xfs/libxfs/xfs_alloc.c
> +++ b/fs/xfs/libxfs/xfs_alloc.c
> @@ -2783,16 +2783,16 @@ xfs_alloc_read_agf(
>   */
>  int				/* error */
>  xfs_alloc_vextent(
> -	xfs_alloc_arg_t	*args)	/* allocation argument structure */
> +	struct xfs_alloc_arg	*args)	/* allocation argument structure */
>  {
> -	xfs_agblock_t	agsize;	/* allocation group size */
> -	int		error;
> -	int		flags;	/* XFS_ALLOC_FLAG_... locking flags */
> -	xfs_mount_t	*mp;	/* mount structure pointer */
> -	xfs_agnumber_t	sagno;	/* starting allocation group number */
> -	xfs_alloctype_t	type;	/* input allocation type */
> -	int		bump_rotor = 0;
> -	xfs_agnumber_t	rotorstep = xfs_rotorstep; /* inode32 agf stepper */
> +	xfs_agblock_t		agsize;	/* allocation group size */
> +	int			error;
> +	int			flags;	/* XFS_ALLOC_FLAG_... locking flags */
> +	struct xfs_mount	*mp;	/* mount structure pointer */
> +	xfs_agnumber_t		sagno;	/* starting allocation group number */
> +	xfs_alloctype_t		type;	/* input allocation type */
> +	int			bump_rotor = 0;
> +	xfs_agnumber_t		rotorstep = xfs_rotorstep; /* inode32 agf stepper */
>  
>  	mp = args->mp;
>  	type = args->otype = args->type;
> @@ -2913,7 +2913,7 @@ xfs_alloc_vextent(
>  			* locking of AGF, which might cause deadlock.
>  			*/
>  			if (++(args->agno) == mp->m_sb.sb_agcount) {
> -				if (args->firstblock != NULLFSBLOCK)
> +				if (args->tp->t_firstblock != NULLFSBLOCK)
>  					args->agno = sagno;
>  				else
>  					args->agno = 0;
> diff --git a/fs/xfs/libxfs/xfs_alloc.h b/fs/xfs/libxfs/xfs_alloc.h
> index e716c993ac4c..00cd5ec4cb6b 100644
> --- a/fs/xfs/libxfs/xfs_alloc.h
> +++ b/fs/xfs/libxfs/xfs_alloc.h
> @@ -74,7 +74,6 @@ typedef struct xfs_alloc_arg {
>  	int		datatype;	/* mask defining data type treatment */
>  	char		wasdel;		/* set if allocation was prev delayed */
>  	char		wasfromfl;	/* set if allocation is from freelist */
> -	xfs_fsblock_t	firstblock;	/* io first block allocated */
>  	struct xfs_owner_info	oinfo;	/* owner of blocks being allocated */
>  	enum xfs_ag_resv_type	resv;	/* block reservation to use */
>  } xfs_alloc_arg_t;
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index c83add15233b..1955b8410410 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -697,7 +697,6 @@ xfs_bmap_extents_to_btree(
>  	args.tp = tp;
>  	args.mp = mp;
>  	xfs_rmap_ino_bmbt_owner(&args.oinfo, ip->i_ino, whichfork);
> -	args.firstblock = tp->t_firstblock;
>  	if (tp->t_firstblock == NULLFSBLOCK) {
>  		args.type = XFS_ALLOCTYPE_START_BNO;
>  		args.fsbno = XFS_INO_TO_FSB(mp, ip->i_ino);
> @@ -845,7 +844,6 @@ xfs_bmap_local_to_extents(
>  	args.tp = tp;
>  	args.mp = ip->i_mount;
>  	xfs_rmap_ino_owner(&args.oinfo, ip->i_ino, whichfork, 0);
> -	args.firstblock = tp->t_firstblock;
>  	/*
>  	 * Allocate a block.  We know we need only one, since the
>  	 * file currently fits in an inode.
> @@ -3445,7 +3443,6 @@ xfs_bmap_btalloc(
>  
>  	/* Trim the allocation back to the maximum an AG can fit. */
>  	args.maxlen = min(ap->length, mp->m_ag_max_usable);
> -	args.firstblock = ap->tp->t_firstblock;
>  	blen = 0;
>  	if (nullfb) {
>  		/*
> diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c
> index 8a9b98b11e34..628ed82ca286 100644
> --- a/fs/xfs/libxfs/xfs_bmap_btree.c
> +++ b/fs/xfs/libxfs/xfs_bmap_btree.c
> @@ -208,7 +208,6 @@ xfs_bmbt_alloc_block(
>  	args.tp = cur->bc_tp;
>  	args.mp = cur->bc_mp;
>  	args.fsbno = cur->bc_tp->t_firstblock;
> -	args.firstblock = args.fsbno;
>  	xfs_rmap_ino_bmbt_owner(&args.oinfo, cur->bc_private.b.ip->i_ino,
>  			cur->bc_private.b.whichfork);
>  
> diff --git a/fs/xfs/libxfs/xfs_refcount_btree.c b/fs/xfs/libxfs/xfs_refcount_btree.c
> index 393aa88f93db..26d2300ed865 100644
> --- a/fs/xfs/libxfs/xfs_refcount_btree.c
> +++ b/fs/xfs/libxfs/xfs_refcount_btree.c
> @@ -70,7 +70,6 @@ xfs_refcountbt_alloc_block(
>  	args.type = XFS_ALLOCTYPE_NEAR_BNO;
>  	args.fsbno = XFS_AGB_TO_FSB(cur->bc_mp, cur->bc_private.a.agno,
>  			xfs_refc_block(args.mp));
> -	args.firstblock = args.fsbno;
>  	xfs_rmap_ag_owner(&args.oinfo, XFS_RMAP_OWN_REFC);
>  	args.minlen = args.maxlen = args.prod = 1;
>  	args.resv = XFS_AG_RESV_METADATA;
> diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
> index 972d45d28097..392e026bea79 100644
> --- a/fs/xfs/xfs_trace.h
> +++ b/fs/xfs/xfs_trace.h
> @@ -1604,7 +1604,7 @@ DECLARE_EVENT_CLASS(xfs_alloc_class,
>  		__entry->wasfromfl = args->wasfromfl;
>  		__entry->resv = args->resv;
>  		__entry->datatype = args->datatype;
> -		__entry->firstblock = args->firstblock;
> +		__entry->firstblock = args->tp->t_firstblock;
>  	),
>  	TP_printk("dev %d:%d agno %u agbno %u minlen %u maxlen %u mod %u "
>  		  "prod %u minleft %u total %u alignment %u minalignslop %u "
> -- 
> 2.17.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 20/25] xfs: use ->t_firstblock in dq alloc
  2018-07-03 17:23 ` [PATCH 20/25] xfs: use ->t_firstblock in dq alloc Brian Foster
@ 2018-07-04  0:54   ` Darrick J. Wong
  0 siblings, 0 replies; 58+ messages in thread
From: Darrick J. Wong @ 2018-07-04  0:54 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-xfs

On Tue, Jul 03, 2018 at 01:23:14PM -0400, Brian Foster wrote:
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/xfs_dquot.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
> index 84359eeb20f4..3b61b4d266b4 100644
> --- a/fs/xfs/xfs_dquot.c
> +++ b/fs/xfs/xfs_dquot.c
> @@ -540,14 +540,13 @@ xfs_qm_dqread_alloc(
>  	struct xfs_trans	*tp;
>  	struct xfs_defer_ops	dfops;
>  	struct xfs_buf		*bp;
> -	xfs_fsblock_t		firstblock;
>  	int			error;
>  
>  	error = xfs_trans_alloc(mp, &M_RES(mp)->tr_qm_dqalloc,
>  			XFS_QM_DQALLOC_SPACE_RES(mp), 0, 0, &tp);
>  	if (error)
>  		goto err;
> -	xfs_defer_init(tp, &dfops, &firstblock);
> +	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
>  
>  	error = xfs_dquot_disk_alloc(&tp, dqp, &bp);
>  	if (error)
> -- 
> 2.17.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 21/25] xfs: replace no-op firstblock init with ->t_firstblock
  2018-07-03 17:23 ` [PATCH 21/25] xfs: replace no-op firstblock init with ->t_firstblock Brian Foster
@ 2018-07-04  0:54   ` Darrick J. Wong
  0 siblings, 0 replies; 58+ messages in thread
From: Darrick J. Wong @ 2018-07-04  0:54 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-xfs

On Tue, Jul 03, 2018 at 01:23:15PM -0400, Brian Foster wrote:
> xfs_refcount_recover_cow_leftovers() has no need for a firstblock
> variable and so passes an unrelated xfs_fsblock_t to
> xfs_defer_init() to avoid declaring one. Replace this no-op
> initialization with ->t_firstblock. This will be optimized away by
> the removal of the xfs_defer_init() firstblock param.
> 
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_refcount.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c
> index 8dc380574cd8..d81c17aac710 100644
> --- a/fs/xfs/libxfs/xfs_refcount.c
> +++ b/fs/xfs/libxfs/xfs_refcount.c
> @@ -1691,7 +1691,7 @@ xfs_refcount_recover_cow_leftovers(
>  		trace_xfs_refcount_recover_extent(mp, agno, &rr->rr_rrec);
>  
>  		/* Free the orphan record */
> -		xfs_defer_init(tp, &dfops, &fsb);
> +		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
>  		agbno = rr->rr_rrec.rc_startblock - XFS_REFC_COW_START;
>  		fsb = XFS_AGB_TO_FSB(mp, agno, agbno);
>  		error = xfs_refcount_free_cow_extent(mp, tp->t_dfops, fsb,
> -- 
> 2.17.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 22/25] xfs: use ->t_firstblock in reflink cow block cancel
  2018-07-03 17:23 ` [PATCH 22/25] xfs: use ->t_firstblock in reflink cow block cancel Brian Foster
@ 2018-07-04  0:55   ` Darrick J. Wong
  0 siblings, 0 replies; 58+ messages in thread
From: Darrick J. Wong @ 2018-07-04  0:55 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-xfs

On Tue, Jul 03, 2018 at 01:23:16PM -0400, Brian Foster wrote:
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/xfs_reflink.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> index cf6080d42273..d509bd7fa822 100644
> --- a/fs/xfs/xfs_reflink.c
> +++ b/fs/xfs/xfs_reflink.c
> @@ -546,7 +546,6 @@ xfs_reflink_cancel_cow_blocks(
>  	struct xfs_ifork		*ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK);
>  	struct xfs_bmbt_irec		got, del;
>  	struct xfs_iext_cursor		icur;
> -	xfs_fsblock_t			firstfsb;
>  	struct xfs_defer_ops		dfops;
>  	struct xfs_defer_ops		*odfops = (*tpp)->t_dfops;
>  	int				error = 0;
> @@ -575,7 +574,7 @@ xfs_reflink_cancel_cow_blocks(
>  			if (error)
>  				break;
>  		} else if (del.br_state == XFS_EXT_UNWRITTEN || cancel_real) {
> -			xfs_defer_init(*tpp, &dfops, &firstfsb);
> +			xfs_defer_init(*tpp, &dfops, &(*tpp)->t_firstblock);
>  
>  			/* Free the CoW orphan record. */
>  			error = xfs_refcount_free_cow_extent(ip->i_mount,
> -- 
> 2.17.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 23/25] xfs: use ->t_firstblock in extent swap
  2018-07-03 17:23 ` [PATCH 23/25] xfs: use ->t_firstblock in extent swap Brian Foster
@ 2018-07-04  0:55   ` Darrick J. Wong
  0 siblings, 0 replies; 58+ messages in thread
From: Darrick J. Wong @ 2018-07-04  0:55 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-xfs

On Tue, Jul 03, 2018 at 01:23:17PM -0400, Brian Foster wrote:
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/xfs_bmap_util.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
> index 6d2baf51fec9..96810bea07fd 100644
> --- a/fs/xfs/xfs_bmap_util.c
> +++ b/fs/xfs/xfs_bmap_util.c
> @@ -1569,7 +1569,6 @@ xfs_swap_extent_rmap(
>  	xfs_fileoff_t			offset_fsb;
>  	xfs_fileoff_t			end_fsb;
>  	xfs_filblks_t			count_fsb;
> -	xfs_fsblock_t			firstfsb;
>  	int				error;
>  	xfs_filblks_t			ilen;
>  	xfs_filblks_t			rlen;
> @@ -1605,7 +1604,7 @@ xfs_swap_extent_rmap(
>  
>  		/* Unmap the old blocks in the source file. */
>  		while (tirec.br_blockcount) {
> -			xfs_defer_init(tp, tp->t_dfops, &firstfsb);
> +			xfs_defer_init(tp, tp->t_dfops, &tp->t_firstblock);
>  			trace_xfs_swap_extent_rmap_remap_piece(tip, &tirec);
>  
>  			/* Read extent from the source file */
> @@ -1847,7 +1846,6 @@ xfs_swap_extents(
>  	struct xfs_ifork	*cowfp;
>  	uint64_t		f;
>  	int			resblks = 0;
> -	xfs_fsblock_t		firstfsb;
>  
>  	/*
>  	 * Lock the inodes against other IO, page faults and truncate to
> @@ -1910,7 +1908,7 @@ xfs_swap_extents(
>  	error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, resblks, 0, 0, &tp);
>  	if (error)
>  		goto out_unlock;
> -	xfs_defer_init(tp, &dfops, &firstfsb);
> +	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
>  
>  	/*
>  	 * Lock and join the inodes to the tansaction so that transaction commit
> -- 
> 2.17.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 24/25] xfs: use ->t_firstblock in inode inactivate
  2018-07-03 17:23 ` [PATCH 24/25] xfs: use ->t_firstblock in inode inactivate Brian Foster
@ 2018-07-04  0:55   ` Darrick J. Wong
  0 siblings, 0 replies; 58+ messages in thread
From: Darrick J. Wong @ 2018-07-04  0:55 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-xfs

On Tue, Jul 03, 2018 at 01:23:18PM -0400, Brian Foster wrote:
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/xfs_inode.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 5e1eaa26435c..48d22134b06f 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -1772,7 +1772,6 @@ xfs_inactive_ifree(
>  	struct xfs_inode *ip)
>  {
>  	struct xfs_defer_ops	dfops;
> -	xfs_fsblock_t		first_block;
>  	struct xfs_mount	*mp = ip->i_mount;
>  	struct xfs_trans	*tp;
>  	int			error;
> @@ -1809,7 +1808,7 @@ xfs_inactive_ifree(
>  	xfs_ilock(ip, XFS_ILOCK_EXCL);
>  	xfs_trans_ijoin(tp, ip, 0);
>  
> -	xfs_defer_init(tp, &dfops, &first_block);
> +	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
>  	error = xfs_ifree(tp, ip);
>  	if (error) {
>  		/*
> -- 
> 2.17.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 25/25] xfs: remove xfs_defer_init() firstblock param
  2018-07-03 17:23 ` [PATCH 25/25] xfs: remove xfs_defer_init() firstblock param Brian Foster
@ 2018-07-04  1:27   ` Darrick J. Wong
  2018-07-08 15:37     ` Christoph Hellwig
  0 siblings, 1 reply; 58+ messages in thread
From: Darrick J. Wong @ 2018-07-04  1:27 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-xfs, Allison Henderson

On Tue, Jul 03, 2018 at 01:23:19PM -0400, Brian Foster wrote:
> All but one caller of xfs_defer_init() passes in the ->t_firstblock
> of the associated transaction. The one outlier is
> xlog_recover_process_intents(), which simply passes a dummy value
> because a valid pointer is required. This firstblock variable can
> simply be removed.
> 
> At this point we could remove the xfs_defer_init() firstblock
> parameter and initialize ->t_firstblock directly. Even that is not
> necessary, however, because ->t_firstblock is automatically
> reinitialized in the new transaction on a transaction roll. Since
> xfs_defer_init() should never occur more than once on a particular
> transaction (since the corresponding finish will roll it), replace
> the reinit from xfs_defer_init() with an assert that verifies the
> transaction has a NULLFSBLOCK firstblock.
> 
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Well after the first day of testing I didn't see any new problems with
either of these two patchsets.

Moving on to the question of whether or not to embed a struct
xfs_defer_ops into struct xfs_trans instead of just a pointer, it looks
to me like that should be a pretty straightforward conversion.  Most of
the defer_ops users keep it within the scope of a single
xfs_trans_{alloc,commit} pair so we can pass *tp instead of *dfops into
the helpers.

The one big exception to that of course is the log item replay where we
don't want to finish any of the new defer_ops until we're done with
replay, for which we'll need to have a xfs_defer_move to transfer all
the items and [bi]join'd state from one dfops to another.  This is
probably the same mechanism that you'd have to use to preserve dfops
state in xfs_defer_trans_roll.

The other area of trickiness I anticipate is Allison's reworking of the
xattr code's usage of defer_ops to eliminate the repeated creation and
finishing of defer ops.  Even if attribute operations can still allocate
and commit multiple transactions, we'll have to find a way to carry the
defer_ops state (the attr intent item and presumably a _defer_ijoin'd
inode) across every one of those transactions.  I'm not sure how far
she's gotten with that, but some coordination is needed.

Anyway, we can leave that for after the break. :)

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_attr.c        | 28 ++++++++++------------------
>  fs/xfs/libxfs/xfs_attr_remote.c |  9 +++------
>  fs/xfs/libxfs/xfs_bmap.c        |  4 ++--
>  fs/xfs/libxfs/xfs_defer.c       |  5 ++---
>  fs/xfs/libxfs/xfs_defer.h       |  3 +--
>  fs/xfs/libxfs/xfs_refcount.c    |  2 +-
>  fs/xfs/xfs_bmap_util.c          | 12 ++++++------
>  fs/xfs/xfs_dquot.c              |  4 ++--
>  fs/xfs/xfs_inode.c              | 12 ++++++------
>  fs/xfs/xfs_iomap.c              |  6 +++---
>  fs/xfs/xfs_log_recover.c        |  3 +--
>  fs/xfs/xfs_reflink.c            |  8 ++++----
>  fs/xfs/xfs_rtalloc.c            |  2 +-
>  fs/xfs/xfs_symlink.c            |  4 ++--
>  14 files changed, 44 insertions(+), 58 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
> index 153d2e29f872..927d4c968f9a 100644
> --- a/fs/xfs/libxfs/xfs_attr.c
> +++ b/fs/xfs/libxfs/xfs_attr.c
> @@ -251,7 +251,7 @@ xfs_attr_set(
>  			rsvd ? XFS_TRANS_RESERVE : 0, &args.trans);
>  	if (error)
>  		return error;
> -	xfs_defer_init(args.trans, &dfops, &args.trans->t_firstblock);
> +	xfs_defer_init(args.trans, &dfops);
>  
>  	xfs_ilock(dp, XFS_ILOCK_EXCL);
>  	error = xfs_trans_reserve_quota_nblks(args.trans, dp, args.total, 0,
> @@ -422,7 +422,7 @@ xfs_attr_remove(
>  			&args.trans);
>  	if (error)
>  		return error;
> -	xfs_defer_init(args.trans, &dfops, &args.trans->t_firstblock);
> +	xfs_defer_init(args.trans, &dfops);
>  
>  	xfs_ilock(dp, XFS_ILOCK_EXCL);
>  	/*
> @@ -593,8 +593,7 @@ xfs_attr_leaf_addname(
>  		 * Commit that transaction so that the node_addname() call
>  		 * can manage its own transactions.
>  		 */
> -		xfs_defer_init(args->trans, args->trans->t_dfops,
> -			       &args->trans->t_firstblock);
> +		xfs_defer_init(args->trans, args->trans->t_dfops);
>  		error = xfs_attr3_leaf_to_node(args);
>  		if (error)
>  			goto out_defer_cancel;
> @@ -683,8 +682,7 @@ xfs_attr_leaf_addname(
>  		 * If the result is small enough, shrink it all into the inode.
>  		 */
>  		if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
> -			xfs_defer_init(args->trans, args->trans->t_dfops,
> -				       &args->trans->t_firstblock);
> +			xfs_defer_init(args->trans, args->trans->t_dfops);
>  			error = xfs_attr3_leaf_to_shortform(bp, args, forkoff);
>  			/* bp is gone due to xfs_da_shrink_inode */
>  			if (error)
> @@ -749,8 +747,7 @@ xfs_attr_leaf_removename(
>  	 * If the result is small enough, shrink it all into the inode.
>  	 */
>  	if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
> -		xfs_defer_init(args->trans, args->trans->t_dfops,
> -			       &args->trans->t_firstblock);
> +		xfs_defer_init(args->trans, args->trans->t_dfops);
>  		error = xfs_attr3_leaf_to_shortform(bp, args, forkoff);
>  		/* bp is gone due to xfs_da_shrink_inode */
>  		if (error)
> @@ -879,8 +876,7 @@ xfs_attr_node_addname(
>  			 */
>  			xfs_da_state_free(state);
>  			state = NULL;
> -			xfs_defer_init(args->trans, args->trans->t_dfops,
> -				       &args->trans->t_firstblock);
> +			xfs_defer_init(args->trans, args->trans->t_dfops);
>  			error = xfs_attr3_leaf_to_node(args);
>  			if (error)
>  				goto out_defer_cancel;
> @@ -907,8 +903,7 @@ xfs_attr_node_addname(
>  		 * in the index/blkno/rmtblkno/rmtblkcnt fields and
>  		 * in the index2/blkno2/rmtblkno2/rmtblkcnt2 fields.
>  		 */
> -		xfs_defer_init(args->trans, args->trans->t_dfops,
> -			       &args->trans->t_firstblock);
> +		xfs_defer_init(args->trans, args->trans->t_dfops);
>  		error = xfs_da3_split(state);
>  		if (error)
>  			goto out_defer_cancel;
> @@ -1006,8 +1001,7 @@ xfs_attr_node_addname(
>  		 * Check to see if the tree needs to be collapsed.
>  		 */
>  		if (retval && (state->path.active > 1)) {
> -			xfs_defer_init(args->trans, args->trans->t_dfops,
> -				       &args->trans->t_firstblock);
> +			xfs_defer_init(args->trans, args->trans->t_dfops);
>  			error = xfs_da3_join(state);
>  			if (error)
>  				goto out_defer_cancel;
> @@ -1132,8 +1126,7 @@ xfs_attr_node_removename(
>  	 * Check to see if the tree needs to be collapsed.
>  	 */
>  	if (retval && (state->path.active > 1)) {
> -		xfs_defer_init(args->trans, args->trans->t_dfops,
> -			       &args->trans->t_firstblock);
> +		xfs_defer_init(args->trans, args->trans->t_dfops);
>  		error = xfs_da3_join(state);
>  		if (error)
>  			goto out_defer_cancel;
> @@ -1165,8 +1158,7 @@ xfs_attr_node_removename(
>  			goto out;
>  
>  		if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
> -			xfs_defer_init(args->trans, args->trans->t_dfops,
> -				       &args->trans->t_firstblock);
> +			xfs_defer_init(args->trans, args->trans->t_dfops);
>  			error = xfs_attr3_leaf_to_shortform(bp, args, forkoff);
>  			/* bp is gone due to xfs_da_shrink_inode */
>  			if (error)
> diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c
> index f02c705965ff..7841e6255129 100644
> --- a/fs/xfs/libxfs/xfs_attr_remote.c
> +++ b/fs/xfs/libxfs/xfs_attr_remote.c
> @@ -480,8 +480,7 @@ xfs_attr_rmtval_set(
>  		 * extent and then crash then the block may not contain the
>  		 * correct metadata after log recovery occurs.
>  		 */
> -		xfs_defer_init(args->trans, args->trans->t_dfops,
> -			       &args->trans->t_firstblock);
> +		xfs_defer_init(args->trans, args->trans->t_dfops);
>  		nmap = 1;
>  		error = xfs_bmapi_write(args->trans, dp, (xfs_fileoff_t)lblkno,
>  				  blkcnt, XFS_BMAPI_ATTRFORK, args->total, &map,
> @@ -523,8 +522,7 @@ xfs_attr_rmtval_set(
>  
>  		ASSERT(blkcnt > 0);
>  
> -		xfs_defer_init(args->trans, args->trans->t_dfops,
> -			       &args->trans->t_firstblock);
> +		xfs_defer_init(args->trans, args->trans->t_dfops);
>  		nmap = 1;
>  		error = xfs_bmapi_read(dp, (xfs_fileoff_t)lblkno,
>  				       blkcnt, &map, &nmap,
> @@ -628,8 +626,7 @@ xfs_attr_rmtval_remove(
>  	blkcnt = args->rmtblkcnt;
>  	done = 0;
>  	while (!done) {
> -		xfs_defer_init(args->trans, args->trans->t_dfops,
> -			       &args->trans->t_firstblock);
> +		xfs_defer_init(args->trans, args->trans->t_dfops);
>  		error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt,
>  				    XFS_BMAPI_ATTRFORK, 1, &done);
>  		if (error)
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 1955b8410410..c7f7ef43d032 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -1038,7 +1038,7 @@ xfs_bmap_add_attrfork(
>  			rsvd ? XFS_TRANS_RESERVE : 0, &tp);
>  	if (error)
>  		return error;
> -	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> +	xfs_defer_init(tp, &dfops);
>  
>  	xfs_ilock(ip, XFS_ILOCK_EXCL);
>  	error = xfs_trans_reserve_quota_nblks(tp, ip, blks, 0, rsvd ?
> @@ -5970,7 +5970,7 @@ xfs_bmap_split_extent(
>  			XFS_DIOSTRAT_SPACE_RES(mp, 0), 0, 0, &tp);
>  	if (error)
>  		return error;
> -	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> +	xfs_defer_init(tp, &dfops);
>  
>  	xfs_ilock(ip, XFS_ILOCK_EXCL);
>  	xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
> diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c
> index 6b25a9436829..2713e2d808a7 100644
> --- a/fs/xfs/libxfs/xfs_defer.c
> +++ b/fs/xfs/libxfs/xfs_defer.c
> @@ -524,16 +524,15 @@ xfs_defer_init_op_type(
>  void
>  xfs_defer_init(
>  	struct xfs_trans		*tp,
> -	struct xfs_defer_ops		*dop,
> -	xfs_fsblock_t			*fbp)
> +	struct xfs_defer_ops		*dop)
>  {
>  	struct xfs_mount		*mp = NULL;
>  
>  	memset(dop, 0, sizeof(struct xfs_defer_ops));
> -	*fbp = NULLFSBLOCK;
>  	INIT_LIST_HEAD(&dop->dop_intake);
>  	INIT_LIST_HEAD(&dop->dop_pending);
>  	if (tp) {
> +		ASSERT(tp->t_firstblock == NULLFSBLOCK);
>  		tp->t_dfops = dop;
>  		mp = tp->t_mountp;
>  	}
> diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h
> index 56eaaac31df5..c17c9deda995 100644
> --- a/fs/xfs/libxfs/xfs_defer.h
> +++ b/fs/xfs/libxfs/xfs_defer.h
> @@ -63,8 +63,7 @@ void xfs_defer_add(struct xfs_defer_ops *dop, enum xfs_defer_ops_type type,
>  		struct list_head *h);
>  int xfs_defer_finish(struct xfs_trans **tp, struct xfs_defer_ops *dop);
>  void xfs_defer_cancel(struct xfs_defer_ops *dop);
> -void xfs_defer_init(struct xfs_trans *tp, struct xfs_defer_ops *dop,
> -		    xfs_fsblock_t *fbp);
> +void xfs_defer_init(struct xfs_trans *tp, struct xfs_defer_ops *dop);
>  bool xfs_defer_has_unfinished_work(struct xfs_defer_ops *dop);
>  int xfs_defer_ijoin(struct xfs_defer_ops *dop, struct xfs_inode *ip);
>  int xfs_defer_bjoin(struct xfs_defer_ops *dop, struct xfs_buf *bp);
> diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c
> index d81c17aac710..2ecfb0518580 100644
> --- a/fs/xfs/libxfs/xfs_refcount.c
> +++ b/fs/xfs/libxfs/xfs_refcount.c
> @@ -1691,7 +1691,7 @@ xfs_refcount_recover_cow_leftovers(
>  		trace_xfs_refcount_recover_extent(mp, agno, &rr->rr_rrec);
>  
>  		/* Free the orphan record */
> -		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> +		xfs_defer_init(tp, &dfops);
>  		agbno = rr->rr_rrec.rc_startblock - XFS_REFC_COW_START;
>  		fsb = XFS_AGB_TO_FSB(mp, agno, agbno);
>  		error = xfs_refcount_free_cow_extent(mp, tp->t_dfops, fsb,
> diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
> index 96810bea07fd..7fb51534ebd3 100644
> --- a/fs/xfs/xfs_bmap_util.c
> +++ b/fs/xfs/xfs_bmap_util.c
> @@ -970,7 +970,7 @@ xfs_alloc_file_space(
>  
>  		xfs_trans_ijoin(tp, ip, 0);
>  
> -		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> +		xfs_defer_init(tp, &dfops);
>  		error = xfs_bmapi_write(tp, ip, startoffset_fsb,
>  					allocatesize_fsb, alloc_type, resblks,
>  					imapp, &nimaps);
> @@ -1039,7 +1039,7 @@ xfs_unmap_extent(
>  
>  	xfs_trans_ijoin(tp, ip, 0);
>  
> -	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> +	xfs_defer_init(tp, &dfops);
>  	error = xfs_bunmapi(tp, ip, startoffset_fsb, len_fsb, 0, 2, done);
>  	if (error)
>  		goto out_bmap_cancel;
> @@ -1340,7 +1340,7 @@ xfs_collapse_file_space(
>  			goto out_trans_cancel;
>  		xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
>  
> -		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> +		xfs_defer_init(tp, &dfops);
>  		error = xfs_bmap_collapse_extents(tp, ip, &next_fsb, shift_fsb,
>  				&done);
>  		if (error)
> @@ -1418,7 +1418,7 @@ xfs_insert_file_space(
>  
>  		xfs_ilock(ip, XFS_ILOCK_EXCL);
>  		xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
> -		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> +		xfs_defer_init(tp, &dfops);
>  		error = xfs_bmap_insert_extents(tp, ip, &next_fsb, shift_fsb,
>  				&done, stop_fsb);
>  		if (error)
> @@ -1604,7 +1604,7 @@ xfs_swap_extent_rmap(
>  
>  		/* Unmap the old blocks in the source file. */
>  		while (tirec.br_blockcount) {
> -			xfs_defer_init(tp, tp->t_dfops, &tp->t_firstblock);
> +			xfs_defer_init(tp, tp->t_dfops);
>  			trace_xfs_swap_extent_rmap_remap_piece(tip, &tirec);
>  
>  			/* Read extent from the source file */
> @@ -1908,7 +1908,7 @@ xfs_swap_extents(
>  	error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, resblks, 0, 0, &tp);
>  	if (error)
>  		goto out_unlock;
> -	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> +	xfs_defer_init(tp, &dfops);
>  
>  	/*
>  	 * Lock and join the inodes to the tansaction so that transaction commit
> diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
> index 3b61b4d266b4..c53de34c9ae5 100644
> --- a/fs/xfs/xfs_dquot.c
> +++ b/fs/xfs/xfs_dquot.c
> @@ -295,7 +295,7 @@ xfs_dquot_disk_alloc(
>  
>  	trace_xfs_dqalloc(dqp);
>  
> -	xfs_defer_init(tp, tp->t_dfops, &tp->t_firstblock);
> +	xfs_defer_init(tp, tp->t_dfops);
>  
>  	xfs_ilock(quotip, XFS_ILOCK_EXCL);
>  	if (!xfs_this_quota_on(dqp->q_mount, dqp->dq_flags)) {
> @@ -546,7 +546,7 @@ xfs_qm_dqread_alloc(
>  			XFS_QM_DQALLOC_SPACE_RES(mp), 0, 0, &tp);
>  	if (error)
>  		goto err;
> -	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> +	xfs_defer_init(tp, &dfops);
>  
>  	error = xfs_dquot_disk_alloc(&tp, dqp, &bp);
>  	if (error)
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 48d22134b06f..7b2694d3901a 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -1194,7 +1194,7 @@ xfs_create(
>  	xfs_ilock(dp, XFS_ILOCK_EXCL | XFS_ILOCK_PARENT);
>  	unlock_dp_on_error = true;
>  
> -	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> +	xfs_defer_init(tp, &dfops);
>  
>  	/*
>  	 * Reserve disk quota and the inode.
> @@ -1448,7 +1448,7 @@ xfs_link(
>  			goto error_return;
>  	}
>  
> -	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> +	xfs_defer_init(tp, &dfops);
>  
>  	/*
>  	 * Handle initial link state of O_TMPFILE inode
> @@ -1579,7 +1579,7 @@ xfs_itruncate_extents_flags(
>  	ASSERT(first_unmap_block < last_block);
>  	unmap_len = last_block - first_unmap_block + 1;
>  	while (!done) {
> -		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> +		xfs_defer_init(tp, &dfops);
>  		error = xfs_bunmapi(tp, ip, first_unmap_block, unmap_len, flags,
>  				    XFS_ITRUNC_MAX_EXTENTS, &done);
>  		if (error)
> @@ -1808,7 +1808,7 @@ xfs_inactive_ifree(
>  	xfs_ilock(ip, XFS_ILOCK_EXCL);
>  	xfs_trans_ijoin(tp, ip, 0);
>  
> -	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> +	xfs_defer_init(tp, &dfops);
>  	error = xfs_ifree(tp, ip);
>  	if (error) {
>  		/*
> @@ -2651,7 +2651,7 @@ xfs_remove(
>  	if (error)
>  		goto out_trans_cancel;
>  
> -	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> +	xfs_defer_init(tp, &dfops);
>  	error = xfs_dir_removename(tp, dp, name, ip->i_ino, resblks);
>  	if (error) {
>  		ASSERT(error != -ENOENT);
> @@ -3008,7 +3008,7 @@ xfs_rename(
>  		goto out_trans_cancel;
>  	}
>  
> -	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> +	xfs_defer_init(tp, &dfops);
>  
>  	/* RENAME_EXCHANGE is unique from here on. */
>  	if (flags & RENAME_EXCHANGE)
> diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
> index 46ade3f7a5a3..641861bf4b92 100644
> --- a/fs/xfs/xfs_iomap.c
> +++ b/fs/xfs/xfs_iomap.c
> @@ -253,7 +253,7 @@ xfs_iomap_write_direct(
>  	 * From this point onwards we overwrite the imap pointer that the
>  	 * caller gave to us.
>  	 */
> -	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> +	xfs_defer_init(tp, &dfops);
>  	nimaps = 1;
>  	error = xfs_bmapi_write(tp, ip, offset_fsb, count_fsb,
>  				bmapi_flags, resblks, imap, &nimaps);
> @@ -713,7 +713,7 @@ xfs_iomap_write_allocate(
>  			xfs_ilock(ip, XFS_ILOCK_EXCL);
>  			xfs_trans_ijoin(tp, ip, 0);
>  
> -			xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> +			xfs_defer_init(tp, &dfops);
>  
>  			/*
>  			 * it is possible that the extents have changed since
> @@ -872,7 +872,7 @@ xfs_iomap_write_unwritten(
>  		/*
>  		 * Modify the unwritten extent state of the buffer.
>  		 */
> -		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> +		xfs_defer_init(tp, &dfops);
>  		nimaps = 1;
>  		error = xfs_bmapi_write(tp, ip, offset_fsb, count_fsb,
>  					XFS_BMAPI_CONVERT, resblks, &imap,
> diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
> index 940eb30e0271..8317023293a5 100644
> --- a/fs/xfs/xfs_log_recover.c
> +++ b/fs/xfs/xfs_log_recover.c
> @@ -4890,7 +4890,6 @@ xlog_recover_process_intents(
>  	struct xfs_ail_cursor	cur;
>  	struct xfs_log_item	*lip;
>  	struct xfs_ail		*ailp;
> -	xfs_fsblock_t		firstfsb;
>  	int			error = 0;
>  #if defined(DEBUG) || defined(XFS_WARN)
>  	xfs_lsn_t		last_lsn;
> @@ -4902,7 +4901,7 @@ xlog_recover_process_intents(
>  #if defined(DEBUG) || defined(XFS_WARN)
>  	last_lsn = xlog_assign_lsn(log->l_curr_cycle, log->l_curr_block);
>  #endif
> -	xfs_defer_init(NULL, &dfops, &firstfsb);
> +	xfs_defer_init(NULL, &dfops);
>  	while (lip != NULL) {
>  		/*
>  		 * We're done when we see something other than an intent.
> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> index d509bd7fa822..79b9ce855c72 100644
> --- a/fs/xfs/xfs_reflink.c
> +++ b/fs/xfs/xfs_reflink.c
> @@ -424,7 +424,7 @@ xfs_reflink_allocate_cow(
>  
>  	xfs_trans_ijoin(tp, ip, 0);
>  
> -	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> +	xfs_defer_init(tp, &dfops);
>  	nimaps = 1;
>  
>  	/* Allocate the entire reservation as unwritten blocks. */
> @@ -574,7 +574,7 @@ xfs_reflink_cancel_cow_blocks(
>  			if (error)
>  				break;
>  		} else if (del.br_state == XFS_EXT_UNWRITTEN || cancel_real) {
> -			xfs_defer_init(*tpp, &dfops, &(*tpp)->t_firstblock);
> +			xfs_defer_init(*tpp, &dfops);
>  
>  			/* Free the CoW orphan record. */
>  			error = xfs_refcount_free_cow_extent(ip->i_mount,
> @@ -756,7 +756,7 @@ xfs_reflink_end_cow(
>  			goto prev_extent;
>  
>  		/* Unmap the old blocks in the data fork. */
> -		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> +		xfs_defer_init(tp, &dfops);
>  		rlen = del.br_blockcount;
>  		error = __xfs_bunmapi(tp, ip, del.br_startoff, &rlen, 0, 1);
>  		if (error)
> @@ -1104,7 +1104,7 @@ xfs_reflink_remap_extent(
>  	/* Unmap the old blocks in the data fork. */
>  	rlen = unmap_len;
>  	while (rlen) {
> -		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> +		xfs_defer_init(tp, &dfops);
>  		error = __xfs_bunmapi(tp, ip, destoff, &rlen, 0, 1);
>  		if (error)
>  			goto out_defer;
> diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
> index edd949376a51..bc471d42a968 100644
> --- a/fs/xfs/xfs_rtalloc.c
> +++ b/fs/xfs/xfs_rtalloc.c
> @@ -786,7 +786,7 @@ xfs_growfs_rt_alloc(
>  		xfs_ilock(ip, XFS_ILOCK_EXCL);
>  		xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
>  
> -		xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> +		xfs_defer_init(tp, &dfops);
>  		/*
>  		 * Allocate blocks to the bitmap file.
>  		 */
> diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
> index a3dc552a5b97..d1ab0afa2723 100644
> --- a/fs/xfs/xfs_symlink.c
> +++ b/fs/xfs/xfs_symlink.c
> @@ -245,7 +245,7 @@ xfs_symlink(
>  	 * Initialize the bmap freelist prior to calling either
>  	 * bmapi or the directory create code.
>  	 */
> -	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> +	xfs_defer_init(tp, &dfops);
>  
>  	/*
>  	 * Allocate an inode for the symlink.
> @@ -438,7 +438,7 @@ xfs_inactive_symlink_rmt(
>  	 * Find the block(s) so we can inval and unmap them.
>  	 */
>  	done = 0;
> -	xfs_defer_init(tp, &dfops, &tp->t_firstblock);
> +	xfs_defer_init(tp, &dfops);
>  	nmaps = ARRAY_SIZE(mval);
>  	error = xfs_bmapi_read(ip, 0, xfs_symlink_blocks(mp, size),
>  				mval, &nmaps, 0);
> -- 
> 2.17.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 01/25] xfs: allow null firstblock in xfs_bmapi_write() when tp is null
  2018-07-03 17:22 ` [PATCH 01/25] xfs: allow null firstblock in xfs_bmapi_write() when tp is null Brian Foster
  2018-07-04  0:24   ` Darrick J. Wong
@ 2018-07-08 15:26   ` Christoph Hellwig
  1 sibling, 0 replies; 58+ messages in thread
From: Christoph Hellwig @ 2018-07-08 15:26 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-xfs

On Tue, Jul 03, 2018 at 01:22:55PM -0400, Brian Foster wrote:
> xfs_bmapi_write() always expects a valid firstblock pointer. It
> immediately dereferences the pointer to help determine how to
> initialize the bma.minleft field. The remaining accesses are
> related to modifying btree format forks, which is only relevant for
> !COW fork callers.
> 
> The reflink code passes a NULL transaction to xfs_bmapi_write() in a
> couple places that do COW fork unwritten conversion. The purpose of
> the firstblock field is to track the first block allocation in the
> current transaction, so technically firstblock should not be
> required for these callers either.
> 
> Tweak xfs_bmapi_write() to initialize the bma correctly without
> accessing the firstblock pointer if no transaction is provided in
> the first place. Update the reflink callers to pass NULL instead of
> otherwise unused firstblock references.
> 
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 02/25] xfs: add firstblock field to xfs_trans
  2018-07-03 17:22 ` [PATCH 02/25] xfs: add firstblock field to xfs_trans Brian Foster
  2018-07-04  0:41   ` Darrick J. Wong
@ 2018-07-08 15:26   ` Christoph Hellwig
  1 sibling, 0 replies; 58+ messages in thread
From: Christoph Hellwig @ 2018-07-08 15:26 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-xfs

On Tue, Jul 03, 2018 at 01:22:56PM -0400, Brian Foster wrote:
> A firstblock var is typically allocated and initialized along with
> xfs_defer_ops structures and passed around independent from the
> associated transaction. To facilitate combining the two, add an
> optional ->t_firstblock field to xfs_trans that can be used in place
> of an on-stack variable.
> 
> The firstblock value follows the lifetime of the transaction, so
> initialize it on allocation and when a transaction rolls.
> 
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 25/25] xfs: remove xfs_defer_init() firstblock param
  2018-07-04  1:27   ` Darrick J. Wong
@ 2018-07-08 15:37     ` Christoph Hellwig
  2018-07-08 16:34       ` Darrick J. Wong
  2018-07-10  1:07       ` Brian Foster
  0 siblings, 2 replies; 58+ messages in thread
From: Christoph Hellwig @ 2018-07-08 15:37 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Brian Foster, linux-xfs, Allison Henderson

On Tue, Jul 03, 2018 at 06:27:43PM -0700, Darrick J. Wong wrote:
> Moving on to the question of whether or not to embed a struct
> xfs_defer_ops into struct xfs_trans instead of just a pointer, it looks
> to me like that should be a pretty straightforward conversion.  Most of
> the defer_ops users keep it within the scope of a single
> xfs_trans_{alloc,commit} pair so we can pass *tp instead of *dfops into
> the helpers.

I'd like to see that happen eventually, probably rather sooner than
later.

> The one big exception to that of course is the log item replay where we
> don't want to finish any of the new defer_ops until we're done with
> replay, for which we'll need to have a xfs_defer_move to transfer all
> the items and [bi]join'd state from one dfops to another.  This is
> probably the same mechanism that you'd have to use to preserve dfops
> state in xfs_defer_trans_roll.

Yes.  As far as I can tell we can just list_split_init the two lists
over, copy over the inodes and bufs arrays (at least if we are rolling
the transaction) and mostly ignore dop_low and dop_commited.

Now the transaction itself actually already has a list of items joined
to them, which must include dop_inodes and dop_bufs, and I suspect
we should just look at the items and rejoin all inodes and bufs instead
of separately keeping track of them for the normal roll case.  We'd
just need some special outside storage for the log recovery case.

> The other area of trickiness I anticipate is Allison's reworking of the
> xattr code's usage of defer_ops to eliminate the repeated creation and
> finishing of defer ops.  Even if attribute operations can still allocate
> and commit multiple transactions, we'll have to find a way to carry the
> defer_ops state (the attr intent item and presumably a _defer_ijoin'd
> inode) across every one of those transactions.  I'm not sure how far
> she's gotten with that, but some coordination is needed.

In general attribute operations should be rolling transactions, and
if they aren't we probably found a bug.  Once it is a rolling
transaction we've already got all the state coverted by the
xfs_defer_trans_roll equivalent case.

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 25/25] xfs: remove xfs_defer_init() firstblock param
  2018-07-08 15:37     ` Christoph Hellwig
@ 2018-07-08 16:34       ` Darrick J. Wong
  2018-07-10  1:07       ` Brian Foster
  1 sibling, 0 replies; 58+ messages in thread
From: Darrick J. Wong @ 2018-07-08 16:34 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Brian Foster, linux-xfs, Allison Henderson

On Sun, Jul 08, 2018 at 08:37:08AM -0700, Christoph Hellwig wrote:
> On Tue, Jul 03, 2018 at 06:27:43PM -0700, Darrick J. Wong wrote:
> > Moving on to the question of whether or not to embed a struct
> > xfs_defer_ops into struct xfs_trans instead of just a pointer, it looks
> > to me like that should be a pretty straightforward conversion.  Most of
> > the defer_ops users keep it within the scope of a single
> > xfs_trans_{alloc,commit} pair so we can pass *tp instead of *dfops into
> > the helpers.
> 
> I'd like to see that happen eventually, probably rather sooner than
> later.
> 
> > The one big exception to that of course is the log item replay where we
> > don't want to finish any of the new defer_ops until we're done with
> > replay, for which we'll need to have a xfs_defer_move to transfer all
> > the items and [bi]join'd state from one dfops to another.  This is
> > probably the same mechanism that you'd have to use to preserve dfops
> > state in xfs_defer_trans_roll.
> 
> Yes.  As far as I can tell we can just list_split_init the two lists
> over, copy over the inodes and bufs arrays (at least if we are rolling
> the transaction) and mostly ignore dop_low and dop_commited.
> 
> Now the transaction itself actually already has a list of items joined
> to them, which must include dop_inodes and dop_bufs, and I suspect
> we should just look at the items and rejoin all inodes and bufs instead
> of separately keeping track of them for the normal roll case.  We'd
> just need some special outside storage for the log recovery case.

That would be a useful property to have, especially since it would solve
the problem where you can lock an AGF in between a refcount update
finishing and a rmap update finishing and see intermediate results.  The
whole complex update is atomic, but we don't quite succeed in locking
out reads while we're committing.  However, the tricky part will be to
make sure we don't break any AG order locking rules.

> > The other area of trickiness I anticipate is Allison's reworking of the
> > xattr code's usage of defer_ops to eliminate the repeated creation and
> > finishing of defer ops.  Even if attribute operations can still allocate
> > and commit multiple transactions, we'll have to find a way to carry the
> > defer_ops state (the attr intent item and presumably a _defer_ijoin'd
> > inode) across every one of those transactions.  I'm not sure how far
> > she's gotten with that, but some coordination is needed.
> 
> In general attribute operations should be rolling transactions, and
> if they aren't we probably found a bug.  Once it is a rolling
> transaction we've already got all the state coverted by the
> xfs_defer_trans_roll equivalent case.

<nod>

--D

> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 25/25] xfs: remove xfs_defer_init() firstblock param
  2018-07-08 15:37     ` Christoph Hellwig
  2018-07-08 16:34       ` Darrick J. Wong
@ 2018-07-10  1:07       ` Brian Foster
  1 sibling, 0 replies; 58+ messages in thread
From: Brian Foster @ 2018-07-10  1:07 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Darrick J. Wong, linux-xfs, Allison Henderson

On Sun, Jul 08, 2018 at 08:37:08AM -0700, Christoph Hellwig wrote:
> On Tue, Jul 03, 2018 at 06:27:43PM -0700, Darrick J. Wong wrote:
> > Moving on to the question of whether or not to embed a struct
> > xfs_defer_ops into struct xfs_trans instead of just a pointer, it looks
> > to me like that should be a pretty straightforward conversion.  Most of
> > the defer_ops users keep it within the scope of a single
> > xfs_trans_{alloc,commit} pair so we can pass *tp instead of *dfops into
> > the helpers.
> 
> I'd like to see that happen eventually, probably rather sooner than
> later.
> 
> > The one big exception to that of course is the log item replay where we
> > don't want to finish any of the new defer_ops until we're done with
> > replay, for which we'll need to have a xfs_defer_move to transfer all
> > the items and [bi]join'd state from one dfops to another.  This is
> > probably the same mechanism that you'd have to use to preserve dfops
> > state in xfs_defer_trans_roll.
> 
> Yes.  As far as I can tell we can just list_split_init the two lists
> over, copy over the inodes and bufs arrays (at least if we are rolling
> the transaction) and mostly ignore dop_low and dop_commited.
> 

I have a series in progress that takes care of most of this. It has some
details left to work out and needs cleanup, but survived an initial
round of tests. Unfortunately I won't have much time to get to it this
week, but hopefully I'll have it cleaned up enough to post something
next week.

Brian

> Now the transaction itself actually already has a list of items joined
> to them, which must include dop_inodes and dop_bufs, and I suspect
> we should just look at the items and rejoin all inodes and bufs instead
> of separately keeping track of them for the normal roll case.  We'd
> just need some special outside storage for the log recovery case.
> 
> > The other area of trickiness I anticipate is Allison's reworking of the
> > xattr code's usage of defer_ops to eliminate the repeated creation and
> > finishing of defer ops.  Even if attribute operations can still allocate
> > and commit multiple transactions, we'll have to find a way to carry the
> > defer_ops state (the attr intent item and presumably a _defer_ijoin'd
> > inode) across every one of those transactions.  I'm not sure how far
> > she's gotten with that, but some coordination is needed.
> 
> In general attribute operations should be rolling transactions, and
> if they aren't we probably found a bug.  Once it is a rolling
> transaction we've already got all the state coverted by the
> xfs_defer_trans_roll equivalent case.

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 00/25] xfs: embed firstblock in xfs_trans
  2018-07-03 17:22 [PATCH 00/25] xfs: embed firstblock in xfs_trans Brian Foster
                   ` (24 preceding siblings ...)
  2018-07-03 17:23 ` [PATCH 25/25] xfs: remove xfs_defer_init() firstblock param Brian Foster
@ 2018-07-10  7:11 ` Christoph Hellwig
  25 siblings, 0 replies; 58+ messages in thread
From: Christoph Hellwig @ 2018-07-10  7:11 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-xfs

The whole series looks good to me:

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 58+ messages in thread

end of thread, other threads:[~2018-07-10  7:11 UTC | newest]

Thread overview: 58+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-03 17:22 [PATCH 00/25] xfs: embed firstblock in xfs_trans Brian Foster
2018-07-03 17:22 ` [PATCH 01/25] xfs: allow null firstblock in xfs_bmapi_write() when tp is null Brian Foster
2018-07-04  0:24   ` Darrick J. Wong
2018-07-08 15:26   ` Christoph Hellwig
2018-07-03 17:22 ` [PATCH 02/25] xfs: add firstblock field to xfs_trans Brian Foster
2018-07-04  0:41   ` Darrick J. Wong
2018-07-08 15:26   ` Christoph Hellwig
2018-07-03 17:22 ` [PATCH 03/25] xfs: use ->t_firstblock in dir ops Brian Foster
2018-07-04  0:42   ` Darrick J. Wong
2018-07-03 17:22 ` [PATCH 04/25] xfs: remove firstblock param from xfs " Brian Foster
2018-07-03 18:06   ` Darrick J. Wong
2018-07-03 18:15     ` Brian Foster
2018-07-03 17:22 ` [PATCH 05/25] xfs: use ->t_firstblock in attrfork add Brian Foster
2018-07-04  0:43   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 06/25] xfs: use ->t_firstblock in xattr ops Brian Foster
2018-07-04  0:45   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 07/25] xfs: use ->t_firstblock for all xfs_bmapi_write() callers Brian Foster
2018-07-04  0:47   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 08/25] xfs: use ->t_firstblock for all xfs_bunmapi() callers Brian Foster
2018-07-04  0:47   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 09/25] xfs: use ->t_firstblock in xfs_bmapi_remap() Brian Foster
2018-07-04  0:47   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 10/25] xfs: use ->t_firstblock in insert/collapse range Brian Foster
2018-07-04  0:48   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 11/25] xfs: remove xfs_bmapi_write() firstblock param Brian Foster
2018-07-04  0:50   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 12/25] xfs: remove xfs_bunmapi() " Brian Foster
2018-07-04  0:51   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 13/25] xfs: remove bmap insert/collapse " Brian Foster
2018-07-04  0:51   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 14/25] xfs: use ->t_firstblock in bmap extent split Brian Foster
2018-07-04  0:51   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 15/25] xfs: remove xfs_bmalloca firstblock field Brian Foster
2018-07-04  0:52   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 16/25] xfs: remove bmap extent add helper firstblock params Brian Foster
2018-07-04  0:52   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 17/25] xfs: remove bmap format helpers " Brian Foster
2018-07-04  0:53   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 18/25] xfs: remove xfs_btree_cur private firstblock field Brian Foster
2018-07-04  0:54   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 19/25] xfs: remove xfs_alloc_arg " Brian Foster
2018-07-04  0:54   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 20/25] xfs: use ->t_firstblock in dq alloc Brian Foster
2018-07-04  0:54   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 21/25] xfs: replace no-op firstblock init with ->t_firstblock Brian Foster
2018-07-04  0:54   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 22/25] xfs: use ->t_firstblock in reflink cow block cancel Brian Foster
2018-07-04  0:55   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 23/25] xfs: use ->t_firstblock in extent swap Brian Foster
2018-07-04  0:55   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 24/25] xfs: use ->t_firstblock in inode inactivate Brian Foster
2018-07-04  0:55   ` Darrick J. Wong
2018-07-03 17:23 ` [PATCH 25/25] xfs: remove xfs_defer_init() firstblock param Brian Foster
2018-07-04  1:27   ` Darrick J. Wong
2018-07-08 15:37     ` Christoph Hellwig
2018-07-08 16:34       ` Darrick J. Wong
2018-07-10  1:07       ` Brian Foster
2018-07-10  7:11 ` [PATCH 00/25] xfs: embed firstblock in xfs_trans Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.