From: Ilya Dryomov Date: Thu, 1 May 2014 12:08:03 +0000 (+0400) Subject: test_librbd_fsx: add holebdy option X-Git-Tag: v0.81~48^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fef984b937f1169ca3d52987101f8c83a9c65646;p=ceph.git test_librbd_fsx: add holebdy option In preparation for krbd mode support, provide an option to specify alignment for discards. The kernel will reject discard requests whose offset and length are not sector-size aligned. Signed-off-by: Ilya Dryomov --- diff --git a/src/test/librbd/fsx.c b/src/test/librbd/fsx.c index e4774e08a621..09212242b5b5 100644 --- a/src/test/librbd/fsx.c +++ b/src/test/librbd/fsx.c @@ -127,6 +127,7 @@ int closeprob = 0; /* -c flag */ int debug = 0; /* -d flag */ unsigned long debugstart = 0; /* -D flag */ int flush = 0; /* -f flag */ +int holebdy = 1; /* -h flag */ int do_fsync = 0; /* -y flag */ unsigned long maxfilelen = 256 * 1024; /* -l flag */ int sizechecks = 1; /* -n flag disables them */ @@ -731,6 +732,8 @@ do_punch_hole(unsigned offset, unsigned length) int max_len = 0; int ret; + offset -= offset % holebdy; + length -= length % holebdy; if (length == 0) { if (!quiet && testcalls > simulatedopcount) prt("skipping zero length punch hole\n"); @@ -1108,11 +1111,12 @@ void usage(void) { fprintf(stdout, "usage: %s", - "fsx [-dfnqxyACFHLORWZ] [-b opnum] [-c Prob] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] pname iname\n\ + "fsx [-dfnqxyACFHLORWZ] [-b opnum] [-c Prob] [-h holebdy] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] pname iname\n\ -b opnum: beginning operation number (default 1)\n\ -c P: 1 in P chance of file close+open at each op (default infinity)\n\ -d: debug output for all operations\n\ -f: flush and invalidate cache after I/O\n\ + -h holebdy: 4096 would make discards page aligned (default 1)\n\ -l flen: the upper bound on file size (default 262144)\n\ -m startop:endop: monitor (print debug output) specified byte range (default 0:infinity)\n\ -n: no verifications of file size\n\ @@ -1320,7 +1324,7 @@ main(int argc, char **argv) setvbuf(stdout, (char *)0, _IOLBF, 0); /* line buffered stdout */ - while ((ch = getopt(argc, argv, "b:c:dfl:m:no:p:qr:s:t:w:xyACD:FHLN:OP:RS:WZ")) + while ((ch = getopt(argc, argv, "b:c:dfh:l:m:no:p:qr:s:t:w:xyACD:FHLN:OP:RS:WZ")) != EOF) switch (ch) { case 'b': @@ -1347,6 +1351,11 @@ main(int argc, char **argv) case 'f': flush = 1; break; + case 'h': + holebdy = getnum(optarg, &endp); + if (holebdy <= 0) + usage(); + break; case 'l': maxfilelen = getnum(optarg, &endp); if (maxfilelen <= 0)