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. Signed-off-by: Jeff Cody <jc...@redhat.com> --- 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(-) diff --git a/block/gluster.c b/block/gluster.c index e7bd13c..acb1934 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -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; } /* -- 2.7.4