diff mbox

[02/25] xfs: add firstblock field to xfs_trans

Message ID 20180703172319.24509-3-bfoster@redhat.com (mailing list archive)
State Accepted
Headers show

Commit Message

Brian Foster July 3, 2018, 5:22 p.m. UTC
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(+)

Comments

Darrick J. Wong July 4, 2018, 12:41 a.m. UTC | #1
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
--
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
Christoph Hellwig July 8, 2018, 3:26 p.m. UTC | #2
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>
--
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
diff mbox

Patch

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 */