All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xiao Yang <yangx.jy@cn.fujitsu.com>
To: eguan@redhat.com
Cc: fstests@vger.kernel.org, Xiao Yang <yangx.jy@cn.fujitsu.com>
Subject: [PATCH v2] xfs/133,4: make sure xfs_db sets negative i_size
Date: Wed, 22 Feb 2017 17:31:40 +0800	[thread overview]
Message-ID: <1487755900-6083-1-git-send-email-yangx.jy@cn.fujitsu.com> (raw)
In-Reply-To: <1487583465-17572-1-git-send-email-yangx.jy@cn.fujitsu.com>

1) xfs/133 and xfs/134 work abnornamlly on RHEL6.8GA and RHEL6.9Beta
   because xfs_db fails to set i_size to -1 or -512 and reports "usage:
   write fieldname value".  The special argument "--" is only used to
   end option-scanning in getopt().  So we should add "--" for write
   command in xfs_db when -c option is supported by write command.
   getopt() has been produced by 'commit c9f5e3db22098 ("xfs_db: Allow
   writes of corrupted data")'.

2) When xfs_db fails to set a negative i_size due to unknown error, we
   can skip these cases which don't trigger the kernel bug.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
 tests/xfs/133 | 13 ++++++++++++-
 tests/xfs/134 | 17 ++++++++++++++---
 2 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/tests/xfs/133 b/tests/xfs/133
index d756d2e..91b3b9b 100755
--- a/tests/xfs/133
+++ b/tests/xfs/133
@@ -63,7 +63,18 @@ inum=$(stat -c "%i" $testdir/a)
 
 echo "Corrupt filesystem"
 _scratch_unmount
-_scratch_xfs_db -x -c "inode ${inum}" -c 'write core.size -- -1' >> $seqres.full
+
+# 1) we should add "--" for write command in xfs_db when -c option is
+#    supported by write command.
+# 2) check whether xfs_db succeeds to set i_size to -1 or not
+_scratch_xfs_db -x -c "help" | grep -q "write \[-c\]"
+if [ $? -eq 0 ]; then
+	_scratch_xfs_db -x -c "inode ${inum}" -c 'write core.size -- -1' >> $seqres.full 2>&1 || \
+	_notrun "Could not set i_size to -1 successfully, skip test."
+else
+	_scratch_xfs_db -x -c "inode ${inum}" -c 'write core.size -1' >> $seqres.full 2>&1 || \
+	_notrun "Could not set i_size to -1 successfully, skip test."
+fi
 
 echo "Remount, try to append"
 _scratch_mount
diff --git a/tests/xfs/134 b/tests/xfs/134
index 09466cd..788f8e9 100755
--- a/tests/xfs/134
+++ b/tests/xfs/134
@@ -63,9 +63,20 @@ inum=$(stat -c "%i" $testdir/a)
 
 echo "Corrupt filesystem"
 _scratch_unmount
-# Set the file size to the highest multiple of 512 below
-# -1 so that we can perform a dio write.
-_scratch_xfs_db -x -c "inode ${inum}" -c 'write core.size -- -512' >> $seqres.full
+
+# 1) Set the file size to the highest multiple of 512 below -1 so
+#    that we can perform a dio write.
+# 2) we should add "--" for write command in xfs_db when -c option is
+#    supported by write command.
+# 3) check whether xfs_db succeeds to set i_size to -512 or not
+_scratch_xfs_db -x -c "help" | grep -q "write \[-c\]"
+if [ $? -eq 0 ]; then
+	_scratch_xfs_db -x -c "inode ${inum}" -c 'write core.size -- -512' >> $seqres.full 2>&1 || \
+	_notrun "Could not set i_size to -512 successfully, skip test."
+else
+	_scratch_xfs_db -x -c "inode ${inum}" -c 'write core.size -512' >> $seqres.full 2>&1 || \
+	_notrun "Could not set i_size to -512 successfully, skip test."
+fi
 
 echo "Remount, try to append"
 _scratch_mount
-- 
1.8.3.1




  reply	other threads:[~2017-02-22  9:33 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-13 11:21 [PATCH] shared/005,7: add check whether debugfs succeeds to set a negative i_size or not Xiao Yang
2017-02-20  2:13 ` Xiao Yang
2017-02-20  2:36   ` Eryu Guan
2017-02-20  5:02     ` [PATCH] shared/005,7: fix making sure debugfs sets negative i_size && add strict check for dd Xiao Yang
2017-02-22  4:20       ` Eryu Guan
2017-02-22  4:56         ` Xiao Yang
2017-02-22  6:53           ` Eryu Guan
2017-02-22  8:17             ` [PATCH v2] shared/005,7: fix making sure debugfs sets negative i_size Xiao Yang
2017-02-20  9:37     ` [PATCH] xfs/133,4: make sure xfs_db sets negative i_size && add strict check for dd Xiao Yang
2017-02-22  9:31       ` Xiao Yang [this message]
2017-02-22 10:49         ` [PATCH v2] xfs/133,4: make sure xfs_db sets negative i_size Eryu Guan
2017-02-23  3:23           ` Xiao Yang
2017-02-23  3:35           ` [PATCH v3] " Xiao Yang

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=1487755900-6083-1-git-send-email-yangx.jy@cn.fujitsu.com \
    --to=yangx.jy@cn.fujitsu.com \
    --cc=eguan@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 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.