From 0c594c8b51a8433d8f4dd498e68dc2d9ee158611 Mon Sep 17 00:00:00 2001 From: jcl Date: Fri, 8 Mar 2013 14:39:51 +0100 Subject: [PATCH] LU-2930 test: add tests for data version This patch adds support of dataversion access in multiop and use it to test dataversion on volatile file. It also adds a test in sanity.sh to validate dataversion works as expected (changes between writes) Signed-off-by: JC Lafoucriere Change-Id: I62c2b2124d225331873185d92f5c2404a74b1196 Reviewed-on: http://review.whamcloud.com/5660 Reviewed-by: Faccini Bruno Tested-by: Hudson Tested-by: Maloo Reviewed-by: Johann Lombardi --- lustre/tests/multiop.c | 113 +++++++++++++++++++++++++++---------------------- lustre/tests/sanity.sh | 31 ++++++++++++++ 2 files changed, 93 insertions(+), 51 deletions(-) diff --git a/lustre/tests/multiop.c b/lustre/tests/multiop.c index c93c381..b1a157d 100644 --- a/lustre/tests/multiop.c +++ b/lustre/tests/multiop.c @@ -66,40 +66,41 @@ sem_t sem; char usage[] = "Usage: %s filename command-sequence [path...]\n" " command-sequence items:\n" -" c close\n" -" B[num] call setstripe ioctl to create stripes\n" -" C[num] create with optional stripes\n" -" d mkdir\n" -" D open(O_DIRECTORY)\n" -" f statfs\n" +" c close\n" +" B[num] call setstripe ioctl to create stripes\n" +" C[num] create with optional stripes\n" +" d mkdir\n" +" D open(O_DIRECTORY)\n" +" f statfs\n" " F print FID\n" -" G gid get grouplock\n" -" g gid put grouplock\n" -" K link path to filename\n" -" L link filename to path\n" -" l symlink filename to path\n" -" m mknod\n" -" M rw mmap to EOF (must open and stat prior)\n" -" n rename path to filename\n" -" N rename filename to path\n" -" o open(O_RDONLY)\n" -" O open(O_CREAT|O_RDWR)\n" -" r[num] read [optional length]\n" -" R reference entire mmap-ed region\n" -" s stat\n" -" S fstat\n" -" t fchmod\n" -" T[num] ftruncate [optional position, default 0]\n" -" u unlink\n" -" U munmap\n" -" v verbose\n" +" G gid get grouplock\n" +" g gid put grouplock\n" +" K link path to filename\n" +" L link\n" +" l symlink filename to path\n" +" m mknod\n" +" M rw mmap to EOF (must open and stat prior)\n" +" n rename path to filename\n" +" N rename filename to path\n" +" o open(O_RDONLY)\n" +" O open(O_CREAT|O_RDWR)\n" +" r[num] read [optional length]\n" +" R reference entire mmap-ed region\n" +" s stat\n" +" S fstat\n" +" t fchmod\n" +" T[num] ftruncate [optional position, default 0]\n" +" u unlink\n" +" U munmap\n" +" v verbose\n" " V open a volatile file\n" -" w[num] write optional length\n" -" W write entire mmap-ed region\n" -" y fsync\n" -" Y fdatasync\n" -" z[num] seek [optional position, default 0]\n" -" _ wait for signal\n"; +" w[num] write optional length\n" +" x get file data version\n" +" W write entire mmap-ed region\n" +" y fsync\n" +" Y fdatasync\n" +" z[num] seek [optional position, default 0]\n" +" _ wait for signal\n"; void usr1_handler(int unused) { @@ -195,21 +196,22 @@ int get_flags(char *data, int *rflags) int main(int argc, char **argv) { - char *fname, *commands; - const char *newfile; - const char *oldpath; - struct stat st; - struct statfs stfs; - size_t mmap_len = 0, i; - unsigned char *mmap_ptr = NULL, junk = 0; - int rc, len, fd = -1; - int flags; - int save_errno; - int verbose = 0; - int gid = 0; - lustre_fid fid; - struct timespec ts; - struct lov_user_md_v3 lum; + char *fname, *commands; + const char *newfile; + const char *oldpath; + struct stat st; + struct statfs stfs; + size_t mmap_len = 0, i; + unsigned char *mmap_ptr = NULL, junk = 0; + int rc, len, fd = -1; + int flags; + int save_errno; + int verbose = 0; + int gid = 0; + lustre_fid fid; + struct timespec ts; + struct lov_user_md_v3 lum; + __u64 dv; if (argc < 3) { fprintf(stderr, usage, argv[0]); @@ -536,10 +538,19 @@ int main(int argc, char **argv) len -= rc; } break; - case 'W': - for (i = 0; i < mmap_len && mmap_ptr; i += 4096) - mmap_ptr[i] += junk++; - break; + case 'W': + for (i = 0; i < mmap_len && mmap_ptr; i += 4096) + mmap_ptr[i] += junk++; + break; + case 'x': + rc = llapi_get_data_version(fd, &dv, 0); + if (rc) { + fprintf(stderr, "cannot get file data version" + " %d\n", rc); + exit(-rc); + } + printf("dataversion is "LPU64"\n", dv); + break; case 'y': if (fsync(fd) == -1) { save_errno = errno; diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index d3f3b5b..f3de47f 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -9869,6 +9869,37 @@ test_185() { # LU-2441 } run_test 185 "Volatile file support" +test_187a() { + local dir0=$DIR/$tdir/$testnum + mkdir -p $dir0 || error "creating dir $dir0" + + local file=$dir0/file1 + dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync + local dv1=$($LFS data_version $file) + dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync + local dv2=$($LFS data_version $file) + [[ $dv1 != $dv2 ]] || + error "data version did not change on write $dv1 == $dv2" + + # clean up + rm -f $file1 +} +run_test 187a "Test data version change" + +test_187b() { + local dir0=$DIR/$tdir/$testnum + mkdir -p $dir0 || error "creating dir $dir0" + + declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ") + [[ ${DV[0]} != ${DV[1]} ]] || + error "data version did not change on write"\ + " ${DV[0]} == ${DV[1]}" + + # clean up + rm -f $file1 +} +run_test 187b "Test data version change on volatile file" + # OST pools tests check_file_in_pool() { -- 1.8.3.1