Skip to contentSkip to conversation

block: add gluster ifdef guard checks for SEEK_DATA/SEEK_HOLE support

PATCH Superseded Jeff Cody 2 participants 3 messages Oct 7, 2016 Block layer

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jeff Cody

author
#0 lore raw

PATCH 1/1 block: add gluster ifdef guard checks for SEEK_DATA/SEEK_HOLE support

Add checks to see if the system compiling QEMU has support for SEEK_HOLE/SEEK_DATA. If the system does not, we will flag that seek data is unsupported in gluster.

Note: this is not a check on whether the gluster server itself supports SEEK_DATA (that is already done during runtime), but rather if the compilation environment supports SEEK_DATA.

---

Note: this patch is untested on older systems that do not support SEEK_DATA (e.g.. RHEL6). This won't be pulled into my tree until it is verified.

 block/gluster.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
block/gluster.c +9 -2
index e7bd13c..acb1934 100644
@@ -672,8 +672,10 @@ static void qemu_gluster_parse_flags(int bdrv_flags, int *open_flags)
  */
 static bool qemu_gluster_test_seek(struct glfs_fd *fd)
 {
-    off_t ret, eof;
+    off_t ret = 0;
+    off_t eof;
 
+#if defined SEEK_HOLE && defined SEEK_DATA
     eof = glfs_lseek(fd, 0, SEEK_END);
     if (eof < 0) {
         /* this should never occur */
@@ -682,6 +684,7 @@ static bool qemu_gluster_test_seek(struct glfs_fd *fd)
 
     /* this should always fail with ENXIO if SEEK_DATA is supported */
     ret = glfs_lseek(fd, eof, SEEK_DATA);
+#endif
     return (ret < 0) && (errno == ENXIO);
 }
 
@@ -1185,9 +1188,10 @@ static int find_allocation(BlockDriverState *bs, off_t start,
     off_t offs;
 
     if (!s->supports_seek_data) {
-        return -ENOTSUP;
+        goto exit;
     }
 
+#if defined SEEK_HOLE && defined SEEK_DATA
     /*
      * SEEK_DATA cases:
      * D1. offs == start: start is in data
@@ -1251,6 +1255,9 @@ static int find_allocation(BlockDriverState *bs, off_t start,
 
     /* D1 and H1 */
     return -EBUSY;
+#endif
+exit:
+    return -ENOTSUP;
 }
 
 /*
Signature · 1 line
2.7.4
Tested-by Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Jeff Cody

Add checks to see if the system compiling QEMU has support for SEEK_HOLE/SEEK_DATA. If the system does not, we will flag that seek data is unsupported in gluster.

Note: this is not a check on whether the gluster server itself supports SEEK_DATA (that is already done during runtime), but rather if the compilation environment supports SEEK_DATA.

Quoted 6 lines

---

Note: this patch is untested on older systems that do not support SEEK_DATA (e.g.. RHEL6). This won't be pulled into my tree until it is verified.

CC block/gluster.o
block/gluster.c: In function ‘qemu_gluster_test_seek’:
block/gluster.c:676: warning: unused variable ‘eof’ block/gluster.c: In function ‘find_allocation’:
block/gluster.c:1188: warning: unused variable ‘offs’

but compilation succeeded in spite of the warning. Would be nice to clean that up for -Werror users.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
author
#2 lore raw
Quoted 22 lines · Eric Blake
Quoted 8 lines · Jeff Cody

Add checks to see if the system compiling QEMU has support for SEEK_HOLE/SEEK_DATA. If the system does not, we will flag that seek data is unsupported in gluster.

Note: this is not a check on whether the gluster server itself supports SEEK_DATA (that is already done during runtime), but rather if the compilation environment supports SEEK_DATA.

Quoted 6 lines

---

Note: this patch is untested on older systems that do not support SEEK_DATA (e.g.. RHEL6). This won't be pulled into my tree until it is verified.

CC block/gluster.o
block/gluster.c: In function ‘qemu_gluster_test_seek’:
block/gluster.c:676: warning: unused variable ‘eof’ block/gluster.c: In function ‘find_allocation’:
block/gluster.c:1188: warning: unused variable ‘offs’

Quoted 6 lines

but compilation succeeded in spite of the warning. Would be nice to clean that up for -Werror users.

Thanks Eric. I'll clean that up for a v2.

Jeff