From 81285582b9898374e98d1d6d55ccac8340408d72 Mon Sep 17 00:00:00 2001 From: Ned Bass Date: Fri, 10 Apr 2015 15:17:30 -0700 Subject: xattrtest: allow verify with -R and other improvements - Use a fixed buffer of random bytes when random xattr values are in effect. This eliminates the potential performance bottleneck of reading from /dev/urandom for each file. This also allows us to verify xattrs in random value mode. - Show the rate of operations per second in addition to elapsed time for each phase of the test. This may be useful for benchmarking. - Set default xattr size to 6 so that verify doesn't fail if user doesn't specify a size. We need at least six bytes to store the leading "size=X" string that is used for verification. - Allow user to execute just one phase of the test. Acceptable values for -o and their meanings are: 1 - run the create phase 2 - run the setxattr phase 3 - run the getxattr phase 4 - run the unlink phase Signed-off-by: Ned Bass Signed-off-by: Brian Behlendorf --- tests/zfs-tests/cmd/xattrtest/xattrtest.c | 192 +++++++++++++++++++----------- 1 file changed, 124 insertions(+), 68 deletions(-) diff --git a/tests/zfs-tests/cmd/xattrtest/xattrtest.c b/tests/zfs-tests/cmd/xattrtest/xattrtest.c index 22f798db2..6b07d141a 100644 --- a/tests/zfs-tests/cmd/xattrtest/xattrtest.c +++ b/tests/zfs-tests/cmd/xattrtest/xattrtest.c @@ -51,7 +51,7 @@ extern char *program_invocation_short_name; program_invocation_short_name, __FILE__, __LINE__, \ __func__, ## __VA_ARGS__); -static const char shortopts[] = "hvycdn:f:x:s:p:t:e:rRk"; +static const char shortopts[] = "hvycdn:f:x:s:p:t:e:rRko:"; static const struct option longopts[] = { { "help", no_argument, 0, 'h' }, { "verbose", no_argument, 0, 'v' }, @@ -68,9 +68,19 @@ static const struct option longopts[] = { { "random", no_argument, 0, 'r' }, { "randomvalue", no_argument, 0, 'R' }, { "keep", no_argument, 0, 'k' }, + { "only", required_argument, 0, 'o' }, { 0, 0, 0, 0 } }; +enum phases { + PHASE_ALL = 0, + PHASE_CREATE, + PHASE_SETXATTR, + PHASE_GETXATTR, + PHASE_UNLINK, + PHASE_INVAL +}; + static int verbose = 0; static int verify = 0; static int synccaches = 0; @@ -78,18 +88,22 @@ static int dropcaches = 0; static int nth = 0; static int files = 1000; static int xattrs = 1; -static int size = 1; +static int size = 6; static int size_is_random = 0; static int value_is_random = 0; static int keep_files = 0; +static int phase = PHASE_ALL; static char path[PATH_MAX] = "/tmp/xattrtest"; static char script[PATH_MAX] = "/bin/true"; +static char xattrbytes[XATTR_SIZE_MAX]; static int usage(int argc, char **argv) { fprintf(stderr, "usage: %s [-hvycdrRk] [-n ] [-f ] [-x ]\n" - " [-s ] [-p ] [-t