]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test_librbd_fsx: add holebdy option
authorIlya Dryomov <ilya.dryomov@inktank.com>
Thu, 1 May 2014 12:08:03 +0000 (16:08 +0400)
committerIlya Dryomov <ilya.dryomov@inktank.com>
Wed, 7 May 2014 13:30:05 +0000 (17:30 +0400)
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 <ilya.dryomov@inktank.com>
src/test/librbd/fsx.c

index e4774e08a6217bfc09a2eb05734f6844baa713f9..09212242b5b51761d438167cf99c1f591d7be4b2 100644 (file)
@@ -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)