From: Dmitry Monakhov <dmonakhov@openvz.org>
To: linux-fsdevel@vger.kernel.org
Cc: xfs@oss.sgi.com, hch@lst.de, aelder@sgi.com, tytso@mit.edu,
Dmitry Monakhov <dmonakhov@openvz.org>
Subject: [PATCH 02/12] xfstests: add different logging option to fsstress
Date: Thu, 3 Nov 2011 18:24:51 +0400 [thread overview]
Message-ID: <1320330301-2682-3-git-send-email-dmonakhov@openvz.org> (raw)
In-Reply-To: <1320330301-2682-1-git-send-email-dmonakhov@openvz.org>
Currently the only way to log fsstress's output is to redirect it's shared
stdout to pipe which is very painfull because:
1) Pipe writers are serialized via i_mutex so we waste cpu-cores power on stupid
sinchronization for loging purpose, instead of hunting real race conditions,
and bugs inside file system.
2) Usually output is corrupted due to luck of sychronization on shared stdout.
Since fsstress's children operate on independend paths, let's just open didicated
log file for each child and simply avoid useless sycnhronization.
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
ltp/fsstress.c | 33 ++++++++++++++++++++++++++++++++-
1 files changed, 32 insertions(+), 1 deletions(-)
diff --git a/ltp/fsstress.c b/ltp/fsstress.c
index 51ecda2..c7001f3 100644
--- a/ltp/fsstress.c
+++ b/ltp/fsstress.c
@@ -258,6 +258,8 @@ int main(int argc, char **argv)
char buf[10];
int c;
char *dirname = NULL;
+ char *logname = NULL;
+ char rpath[PATH_MAX];
int fd;
int i;
int j;
@@ -273,7 +275,7 @@ int main(int argc, char **argv)
nops = sizeof(ops) / sizeof(ops[0]);
ops_end = &ops[nops];
myprog = argv[0];
- while ((c = getopt(argc, argv, "d:e:f:i:m:n:p:rs:vwzHS")) != -1) {
+ while ((c = getopt(argc, argv, "d:e:f:i:m:n:o:p:rs:vwzHS")) != -1) {
switch (c) {
case 'd':
dirname = optarg;
@@ -311,6 +313,10 @@ int main(int argc, char **argv)
case 'n':
operations = atoi(optarg);
break;
+ case 'o':
+ logname = optarg;
+ break;
+
case 'p':
nproc = atoi(optarg);
break;
@@ -351,10 +357,26 @@ int main(int argc, char **argv)
}
(void)mkdir(dirname, 0777);
+ if (logname && logname[0] != '/') {
+ if (getcwd(rpath, sizeof(rpath)) < 0){
+ perror("getcwd failed");
+ exit(1);
+ }
+ } else {
+ rpath[0] = '\0';
+ }
if (chdir(dirname) < 0) {
perror(dirname);
exit(1);
}
+ if (logname) {
+ char path[PATH_MAX];
+ snprintf(path, sizeof(path), "%s/%s", rpath, logname);
+ if (freopen(path, "a", stdout) == NULL) {
+ perror("freopen logfile failed");
+ exit(1);
+ }
+ }
sprintf(buf, "fss%x", (unsigned int)getpid());
fd = creat(buf, 0666);
if (lseek64(fd, (off64_t)(MAXFSIZE32 + 1ULL), SEEK_SET) < 0)
@@ -409,6 +431,15 @@ int main(int argc, char **argv)
close(fd);
for (i = 0; i < nproc; i++) {
if (fork() == 0) {
+ if (logname) {
+ char path[PATH_MAX];
+ snprintf(path, sizeof(path), "%s/%s.%d",
+ rpath, logname, i);
+ if (freopen(path, "a", stdout) == NULL) {
+ perror("freopen logfile failed");
+ exit(1);
+ }
+ }
procid = i;
doproc();
return 0;
--
1.7.1
next prev parent reply other threads:[~2011-11-03 14:25 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-03 14:24 [PATCH 00/12] Bunch of new stress tests -v4 Dmitry Monakhov
2011-11-03 14:24 ` [PATCH 01/12] xfstests: fsstress dump inode info when possible Dmitry Monakhov
2011-11-03 14:24 ` Dmitry Monakhov [this message]
2011-11-03 14:24 ` [PATCH 03/12] xfstests: fsstress should kill children tasks before exit Dmitry Monakhov
2011-11-03 14:24 ` [PATCH 04/12] xfstests: fsstress add command line style output for show_opts Dmitry Monakhov
2011-11-03 14:24 ` [PATCH 05/12] xfstests: freeze fsstress options for 117'th Dmitry Monakhov
2011-11-03 14:24 ` [PATCH 06/12] xfstests: add fallocate support to fsstress Dmitry Monakhov
2011-11-03 14:24 ` [PATCH 07/12] xfstests: fsstress add FS_IOC_{SET,GET}FLAGS operations v2 Dmitry Monakhov
2011-11-03 14:24 ` [PATCH 08/12] xfstests: add fiemap operation to fsstress Dmitry Monakhov
2011-11-03 14:24 ` [PATCH 09/12] xfstests: add a new test that runs fsstress under ENOSPC conditions Dmitry Monakhov
2011-11-07 21:22 ` Dave Chinner
2011-11-08 8:32 ` Dmitry Monakhov
2011-11-07 21:25 ` Dave Chinner
2011-11-03 14:24 ` [PATCH 10/12] xfstests: add a new quota " Dmitry Monakhov
2011-11-03 14:25 ` [PATCH 11/12] xfstress: add regression testcase for d583fb87a3ff0 Dmitry Monakhov
2011-11-03 14:25 ` [PATCH 12/12] xfstress: Test data journaling flag switch for a single file Dmitry Monakhov
2011-11-03 14:55 ` [PATCH 00/12] Bunch of new stress tests -v4 Christoph Hellwig
2011-11-03 15:21 ` Dmitry Monakhov
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=1320330301-2682-3-git-send-email-dmonakhov@openvz.org \
--to=dmonakhov@openvz.org \
--cc=aelder@sgi.com \
--cc=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=tytso@mit.edu \
--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;
as well as URLs for NNTP newsgroup(s).