From: Zorro Lang <zlang@redhat.com>
To: fstests@vger.kernel.org
Subject: [PATCH 3/4] fsstress: do memset randomly before write operations
Date: Sat, 17 Jun 2017 00:11:05 +0800 [thread overview]
Message-ID: <1497629466-22647-3-git-send-email-zlang@redhat.com> (raw)
In-Reply-To: <1497629466-22647-1-git-send-email-zlang@redhat.com>
Recently we found a bug by trigger a page fault when io-vector of
writev is in processing. If do memset between malloc() and write
operations, memset will init the pages. So do memset randomly
maybe help to cover above situation.
Signed-off-by: Zorro Lang <zlang@redhat.com>
---
ltp/fsstress.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/ltp/fsstress.c b/ltp/fsstress.c
index 4ff90d5..e1b73e4 100644
--- a/ltp/fsstress.c
+++ b/ltp/fsstress.c
@@ -1924,7 +1924,8 @@ do_aio_rw(int opno, long r, int flags)
off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
off -= (off % align);
off %= maxfsize;
- memset(buf, nameseq & 0xff, len);
+ /* randomly memset maybe trigger page fault at write time */
+ if (random() / 2) memset(buf, nameseq & 0xff, len);
io_prep_pwrite(&iocb, fd, buf, len, off);
} else {
off = (off64_t)(lr % stb.st_size);
@@ -2455,7 +2456,8 @@ dwrite_f(int opno, long r)
buf = memalign(diob.d_mem, len);
off %= maxfsize;
lseek64(fd, off, SEEK_SET);
- memset(buf, nameseq & 0xff, len);
+ /* randomly memset maybe trigger page fault at write time */
+ if (random() / 2) memset(buf, nameseq & 0xff, len);
e = write(fd, buf, len) < 0 ? errno : 0;
free(buf);
if (v)
@@ -3672,7 +3674,8 @@ write_f(int opno, long r)
lseek64(fd, off, SEEK_SET);
len = (random() % FILELEN_MAX) + 1;
buf = malloc(len);
- memset(buf, nameseq & 0xff, len);
+ /* randomly memset maybe trigger page fault at write time */
+ if (random() / 2) memset(buf, nameseq & 0xff, len);
e = write(fd, buf, len) < 0 ? errno : 0;
free(buf);
if (v)
@@ -3733,7 +3736,8 @@ writev_f(int opno, long r)
lseek64(fd, off, SEEK_SET);
len = (random() % FILELEN_MAX) + 1;
buf = malloc(len);
- memset(buf, nameseq & 0xff, len);
+ /* randomly memset maybe trigger page fault at write time */
+ if (random() / 2) memset(buf, nameseq & 0xff, len);
iovcnt = (random() % MIN(len, IOV_MAX)) + 1;
iov = malloc(sizeof(struct iovec) * iovcnt);
--
2.7.4
next prev parent reply other threads:[~2017-06-16 16:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-16 16:11 [PATCH 1/4] fsstress: new writev and readv operations test Zorro Lang
2017-06-16 16:11 ` [PATCH 2/4] fsstress: add AIO read/write and fsync test Zorro Lang
2017-07-11 4:10 ` Eryu Guan
2017-06-16 16:11 ` Zorro Lang [this message]
2017-06-19 9:52 ` [PATCH 3/4] fsstress: do memset randomly before write operations Zorro Lang
2017-06-16 16:11 ` [PATCH 4/4] xfs/068: update golden output due to new operations in fsstress Zorro Lang
2017-07-11 3:49 ` [PATCH 1/4] fsstress: new writev and readv operations test Eryu Guan
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=1497629466-22647-3-git-send-email-zlang@redhat.com \
--to=zlang@redhat.com \
--cc=fstests@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox