fsstress: fallback to block size for min dio size
authorZorro Lang <zlang@redhat.com>
Thu, 31 Aug 2017 05:59:43 +0000 (13:59 +0800)
committerEryu Guan <eguan@redhat.com>
Sun, 3 Sep 2017 04:20:00 +0000 (12:20 +0800)
XFS_IOC_DIOINFO is only used for XFS, but fsstress use it to get
DIO aligned size. If XFS_IOC_DIOINFO returns error, then stop
doing any DIO related test (dread/dwrite/aread/awrite etc). That
means we never do DIO related test on other filesystems by fsstress.

The real minimal dio size is really not so important for DIO test
in fsstress. The multiple of real min dio size is fine too. I think
the stat.st_blksize get from stat() system call can be used to be
a fake minimal dio size, if XFS_IOC_DIOINFO fails (not supported).

Note that the equation about d_maxiosz is copied from kernel
XFS_IOC_DIOINFO ioctl source code:

  case XFS_IOC_DIOINFO: {
    ...

    da.d_mem =  da.d_miniosz = target->bt_logical_sectorsize;
    da.d_maxiosz = INT_MAX & ~(da.d_miniosz - 1);

    ...
  }

[eguan: update commit log add d_maxiosz reference]

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
ltp/fsstress.c

index 7ae7fdf252734fdf330e9e749c88eddfe09a3bee..24c063e350ca8ec073def89e9e1e03f22525e5e8 100644 (file)
@@ -1901,11 +1901,11 @@ do_aio_rw(int opno, long r, int flags)
        if (xfsctl(f.path, fd, XFS_IOC_DIOINFO, &diob) < 0) {
                if (v)
                        printf(
-                       "%d/%d: do_aio_rw - xfsctl(XFS_IOC_DIOINFO) %s%s failed %d\n",
+                       "%d/%d: do_aio_rw - xfsctl(XFS_IOC_DIOINFO) %s%s return %d,"
+                       " fallback to stat()\n",
                                procid, opno, f.path, st, errno);
-               free_pathname(&f);
-               close(fd);
-               return;
+               diob.d_mem = diob.d_miniosz = stb.st_blksize;
+               diob.d_maxiosz = INT_MAX & ~(diob.d_miniosz - 1);
        }
        dio_env = getenv("XFS_DIO_MIN");
        if (dio_env)
@@ -2352,11 +2352,11 @@ dread_f(int opno, long r)
        if (xfsctl(f.path, fd, XFS_IOC_DIOINFO, &diob) < 0) {
                if (v)
                        printf(
-                       "%d/%d: dread - xfsctl(XFS_IOC_DIOINFO) %s%s failed %d\n",
+                       "%d/%d: dread - xfsctl(XFS_IOC_DIOINFO) %s%s return %d,"
+                       " fallback to stat()\n",
                                procid, opno, f.path, st, errno);
-               free_pathname(&f);
-               close(fd);
-               return;
+               diob.d_mem = diob.d_miniosz = stb.st_blksize;
+               diob.d_maxiosz = INT_MAX & ~(diob.d_miniosz - 1);
        }
 
        dio_env = getenv("XFS_DIO_MIN");
@@ -2430,11 +2430,10 @@ dwrite_f(int opno, long r)
        if (xfsctl(f.path, fd, XFS_IOC_DIOINFO, &diob) < 0) {
                if (v)
                        printf("%d/%d: dwrite - xfsctl(XFS_IOC_DIOINFO)"
-                               " %s%s failed %d\n",
+                               " %s%s return %d, fallback to stat()\n",
                               procid, opno, f.path, st, errno);
-               free_pathname(&f);
-               close(fd);
-               return;
+               diob.d_mem = diob.d_miniosz = stb.st_blksize;
+               diob.d_maxiosz = INT_MAX & ~(diob.d_miniosz - 1);
        }
 
        dio_env = getenv("XFS_DIO_MIN");