All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: sandeen@redhat.com
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 9/7] xfs_db: btdump should avoid eval for push and pop of cursor
Date: Thu, 3 Aug 2017 10:04:04 -0700	[thread overview]
Message-ID: <20170803170404.GU4477@magnolia> (raw)
In-Reply-To: <150153520589.26081.8786864874176090813.stgit@magnolia>

We can call the cursor push and pop functions directly from btdump,
so skip all the eval overhead.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 db/btdump.c |   50 +++++++++++++++-----------------------------------
 db/io.c     |   22 ++++++++++++++--------
 db/io.h     |    1 +
 3 files changed, 30 insertions(+), 43 deletions(-)

diff --git a/db/btdump.c b/db/btdump.c
index f525a4a..59c5712 100644
--- a/db/btdump.c
+++ b/db/btdump.c
@@ -82,11 +82,9 @@ dump_btlevel(
 	xfs_daddr_t		orig_daddr = iocur_top->bb;
 	xfs_daddr_t		last_daddr;
 	unsigned int		nr;
-	int			ret;
+	int			ret = 0;
 
-	ret = eval("push");
-	if (ret)
-		return ret;
+	push_cur_and_set_type();
 
 	nr = 1;
 	do {
@@ -111,10 +109,8 @@ dump_btlevel(
 		nr++;
 	} while (iocur_top->bb != orig_daddr && iocur_top->bb != last_daddr);
 
-	ret = eval("pop");
-	return ret;
 err:
-	eval("pop");
+	pop_cur();
 	return ret;
 }
 
@@ -126,11 +122,9 @@ dump_btree(
 	xfs_daddr_t	orig_daddr = iocur_top->bb;
 	xfs_daddr_t	last_daddr;
 	int		level;
-	int		ret;
+	int		ret = 0;
 
-	ret = eval("push");
-	if (ret)
-		return ret;
+	push_cur_and_set_type();
 
 	cur_agno = XFS_FSB_TO_AGNO(mp, XFS_DADDR_TO_FSB(mp, iocur_top->bb));
 	level = xfs_btree_get_level(iocur_top->data);
@@ -153,10 +147,8 @@ dump_btree(
 		 iocur_top->bb != orig_daddr &&
 		 iocur_top->bb != last_daddr);
 
-	ret = eval("pop");
-	return ret;
 err:
-	eval("pop");
+	pop_cur();
 	return ret;
 }
 
@@ -177,7 +169,7 @@ dump_inode(
 {
 	char			*prefix;
 	struct xfs_dinode	*dip;
-	int			ret;
+	int			ret = 0;
 
 	if (attrfork)
 		prefix = "a.bmbt";
@@ -201,9 +193,7 @@ dump_inode(
 		}
 	}
 
-	ret = eval("push");
-	if (ret)
-		return ret;
+	push_cur_and_set_type();
 
 	if (dump_node_blocks) {
 		ret = eval("print %s.keys", prefix);
@@ -222,10 +212,8 @@ dump_inode(
 	if (ret)
 		goto err;
 
-	ret = eval("pop");
-	return ret;
 err:
-	eval("pop");
+	pop_cur();
 	return ret;
 }
 
@@ -397,11 +385,9 @@ dump_dablevel(
 	xfs_daddr_t		orig_daddr = iocur_top->bb;
 	xfs_daddr_t		last_daddr;
 	unsigned int		nr;
-	int			ret;
+	int			ret = 0;
 
-	ret = eval("push");
-	if (ret)
-		return ret;
+	push_cur_and_set_type();
 
 	nr = 1;
 	do {
@@ -421,10 +407,8 @@ dump_dablevel(
 		nr++;
 	} while (iocur_top->bb != orig_daddr && iocur_top->bb != last_daddr);
 
-	ret = eval("pop");
-	return ret;
 err:
-	eval("pop");
+	pop_cur();
 	return ret;
 }
 
@@ -436,11 +420,9 @@ dump_dabtree(
 	xfs_daddr_t			orig_daddr = iocur_top->bb;
 	xfs_daddr_t			last_daddr;
 	int				level;
-	int				ret;
+	int				ret = 0;
 
-	ret = eval("push");
-	if (ret)
-		return ret;
+	push_cur_and_set_type();
 
 	cur_agno = XFS_FSB_TO_AGNO(mp, XFS_DADDR_TO_FSB(mp, iocur_top->bb));
 	level = dbp->level(iocur_top->data);
@@ -468,10 +450,8 @@ dump_dabtree(
 		 iocur_top->bb != orig_daddr &&
 		 iocur_top->bb != last_daddr);
 
-	ret = eval("pop");
-	return ret;
 err:
-	eval("pop");
+	pop_cur();
 	return ret;
 }
 
diff --git a/db/io.c b/db/io.c
index fd9b9f4..0974fee 100644
--- a/db/io.c
+++ b/db/io.c
@@ -220,6 +220,19 @@ push_cur(void)
 	cur_typ = NULL;
 }
 
+void
+push_cur_and_set_type(void)
+{
+	/* save current state */
+	push_cur();
+	if (iocur_top[-1].typ && iocur_top[-1].typ->typnm == TYP_INODE)
+		set_cur_inode(iocur_top[-1].ino);
+	else
+		set_cur(iocur_top[-1].typ, iocur_top[-1].bb,
+			iocur_top[-1].blen, DB_RING_IGN,
+			iocur_top[-1].bbmap);
+}
+
 static int
 push_f(
 	int		argc,
@@ -240,14 +253,7 @@ push_f(
 		}
 	}
 
-	/* save current state */
-	push_cur();
-	if (iocur_top[-1].typ && iocur_top[-1].typ->typnm == TYP_INODE)
-		set_cur_inode(iocur_top[-1].ino);
-	else
-		set_cur(iocur_top[-1].typ, iocur_top[-1].bb,
-			iocur_top[-1].blen, DB_RING_IGN,
-			iocur_top[-1].bbmap);
+	push_cur_and_set_type();
 
 	/* run requested command */
 	if (argc>1)
diff --git a/db/io.h b/db/io.h
index df0fdd7..d238685 100644
--- a/db/io.h
+++ b/db/io.h
@@ -57,6 +57,7 @@ extern void	off_cur(int off, int len);
 extern void	pop_cur(void);
 extern void	print_iocur(char *tag, iocur_t *ioc);
 extern void	push_cur(void);
+extern void	push_cur_and_set_type(void);
 extern int	read_buf(int64_t daddr, int count, void *bufp);
 extern void     write_cur(void);
 extern void	set_cur(const struct typ *type, xfs_daddr_t blknum,

  parent reply	other threads:[~2017-08-03 17:04 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-31 21:06 [PATCH 0/7] xfsprogs: 4.13 rollup Darrick J. Wong
2017-07-31 21:06 ` [PATCH 1/7] xfs: remove double-underscore integer types Darrick J. Wong
2017-07-31 21:23   ` Eric Sandeen
2017-07-31 21:25     ` Darrick J. Wong
2017-08-02  9:13   ` Carlos Maiolino
2017-08-02 16:01     ` Darrick J. Wong
2017-07-31 21:07 ` [PATCH 2/7] xfs_repair: fix symlink target length checks by changing MAXPATHLEN to XFS_SYMLINK_MAXLEN Darrick J. Wong
2017-07-31 21:42   ` Eric Sandeen
2017-08-02  9:14   ` Carlos Maiolino
2017-07-31 21:07 ` [PATCH 3/7] xfs_db: fix metadump redirection (again) Darrick J. Wong
2017-07-31 21:57   ` Eric Sandeen
2017-08-01 16:23   ` [PATCH v2 " Darrick J. Wong
2017-08-02  9:17     ` Carlos Maiolino
2017-07-31 21:07 ` [PATCH 4/7] xfs_db: dump dir/attr btrees Darrick J. Wong
2017-07-31 22:05   ` Eric Sandeen
2017-08-01 14:59     ` Darrick J. Wong
2017-08-01 15:40   ` [PATCH v2 " Darrick J. Wong
2017-08-01 16:21     ` Eric Sandeen
2017-08-02  9:22     ` Carlos Maiolino
2017-08-02  9:24     ` Carlos Maiolino
2017-08-02 16:03       ` Darrick J. Wong
2017-07-31 21:07 ` [PATCH 5/7] xfs_db: print attribute remote value blocks Darrick J. Wong
2017-08-01 17:15   ` Eric Sandeen
2017-08-01 20:29     ` Darrick J. Wong
2017-08-01 21:04   ` [PATCH v2 " Darrick J. Wong
2017-08-02  9:36     ` Carlos Maiolino
2017-07-31 21:07 ` [PATCH 6/7] xfs_db: write values into dir/attr blocks and recalculate CRCs Darrick J. Wong
2017-08-02  9:40   ` Carlos Maiolino
2017-08-03 16:02   ` Eric Sandeen
2017-08-03 16:40     ` Darrick J. Wong
2017-07-31 21:07 ` [PATCH 7/7] xfs_db: introduce fuzz command Darrick J. Wong
2017-08-02 11:06   ` Carlos Maiolino
2017-08-03 16:47   ` [PATCH 8/7] xfs_db: use TYP_F_CRC_FUNC for inodes & dquots Eric Sandeen
2017-08-03 16:58     ` Darrick J. Wong
2017-08-03 17:15     ` [PATCH 8/7 V2] " Eric Sandeen
2017-08-03 18:05       ` Darrick J. Wong
2017-08-03 17:04 ` Darrick J. Wong [this message]
2017-08-03 17:18   ` [PATCH 9/7] xfs_db: btdump should avoid eval for push and pop of cursor Eric Sandeen

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=20170803170404.GU4477@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@redhat.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 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.