diff mbox

[v2,1/1] block: add gluster ifdef guard checks for SEEK_DATA/SEEK_HOLE support

Message ID 00370bce5c98140d6c56ad5145635ec6551265cc.1475876377.git.jcody@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jeff Cody Oct. 7, 2016, 9:48 p.m. UTC
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.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Jeff Cody <jcody@redhat.com>
---

Changes from v1:
    - Fixed undefined variable warnings by moving variable declarations
    - Add a bit more whitespace to improve readability


 block/gluster.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

Comments

Eric Blake Oct. 7, 2016, 10:21 p.m. UTC | #1
On 10/07/2016 04:48 PM, Jeff Cody wrote:
> 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.
> 
> Reviewed-by: Eric Blake <eblake@redhat.com>
> Signed-off-by: Jeff Cody <jcody@redhat.com>
> ---
> 
> Changes from v1:
>     - Fixed undefined variable warnings by moving variable declarations
>     - Add a bit more whitespace to improve readability
> 
> 
>  block/gluster.c | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)

Tested-by: Eric Blake <eblake@redhat.com>
diff mbox

Patch

diff --git a/block/gluster.c b/block/gluster.c
index e7bd13c..4796bcb 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -672,7 +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;
+
+#if defined SEEK_HOLE && defined SEEK_DATA
+    off_t eof;
 
     eof = glfs_lseek(fd, 0, SEEK_END);
     if (eof < 0) {
@@ -682,6 +685,8 @@  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);
 }
 
@@ -1182,12 +1187,14 @@  static int find_allocation(BlockDriverState *bs, off_t start,
                            off_t *data, off_t *hole)
 {
     BDRVGlusterState *s = bs->opaque;
-    off_t offs;
 
     if (!s->supports_seek_data) {
-        return -ENOTSUP;
+        goto exit;
     }
 
+#if defined SEEK_HOLE && defined SEEK_DATA
+    off_t offs;
+
     /*
      * SEEK_DATA cases:
      * D1. offs == start: start is in data
@@ -1251,6 +1258,10 @@  static int find_allocation(BlockDriverState *bs, off_t start,
 
     /* D1 and H1 */
     return -EBUSY;
+#endif
+
+exit:
+    return -ENOTSUP;
 }
 
 /*