public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: xfs@oss.sgi.com
Subject: [PATCH 44/55] xfs: refactor xfs_trans_reserve() interface
Date: Thu,  5 Sep 2013 08:05:48 +1000	[thread overview]
Message-ID: <1378332359-14737-45-git-send-email-david@fromorbit.com> (raw)
In-Reply-To: <1378332359-14737-1-git-send-email-david@fromorbit.com>

From: Jie Liu <jeff.liu@oracle.com>

With the new xfs_trans_res structure has been introduced, the log
reservation size, log count as well as log flags are pre-initialized
at mount time.  So it's time to refine xfs_trans_reserve() interface
to be more neat.

Also, introduce a new helper M_RES() to return a pointer to the
mp->m_resv structure to simplify the input.

Signed-off-by: Jie Liu <jeff.liu@oracle.com>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 include/libxfs.h         |  3 +-
 include/xfs_trans_resv.h |  3 ++
 libxfs/trans.c           | 20 +++++------
 libxfs/util.c            | 15 +++++---
 libxfs/xfs_attr.c        | 33 +++++++++---------
 libxfs/xfs_bmap.c        |  4 +--
 libxfs/xfs_trans_resv.c  |  7 ++--
 mkfs/proto.c             | 24 ++++++++-----
 mkfs/xfs_mkfs.c          |  5 ++-
 repair/phase5.c          |  3 +-
 repair/phase6.c          | 89 +++++++++++++++++++++++-------------------------
 repair/phase7.c          |  7 ++--
 12 files changed, 115 insertions(+), 98 deletions(-)

diff --git a/include/libxfs.h b/include/libxfs.h
index e48ab70..533d336 100644
--- a/include/libxfs.h
+++ b/include/libxfs.h
@@ -513,7 +513,8 @@ extern int	xfs_trans_roll(struct xfs_trans **, struct xfs_inode *);
 
 extern xfs_trans_t	*libxfs_trans_alloc (xfs_mount_t *, int);
 extern xfs_trans_t	*libxfs_trans_dup (xfs_trans_t *);
-extern int	libxfs_trans_reserve (xfs_trans_t *, uint,uint,uint,uint,uint);
+extern int	libxfs_trans_reserve(struct xfs_trans *, struct xfs_trans_res *,
+				     uint, uint);
 extern int	libxfs_trans_commit (xfs_trans_t *, uint);
 extern void	libxfs_trans_cancel (xfs_trans_t *, int);
 extern xfs_buf_t	*libxfs_trans_getsb (xfs_trans_t *, xfs_mount_t *, int);
diff --git a/include/xfs_trans_resv.h b/include/xfs_trans_resv.h
index b8d5666..140d3f3 100644
--- a/include/xfs_trans_resv.h
+++ b/include/xfs_trans_resv.h
@@ -65,6 +65,9 @@ struct xfs_trans_resv {
 	struct xfs_trans_res	tr_fsyncts;	/* update timestamps on fsync */
 };
 
+/* shorthand way of accessing reservation structure */
+#define M_RES(mp)	(&(mp)->m_resv)
+
 /*
  * Per-extent log reservation for the allocation btree changes
  * involved in freeing or allocating an extent.
diff --git a/libxfs/trans.c b/libxfs/trans.c
index 2fc0ecc..6a05673 100644
--- a/libxfs/trans.c
+++ b/libxfs/trans.c
@@ -91,7 +91,7 @@ libxfs_trans_roll(
 	struct xfs_inode	*dp)
 {
 	struct xfs_trans	*trans;
-	unsigned int		logres, count;
+	struct xfs_trans_res	tres;
 	int			error;
 
 	/*
@@ -103,8 +103,8 @@ libxfs_trans_roll(
 	/*
 	 * Copy the critical parameters from one trans to the next.
 	 */
-	logres = trans->t_log_res;
-	count = trans->t_log_count;
+	tres.tr_logres = trans->t_log_res;
+	tres.tr_logcount = trans->t_log_count;
 	*tpp = xfs_trans_dup(trans);
 
 	/*
@@ -128,8 +128,8 @@ libxfs_trans_roll(
 	 * across this call, or that anything that is locked be logged in
 	 * the prior and the next transactions.
 	 */
-	error = xfs_trans_reserve(trans, 0, logres, 0,
-				  XFS_TRANS_PERM_LOG_RES, count);
+	tres.tr_logflags = XFS_TRANS_PERM_LOG_RES;
+	error = xfs_trans_reserve(trans, &tres, 0, 0);
 	/*
 	 *  Ensure that the inode is in the new transaction and locked.
 	 */
