Linux RAID subsystem development
 help / color / mirror / Atom feed
From: Song Liu <songliubraving@fb.com>
To: linux-raid@vger.kernel.org
Cc: neilb@suse.com, shli@fb.com, kernel-team@fb.com,
	dan.j.williams@intel.com, hch@infradead.org,
	liuzhengyuan@kylinos.cn, liuyun01@kylinos.cn,
	Song Liu <songliubraving@fb.com>,
	Jes.Sorensen@redhat.com
Subject: [PATCH] mdadm: add test case for raid5 write back cache
Date: Thu, 15 Dec 2016 16:00:16 -0800	[thread overview]
Message-ID: <20161216000016.3840135-1-songliubraving@fb.com> (raw)

This test cases checks data integrity of raid5 write back cache
under various scenarios:

degraded mode, non-overwrite, raid-5/6.

Signed-off-by: Song Liu <songliubraving@fb.com>
---
 tests/21raid5cache | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 87 insertions(+)
 create mode 100644 tests/21raid5cache

diff --git a/tests/21raid5cache b/tests/21raid5cache
new file mode 100644
index 0000000..0dd97bf
--- /dev/null
+++ b/tests/21raid5cache
@@ -0,0 +1,87 @@
+# check data integrity with raid5 write back cache
+
+# create a 4kB random file and 4 files each with a 1kB chunk of the random file:
+#    randfile: ABCD   randchunk[0-3]:  A  B  C  D
+#
+# then create another random 1kB chunk E, and a new random page with A, B, E, D:
+#    randchunk4: E    newrandfile:   ABED
+create_random_data() {
+    dd if=/dev/urandom of=/tmp/randfile bs=4k count=1
+    for x in {0..3}
+    do
+        dd if=/tmp/randfile of=/tmp/randchunk$x bs=1k count=1 skip=$x count=1
+    done
+
+    dd if=/dev/urandom of=/tmp/randchunk4 bs=1k count=1
+
+    rm /tmp/newrandfile
+    for x in 0 1 4 3
+    do
+        cat /tmp/randchunk$x >> /tmp/newrandfile
+    done
+}
+
+# create array, $1 could be 5 for raid5 and 6 for raid6
+create_array() {
+    if [ $1 -lt 5 -o $1 -gt 6 ]
+    then
+        echo wrong array type $1
+        exit 2
+    fi
+
+    mdadm -CR $md0 -c4 -l5 -n10 $dev0 $dev1 $dev2 $dev3 $dev4 $dev5 $dev6 $dev11 $dev8 $dev9 --write-journal $dev10
+    check wait
+    echo write-back > /sys/block/md0/md/journal_mode
+}
+
+restart_array_write_back() {
+    mdadm -S $md0
+    mdadm -A $md0 $dev0 $dev1 $dev2 $dev3 $dev4 $dev5 $dev6 $dev11 $dev8 $dev9 $dev10
+    echo write-back > /sys/block/md0/md/journal_mode
+}
+
+# compare the first page of md0 with file in $1
+cmp_first_page() {
+    cmp  -n 4096 $1 $md0 || { echo cmp failed ; exit 2 ; }
+}
+
+# write 3 pages after the first page of md0
+write_three_pages() {
+    for x in {1..3}
+    do
+        dd if=/dev/urandom of=$md0 bs=4k count=1 seek=$x count=1
+    done
+}
+
+# run_test <array_type:5/6> <degraded_or_not:yes/no>
+run_test() {
+    create_random_data
+    create_array $1
+
+    if [ $2 == yes ]
+    then
+        mdadm --fail $md0 $dev0
+    fi
+
+    dd if=/tmp/randfile of=$md0 bs=4k count=1
+    restart_array_write_back
+    cmp_first_page /tmp/randfile
+    restart_array_write_back
+    write_three_pages
+    cmp_first_page /tmp/randfile
+
+
+    dd if=/tmp/randchunk4 of=/dev/md0 bs=1k count=1 seek=2
+    restart_array_write_back
+    cmp_first_page /tmp/newrandfile
+    restart_array_write_back
+    write_three_pages
+    cmp_first_page /tmp/newrandfile
+
+    mdadm -S $md0
+}
+
+run_test 5 no
+run_test 5 yes
+run_test 6 no
+run_test 6 yes
-- 
2.9.3


             reply	other threads:[~2016-12-16  0:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-16  0:00 Song Liu [this message]
2016-12-19 15:08 ` [PATCH] mdadm: add test case for raid5 write back cache Jes Sorensen

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=20161216000016.3840135-1-songliubraving@fb.com \
    --to=songliubraving@fb.com \
    --cc=Jes.Sorensen@redhat.com \
    --cc=dan.j.williams@intel.com \
    --cc=hch@infradead.org \
    --cc=kernel-team@fb.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=liuyun01@kylinos.cn \
    --cc=liuzhengyuan@kylinos.cn \
    --cc=neilb@suse.com \
    --cc=shli@fb.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