All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: guaneryu@gmail.com, darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org
Subject: [PATCH 06/12] fsx: add five-argument logging function
Date: Thu, 22 Nov 2018 09:59:06 -0800	[thread overview]
Message-ID: <154290954603.1218.7246941650070239499.stgit@magnolia> (raw)
In-Reply-To: <154290950237.1218.9937108728673485814.stgit@magnolia>

From: Darrick J. Wong <darrick.wong@oracle.com>

Add a five-argument logging function to support new operations.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 ltp/fsx.c |   45 ++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 40 insertions(+), 5 deletions(-)


diff --git a/ltp/fsx.c b/ltp/fsx.c
index dabad302..c525ba13 100644
--- a/ltp/fsx.c
+++ b/ltp/fsx.c
@@ -51,7 +51,8 @@ enum opflags { FL_NONE = 0, FL_SKIPPED = 1, FL_CLOSE_OPEN = 2, FL_KEEP_SIZE = 4
 
 struct log_entry {
 	int	operation;
-	int	args[3];
+	int	nr_args;
+	int	args[4];
 	enum opflags flags;
 };
 
@@ -278,6 +279,27 @@ static int op_code(const char *name)
 	return -1;
 }
 
+void
+log5(int operation, int arg0, int arg1, int arg2, enum opflags flags)
+{
+	struct log_entry *le;
+
+	le = &oplog[logptr];
+	le->operation = operation;
+	if (closeopen)
+		flags |= FL_CLOSE_OPEN;
+	le->args[0] = arg0;
+	le->args[1] = arg1;
+	le->args[2] = arg2;
+	le->args[3] = file_size;
+	le->nr_args = 4;
+	le->flags = flags;
+	logptr++;
+	logcount++;
+	if (logptr >= LOGSIZE)
+		logptr = 0;
+}
+
 void
 log4(int operation, int arg0, int arg1, enum opflags flags)
 {
@@ -290,6 +312,7 @@ log4(int operation, int arg0, int arg1, enum opflags flags)
 	le->args[0] = arg0;
 	le->args[1] = arg1;
 	le->args[2] = file_size;
+	le->nr_args = 3;
 	le->flags = flags;
 	logptr++;
 	logcount++;
@@ -439,11 +462,13 @@ logdump(void)
 			i = 0;
 
 		if (logopsf) {
+			int j;
+
 			if (lp->flags & FL_SKIPPED)
 				fprintf(logopsf, "skip ");
-			fprintf(logopsf, "%s 0x%x 0x%x 0x%x",
-				op_name(lp->operation),
-				lp->args[0], lp->args[1], lp->args[2]);
+			fprintf(logopsf, "%s", op_name(lp->operation));
+			for (j = 0; j < lp->nr_args; j++)
+				fprintf(logopsf, " 0x%x", lp->args[j]);
 			if (lp->flags & FL_KEEP_SIZE)
 				fprintf(logopsf, " keep_size");
 			if (lp->flags & FL_CLOSE_OPEN)
@@ -1413,6 +1438,15 @@ cleanup(int sig)
 	exit(sig);
 }
 
+static int
+op_args_count(int operation)
+{
+	switch (operation) {
+	default:
+		return 3;
+	}
+}
+
 static int
 read_op(struct log_entry *log_entry)
 {
@@ -1445,7 +1479,8 @@ read_op(struct log_entry *log_entry)
 		log_entry->operation = op_code(str);
 		if (log_entry->operation == -1)
 			goto fail;
-		for (i = 0; i < 3; i++) {
+		log_entry->nr_args = op_args_count(log_entry->operation);
+		for (i = 0; i < log_entry->nr_args; i++) {
 			char *end;
 
 			str = strtok(NULL, " \t\n");

  parent reply	other threads:[~2018-11-23  4:39 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-22 17:58 [PATCH v3 00/12] xfstests: add copy/dedupe/clone to fsx/fsstress Darrick J. Wong
2018-11-22 17:58 ` [PATCH 01/12] fsstress: fix compiler warnings Darrick J. Wong
2018-11-24 18:22   ` Allison Henderson
2018-11-22 17:58 ` [PATCH 02/12] fsstress: check system call return values Darrick J. Wong
2018-11-24 18:22   ` Allison Henderson
2018-11-22 17:58 ` [PATCH 03/12] fsx: shut up compiler warnings Darrick J. Wong
2018-11-24 18:23   ` Allison Henderson
2018-11-22 17:58 ` [PATCH 04/12] fsx: always check buffer after each operation Darrick J. Wong
2018-11-24 18:24   ` Allison Henderson
2018-11-22 17:58 ` [PATCH 05/12] fsx: use an enum to define the operation commands Darrick J. Wong
2018-11-24 18:23   ` Allison Henderson
2018-11-22 17:59 ` Darrick J. Wong [this message]
2018-11-24 18:23   ` [PATCH 06/12] fsx: add five-argument logging function Allison Henderson
2018-11-22 17:59 ` [PATCH 07/12] fsx: add FICLONERANGE support Darrick J. Wong
2018-11-22 17:59 ` [PATCH 08/12] fsx: add FIDEDUPERANGE support Darrick J. Wong
2018-11-22 17:59 ` [PATCH 09/12] fsstress: add copy_file_range support Darrick J. Wong
2018-11-22 17:59 ` [PATCH 10/12] fsx: " Darrick J. Wong
2018-11-22 17:59 ` [PATCH 11/12] common/dump: disable copyrange Darrick J. Wong
2018-11-22 17:59 ` [PATCH 12/12] generic: long fsx soak tests Darrick J. Wong
2018-11-25 16:27   ` Eryu Guan
2018-11-26 20:50     ` Darrick J. Wong
2018-12-07  6:23 [PATCH v4 00/12] xfstests: add copy/dedupe/clone to fsx/fsstress Darrick J. Wong
2018-12-07  6:23 ` [PATCH 06/12] fsx: add five-argument logging function Darrick J. Wong

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=154290954603.1218.7246941650070239499.stgit@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=fstests@vger.kernel.org \
    --cc=guaneryu@gmail.com \
    --cc=linux-xfs@vger.kernel.org \
    /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.