@@ -176,12 +176,10 @@ libxfs_trans_dup(
 
 int
 libxfs_trans_reserve(
-	xfs_trans_t	*tp,
-	uint		blocks,
-	uint		logspace,
-	uint		rtextents,
-	uint		flags,
-	uint		logcount)
+	struct xfs_trans	*tp,
+	struct xfs_trans_res	*resp,
+	uint			blocks,
+	uint			rtextents)
 {
 	xfs_sb_t	*mpsb = &tp->t_mountp->m_sb;
 
diff --git a/libxfs/util.c b/libxfs/util.c
index 1d3113a..d7459e0 100644
--- a/libxfs/util.c
+++ b/libxfs/util.c
@@ -473,7 +473,8 @@ libxfs_alloc_file_space(
 
 		tp = xfs_trans_alloc(mp, XFS_TRANS_DIOSTRAT);
 		resblks = (uint)XFS_DIOSTRAT_SPACE_RES(mp, datablocks);
-		error = xfs_trans_reserve(tp, resblks, 0, 0, 0, 0);
+		error = xfs_trans_reserve(tp, &M_RES(mp)->tr_write,
+					  resblks, 0);
 		if (error)
 			break;
 		xfs_trans_ijoin(tp, ip, 0);
@@ -536,7 +537,6 @@ libxfs_inode_alloc(
 	struct fsxattr	*fsx,
 	xfs_inode_t	**ipp)
 {
-	int		i;
 	xfs_buf_t	*ialloc_context;
 	xfs_inode_t	*ip;
 	xfs_trans_t	*ntp;
@@ -555,13 +555,20 @@ libxfs_inode_alloc(
 	}
 
 	if (ialloc_context) {
+		struct xfs_trans_res	tres;
+
 		xfs_trans_bhold(*tp, ialloc_context);
+		tres.tr_logres = (*tp)->t_log_res;
+		tres.tr_logcount = (*tp)->t_log_count;
+
 		ntp = xfs_trans_dup(*tp);
 		xfs_trans_commit(*tp, 0);
 		*tp = ntp;
-		if ((i = xfs_trans_reserve(*tp, 0, 0, 0, 0, 0))) {
+		tres.tr_logflags = XFS_TRANS_PERM_LOG_RES;
+		error = xfs_trans_reserve(*tp, &tres, 0, 0);
+		if (error) {
 			fprintf(stderr, _("%s: cannot reserve space: %s\n"),
-				progname, strerror(i));
+				progname, strerror(error));
 			exit(1);
 		}
 		xfs_trans_bjoin(*tp, ialloc_context);
diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c
index c96083e..17519d3 100644
--- a/libxfs/xfs_attr.c
+++ b/libxfs/xfs_attr.c
@@ -202,13 +202,14 @@ xfs_attr_set_int(
 	int		valuelen,
 	int		flags)
 {
-	xfs_da_args_t	args;
-	xfs_fsblock_t	firstblock;
-	xfs_bmap_free_t flist;
-	int		error, err2, committed;
-	xfs_mount_t	*mp = dp->i_mount;
-	int             rsvd = (flags & ATTR_ROOT) != 0;
-	int		local;
+	xfs_da_args_t		args;
+	xfs_fsblock_t		firstblock;
+	xfs_bmap_free_t		flist;
+	int			error, err2, committed;
+	struct xfs_mount	*mp = dp->i_mount;
+	struct xfs_trans_res	tres;
+	int			rsvd = (flags & ATTR_ROOT) != 0;
+	int			local;
 
 	/*
 	 * Attach the dquots to the inode.
@@ -268,11 +269,11 @@ xfs_attr_set_int(
 	if (rsvd)
 		args.trans->t_flags |= XFS_TRANS_RESERVE;
 
-	error = xfs_trans_reserve(args.trans, args.total,
-				  XFS_ATTRSETM_LOG_RES(mp) +
-				  XFS_ATTRSETRT_LOG_RES(mp) * args.total,
-				  0, XFS_TRANS_PERM_LOG_RES,
-				  XFS_ATTRSET_LOG_COUNT);
+	tres.tr_logres = M_RES(mp)->tr_attrsetm.tr_logres +
+			 M_RES(mp)->tr_attrsetrt.tr_logres * args.total;
+	tres.tr_logcount = XFS_ATTRSET_LOG_COUNT;
+	tres.tr_logflags = XFS_TRANS_PERM_LOG_RES;
+	error = xfs_trans_reserve(args.trans, &tres, args.total, 0);
 	if (error) {
 		xfs_trans_cancel(args.trans, 0);
 		return(error);
@@ -492,11 +493,9 @@ xfs_attr_remove_int(xfs_inode_t *dp, struct xfs_name *name, int flags)
 	if (flags & ATTR_ROOT)
 		args.trans->t_flags |= XFS_TRANS_RESERVE;
 
-	if ((error = xfs_trans_reserve(args.trans,
-				      XFS_ATTRRM_SPACE_RES(mp),
-				      XFS_ATTRRM_LOG_RES(mp),
-				      0, XFS_TRANS_PERM_LOG_RES,
-				      XFS_ATTRRM_LOG_COUNT))) {
+	error = xfs_trans_reserve(args.trans, &M_RES(mp)->tr_attrrm,
+				  XFS_ATTRRM_SPACE_RES(mp), 0);
+	if (error) {
 		xfs_trans_cancel(args.trans, 0);
 		return(error);
 	}
diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c
index eeaea94..2d480cc 100644
--- a/libxfs/xfs_bmap.c
+++ b/libxfs/xfs_bmap.c
@@ -1113,8 +1113,8 @@ xfs_bmap_add_attrfork(
 	blks = XFS_ADDAFORK_SPACE_RES(mp);
 	if (rsvd)
 		tp->t_flags |= XFS_TRANS_RESERVE;
-	if ((error = xfs_trans_reserve(tp, blks, XFS_ADDAFORK_LOG_RES(mp), 0,
-			XFS_TRANS_PERM_LOG_RES, XFS_ADDAFORK_LOG_COUNT)))
+	error = xfs_trans_reserve(tp, &M_RES(mp)->tr_addafork, blks, 0);
+	if (error)
 		goto error0;
 	xfs_ilock(ip, XFS_ILOCK_EXCL);
 	error = xfs_trans_reserve_quota_nblks(tp, ip, blks, 0, rsvd ?
diff --git a/libxfs/xfs_trans_resv.c b/libxfs/xfs_trans_resv.c
index 36aeafe..d134136 100644
--- a/libxfs/xfs_trans_resv.c
+++ b/libxfs/xfs_trans_resv.c
@@ -522,7 +522,8 @@ xfs_calc_attrsetm_reservation(
  * Since the runtime attribute transaction space is dependent on the total
  * blocks needed for the 1st bmap, here we calculate out the space unit for
  * one block so that the caller could figure out the total space according
- * to the attibute extent length in blocks by: ext * XFS_ATTRSETRT_LOG_RES(mp).
+ * to the attibute extent length in blocks by:
+ *	ext * M_RES(mp)->tr_attrsetrt.tr_logres
  */
 STATIC uint
 xfs_calc_attrsetrt_reservation(
@@ -594,14 +595,14 @@ xfs_calc_qm_setqlim_reservation(
 
 /*
  * Allocating quota on disk if needed.
- *	the write transaction log space: XFS_WRITE_LOG_RES(mp)
+ *	the write transaction log space: M_RES(mp)->tr_write.tr_logres
  *	the unit of quota allocation: one system block size
  */
 STATIC uint
 xfs_calc_qm_dqalloc_reservation(
 	struct xfs_mount	*mp)
 {
-	return XFS_WRITE_LOG_RES(mp) +
+	return M_RES(mp)->tr_write.tr_logres +
 		xfs_calc_buf_res(1,
 			XFS_FSB_TO_B(mp, XFS_DQUOT_CLUSTER_SIZE_FSB) - 1);
 }
diff --git a/mkfs/proto.c b/mkfs/proto.c
index c156ddb..0cdef41 100644
--- a/mkfs/proto.c
+++ b/mkfs/proto.c
@@ -119,7 +119,9 @@ getres(
 
 	mp = tp->t_mountp;
 	for (i = 0, r = MKFS_BLOCKRES(blocks); r >= blocks; r--) {
-		i = libxfs_trans_reserve(tp, r, 0, 0, 0, 0);
+		struct xfs_trans_res    tres = {0};
+
+		i = libxfs_trans_reserve(tp, &tres, r, 0);
 		if (i == 0)
 			return;
 	}
@@ -617,13 +619,16 @@ rtinit(
 	xfs_trans_t	*tp;
 	struct cred	creds;
 	struct fsxattr	fsxattrs;
+	struct xfs_trans_res tres = {0};
 
 	/*
 	 * First, allocate the inodes.
 	 */
 	tp = libxfs_trans_alloc(mp, 0);
-	if ((i = libxfs_trans_reserve(tp, MKFS_BLOCKRES_INODE, 0, 0, 0, 0)))
+	i = libxfs_trans_reserve(tp, &tres, MKFS_BLOCKRES_INODE, 0);
+	if (i)
 		res_failed(i);
+
 	memset(&creds, 0, sizeof(creds));
 	memset(&fsxattrs, 0, sizeof(fsxattrs));
 	error = libxfs_inode_alloc(&tp, NULL, S_IFREG, 1, 0,
@@ -660,9 +665,11 @@ rtinit(
 	 * Next, give the bitmap file some zero-filled blocks.
 	 */
 	tp = libxfs_trans_alloc(mp, 0);
-	if ((i = libxfs_trans_reserve(tp, mp->m_sb.sb_rbmblocks +
-			(XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1), 0, 0, 0, 0)))
+	i = libxfs_trans_reserve(tp, &tres, mp->m_sb.sb_rbmblocks +
+				 (XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1), 0);
+	if (i)
 		res_failed(i);
+
 	libxfs_trans_ijoin(tp, rbmip, 0);
 	libxfs_trans_ihold(tp, rbmip);
 	bno = 0;
@@ -696,9 +703,9 @@ rtinit(
 	 */
 	tp = libxfs_trans_alloc(mp, 0);
 	nsumblocks = mp->m_rsumsize >> mp->m_sb.sb_blocklog;
-	if ((i = libxfs_trans_reserve(tp,
-			nsumblocks + (XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1),
-			0, 0, 0, 0)))
+	i = libxfs_trans_reserve(tp, &tres, nsumblocks +
+				 (XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1), 0);
+	if (i)
 		res_failed(i);
 	libxfs_trans_ijoin(tp, rsumip, 0);
 	libxfs_trans_ihold(tp, rsumip);
@@ -733,7 +740,8 @@ rtinit(
 	 */
 	for (bno = 0; bno < mp->m_sb.sb_rextents; bno = ebno) {
 		tp = libxfs_trans_alloc(mp, 0);
-		if ((i = libxfs_trans_reserve(tp, 0, 0, 0, 0, 0)))
+		i = libxfs_trans_reserve(tp, &tres, 0, 0);
+		if (i)
 			res_failed(i);
 		libxfs_trans_ijoin(tp, rbmip, 0);
 		libxfs_trans_ihold(tp, rbmip);
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 4bdacee..6e243ab 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -2821,6 +2821,7 @@ an AG size that is one stripe unit smaller, for example %llu.\n"),
 	for (agno = 0; agno < agcount; agno++) {
 		xfs_alloc_arg_t	args;
 		xfs_trans_t	*tp;
+		struct xfs_trans_res tres = {0};
 
 		memset(&args, 0, sizeof(args));
 		args.tp = tp = libxfs_trans_alloc(mp, 0);
@@ -2828,8 +2829,10 @@ an AG size that is one stripe unit smaller, for example %llu.\n"),
 		args.agno = agno;
 		args.alignment = 1;
 		args.pag = xfs_perag_get(mp,agno);
-		if ((c = libxfs_trans_reserve(tp, worst_freelist, 0, 0, 0, 0)))
+		c = libxfs_trans_reserve(tp, &tres, worst_freelist, 0);
+		if (c)
 			res_failed(c);
+
 		libxfs_alloc_fix_freelist(&args, 0);
 		xfs_perag_put(args.pag);
 		libxfs_trans_commit(tp, 0);
diff --git a/repair/phase5.c b/repair/phase5.c
index d61e19f..77eb125 100644
--- a/repair/phase5.c
+++ b/repair/phase5.c
@@ -1405,6 +1405,7 @@ build_agf_agfl(xfs_mount_t	*mp,
 	{
 		xfs_alloc_arg_t	args;
 		xfs_trans_t	*tp;
+		struct xfs_trans_res tres = {0};
 
 		memset(&args, 0, sizeof(args));
 		args.tp = tp = libxfs_trans_alloc(mp, 0);
@@ -1412,7 +1413,7 @@ build_agf_agfl(xfs_mount_t	*mp,
 		args.agno = agno;
 		args.alignment = 1;
 		args.pag = xfs_perag_get(mp,agno);
-		libxfs_trans_reserve(tp, XFS_MIN_FREELIST(agf, mp), 0, 0, 0, 0);
+		libxfs_trans_reserve(tp, &tres, XFS_MIN_FREELIST(agf, mp), 0);
 		libxfs_alloc_fix_freelist(&args, 0);
 		xfs_perag_put(args.pag);
 		libxfs_trans_commit(tp, 0);
diff --git a/repair/phase6.c b/repair/phase6.c
index 65e6301..3dec573 100644
--- a/repair/phase6.c
+++ b/repair/phase6.c
@@ -429,13 +429,15 @@ mk_rbmino(xfs_mount_t *mp)
 	xfs_bmbt_irec_t	map[XFS_BMAP_MAX_NMAP];
 	int		vers;
 	int		times;
+	struct xfs_trans_res tres = {0};
 
 	/*
 	 * first set up inode
 	 */
 	tp = libxfs_trans_alloc(mp, 0);
 
-	if ((i = libxfs_trans_reserve(tp, 10, 0, 0, 0, 0)))
+	i = libxfs_trans_reserve(tp, &tres, 10, 0);
+	if (i)
 		res_failed(i);
 
 	error = libxfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0, 0, &ip);
@@ -490,8 +492,9 @@ mk_rbmino(xfs_mount_t *mp)
 	 * from mkfs)
 	 */
 	tp = libxfs_trans_alloc(mp, 0);
-	if ((error = libxfs_trans_reserve(tp, mp->m_sb.sb_rbmblocks +
-			(XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1), 0, 0, 0, 0)))
+	error = libxfs_trans_reserve(tp, &tres, mp->m_sb.sb_rbmblocks +
+				(XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1), 0);
+	if (error)
 		res_failed(error);
 
 	libxfs_trans_ijoin(tp, ip, 0);
@@ -536,13 +539,15 @@ fill_rbmino(xfs_mount_t *mp)
 	int		error;
 	xfs_dfiloff_t	bno;
 	xfs_bmbt_irec_t	map;
+	struct xfs_trans_res tres = {0};
 
 	bmp = btmcompute;
 	bno = 0;
 
 	tp = libxfs_trans_alloc(mp, 0);
 
-	if ((error = libxfs_trans_reserve(tp, 10, 0, 0, 0, 0)))
+	error = libxfs_trans_reserve(tp, &tres, 10, 0);
+	if (error)
 		res_failed(error);
 
 	error = libxfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0, 0, &ip);
@@ -605,6 +610,7 @@ fill_rsumino(xfs_mount_t *mp)
 	xfs_dfiloff_t	bno;
 	xfs_dfiloff_t	end_bno;
 	xfs_bmbt_irec_t	map;
+	struct xfs_trans_res tres = {0};
 
 	smp = sumcompute;
 	bno = 0;
@@ -612,7 +618,8 @@ fill_rsumino(xfs_mount_t *mp)
 
 	tp = libxfs_trans_alloc(mp, 0);
 
-	if ((error = libxfs_trans_reserve(tp, 10, 0, 0, 0, 0)))
+	error = libxfs_trans_reserve(tp, &tres, 10, 0);
+	if (error)
 		res_failed(error);
 
 	error = libxfs_trans_iget(mp, tp, mp->m_sb.sb_rsumino, 0, 0, &ip);
@@ -679,14 +686,15 @@ mk_rsumino(xfs_mount_t *mp)
 	xfs_bmbt_irec_t	map[XFS_BMAP_MAX_NMAP];
 	int		vers;
 	int		times;
+	struct xfs_trans_res tres = {0};
 
 	/*
 	 * first set up inode
 	 */
 	tp = libxfs_trans_alloc(mp, 0);
 
-	if ((i = libxfs_trans_reserve(tp, 10, XFS_ICHANGE_LOG_RES(mp), 0,
-				XFS_TRANS_PERM_LOG_RES, XFS_MKDIR_LOG_COUNT)))
+	i = libxfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 10, 0);
+	if (i)
 		res_failed(i);
 
 	error = libxfs_trans_iget(mp, tp, mp->m_sb.sb_rsumino, 0, 0, &ip);
@@ -744,11 +752,12 @@ mk_rsumino(xfs_mount_t *mp)
 	xfs_bmap_init(&flist, &first);
 
 	nsumblocks = mp->m_rsumsize >> mp->m_sb.sb_blocklog;
-	if ((error = libxfs_trans_reserve(tp,
-				  mp->m_sb.sb_rbmblocks +
-				      (XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1),
-				  BBTOB(128), 0, XFS_TRANS_PERM_LOG_RES,
-				  XFS_DEFAULT_PERM_LOG_COUNT)))
+	tres.tr_logres = BBTOB(128);
+	tres.tr_logcount = XFS_DEFAULT_PERM_LOG_COUNT;
+	tres.tr_logflags = XFS_TRANS_PERM_LOG_RES;
+	error = libxfs_trans_reserve(tp, &tres, mp->m_sb.sb_rbmblocks +
+			      (XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1), 0);
+	if (error)
 		res_failed(error);
 
 	libxfs_trans_ijoin(tp, ip, 0);
@@ -800,8 +809,8 @@ mk_root_dir(xfs_mount_t *mp)
 	tp = libxfs_trans_alloc(mp, 0);
 	ip = NULL;
 
-	if ((i = libxfs_trans_reserve(tp, 10, XFS_ICHANGE_LOG_RES(mp), 0,
-				XFS_TRANS_PERM_LOG_RES, XFS_MKDIR_LOG_COUNT)))
+	i = libxfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 10, 0);
+	if (i)
 		res_failed(i);
 
 	error = libxfs_trans_iget(mp, tp, mp->m_sb.sb_rootino, 0, 0, &ip);
@@ -906,8 +915,8 @@ mk_orphanage(xfs_mount_t *mp)
 	xfs_bmap_init(&flist, &first);
 
 	nres = XFS_MKDIR_SPACE_RES(mp, xname.len);
-	if ((i = libxfs_trans_reserve(tp, nres, XFS_MKDIR_LOG_RES(mp), 0,
-				XFS_TRANS_PERM_LOG_RES, XFS_MKDIR_LOG_COUNT)))
+	i = libxfs_trans_reserve(tp, &M_RES(mp)->tr_mkdir, nres, 0);
+	if (i)
 		res_failed(i);
 
 	/*
@@ -1059,10 +1068,9 @@ mv_orphanage(
 		if (err) {
 			ASSERT(err == ENOENT);
 
-			if ((err = libxfs_trans_reserve(tp, nres,
-					XFS_RENAME_LOG_RES(mp), 0,
-					XFS_TRANS_PERM_LOG_RES,
-					XFS_RENAME_LOG_COUNT)))
+			err = libxfs_trans_reserve(tp, &M_RES(mp)->tr_rename,
+						   nres, 0);
+			if (err)
 				do_error(
 	_("space reservation failed (%d), filesystem may be out of space\n"),
 					err);
@@ -1103,10 +1111,9 @@ mv_orphanage(
 			libxfs_trans_commit(tp,
 				XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_SYNC);
 		} else  {
-			if ((err = libxfs_trans_reserve(tp, nres,
-					XFS_RENAME_LOG_RES(mp), 0,
-					XFS_TRANS_PERM_LOG_RES,
-					XFS_RENAME_LOG_COUNT)))
+			err = libxfs_trans_reserve(tp, &M_RES(mp)->tr_rename,
+						   nres, 0);
+			if (err)
 				do_error(
 	_("space reservation failed (%d), filesystem may be out of space\n"),
 					err);
@@ -1161,8 +1168,8 @@ mv_orphanage(
 		 * also accounted for in the create
 		 */
 		nres = XFS_DIRENTER_SPACE_RES(mp, xname.len);
-		err = libxfs_trans_reserve(tp, nres, XFS_REMOVE_LOG_RES(mp), 0,
-				XFS_TRANS_PERM_LOG_RES, XFS_REMOVE_LOG_COUNT);
+		err = libxfs_trans_reserve(tp, &M_RES(mp)->tr_remove,
+					   nres, 0);
 		if (err)
 			do_error(
 	_("space reservation failed (%d), filesystem may be out of space\n"),
@@ -1257,8 +1264,7 @@ longform_dir2_rebuild(
 
 	tp = libxfs_trans_alloc(mp, 0);
 	nres = XFS_REMOVE_SPACE_RES(mp);
-	error = libxfs_trans_reserve(tp, nres, XFS_REMOVE_LOG_RES(mp), 0,
-			XFS_TRANS_PERM_LOG_RES, XFS_REMOVE_LOG_COUNT);
+	error = libxfs_trans_reserve(tp, &M_RES(mp)->tr_remove, nres, 0);
 	if (error)
 		res_failed(error);
 	libxfs_trans_ijoin(tp, ip, 0);
@@ -1298,8 +1304,8 @@ longform_dir2_rebuild(
 
 		tp = libxfs_trans_alloc(mp, 0);
 		nres = XFS_CREATE_SPACE_RES(mp, p->name.len);
-		error = libxfs_trans_reserve(tp, nres, XFS_CREATE_LOG_RES(mp),
-				0, XFS_TRANS_PERM_LOG_RES, XFS_CREATE_LOG_COUNT);
+		error = libxfs_trans_reserve(tp, &M_RES(mp)->tr_create,
+					     nres, 0);
 		if (error) {
 			do_warn(
 	_("space reservation failed (%d), filesystem may be out of space\n"),
@@ -1360,8 +1366,7 @@ dir2_kill_block(
 
 	tp = libxfs_trans_alloc(mp, 0);
 	nres = XFS_REMOVE_SPACE_RES(mp);
-	error = libxfs_trans_reserve(tp, nres, XFS_REMOVE_LOG_RES(mp), 0,
-			XFS_TRANS_PERM_LOG_RES, XFS_REMOVE_LOG_COUNT);
+	error = libxfs_trans_reserve(tp, &M_RES(mp)->tr_remove, nres, 0);
 	if (error)
 		res_failed(error);
 	libxfs_trans_ijoin(tp, ip, 0);
@@ -1549,8 +1554,7 @@ longform_dir2_entry_check_data(
 		freetab->nents = db + 1;
 
 	tp = libxfs_trans_alloc(mp, 0);
-	error = libxfs_trans_reserve(tp, 0, XFS_REMOVE_LOG_RES(mp), 0,
-		XFS_TRANS_PERM_LOG_RES, XFS_REMOVE_LOG_COUNT);
+	error = libxfs_trans_reserve(tp, &M_RES(mp)->tr_remove, 0, 0);
 	if (error)
 		res_failed(error);
 	libxfs_trans_ijoin(tp, ip, 0);
@@ -2607,10 +2611,8 @@ process_dir_inode(
 			 * new define in ourselves.
 			 */
 			nres = no_modify ? 0 : XFS_REMOVE_SPACE_RES(mp);
-			error = libxfs_trans_reserve(tp, nres,
-					XFS_REMOVE_LOG_RES(mp), 0,
-					XFS_TRANS_PERM_LOG_RES,
-					XFS_REMOVE_LOG_COUNT);
+			error = libxfs_trans_reserve(tp, &M_RES(mp)->tr_remove,
+						     nres, 0);
 			if (error)
 				res_failed(error);
 
@@ -2658,8 +2660,7 @@ process_dir_inode(
 		ASSERT(tp != NULL);
 
 		nres = XFS_MKDIR_SPACE_RES(mp, 2);
-		error = libxfs_trans_reserve(tp, nres, XFS_MKDIR_LOG_RES(mp),
-				0, XFS_TRANS_PERM_LOG_RES, XFS_MKDIR_LOG_COUNT);
+		error = libxfs_trans_reserve(tp, &M_RES(mp)->tr_mkdir, nres, 0);
 		if (error)
 			res_failed(error);
 
@@ -2720,12 +2721,8 @@ process_dir_inode(
 			ASSERT(tp != NULL);
 
 			nres = XFS_MKDIR_SPACE_RES(mp, 1);
-			error = libxfs_trans_reserve(tp, nres,
-					XFS_MKDIR_LOG_RES(mp),
-					0,
-					XFS_TRANS_PERM_LOG_RES,
-					XFS_MKDIR_LOG_COUNT);
-
+			error = libxfs_trans_reserve(tp, &M_RES(mp)->tr_mkdir,
+						     nres, 0);
 			if (error)
 				res_failed(error);
 
diff --git a/repair/phase7.c b/repair/phase7.c
index bd1668e..18f2d88 100644
--- a/repair/phase7.c
+++ b/repair/phase7.c
@@ -68,13 +68,12 @@ update_inode_nlinks(
 	xfs_inode_t		*ip;
 	int			error;
 	int			dirty;
+	int			nres;
 
 	tp = libxfs_trans_alloc(mp, XFS_TRANS_REMOVE);
 
-	error = libxfs_trans_reserve(tp, (no_modify ? 0 : 10),
-			XFS_REMOVE_LOG_RES(mp), 0, XFS_TRANS_PERM_LOG_RES,
-			XFS_REMOVE_LOG_COUNT);
-
+	nres = no_modify ? 0 : 10;
+	error = libxfs_trans_reserve(tp, &M_RES(mp)->tr_remove, nres, 0);
 	ASSERT(error == 0);
 
 	error = libxfs_trans_iget(mp, tp, ino, 0, 0, &ip);
-- 
1.8.3.2

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  parent reply	other threads:[~2013-09-04 22:21 UTC|newest]

Thread overview: 136+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-04 22:05 [PATCH 00/55] xfsprogs: bring code up to date with kernel Dave Chinner
2013-09-04 22:05 ` [PATCH 01/55] xfsprogs: introduce xfs_icreate.h Dave Chinner
2013-09-05 14:35   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 02/55] xfsprogs: port inode create transaction changes Dave Chinner
2013-09-05 15:25   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 03/55] xfsprogs: teach logprint about icreate transaction Dave Chinner
2013-09-05 15:29   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 04/55] libxfs: fix directory/attribute format issues Dave Chinner
2013-09-05 15:36   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 05/55] libxfs: ensure btree root split sets blkno correctly Dave Chinner
2013-09-05 15:37   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 06/55] libxfs: fix byte swapping on constants Dave Chinner
2013-09-05 15:41   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 07/55] libxfs: sync xfs_da_btree.c Dave Chinner
2013-09-05 15:46   ` Mark Tinguely
2013-09-05 15:52   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 08/55] libxfs: update xfs_alloc to current kernel version Dave Chinner
2013-09-05 15:53   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 09/55] libxfs: sync attr code with kernel Dave Chinner
2013-09-05 15:59   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 10/55] libxfs: sync dir2 kernel differences Dave Chinner
2013-09-05 16:32   ` Mark Tinguely
2013-09-17 15:14   ` Eric Sandeen
2013-09-18  3:36     ` Dave Chinner
2013-09-18  5:03       ` Dave Chinner
2013-09-04 22:05 ` [PATCH 11/55] libxfs: sync xfs_ialloc.c to the kernel code Dave Chinner
2013-09-05 18:46   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 12/55] xfsprogs: define min/max once and use them everywhere Dave Chinner
2013-09-05 18:47   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 13/55] libxfs: fix compile warnings Dave Chinner
2013-09-05 18:50   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 14/55] xfs: remove local fork format handling from xfs_bmapi_write() Dave Chinner
2013-09-05 18:55   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 15/55] libxfs: local to remote format support of remote symlinks Dave Chinner
2013-09-05 18:56   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 16/55] xfs: separate out log format definitions Dave Chinner
2013-09-05 19:01   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 17/55] xfs: split out inode log item format definition Dave Chinner
2013-09-05 19:14   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 18/55] xfs: split out buf log item format definitions Dave Chinner
2013-09-05 19:18   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 19/55] xfs: split out inode log item format definition Dave Chinner
2013-09-05 19:20   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 20/55] xfs: separate dquot on disk format definitions out of xfs_quota.h Dave Chinner
2013-09-05 19:33   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 21/55] xfs: separate icreate log format definitions from xfs_icreate_item.h Dave Chinner
2013-09-05 21:12   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 22/55] xfs: split out on-disk transaction definitions Dave Chinner
2013-09-05 21:21   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 23/55] xfs: introduce xfs_rtalloc_defs.h Dave Chinner
2013-09-05 21:26   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 24/55] xfs: introduce xfs_quota_defs.h Dave Chinner
2013-09-05 21:29   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 25/55] libxfs: introduce xfs_trans_resv.c Dave Chinner
2013-09-05 21:45   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 26/55] libxfs: move transaction code to trans.c Dave Chinner
2013-09-05 21:51   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 27/55] xfs: move inode fork definitions to a new header file Dave Chinner
2013-09-05 21:55   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 28/55] xfs: move unrealted definitions out of xfs_inode.h Dave Chinner
2013-09-05 22:05   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 29/55] xfs: introduce xfs_inode_buf.c for inode buffer operations Dave Chinner
2013-09-05 22:27   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 30/55] xfs: split out the remote symlink handling Dave Chinner
2013-09-06 15:13   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 31/55] libxfs: switch over to xfs_sb.c and remove xfs_mount.c Dave Chinner
2013-09-06 18:15   ` Mark Tinguely
2013-09-06 21:40     ` Dave Chinner
2013-09-06 21:43       ` Mark Tinguely
2013-09-10  1:02         ` [PATCH 31/55 V2] " Dave Chinner
2013-09-10 14:11           ` Mark Tinguely
2013-09-10 21:32             ` [PATCH 31/55 V3] " Dave Chinner
2013-09-11 13:25               ` Mark Tinguely
2013-09-11 14:24                 ` Mark Tinguely
2013-09-13 14:17                   ` Mark Tinguely
2013-09-15  3:27                   ` Dave Chinner
2013-09-11 15:11                 ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 32/55] xfs: create xfs_bmap_util.[ch] Dave Chinner
2013-09-06 15:30   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 33/55] xfsprogs: sync minor kernel header differences Dave Chinner
2013-09-06 15:44   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 34/55] xfs: don't special case shared superblock mounts Dave Chinner
2013-09-06 15:48   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 35/55] xfs: move swap extent code to xfs_extent_ops Dave Chinner
2013-09-06 17:13   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 36/55] xfs: kill __KERNEL__ check for debug code in allocation code Dave Chinner
2013-09-06 17:20   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 37/55] xfs: remove __KERNEL__ from debug code Dave Chinner
2013-09-06 17:28   ` Mark Tinguely
2013-09-06 21:41     ` Dave Chinner
2013-09-06 21:42       ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 38/55] xfs: remove __KERNEL__ check from xfs_dir2_leaf.c Dave Chinner
2013-09-06 17:29   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 39/55] xfs: move kernel specific type definitions to xfs.h Dave Chinner
2013-09-06 17:31   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 40/55] xfs: make struct xfs_perag kernel only Dave Chinner
2013-09-06 18:06   ` Mark Tinguely
2013-09-06 21:50     ` Dave Chinner
2013-09-04 22:05 ` [PATCH 41/55] xfs: Introduce a new structure to hold transaction reservation items Dave Chinner
2013-09-06 18:20   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 42/55] xfs: Introduce tr_fsyncts to m_reservation Dave Chinner
2013-09-06 18:20   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 43/55] xfs: Make writeid transaction use tr_writeid Dave Chinner
2013-09-06 18:21   ` Mark Tinguely
2013-09-04 22:05 ` Dave Chinner [this message]
2013-09-06 18:21   ` [PATCH 44/55] xfs: refactor xfs_trans_reserve() interface Mark Tinguely
2013-09-04 22:05 ` [PATCH 45/55] xfs: Get rid of all XFS_XXX_LOG_RES() macro Dave Chinner
2013-09-06 18:22   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 46/55] xfs: Add xfs_log_rlimit.c Dave Chinner
2013-09-06 18:22   ` Mark Tinguely
2013-10-06 17:56   ` Eric Sandeen
2013-10-07  1:46     ` Eric Sandeen
2013-10-07 13:48       ` Mark Tinguely
2014-02-21 19:47         ` Eric Sandeen
2014-02-21 20:40           ` Mark Tinguely
2014-02-21 20:56             ` Eric Sandeen
2014-02-21 21:46               ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 47/55] xfs: Add read-only support for dirent filetype field Dave Chinner
2013-09-06 18:23   ` Mark Tinguely
2013-09-10 21:34   ` [PATCH 47/55 V2] " Dave Chinner
2013-09-04 22:05 ` [PATCH 48/55] xfs: Add write " Dave Chinner
2013-09-06 18:24   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 49/55] xfsprogs: add dtype support to mkfs and db Dave Chinner
2013-09-06 18:25   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 50/55] xfs: di_flushiter considered harmful Dave Chinner
2013-09-06 18:43   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 51/55] xfs: fix calculation of the number of node entries in a dir3 node Dave Chinner
2013-09-06 18:53   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 52/55] xfs: btree block LSN escaping to disk uninitialised Dave Chinner
2013-09-06 18:54   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 53/55] xfs: inode log reservations are too small Dave Chinner
2013-09-06 18:58   ` Mark Tinguely
2013-09-04 22:05 ` [PATCH 54/55] repair: fix segv on directory block read failure Dave Chinner
2013-09-04 23:33   ` Eric Sandeen
2013-09-04 22:05 ` [PATCH 55/55] xfsprogs: cleanup miscellaneous merge faults Dave Chinner
2013-09-06 19:03   ` Mark Tinguely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1378332359-14737-45-git-send-email-david@fromorbit.com \
    --to=david@fromorbit.com \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox